|
@@ -63,12 +63,12 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
@Override
|
|
|
public String appletMsgCheck(String appId, String signature, String timestamp, String nonce, String echoStr) throws Exception {
|
|
|
log.error("验证参数, appId : {}, signature : {}, timestamp : {}, nonce : {}, echoStr : {}", appId, signature, timestamp, nonce, echoStr);
|
|
|
- GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
|
|
|
- .eq(GameApplet::getAppId, appId));
|
|
|
- if (gameApplet == null) {
|
|
|
- throw new BaseException("参数错误, 游戏小程序信息不存在");
|
|
|
+ GameAppletDTO gameAppletDTO = this.getByAppId(appId);
|
|
|
+ GameAppletDTO.MsgConfigBean msgConfigBean = gameAppletDTO.getMsgConfigBean();
|
|
|
+ if (msgConfigBean == null) {
|
|
|
+ throw new BaseException("参数错误, 小游戏应用缺少消息推送配置");
|
|
|
}
|
|
|
- String mySignature = SignUtil.SHA1(gameApplet.getMsgPushToken(), timestamp, nonce);
|
|
|
+ String mySignature = SignUtil.SHA1(msgConfigBean.getMsgPushToken(), timestamp, nonce);
|
|
|
log.error("计算出来的签名, signature : {}, mySignature : {}", signature, mySignature);
|
|
|
if (!Objects.equals(mySignature, signature)) {
|
|
|
throw new BaseException("验证签名不匹配");
|
|
@@ -84,12 +84,12 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
if (Strings.isBlank(postData)) {
|
|
|
return result;
|
|
|
}
|
|
|
- GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
|
|
|
- .eq(GameApplet::getAppId, appId));
|
|
|
- if (gameApplet == null) {
|
|
|
+ GameAppletDTO gameAppletDTO = this.getByAppId(appId);
|
|
|
+ GameAppletDTO.MsgConfigBean msgConfigBean = gameAppletDTO.getMsgConfigBean();
|
|
|
+ if (msgConfigBean == null) {
|
|
|
return result;
|
|
|
}
|
|
|
- String mySignature = SignUtil.SHA1(gameApplet.getMsgPushToken(), timestamp, nonce);
|
|
|
+ String mySignature = SignUtil.SHA1(msgConfigBean.getMsgPushToken(), timestamp, nonce);
|
|
|
if (!Objects.equals(mySignature, signature)) {
|
|
|
log.error("计算出来的签名不匹配, signature : {}, mySignature : {}", signature, mySignature);
|
|
|
return result;
|
|
@@ -100,7 +100,7 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
return result;
|
|
|
}
|
|
|
//用户信息
|
|
|
- UserDTO userDTO = userService.getUserByOpenId(gameApplet.getGameId(), appletMsgDTO.getFromUserName());
|
|
|
+ UserDTO userDTO = userService.getUserByOpenId(gameAppletDTO.getGameId(), appletMsgDTO.getFromUserName());
|
|
|
//查询用户最新订单
|
|
|
Order order = orderService.getOne(new LambdaQueryWrapper<Order>()
|
|
|
.eq(Order::getUserId, userDTO.getId())
|
|
@@ -111,10 +111,10 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
return result;
|
|
|
}
|
|
|
//发送客服消息
|
|
|
- return this.sendCustomMessage(gameApplet, userDTO.getOpenId(), order);
|
|
|
+ return this.sendCustomMessage(gameAppletDTO, userDTO.getOpenId(), order);
|
|
|
}
|
|
|
|
|
|
- private String sendCustomMessage(GameApplet gameApplet, String openId, Order order) {
|
|
|
+ private String sendCustomMessage(GameAppletDTO gameAppletDTO, String openId, Order order) {
|
|
|
//查询订单支付方式
|
|
|
GamePayWayDTO gamePayWayDTO = gamePayWayService.getById(order.getGamePayWayId());
|
|
|
//查询支付应用信息
|
|
@@ -148,7 +148,7 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
paramMap.put("link", linkMap);
|
|
|
log.error("客服消息发送参数, paramMap : {}", JsonUtil.toString(paramMap));
|
|
|
//获取接口token
|
|
|
- String accessToken = wxApiService.getAccessToken(gameApplet.getAppId(), gameApplet.getAppSecret());
|
|
|
+ String accessToken = wxApiService.getAccessToken(gameAppletDTO.getAppId(), gameAppletDTO.getAppSecret());
|
|
|
URI uri = UriComponentsBuilder.fromHttpUrl("https://api.weixin.qq.com/cgi-bin/message/custom/send")
|
|
|
.queryParam("access_token", accessToken)
|
|
|
.build().toUri();
|
|
@@ -168,6 +168,16 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
return BeanUtil.copy(gameApplet, GameAppletDTO.class);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public GameAppletDTO getByAppId(String appId) {
|
|
|
+ GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
|
|
|
+ .eq(GameApplet::getAppId, appId));
|
|
|
+ if (gameApplet == null) {
|
|
|
+ throw new BaseException("参数错误, 游戏小程序信息不存在");
|
|
|
+ }
|
|
|
+ return BeanUtil.copy(gameApplet, GameAppletDTO.class);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public GameAppletVO gameAppletInit(UserData userData) {
|
|
|
GameApplet gameApplet = super.getOne(new LambdaQueryWrapper<GameApplet>()
|