ソースを参照

Merge branch 'package' of GameCenter/game-center into dev

zhimo 1 ヶ月 前
コミット
4d8725ac86

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java

@@ -25,7 +25,7 @@ public class SDKApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功 <腾讯小游戏媒体SDK回传更新订单判断> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <回传逻辑修正> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 5 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/pojo/param/CallBackControlParam.java

@@ -33,4 +33,9 @@ public class CallBackControlParam {
      * 角色等级
      */
     private Long level;
+
+    /**
+     * 是否米大师成功回调
+     */
+    private Boolean mipeiSuces;
 }

+ 25 - 9
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameBackLogMediaSdkServiceImpl.java

@@ -247,10 +247,9 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
             }
             //腾讯小游戏媒体SDK回传, 返回的单位是分, 乘以100
             if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
-                //订单未支付或者已回传
-                if (this.orderPayAndBackCheck(platformOrderDTO)) {
+                if (this.orderPayAndBackCheck(platformOrderDTO, param.getMipeiSuces())) {
                     resultMap.put("callBack", Boolean.FALSE);
-                    resultMap.put("backMsg", "微信小游戏投放腾讯广告或巨量广告, 测试账号, 订单未支付或已回传");
+                    resultMap.put("backMsg", "测试账号, 订单未支付或已回传");
                 } else {
                     int amount = platformOrderDTO.getAmount().multiply(new BigDecimal(100)).intValue();
                     resultMap.put("amount", Collections.singletonList(amount));
@@ -280,12 +279,29 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
             resultMap.put("backMsg", "自然量微信小游戏, 新手引导回传无法判定, 不回传");
             return Tuple2.with(Boolean.FALSE, null);
         }
+        //自然量微信小游戏, 全量回传
+        if (Objects.equals(param.getCallBackTypeEnum(), CallBackTypeEnum.CALL_BACK_PAY_ORDER)) {
+            PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(param.getOrderId());
+            if (this.orderPayAndBackCheck(platformOrderDTO, param.getMipeiSuces())) {
+                resultMap.put("callBack", Boolean.FALSE);
+                resultMap.put("backMsg", "微信小游戏自然量订单未支付或者已回传");
+            } else {
+                resultMap.put("callBack", Boolean.TRUE);
+                resultMap.put("backMsg", "微信小游戏自然量订单全量回传");
+                resultMap.put("amount", Collections.singletonList(platformOrderDTO.getAmount().longValue() * 100));
+            }
+            return Tuple2.with(Boolean.FALSE, null);
+        }
         //其他回传, 还是走判断
         return Tuple2.with(Boolean.TRUE, null);
     }
 
-    private boolean orderPayAndBackCheck(PlatformOrderDTO platformOrderDTO) {
-        //订单未支付或者已回传
+    private boolean orderPayAndBackCheck(PlatformOrderDTO platformOrderDTO, Boolean miPaySuccess) {
+        //未上线新版本, 直接不检测, 或者是米大师的成功回调, 直接信任
+        if (miPaySuccess == null || miPaySuccess) {
+            return false;
+        }
+        //订单是否需要回传, 不需要回传直接返回true
         return !Objects.equals(platformOrderDTO.getStatus(), OrderStatusEnum.SUCCESS_PAY.getValue())
                 || super.count(new LambdaQueryWrapper<GameBackLogMediaSdk>()
                 .eq(GameBackLogMediaSdk::getGameId, platformOrderDTO.getGameId())
@@ -337,7 +353,8 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
                 resultMap.put("backMsg", tuple2.second);
                 break;
             case CALL_BACK_PAY_ORDER:
-                Tuple3<Boolean, List<Long>, String> tuple3 = this.callBackOrderCheck(param.getOrderId(), user, agent);
+                Tuple3<Boolean, List<Long>, String> tuple3 = this.callBackOrderCheck(param.getOrderId(),
+                        param.getMipeiSuces(), user, agent);
                 resultMap.put("callBack", tuple3.first);
                 resultMap.put("amount", tuple3.second);
                 resultMap.put("backMsg", tuple3.third);
@@ -490,7 +507,7 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
         return Tuple2.with(Boolean.TRUE, "执行新手引导回传");
     }
 
-    private Tuple3<Boolean, List<Long>, String> callBackOrderCheck(String orderId, User user, Agent agent) {
+    private Tuple3<Boolean, List<Long>, String> callBackOrderCheck(String orderId, Boolean miPaySuccess, User user, Agent agent) {
         Boolean doBack = Boolean.FALSE;
         List<Long> amount = null;
         String backMsg = null;
@@ -509,8 +526,7 @@ public class GameBackLogMediaSdkServiceImpl extends ServiceImpl<GameBackLogMedia
         if (Objects.equals(agent.getAccountType(), AccountTypeEnum.TENCENT_MINI_GAME.getValue())
                 || Objects.equals(agent.getAccountType(), AccountTypeEnum.BYTE.getValue())) {
             PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(orderId);
-            //订单未支付成功或者已经回传, 不执行回传
-            if (this.orderPayAndBackCheck(platformOrderDTO)) {
+            if (this.orderPayAndBackCheck(platformOrderDTO, miPaySuccess)) {
                 doBack = Boolean.FALSE;
                 backMsg = "微信小游戏投放腾讯广告或巨量广告, 订单未支付或已回传";
             } else {