Browse Source

修改内容:回传

shishaosong 1 năm trước cách đây
mục cha
commit
e0aacaf319

+ 5 - 0
game-back/game-back-base/src/main/java/com/zanxiang/game/back/base/tencent/pojo/dto/TencentOrderDTO.java

@@ -77,4 +77,9 @@ public class TencentOrderDTO implements Serializable {
      * 支付时间
      */
     private LocalDateTime payTime;
+
+    /**
+     * 数据源ID
+     */
+    private Long userActionSetId;
 }

+ 5 - 0
game-back/game-back-base/src/main/java/com/zanxiang/game/back/base/tencent/pojo/dto/TencentUserDTO.java

@@ -51,4 +51,9 @@ public class TencentUserDTO implements Serializable {
      * appid
      */
     private String wechatAppId;
+
+    /**
+     * 数据源ID
+     */
+    private Long userActionSetId;
 }

+ 1 - 1
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/entity/GameTencentBackLog.java

@@ -39,7 +39,7 @@ public class GameTencentBackLog implements Serializable {
     /**
      * 数据源ID
      */
-    private String userActionSetId;
+    private Long userActionSetId;
 
     /**
      * 行为发生时,客户端的时间点

+ 5 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/entity/GameTencentOrder.java

@@ -89,6 +89,11 @@ public class GameTencentOrder implements Serializable {
      */
     private Integer orderStatus;
 
+    /**
+     * 数据源ID
+     */
+    private Long userActionSetId;
+
     /**
      * 支付时间
      */

+ 5 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/entity/GameTencentUser.java

@@ -65,6 +65,11 @@ public class GameTencentUser implements Serializable {
      */
     private String wechatAppId;
 
+    /**
+     * 数据源ID
+     */
+    private Long userActionSetId;
+
     /**
      * 0:未回传;1:回传
      */

+ 33 - 27
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameBackPolicyServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zanxiang.game.back.serve.service.impl;
 
+import cn.hutool.http.HttpStatus;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -26,6 +27,7 @@ import com.zanxiang.game.back.serve.service.IGameTencentUserService;
 import com.zanxiang.game.back.serve.utils.BackPolicyUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.exception.BaseException;
+import com.zanxiang.module.util.pojo.ResultVO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -84,6 +86,7 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
                 .createTime(LocalDateTime.now())
                 .isBack(BackStatusEnum.NO.getBackStatus())
                 .backPolicyId(dto.getBackPolicyId())
+                .userActionSetId(dto.getUserActionSetId())
                 .build();
         gameTencentOrderService.save(gameTencentOrder);
         if (!dto.getOrderStatus().equals(COMPLETE_ORDER) && !dto.getOrderStatus().equals(PURCHASE)) {
@@ -94,6 +97,7 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
                 ActionTypeEnum.PURCHASE.getActionType() : ActionTypeEnum.COMPLETE_ORDER.getActionType();
         DataReportOfAppIdRpcDTO dataReportOfAppIdRpcDTO = DataReportOfAppIdRpcDTO.builder()
                 .appId(dto.getWechatAppId())
+                .userActionSetId(dto.getUserActionSetId())
                 .action(UserActionRpcDTO.builder()
                         .actionTime(dto.getOrderStatus().equals(PURCHASE) ? dto.getPayTime() : dto.getRechargeTime())
                         .actionType(actionType)
@@ -113,6 +117,7 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
                 .orderId(dto.getOrderId())
                 .wechatAppId(dto.getWechatAppId())
                 .wechatOpenid(dto.getWechatOpenid())
+                .userActionSetId(dto.getUserActionSetId())
                 .build();
 
         boolean doBack;
@@ -132,24 +137,23 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
                     ).stream().filter(order -> order.getIsBack().equals(BackStatusEnum.SUCCESS.getBackStatus())).count()
             ).intValue());
         }
