|
@@ -6,10 +6,7 @@ import com.zanxiang.game.module.base.pojo.dto.H5GameConfigDTO;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.HttpStatusEnum;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.PayDeviceEnum;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.PayWayEnum;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.Game;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.GameApplet;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.GameExt;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.Order;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.*;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.GameAppletMapper;
|
|
|
import com.zanxiang.game.module.sdk.enums.OrderStateEnum;
|
|
|
import com.zanxiang.game.module.sdk.pojo.dto.*;
|
|
@@ -73,6 +70,9 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
@Autowired
|
|
|
private MiPayService miPayService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IKfLinkService kfLinkService;
|
|
|
+
|
|
|
@Value("${payConfig.wxPay.customH5Url}")
|
|
|
private String customH5Url;
|
|
|
|
|
@@ -113,10 +113,16 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
}
|
|
|
//消息内容
|
|
|
AppletMsgDTO appletMsgDTO = JsonUtil.toObj(postData, AppletMsgDTO.class);
|
|
|
- //用户客服支付会话
|
|
|
- if (Objects.equals(appletMsgDTO.getMsgType(), AppletMsgDTO.MSG_TYPE_TEXT)
|
|
|
- && Objects.equals(appletMsgDTO.getContent(), AppletMsgDTO.MSG_CONTENT_PAY)) {
|
|
|
- return this.customPayMessage(gameAppletDTO, appletMsgDTO);
|
|
|
+ //文本消息
|
|
|
+ if (Objects.equals(appletMsgDTO.getMsgType(), AppletMsgDTO.MSG_TYPE_TEXT)) {
|
|
|
+ //用户信息
|
|
|
+ UserDTO userDTO = userService.getUserByOpenId(gameAppletDTO.getGameId(), appletMsgDTO.getFromUserName());
|
|
|
+ //用户客服支付会话
|
|
|
+ if (Objects.equals(appletMsgDTO.getContent(), AppletMsgDTO.MSG_CONTENT_PAY)) {
|
|
|
+ return this.customPayMessage(gameAppletDTO, userDTO);
|
|
|
+ }
|
|
|
+ //非客服会话, 返回指定的客服链接
|
|
|
+ return this.customLinkMessage(gameAppletDTO, userDTO);
|
|
|
}
|
|
|
//米大师支付回调事件
|
|
|
if (Objects.equals(appletMsgDTO.getMsgType(), AppletMsgDTO.MSG_TYPE_EVENT)
|
|
@@ -178,9 +184,7 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
return Objects.equals(miPayNotifyResult, Boolean.TRUE) ? successResult : failResult;
|
|
|
}
|
|
|
|
|
|
- private String customPayMessage(GameAppletDTO gameAppletDTO, AppletMsgDTO appletMsgDTO) {
|
|
|
- //用户信息
|
|
|
- UserDTO userDTO = userService.getUserByOpenId(gameAppletDTO.getGameId(), appletMsgDTO.getFromUserName());
|
|
|
+ private String customPayMessage(GameAppletDTO gameAppletDTO, UserDTO userDTO) {
|
|
|
//查询用户最新客服支付订单
|
|
|
Order order = orderService.getOne(new LambdaQueryWrapper<Order>()
|
|
|
.eq(Order::getUserId, userDTO.getId())
|
|
@@ -196,6 +200,18 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
return HttpStatusEnum.SUCCESS.getMsg();
|
|
|
}
|
|
|
|
|
|
+ private String customLinkMessage(GameAppletDTO gameAppletDTO, UserDTO userDTO) {
|
|
|
+ //判断是否配置了第三方客服链接
|
|
|
+ KfLink kfLink = kfLinkService.getById(gameAppletDTO.getAppId());
|
|
|
+ if (kfLink == null || Strings.isBlank(kfLink.getCustomLink())) {
|
|
|
+ return HttpStatusEnum.SUCCESS.getMsg();
|
|
|
+ }
|
|
|
+ //其他消息对象
|
|
|
+ Map<String, Object> textMap = new HashMap<>(1);
|
|
|
+ textMap.put("content", kfLink.getCustomLink());
|
|
|
+ return this.sendCustomMessageApi(gameAppletDTO, userDTO.getOpenId(), "text", textMap);
|
|
|
+ }
|
|
|
+
|
|
|
private String sendCustomMessage(GameAppletDTO gameAppletDTO, String openId, Order order) {
|
|
|
//查询订单支付方式
|
|
|
GamePayWayDTO gamePayWayDTO = gamePayWayService.getById(order.getGamePayWayId());
|