Browse Source

回传策略更新,支持拆单回传

wcc 1 năm trước cách đây
mục cha
commit
45dd3e4ae9

+ 2 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/GameBackApplication.java

@@ -6,12 +6,14 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 @Slf4j
 @EnableDiscoveryClient
 @SpringBootApplication
 @Configuration
 @EnableDubbo
+@EnableScheduling
 public class GameBackApplication {
 
     public static void main(String[] args) {

+ 12 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/controller/OceanengineLogController.java

@@ -6,8 +6,10 @@ import com.zanxiang.game.back.serve.pojo.dto.GameOceanengineOrderLogDTO;
 import com.zanxiang.game.back.serve.pojo.dto.GameOceanengineUserLogDTO;
 import com.zanxiang.game.back.serve.pojo.dto.OrderReportDTO;
 import com.zanxiang.game.back.serve.pojo.vo.GameOceanengineOrderLogVO;
+import com.zanxiang.game.back.serve.pojo.vo.GameOceanengineOrderSplitLogVO;
 import com.zanxiang.game.back.serve.pojo.vo.GameOceanengineUserLogVO;
 import com.zanxiang.game.back.serve.service.IGameOceanengineOrderLogService;
+import com.zanxiang.game.back.serve.service.IGameOceanengineOrderSplitLogService;
 import com.zanxiang.game.back.serve.service.IGameOceanengineUserLogService;
 import com.zanxiang.module.util.NumberUtil;
 import com.zanxiang.module.util.exception.BaseException;
@@ -17,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -24,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.math.BigDecimal;
+import java.util.Collections;
 import java.util.List;
 
 @RestController
@@ -34,6 +38,8 @@ public class OceanengineLogController {
     private IGameOceanengineOrderLogService oceanengineOrderLogService;
     @Autowired
     private IGameOceanengineUserLogService oceanengineUserLogService;
+    @Autowired
+    private IGameOceanengineOrderSplitLogService gameOceanengineOrderSplitLogService;
 
     @PreAuthorize(permissionKey = "gameBack:oceanengine:orderLogs")
     @PostMapping("/orderLogs")
@@ -42,6 +48,12 @@ public class OceanengineLogController {
         return ResultVO.ok(oceanengineOrderLogService.oceanengineOrderLogList(dto));
     }
 
+    @PreAuthorize(permissionKey = "gameBack:oceanengine:orderLogs")
+    @GetMapping("/orderSplitList/{orderId}")
+    public ResultVO<List<GameOceanengineOrderSplitLogVO>> orderSplitList(@PathVariable("orderId") String orderId) {
+        return ResultVO.ok(gameOceanengineOrderSplitLogService.listByOrderNo(Collections.singletonList(orderId)));
+    }
+
     @PreAuthorize(permissionKey = "gameBack:oceanengine:orderReport")
     @PostMapping("/orderReport/{ids}/{backMoney}")
     @ApiOperation(value = "头条订单手动上报")

+ 18 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/controller/TencentLogController.java

@@ -5,9 +5,12 @@ import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.game.back.serve.pojo.dto.GameTencentOrderDTO;
 import com.zanxiang.game.back.serve.pojo.dto.GameTencentUserDTO;
 import com.zanxiang.game.back.serve.pojo.dto.OrderReportDTO;
+import com.zanxiang.game.back.serve.pojo.vo.GameOceanengineOrderSplitLogVO;
+import com.zanxiang.game.back.serve.pojo.vo.GameTencentOrderSplitLogVO;
 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.IGameTencentOrderService;
+import com.zanxiang.game.back.serve.service.IGameTencentOrderSplitLogService;
 import com.zanxiang.game.back.serve.service.IGameTencentUserService;
 import com.zanxiang.module.util.NumberUtil;
 import com.zanxiang.module.util.exception.BaseException;
@@ -17,6 +20,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.math.BigDecimal;
+import java.util.Collections;
 import java.util.List;
 
 @RestController
@@ -34,6 +39,8 @@ public class TencentLogController {
     private IGameTencentUserService tencentUserService;
     @Autowired
     private IGameTencentOrderService tencentOrderService;
+    @Autowired
+    private IGameTencentOrderSplitLogService gameTencentOrderSplitLogService;
 
     @PreAuthorize(permissionKey = "gameBack:tencent:orderLogs")
     @PostMapping("/orderLogs")
@@ -42,6 +49,12 @@ public class TencentLogController {
         return ResultVO.ok(tencentOrderService.tencentOrderLogList(dto));
     }
 
+    @PreAuthorize(permissionKey = "gameBack:tencent:orderLogs")
+    @GetMapping("/orderSplitList/{orderId}")
+    public ResultVO<List<GameTencentOrderSplitLogVO>> orderSplitList(@PathVariable("orderId") String orderId) {
+        return ResultVO.ok(gameTencentOrderSplitLogService.listByOrderNo(Collections.singletonList(orderId)));
+    }
+
     @PreAuthorize(permissionKey = "gameBack:tencent:orderReport")
     @PostMapping("/orderReport/{ids}/{backMoney}")
     @ApiOperation(value = "腾讯订单手动上报")
@@ -69,6 +82,11 @@ public class TencentLogController {
                     throw new BaseException("回传金额错误!");
                 }
             });
+            if (dto.getBetweenMinuteMin() == null || dto.getBetweenMinuteMax() == null
+                    || dto.getBetweenMinuteMin() < 1 || dto.getBetweenMinuteMax() < 1
+                    || dto.getBetweenMinuteMin().compareTo(dto.getBetweenMinuteMax()) >= 0) {
+                throw new BaseException("回传间隔时间错误!");
+            }
         } else {
             if (dto.getBackMoney().compareTo(BigDecimal.ZERO) <= 0) {
                 throw new BaseException("回传金额错误!");

+ 13 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/controller/TencentMiniGameLogController.java

@@ -5,9 +5,12 @@ import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.game.back.serve.pojo.dto.GameTencentMiniGameOrderDTO;
 import com.zanxiang.game.back.serve.pojo.dto.GameTencentMiniGameUserDTO;
 import com.zanxiang.game.back.serve.pojo.dto.OrderReportDTO;
+import com.zanxiang.game.back.serve.pojo.vo.GameOceanengineOrderSplitLogVO;
 import com.zanxiang.game.back.serve.pojo.vo.GameTencentMiniGameOrderVO;
 import com.zanxiang.game.back.serve.pojo.vo.GameTencentMiniGameUserVO;
+import com.zanxiang.game.back.serve.pojo.vo.GameTencentMiniOrderSplitLogVO;
 import com.zanxiang.game.back.serve.service.IGameTencentMiniGameOrderService;
+import com.zanxiang.game.back.serve.service.IGameTencentMiniGameOrderSplitLogService;
 import com.zanxiang.game.back.serve.service.IGameTencentMiniGameUserService;
 import com.zanxiang.module.util.NumberUtil;
 import com.zanxiang.module.util.exception.BaseException;
@@ -17,6 +20,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -24,6 +28,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.math.BigDecimal;
+import java.util.Collections;
 import java.util.List;
 
 @RestController
@@ -34,6 +39,8 @@ public class TencentMiniGameLogController {
     private IGameTencentMiniGameUserService gameTencentMiniGameUserService;
     @Autowired
     private IGameTencentMiniGameOrderService gameTencentMiniGameOrderService;
+    @Autowired
+    private IGameTencentMiniGameOrderSplitLogService gameTencentMiniGameOrderSplitLogService;
 
     @PreAuthorize(permissionKey = "gameBack:tencentMiniGame:orderLogs")
     @PostMapping("/orderLogs")
@@ -42,6 +49,12 @@ public class TencentMiniGameLogController {
         return ResultVO.ok(gameTencentMiniGameOrderService.listOfPage(dto));
     }
 
+    @PreAuthorize(permissionKey = "gameBack:tencentMiniGame:orderLogs")
+    @GetMapping("/orderSplitList/{orderId}")
+    public ResultVO<List<GameTencentMiniOrderSplitLogVO>> orderSplitList(@PathVariable("orderId") String orderId) {
+        return ResultVO.ok(gameTencentMiniGameOrderSplitLogService.listByOrderNo(Collections.singletonList(orderId)));
+    }
+
     @PreAuthorize(permissionKey = "gameBack:tencentMiniGame:orderReport")
     @PostMapping("/orderReport/{ids}/{backMoney}")
     @ApiOperation(value = "腾讯订单手动上报")

+ 8 - 0
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/pojo/dto/OrderReportDTO.java

@@ -18,4 +18,12 @@ public class OrderReportDTO {
     private BigDecimal backMoney;
 
     private List<BigDecimal> splitMoney;
+    /**
+     * 回传间隔时间(/分钟)
+     */
+    private Integer betweenMinuteMin;
+    /**
+     * 回传间隔时间(/分钟)
+     */
+    private Integer betweenMinuteMax;
 }

+ 10 - 1
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameOceanengineOrderLogServiceImpl.java

@@ -34,6 +34,7 @@ import com.zanxiang.game.module.base.rpc.IAgentRpc;
 import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.module.util.NumberUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
+import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -53,6 +54,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -188,6 +190,13 @@ public class GameOceanengineOrderLogServiceImpl extends ServiceImpl<GameOceaneng
                 .filter(order -> !Objects.equals(order.getBackStatus(), BackStatusEnum.SUCCESS.getBackStatus()))
                 .forEach(orderLog -> {
                     if (dto.getSplitOrder()) {
+                        AtomicLong total = new AtomicLong(0);
+                        dto.getSplitMoney().forEach(money -> {
+                            total.addAndGet(NumberUtil.multiply100(money).longValue());
+                        });
+                        if (!orderLog.getAmount().equals(total.get())) {
+                            throw new BaseException("订单充值金额和回传金额对不上");
+                        }
                         log.error("手动拆单回传:{}-{}", orderLog.getId(), StringUtils.join(dto.getSplitMoney(), ","));
                         List<GameOceanengineOrderSplitLog> splitOrderLogList = new ArrayList<>(dto.getSplitMoney().size());
                         LocalDateTime beginTime = LocalDateTime.now();
@@ -207,7 +216,7 @@ public class GameOceanengineOrderLogServiceImpl extends ServiceImpl<GameOceaneng
                                     .createTime(LocalDateTime.now())
                                     .build()
                             );
-                            beginTime = beginTime.plusMinutes(RandomUtils.nextInt(3, 10));
+                            beginTime = beginTime.plusMinutes(RandomUtils.nextInt(dto.getBetweenMinuteMin(), dto.getBetweenMinuteMax()));
                         }
                         gameOceanengineOrderSplitLogService.saveBatch(splitOrderLogList);
                         update(new LambdaUpdateWrapper<GameOceanengineOrderLog>()

+ 10 - 1
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameTencentMiniGameOrderServiceImpl.java

@@ -37,6 +37,7 @@ import com.zanxiang.game.module.base.pojo.vo.AgentRpcVO;
 import com.zanxiang.game.module.base.rpc.IAgentRpc;
 import com.zanxiang.module.util.NumberUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
+import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -54,6 +55,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -198,6 +200,13 @@ public class GameTencentMiniGameOrderServiceImpl extends ServiceImpl<GameTencent
                 .filter(order -> !Objects.equals(order.getBackStatus(), BackStatusEnum.SUCCESS.getBackStatus()))
                 .forEach(orderLog -> {
                     if (dto.getSplitOrder()) {
+                        AtomicLong total = new AtomicLong(0);
+                        dto.getSplitMoney().forEach(money -> {
+                            total.addAndGet(NumberUtil.multiply100(money).longValue());
+                        });
+                        if (!orderLog.getRechargeMoney().equals(total.get())) {
+                            throw new BaseException("订单充值金额和回传金额对不上");
+                        }
                         log.error("手动拆单回传:{}-{}", orderLog.getId(), StringUtils.join(dto.getSplitMoney(), ","));
                         List<GameTencentMiniGameOrderSplitLog> splitOrderLogList = new ArrayList<>(dto.getSplitMoney().size());
                         LocalDateTime beginTime = LocalDateTime.now();
@@ -216,7 +225,7 @@ public class GameTencentMiniGameOrderServiceImpl extends ServiceImpl<GameTencent
                                     .backStatus(BackStatusEnum.NO.getBackStatus())
                                     .createTime(LocalDateTime.now())
                                     .build());
-                            beginTime = beginTime.plusMinutes(RandomUtils.nextInt(3, 10));
+                            beginTime = beginTime.plusMinutes(RandomUtils.nextInt(dto.getBetweenMinuteMin(), dto.getBetweenMinuteMax()));
                         }
                         gameTencentMiniGameOrderSplitLogService.saveBatch(splitOrderLogList);
                         update(new LambdaUpdateWrapper<GameTencentMiniGameOrder>()

+ 10 - 1
game-back/game-back-serve/src/main/java/com/zanxiang/game/back/serve/service/impl/GameTencentOrderServiceImpl.java

@@ -41,6 +41,7 @@ import com.zanxiang.game.module.base.pojo.vo.AgentRpcVO;
 import com.zanxiang.game.module.base.rpc.IAgentRpc;
 import com.zanxiang.module.util.NumberUtil;
 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.collections4.CollectionUtils;
@@ -60,6 +61,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -237,6 +239,13 @@ public class GameTencentOrderServiceImpl extends ServiceImpl<GameTencentOrderMap
                 .filter(order -> !Objects.equals(order.getIsBack(), BackStatusEnum.SUCCESS.getBackStatus()))
                 .forEach(orderLog -> {
                     if (dto.getSplitOrder()) {
+                        AtomicLong total = new AtomicLong(0);
+                        dto.getSplitMoney().forEach(money -> {
+                            total.addAndGet(NumberUtil.multiply100(money).longValue());
+                        });
+                        if (!orderLog.getRechargeMoney().equals(total.get())) {
+                            throw new BaseException("订单充值金额和回传金额对不上");
+                        }
                         log.error("手动拆单回传:{}-{}", orderLog.getId(), StringUtils.join(dto.getSplitMoney(), ","));
                         List<GameTencentOrderSplitLog> splitOrderLogList = new ArrayList<>(dto.getSplitMoney().size());
                         LocalDateTime beginTime = LocalDateTime.now();
@@ -255,7 +264,7 @@ public class GameTencentOrderServiceImpl extends ServiceImpl<GameTencentOrderMap
                                     .backStatus(BackStatusEnum.NO.getBackStatus())
                                     .createTime(LocalDateTime.now())
                                     .build());
-                            beginTime = beginTime.plusMinutes(RandomUtils.nextInt(3, 10));
+                            beginTime = beginTime.plusMinutes(RandomUtils.nextInt(dto.getBetweenMinuteMin(), dto.getBetweenMinuteMax()));
                         }
                         gameTencentOrderSplitLogService.saveBatch(splitOrderLogList);
                         update(new LambdaUpdateWrapper<GameTencentOrder>()