-
-        try {
-            if (dto.getOrderStatus().equals(COMPLETE_ORDER) || doBack) {
-                userActionSetRpc.reportByAppId(dataReportOfAppIdRpcDTO);
+        if (dto.getOrderStatus().equals(COMPLETE_ORDER) || doBack) {
+            ResultVO<Boolean> result = userActionSetRpc.reportByAppId(dataReportOfAppIdRpcDTO);
+            if (result.getCode() == HttpStatus.HTTP_OK) {
                 gameTencentOrder.setIsBack(BackStatusEnum.FAILED.getBackStatus());
                 gameTencentOrderService.updateById(gameTencentOrder);
 
                 gameTencentBackLogService.save(gameTencentBackLog);
-            }
-        } catch (Exception e) {
-            log.error("回传腾讯订单失败,失败原因:{}", e.getMessage());
-            gameTencentOrder.setBackLog(e.getMessage());
-            gameTencentOrder.setIsBack(BackStatusEnum.FAILED.getBackStatus());
-            gameTencentOrderService.updateById(gameTencentOrder);
+            } else {
+                log.error("回传腾讯订单失败,失败原因:{}", result.getMsg());
+                gameTencentOrder.setBackLog(result.getMsg());
+                gameTencentOrder.setIsBack(BackStatusEnum.FAILED.getBackStatus());
+                gameTencentOrderService.updateById(gameTencentOrder);
 
-            gameTencentBackLog.setBackLog(e.getMessage());
-            gameTencentBackLogService.saveOrUpdate(gameTencentBackLog);
-            return false;
+                gameTencentBackLog.setBackLog(result.getMsg());
+                gameTencentBackLogService.saveOrUpdate(gameTencentBackLog);
+                return false;
+            }
         }
         return true;
     }
@@ -175,6 +179,7 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
                     .wechatAppId(dto.getWechatAppId())
                     .wechatOpenid(dto.getWechatOpenid())
                     .isBack(BackStatusEnum.NO.getBackStatus())
+                    .userActionSetId(dto.getUserActionSetId())
                     .createTime(LocalDateTime.now())
                     .build();
             gameTencentUserService.save(gameTencentUser);
@@ -182,6 +187,7 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
 
         DataReportOfAppIdRpcDTO dataReportOfAppIdRpcDTO = DataReportOfAppIdRpcDTO.builder()
                 .appId(dto.getWechatAppId())
+                .userActionSetId(dto.getUserActionSetId())
                 .action(UserActionRpcDTO.builder()
                         .actionTime(dto.getRegisterTime())
                         .actionType(ActionTypeEnum.REGISTER.getActionType())
@@ -200,23 +206,23 @@ public class GameBackPolicyServiceImpl extends ServiceImpl<GameBackPolicyMapper,
                 .actionType(ActionTypeEnum.REGISTER.getActionType())
                 .wechatAppId(dto.getWechatAppId())
                 .wechatOpenid(dto.getWechatOpenid())
+                .userActionSetId(dto.getUserActionSetId())
                 .build();
-        try {
-            userActionSetRpc.reportByAppId(dataReportOfAppIdRpcDTO);
-            gameTencentUser.setIsBack(BackStatusEnum.SUCCESS.getBackStatus());
-            gameTencentUserService.updateById(gameTencentUser);
+            ResultVO<Boolean> result = userActionSetRpc.reportByAppId(dataReportOfAppIdRpcDTO);
+            if (result.getCode() == HttpStatus.HTTP_OK) {
+                gameTencentUser.setIsBack(BackStatusEnum.SUCCESS.getBackStatus());
+                gameTencentUserService.updateById(gameTencentUser);
 
-            gameTencentBackLogService.save(gameTencentBackLog);
-        } catch (Exception e) {
-            log.error("回传腾讯用户失败,失败原因:{}", e.getMessage());
-            gameTencentUser.setBackLog(e.getMessage());
-            gameTencentUser.setIsBack(BackStatusEnum.FAILED.getBackStatus());
-            gameTencentUserService.updateById(gameTencentUser);
+                gameTencentBackLogService.save(gameTencentBackLog);
+            } else {
+                log.error("回传腾讯用户失败,失败原因:{}", result.getMsg());
+                gameTencentUser.setBackLog(result.getMsg());
+                gameTencentUser.setIsBack(BackStatusEnum.FAILED.getBackStatus());
+                gameTencentUserService.updateById(gameTencentUser);
 
-            gameTencentBackLog.setBackLog(e.getMessage());
-            gameTencentBackLogService.saveOrUpdate(gameTencentBackLog);
-            return false;
-        }
+                gameTencentBackLog.setBackLog(result.getMsg());
+                gameTencentBackLogService.saveOrUpdate(gameTencentBackLog);
+            }
         return true;
 
     }

