Selaa lähdekoodia

Merge remote-tracking branch 'origin/package' into package

bilingfeng 1 vuosi sitten
vanhempi
commit
00e419051c

+ 6 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/RoleRechargeRankingDTO.java

@@ -189,4 +189,10 @@ public class RoleRechargeRankingDTO extends BasePage {
     @ApiModelProperty(notes = "是否唤醒 1-是;0-否; 2-空(默认)")
     private Integer isWakeUp;
 
+    /**
+     * 玩家操作系统筛选:windows;mac;ios;devtools;android
+     */
+    @ApiModelProperty(notes = "玩家操作系统筛选:windows;mac;ios;devtools;android")
+    private String os;
+
 }

+ 4 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/RoleManageServiceImpl.java

@@ -133,6 +133,10 @@ public class RoleManageServiceImpl implements IRoleManageService {
             //累计充值金额最大值
             criA.where().andLTE("amount", dto.getTotalRechargeMax());
         }
+        if (StringUtils.isNotBlank(dto.getOs())) {
+            //玩家操作系统
+            criA.where().andEquals("os", dto.getOs());
+        }
         if (dto.getIsRemoveGame() != null) {
             if (dto.getIsRemoveGame() == 2) {
                 //是否退游

+ 8 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/GameVipController.java

@@ -2,6 +2,7 @@ package com.zanxiang.game.module.manage.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zanxiang.erp.security.annotation.PreAuthorize;
+import com.zanxiang.game.module.manage.pojo.params.GameVipAddBatchParam;
 import com.zanxiang.game.module.manage.pojo.params.GameVipAddParam;
 import com.zanxiang.game.module.manage.pojo.params.GameVipListParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameVipListVO;
@@ -52,4 +53,11 @@ public class GameVipController {
         return ResultVO.ok(gameVipService.gameVipList(param));
     }
 
+    @ApiOperation(value = "批量添加VIP档位")
+    @PostMapping("/add/batch")
+    @PreAuthorize(permissionKey = "manage:gameVip:addBatch")
+    public ResultVO<Boolean> addVipBatch(@Validated @RequestBody GameVipAddBatchParam param) {
+        return ResultVO.ok(gameVipService.addBatch(param));
+    }
+
 }

+ 67 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/params/GameVipAddBatchParam.java

@@ -0,0 +1,67 @@
+package com.zanxiang.game.module.manage.pojo.params;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @author tianhua
+ * @version 1.0
+ * @description: TODO
+ * @date 2023/12/7 15:10
+ */
+@Data
+public class GameVipAddBatchParam {
+
+    /**
+     * 游戏id
+     */
+    @NotNull(message = "超父游戏id不能为空")
+    @ApiModelProperty("超父游戏id")
+    private Long superGameId;
+
+    /**
+     * 游戏id
+     */
+    @NotNull(message = "父游戏id不能为空")
+    @ApiModelProperty("父游戏id")
+    private List<Long> parentGameId;
+
+    /**
+     * 游戏VIP参数列表
+     */
+    @NotNull(message = "新增的游戏vip不能为空")
+    @ApiModelProperty("游戏VIP参数列表")
+    private List<GameVipParam> list;
+
+    /**
+     * 内部类
+     */
+    @Data
+    public static class GameVipParam {
+        /**
+         * 充值金额最小(包含)
+         */
+        @NotNull(message = "充值金额最小不能为空")
+        @ApiModelProperty("充值金额最小(包含)")
+        private BigDecimal rechargeMoneyMin;
+
+        /**
+         * 充值金额最大(不包含)
+         */
+        @NotNull(message = "充值金额最大不能为空")
+        @ApiModelProperty("充值金额最大(不包含)")
+        private BigDecimal rechargeMoneyMax;
+
+        /**
+         * vip档位
+         */
+        @NotNull(message = "vip档位不能为空")
+        @ApiModelProperty("vip档位")
+        private Integer vipLevel;
+    }
+
+}

+ 3 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameVipService.java

@@ -2,6 +2,7 @@ package com.zanxiang.game.module.manage.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zanxiang.game.module.manage.pojo.params.GameVipAddBatchParam;
 import com.zanxiang.game.module.manage.pojo.params.GameVipAddParam;
 import com.zanxiang.game.module.manage.pojo.params.GameVipListParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameVipListVO;
@@ -23,4 +24,6 @@ public interface IGameVipService extends IService<GameVip> {
 
     IPage<GameVipListVO> gameVipList(GameVipListParam param);
 
+    boolean addBatch(GameVipAddBatchParam param);
+
 }

+ 56 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameVipServiceImpl.java

@@ -8,6 +8,7 @@ import com.zanxiang.erp.base.ErpServer;
 import com.zanxiang.erp.base.rpc.ISysUserRpc;
 import com.zanxiang.erp.security.util.SecurityUtil;
 import com.zanxiang.game.module.manage.pojo.dto.GameDTO;
+import com.zanxiang.game.module.manage.pojo.params.GameVipAddBatchParam;
 import com.zanxiang.game.module.manage.pojo.params.GameVipAddParam;
 import com.zanxiang.game.module.manage.pojo.params.GameVipListParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameVipListVO;
@@ -18,13 +19,16 @@ import com.zanxiang.game.module.mybatis.entity.GameSupper;
 import com.zanxiang.game.module.mybatis.entity.GameVip;
 import com.zanxiang.game.module.mybatis.mapper.GameVipMapper;
 import com.zanxiang.module.util.exception.BaseException;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author tianhua
@@ -113,6 +117,58 @@ public class GameVipServiceImpl extends ServiceImpl<GameVipMapper, GameVip> impl
                 .convert(this::toVO);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean addBatch(GameVipAddBatchParam param) {
+        checkParam(param);
+        Long sysUserId = SecurityUtil.getUserId();
+        LocalDateTime now = LocalDateTime.now();
+        //得到需要添加的vip列表的所有vip等级
+        List<Integer> vipList = param.getList().stream()
+                .map(GameVipAddBatchParam.GameVipParam::getVipLevel).collect(Collectors.toList());
+
+        int count = count(new LambdaQueryWrapper<GameVip>()
+                .eq(GameVip::getSuperGameId, param.getSuperGameId())
+                .in(GameVip::getParentGameId, param.getParentGameId())
+                .in(GameVip::getVipLevel, vipList)
+                .eq(GameVip::getIsDelete, 0));
+        if (count > 0) {
+            throw new BaseException("已经存在需要添加的VIP等级,请勿重复设置。");
+        }
+        //总共需要建多少个GameVip实例
+        int size = param.getParentGameId().size() * param.getList().size();
+        List<GameVip> list = new ArrayList<>(size);
+        for (int i = 0; i < param.getParentGameId().size(); i++) {
+            //父游戏ID
+            Long parentGameId = param.getParentGameId().get(i);
+            for (GameVipAddBatchParam.GameVipParam gameVipParam : param.getList()) {
+                list.add(GameVip.builder()
+                                .parentGameId(parentGameId)
+                                .superGameId(param.getSuperGameId())
+                                .rechargeMoneyMin(gameVipParam.getRechargeMoneyMin())
+                                .rechargeMoneyMax(gameVipParam.getRechargeMoneyMax())
+                                .vipLevel(gameVipParam.getVipLevel())
+                                .createBy(sysUserId)
+                                .createTime(now)
+                                .updateTime(now)
+                                .updateBy(sysUserId)
+                                .build());
+            }
+        }
+        return saveBatch(list);
+    }
+
+    private void checkParam(GameVipAddBatchParam param) {
+        if (CollectionUtils.isEmpty(param.getList())) {
+            throw new BaseException("至少创建一个VIP档位。");
+        }
+        List<Integer> collect = param.getList().stream()
+                .map(GameVipAddBatchParam.GameVipParam::getVipLevel).collect(Collectors.toList())
+                .stream().distinct().collect(Collectors.toList());
+        if (collect.size() != param.getList().size()) {
+            throw new BaseException("不能创建重复的VIP档位。");
+        }
+    }
 
     private GameVipListVO toVO(GameVip vo) {
         GameDTO game = gameService.getById(vo.getParentGameId());