|
@@ -104,24 +104,31 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
signature, mySignature);
|
|
|
return result;
|
|
|
}
|
|
|
+ //消息内容
|
|
|
AppletMsgDTO appletMsgDTO = JsonUtil.toObj(postData, AppletMsgDTO.class);
|
|
|
- //消息内容判断, 值回复文本消息为2的内容
|
|
|
- if (!Objects.equals(appletMsgDTO.getMsgType(), "text") || !Objects.equals(appletMsgDTO.getContent(), "2")) {
|
|
|
- return result;
|
|
|
- }
|
|
|
//用户信息
|
|
|
UserDTO userDTO = userService.getUserByOpenId(gameAppletDTO.getGameId(), appletMsgDTO.getFromUserName());
|
|
|
- //查询用户最新订单
|
|
|
- Order order = orderService.getOne(new LambdaQueryWrapper<Order>()
|
|
|
- .eq(Order::getUserId, userDTO.getId())
|
|
|
- .eq(Order::getStatus, OrderStateEnum.READY_PAY.getCode())
|
|
|
- .orderByDesc(Order::getCreateTime)
|
|
|
- .last("limit 1"));
|
|
|
- if (order == null) {
|
|
|
- return result;
|
|
|
+ //客服支付
|
|
|
+ if (Objects.equals(appletMsgDTO.getMsgType(), "text") && Objects.equals(appletMsgDTO.getContent(), "2")) {
|
|
|
+ //查询用户最新订单
|
|
|
+ Order order = orderService.getOne(new LambdaQueryWrapper<Order>()
|
|
|
+ .eq(Order::getUserId, userDTO.getId())
|
|
|
+ .eq(Order::getStatus, OrderStateEnum.READY_PAY.getCode())
|
|
|
+ .orderByDesc(Order::getCreateTime)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (order != null) {
|
|
|
+ //发送客服消息
|
|
|
+ return this.sendCustomMessage(gameAppletDTO, userDTO.getOpenId(), order);
|
|
|
+ }
|
|
|
}
|
|
|
- //发送客服消息
|
|
|
- return this.sendCustomMessage(gameAppletDTO, userDTO.getOpenId(), order);
|
|
|
+ //非客服支付, 回复通用消息
|
|
|
+ GameExt gameExt = gameExtService.getByGameId(userDTO.getGameId());
|
|
|
+ String text = "尊敬的玩家您好,请您用QQ添加:" + gameExt.getCustomerQq()
|
|
|
+ + ",联系官方客服哦,客服目前排队比较多,请您耐心等待,请您备注好区服角色,方便客服第一时间为您处理问题";
|
|
|
+ //客服消息参数构造
|
|
|
+ Map<String, Object> textMap = new HashMap<>(1);
|
|
|
+ textMap.put("content", text);
|
|
|
+ return this.sendCustomMessageApi(gameAppletDTO, userDTO.getOpenId(), "text", textMap);
|
|
|
}
|
|
|
|
|
|
private String sendCustomMessage(GameAppletDTO gameAppletDTO, String openId, Order order) {
|
|
@@ -151,11 +158,16 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
linkMap.put("description", "点我充值" + amount + "元,用于购买" + amount + "元档充值");
|
|
|
linkMap.put("url", url);
|
|
|
linkMap.put("thumb_url", thumbUrl);
|
|
|
+ //发送客服消息
|
|
|
+ return this.sendCustomMessageApi(gameAppletDTO, openId, "link", linkMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String sendCustomMessageApi(GameAppletDTO gameAppletDTO, String openId, String msgType, Map<String, Object> msgMap) {
|
|
|
//客服消息参数构造
|
|
|
Map<String, Object> paramMap = new HashMap<>(3);
|
|
|
paramMap.put("touser", openId);
|
|
|
- paramMap.put("msgtype", "link");
|
|
|
- paramMap.put("link", linkMap);
|
|
|
+ paramMap.put("msgtype", msgType);
|
|
|
+ paramMap.put(msgType, msgMap);
|
|
|
log.error("客服消息发送参数, paramMap : {}", JsonUtil.toString(paramMap));
|
|
|
//获取接口token
|
|
|
String accessToken = wxApiService.getAccessToken(gameAppletDTO.getAppId(), gameAppletDTO.getAppSecret());
|