+ 11 - 6
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameTencentOrderServiceImpl.java

@@ -1,5 +1,6 @@
 package com.zanxiang.game.back.serve.service.impl;
 
+import cn.hutool.http.HttpStatus;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zanxiang.advertising.tencent.base.AdvertisingTencentServer;
@@ -22,6 +23,7 @@ import com.zanxiang.game.back.serve.service.IGameTencentBackLogService;
 import com.zanxiang.game.back.serve.service.IGameTencentOrderService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.module.util.bean.BeanUtil;
+import com.zanxiang.module.util.pojo.ResultVO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -86,6 +88,7 @@ public class GameTencentOrderServiceImpl extends ServiceImpl<GameTencentOrderMap
                             ActionTypeEnum.PURCHASE.getActionType() : ActionTypeEnum.COMPLETE_ORDER.getActionType();
                     DataReportOfAppIdRpcDTO dataReportOfAppIdRpcDTO = DataReportOfAppIdRpcDTO.builder()
                             .appId(gameTencentOrder.getWechatAppId())
+                            .userActionSetId(gameTencentOrder.getUserActionSetId())
                             .action(UserActionRpcDTO.builder()
                                     .actionTime(gameTencentOrder.getOrderStatus().equals(PURCHASE) ? gameTencentOrder.getPayTime() : gameTencentOrder.getRechargeTime())
                                     .actionType(actionType)
@@ -105,22 +108,24 @@ public class GameTencentOrderServiceImpl extends ServiceImpl<GameTencentOrderMap
                             .orderId(gameTencentOrder.getOrderId())
                             .wechatAppId(gameTencentOrder.getWechatAppId())
                             .wechatOpenid(gameTencentOrder.getWechatOpenid())
+                            .userActionSetId(gameTencentOrder.getUserActionSetId())
                             .build();
                     gameTencentOrder.setUpdateTime(LocalDateTime.now());
                     gameTencentOrder.setUpdateBy(SecurityUtil.getUserId());
-                    try {
-                        userActionSetRpc.reportByAppId(dataReportOfAppIdRpcDTO);
+
+                    ResultVO<Boolean> result = userActionSetRpc.reportByAppId(dataReportOfAppIdRpcDTO);
+                    if (result.getCode() == HttpStatus.HTTP_OK) {
                         gameTencentOrder.setIsBack(BackStatusEnum.SUCCESS.getBackStatus());
                         updateById(gameTencentOrder);
 
                         gameTencentBackLogService.save(gameTencentBackLog);
-                    } catch (Exception e) {
-                        log.error("回传腾讯订单失败,失败原因:{}", e.getMessage());
-                        gameTencentOrder.setBackLog(e.getMessage());
+                    } else {
+                        log.error("回传腾讯订单失败,失败原因:{}", result.getMsg());
+                        gameTencentOrder.setBackLog(result.getMsg());
                         gameTencentOrder.setIsBack(BackStatusEnum.FAILED.getBackStatus());
                         updateById(gameTencentOrder);
 
-                        gameTencentBackLog.setBackLog(e.getMessage());
+                        gameTencentBackLog.setBackLog(result.getMsg());
                         gameTencentBackLogService.saveOrUpdate(gameTencentBackLog);
                     }
                 });

+ 13 - 10
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameTencentUserServiceImpl.java

@@ -1,7 +1,9 @@
 package com.zanxiang.game.back.serve.service.impl;
 
+import cn.hutool.http.HttpStatus;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.advertising.tencent.base.AdvertisingTencentServer;
 import com.zanxiang.advertising.tencent.base.pojo.dto.DataReportOfAppIdRpcDTO;
 import com.zanxiang.advertising.tencent.base.pojo.dto.UserActionRpcDTO;
@@ -9,19 +11,17 @@ import com.zanxiang.advertising.tencent.base.rpc.IUserActionSetRpc;
 import com.zanxiang.erp.base.ErpServer;
 import com.zanxiang.erp.base.rpc.ISysUserRpc;
 import com.zanxiang.erp.security.util.SecurityUtil;
+import com.zanxiang.game.back.serve.dao.mapper.GameTencentUserMapper;
 import com.zanxiang.game.back.serve.pojo.dto.GameTencentUserDTO;
 import com.zanxiang.game.back.serve.pojo.entity.GameTencentBackLog;
 import com.zanxiang.game.back.serve.pojo.entity.GameTencentUser;
-import com.zanxiang.game.back.serve.pojo.entity.GameTencentUser;
-import com.zanxiang.game.back.serve.dao.mapper.GameTencentUserMapper;
 import com.zanxiang.game.back.serve.pojo.enums.ActionTypeEnum;
 import com.zanxiang.game.back.serve.pojo.enums.BackStatusEnum;
-import com.zanxiang.game.back.serve.pojo.vo.GameTencentOrderVO;
 import com.zanxiang.game.back.serve.pojo.vo.GameTencentUserVO;
 import com.zanxiang.game.back.serve.service.IGameTencentBackLogService;
 import com.zanxiang.game.back.serve.service.IGameTencentUserService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.module.util.bean.BeanUtil;
+import com.zanxiang.module.util.pojo.ResultVO;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -73,6 +73,7 @@ public class GameTencentUserServiceImpl extends ServiceImpl<GameTencentUserMappe
                     String actionType = ActionTypeEnum.REGISTER.getActionType();
                     DataReportOfAppIdRpcDTO dataReportOfAppIdRpcDTO = DataReportOfAppIdRpcDTO.builder()
                             .appId(gameTencentUser.getWechatAppId())
+                            .userActionSetId(gameTencentUser.getUserActionSetId())
                             .action(UserActionRpcDTO.builder()
                                     .actionTime(gameTencentUser.getRegisterTime())
                                     .actionType(actionType)
@@ -91,24 +92,26 @@ public class GameTencentUserServiceImpl extends ServiceImpl<GameTencentUserMappe
                             .actionType(actionType)
                             .wechatAppId(gameTencentUser.getWechatAppId())
                             .wechatOpenid(gameTencentUser.getWechatOpenid())
+                            .userActionSetId(gameTencentUser.getUserActionSetId())
                             .build();
                     gameTencentUser.setUpdateTime(LocalDateTime.now());
                     gameTencentUser.setUpdateBy(SecurityUtil.getUserId());
-                    try {
-                        userActionSetRpc.reportByAppId(dataReportOfAppIdRpcDTO);
+                    ResultVO<Boolean> result = userActionSetRpc.reportByAppId(dataReportOfAppIdRpcDTO);
+                    if (result.getCode() == HttpStatus.HTTP_OK) {
                         gameTencentUser.setIsBack(BackStatusEnum.SUCCESS.getBackStatus());
                         updateById(gameTencentUser);
 
                         gameTencentBackLogService.save(gameTencentBackLog);
-                    } catch (Exception e) {
-                        log.error("回传腾讯用户失败,失败原因:{}", e.getMessage());
-                        gameTencentUser.setBackLog(e.getMessage());
+                    } else {
+                        log.error("回传腾讯用户失败,失败原因:{}", result.getMsg());
+                        gameTencentUser.setBackLog(result.getMsg());
                         gameTencentUser.setIsBack(BackStatusEnum.FAILED.getBackStatus());
                         updateById(gameTencentUser);
 
-                        gameTencentBackLog.setBackLog(e.getMessage());
+                        gameTencentBackLog.setBackLog(result.getMsg());
                         gameTencentBackLogService.saveOrUpdate(gameTencentBackLog);
                     }
+
                 });
         return true;
     }