Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
holmes
Commits
5ec5bec0
Commit
5ec5bec0
authored
Mar 11, 2022
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
/api/message/get逻辑优化
parent
e83ccfc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
43 deletions
+92
-43
OrderController.java
...olmes/controller/mock/keystone/jdbuy/OrderController.java
+78
-43
ApiMessageGetRequest.java
...lmes/entity/mock/keystone/jdbuy/ApiMessageGetRequest.java
+14
-0
No files found.
src/main/java/cn/qg/holmes/controller/mock/keystone/jdbuy/OrderController.java
View file @
5ec5bec0
package
cn
.
qg
.
holmes
.
controller
.
mock
.
keystone
.
jdbuy
;
package
cn
.
qg
.
holmes
.
controller
.
mock
.
keystone
.
jdbuy
;
import
cn.qg.holmes.bean.KeystoneService
;
import
cn.qg.holmes.bean.KeystoneService
;
import
cn.qg.holmes.common.JsonResult
;
import
cn.qg.holmes.entity.mock.keystone.ProductItem
;
import
cn.qg.holmes.entity.mock.keystone.ProductItem
;
import
cn.qg.holmes.entity.mock.keystone.SupplierOrderSku
;
import
cn.qg.holmes.entity.mock.keystone.SupplierOrderSku
;
import
cn.qg.holmes.entity.mock.keystone.jdbuy.*
;
import
cn.qg.holmes.entity.mock.keystone.jdbuy.*
;
...
@@ -15,6 +16,7 @@ import org.apache.commons.lang.RandomStringUtils;
...
@@ -15,6 +16,7 @@ import org.apache.commons.lang.RandomStringUtils;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
...
@@ -41,6 +43,7 @@ public class OrderController {
...
@@ -41,6 +43,7 @@ public class OrderController {
@Autowired
@Autowired
RedisUtils
redisUtils
;
RedisUtils
redisUtils
;
private
String
QYG_ORDER_PREFIX
=
"qyg_order_"
;
private
String
QYG_ORDER_PREFIX
=
"qyg_order_"
;
private
String
API_MESSAGE_PREFIX
=
"api_msg_"
;
/**
/**
* 7.3 企业购提交订单
* 7.3 企业购提交订单
...
@@ -433,6 +436,24 @@ public class OrderController {
...
@@ -433,6 +436,24 @@ public class OrderController {
return
response
;
return
response
;
}
}
/**
* 上传mock消息给/api/message/get接口使用
* @param request
* @return
*/
@PostMapping
(
"/jdbuy/message/mock"
)
public
JsonResult
jdbuyMessageMock
(
@RequestBody
ApiMessageGetRequest
request
)
{
try
{
String
type
=
request
.
getType
();
String
result
=
JSON
.
toJSONString
(
request
.
getResult
());
redisUtils
.
set
(
API_MESSAGE_PREFIX
+
type
,
result
,
172800
);
return
JsonResult
.
buildSuccessResult
(
"消息上传成功."
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
JsonResult
.
buildErrorStateResult
(
"消息上传失败, result格式不对"
,
false
);
}
}
/**
/**
* 11.1 查询推送消息
* 11.1 查询推送消息
*
*
...
@@ -442,50 +463,64 @@ public class OrderController {
...
@@ -442,50 +463,64 @@ public class OrderController {
public
JdCompanyMsgResponse
qygMessageGet
(
JdCompanyMsgRequest
request
)
{
public
JdCompanyMsgResponse
qygMessageGet
(
JdCompanyMsgRequest
request
)
{
String
type
=
request
.
getType
();
String
type
=
request
.
getType
();
JdCompanyMsgResponse
response
=
new
JdCompanyMsgResponse
();
JdCompanyMsgResponse
response
=
new
JdCompanyMsgResponse
();
response
.
setSuccess
(
true
);
Object
value
=
redisUtils
.
get
(
API_MESSAGE_PREFIX
+
type
);
response
.
setResultMessage
(
""
);
if
(
value
!=
null
)
{
response
.
setResultCode
(
"0000"
);
response
.
setSuccess
(
true
);
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
response
.
setResultMessage
(
""
);
switch
(
type
)
{
response
.
setResultCode
(
"0000"
);
case
"10"
:
response
.
setResult
((
List
<
Map
<
String
,
Object
>>)
JSONArray
.
parse
(
value
.
toString
()));
// TODO
redisUtils
.
del
(
API_MESSAGE_PREFIX
+
type
);
break
;
}
else
{
case
"31"
:
response
.
setSuccess
(
false
);
// TODO
response
.
setResultCode
(
"0010"
);
break
;
response
.
setResultMessage
(
"暂无新消息"
);
case
"104"
:
response
.
setResult
(
null
);
// 获取所有key
Set
<
String
>
set
=
redisUtils
.
keys
(
"afs:outline:*"
);
if
(!
set
.
isEmpty
())
{
// 循环遍历key,获取value
for
(
String
afsOutlineKey:
set
)
{
String
afsOutlineValue
=
redisUtils
.
get
(
afsOutlineKey
).
toString
();
AfsOutlineRequest
.
AfsOutlineParam
afsOutlineParam
=
JSON
.
parseObject
(
afsOutlineValue
,
AfsOutlineRequest
.
AfsOutlineParam
.
class
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
Long
.
valueOf
(
RandomStringUtils
.
randomNumeric
(
16
)));
map
.
put
(
"time"
,
DateUtils
.
convertDate
(
new
Date
(),
"yyyy-mm-dd hh:MM:ss"
));
map
.
put
(
"type"
,
104
);
Map
<
String
,
Object
>
childMap
=
new
HashMap
<>();
childMap
.
put
(
"expectationChanged"
,
true
);
childMap
.
put
(
"thirdApplyId"
,
afsOutlineParam
.
getThirdApplyId
());
childMap
.
put
(
"pin"
,
"北京量化派VOP"
);
childMap
.
put
(
"stepPassType"
,
10
);
childMap
.
put
(
"isOffline"
,
true
);
childMap
.
put
(
"applyStep"
,
60
);
childMap
.
put
(
"contractNumber"
,
"VOP-20201209182245"
);
childMap
.
put
(
"orderId"
,
afsOutlineParam
.
getOrderId
());
map
.
put
(
"result"
,
childMap
);
// 处理完就删除
redisUtils
.
del
(
"afs:outline:"
+
afsOutlineParam
.
getOrderId
());
result
.
add
(
map
);
}
}
break
;
default
:
break
;
}
}
response
.
setResult
(
result
);
// switch (type) {
// case "2":
// case "10":
// case "50":
// case "109":
// // 2-商品价格变更, 10-订单消息取消,50-京东地址变更,109-退款消息
// Object value = redisUtils.get(API_MESSAGE_PREFIX + type);
// if (value != null) {
// response.setResult((List<Map<String, Object>>) JSONArray.parse(value.toString()));
// }
// break;
// case "104":
// // 获取所有key
// List<Map<String, Object>> result = new ArrayList<>();
// Set<String> set = redisUtils.keys("afs:outline:*");
// if (!set.isEmpty()) {
// // 循环遍历key,获取value
// for (String afsOutlineKey: set) {
// String afsOutlineValue = redisUtils.get(afsOutlineKey).toString();
// AfsOutlineRequest.AfsOutlineParam afsOutlineParam = JSON.parseObject(afsOutlineValue, AfsOutlineRequest.AfsOutlineParam.class);
// Map<String, Object> map = new HashMap<>();
// map.put("id", Long.valueOf(RandomStringUtils.randomNumeric(16)));
// map.put("time", DateUtils.convertDate(new Date(), "yyyy-mm-dd hh:MM:ss"));
// map.put("type", 104);
// Map<String, Object> childMap = new HashMap<>();
// childMap.put("expectationChanged", true);
// childMap.put("thirdApplyId", afsOutlineParam.getThirdApplyId());
// childMap.put("pin", "北京量化派VOP");
// childMap.put("stepPassType", 10);
// childMap.put("isOffline", true);
// childMap.put("applyStep", 60);
// childMap.put("contractNumber", "VOP-20201209182245");
// childMap.put("orderId", afsOutlineParam.getOrderId());
// map.put("result", childMap);
//
// // 处理完就删除
// redisUtils.del("afs:outline:" + afsOutlineParam.getOrderId());
// result.add(map);
// }
// }
// response.setResult(result);
// break;
// default:
// break;
// }
return
response
;
return
response
;
}
}
...
...
src/main/java/cn/qg/holmes/entity/mock/keystone/jdbuy/ApiMessageGetRequest.java
0 → 100644
View file @
5ec5bec0
package
cn
.
qg
.
holmes
.
entity
.
mock
.
keystone
.
jdbuy
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.Map
;
@Data
public
class
ApiMessageGetRequest
{
private
String
type
;
private
List
<
Map
<
String
,
Object
>>
result
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment