Selaa lähdekoodia

feat : sdk对接修改

bilingfeng 2 vuotta sitten
vanhempi
commit
cbb4478e65

+ 12 - 3
game-module/game-manage/src/main/java/com/zanxiang/manage/controller/GamePayStrategyController.java

@@ -3,6 +3,7 @@ package com.zanxiang.manage.controller;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zanxiang.common.domain.ResultVO;
 import com.zanxiang.erp.security.annotation.PreAuthorize;
+import com.zanxiang.manage.domain.params.GamePayStrategyAddUpdateParam;
 import com.zanxiang.manage.domain.params.GamePayStrategyListParam;
 import com.zanxiang.manage.domain.vo.GamePayStrategyListVO;
 import com.zanxiang.manage.service.IGamePayStrategyService;
@@ -27,9 +28,17 @@ public class GamePayStrategyController {
     @Autowired
     private IGamePayStrategyService gamePayStrategyService;
 
+    @ApiOperation(value = "游戏支付策略新增或者更新")
+    @PostMapping(value = "/add/or/update")
+    @PreAuthorize(permissionKey = "manage:gamePayStrategy:addOrUpdate")
+    @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
+    public ResultVO<Boolean> addOrUpdate(@Validated @RequestBody GamePayStrategyAddUpdateParam param) {
+        return new ResultVO<>(gamePayStrategyService.addOrUpdate(param));
+    }
+
     @ApiOperation(value = "游戏支付策略列表查询")
     @PostMapping(value = "/list")
-    @PreAuthorize(permissionKey = "manage:payStrategy:list")
+    @PreAuthorize(permissionKey = "manage:gamePayStrategy:list")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = GamePayStrategyListVO.class)})
     public ResultVO<IPage<GamePayStrategyListVO>> pageList(@Validated @RequestBody GamePayStrategyListParam param) {
         return new ResultVO<>(gamePayStrategyService.pageList(param));
@@ -37,7 +46,7 @@ public class GamePayStrategyController {
 
     @ApiOperation(value = "游戏支付策略删除")
     @DeleteMapping(value = "/delete")
-    @PreAuthorize(permissionKey = "manage:payStrategy:delete")
+    @PreAuthorize(permissionKey = "manage:gamePayStrategy:delete")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
     public ResultVO<Boolean> deleteById(@RequestParam Long id) {
         return new ResultVO<>(gamePayStrategyService.deleteById(id));
@@ -45,7 +54,7 @@ public class GamePayStrategyController {
 
     @ApiOperation(value = "游戏支付策略状态变更")
     @PatchMapping(value = "/status/update")
-    @PreAuthorize(permissionKey = "manage:payStrategy:statusUpdate")
+    @PreAuthorize(permissionKey = "manage:gamePayStrategy:statusUpdate")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Boolean.class)})
     public ResultVO<Boolean> statusUpdate(@RequestParam Long id, @RequestParam Integer status) {
         return new ResultVO<>(gamePayStrategyService.statusUpdate(id, status));

+ 68 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/GamePayStrategyAddUpdateParam.java

@@ -0,0 +1,68 @@
+package com.zanxiang.manage.domain.params;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+/**
+ * @author : lingfeng
+ * @time : 2023-02-16
+ * @description : 游戏支付策略添加或者更新
+ */
+@Data
+public class GamePayStrategyAddUpdateParam {
+
+    /**
+     * 主键id
+     */
+    @ApiModelProperty(notes = "主键id")
+    private Long id;
+
+    /**
+     * 策略名称
+     */
+    @NotBlank(message = "策略名称不可为空")
+    @ApiModelProperty(notes = "策略名称")
+    private String name;
+
+    /**
+     * 策略类型 1: 切换规则, 2: 显示规则, 3: 订单起量切换规则
+     */
+    @NotNull(message = "策略类型不可为空")
+    @ApiModelProperty(notes = "策略类型 1: 切换规则, 2: 显示规则, 3: 订单起量切换规则")
+    private Integer type;
+
+    /**
+     * 关联游戏id
+     */
+    @NotNull(message = "关联游戏id不可为空")
+    @ApiModelProperty(notes = "关联游戏id")
+    private Long gameId;
+
+    /**
+     * 总支付额度
+     */
+    @ApiModelProperty(notes = "总支付额度")
+    private BigDecimal totalPayAmount;
+
+    /**
+     * 月已用额度
+     */
+    @ApiModelProperty(notes = "月已用额度")
+    private BigDecimal mouthPayAmount;
+
+    /**
+     * 周已用额度
+     */
+    @ApiModelProperty(notes = "周已用额度")
+    private BigDecimal weakerPayAmount;
+
+    /**
+     * 日已用额度
+     */
+    @ApiModelProperty(notes = "日已用额度")
+    private BigDecimal dayPayAmount;
+}

+ 9 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/IGamePayStrategyService.java

@@ -2,6 +2,7 @@ package com.zanxiang.manage.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zanxiang.manage.domain.params.GamePayStrategyAddUpdateParam;
 import com.zanxiang.manage.domain.params.GamePayStrategyListParam;
 import com.zanxiang.manage.domain.vo.GamePayStrategyListVO;
 import com.zanxiang.mybatis.entity.GamePayStrategy;
@@ -13,6 +14,14 @@ import com.zanxiang.mybatis.entity.GamePayStrategy;
  */
 public interface IGamePayStrategyService extends IService<GamePayStrategy> {
 
+    /**
+     * 添加或更新
+     *
+     * @param param 参数
+     * @return boolean
+     */
+    boolean addOrUpdate(GamePayStrategyAddUpdateParam param);
+
     /**
      * 页面列表
      *

+ 52 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/impl/GamePayStrategyServiceImpl.java

@@ -4,11 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zanxiang.common.enums.DeleteEnum;
 import com.zanxiang.common.enums.GameStrategyTypeEnum;
+import com.zanxiang.common.enums.StatusEnum;
+import com.zanxiang.common.exception.BaseException;
 import com.zanxiang.common.utils.bean.BeanUtils;
 import com.zanxiang.manage.domain.dto.GameCategoryDTO;
 import com.zanxiang.manage.domain.dto.GameDTO;
 import com.zanxiang.manage.domain.dto.PayMerchantDTO;
+import com.zanxiang.manage.domain.params.GamePayStrategyAddUpdateParam;
 import com.zanxiang.manage.domain.params.GamePayStrategyListParam;
 import com.zanxiang.manage.domain.vo.GamePayStrategyListVO;
 import com.zanxiang.manage.service.*;
@@ -22,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
 /**
@@ -44,6 +49,53 @@ public class GamePayStrategyServiceImpl extends ServiceImpl<GameStrategyMapper,
     @Autowired
     private IGamePayWayService gamePayWayService;
 
+    @Override
+    public boolean addOrUpdate(GamePayStrategyAddUpdateParam param) {
+        Long id = param.getId();
+        GamePayStrategy gamePayStrategy;
+        if (id == null) {
+            this.gamePayStrategyNameCheck(param.getName());
+            gamePayStrategy = GamePayStrategy.builder()
+                    .name(param.getName())
+                    .type(param.getType())
+                    .gameId(param.getGameId())
+                    .totalPayAmount(param.getTotalPayAmount())
+                    .mouthPayAmount(param.getMouthPayAmount())
+                    .weakerPayAmount(param.getWeakerPayAmount())
+                    .dayPayAmount(param.getDayPayAmount())
+                    .status(StatusEnum.YES.getCode())
+                    .isDelete(DeleteEnum.NO.getCode())
+                    .createTime(LocalDateTime.now())
+                    .updateTime(LocalDateTime.now())
+                    .build();
+        } else {
+            gamePayStrategy = super.getById(id);
+            if (gamePayStrategy == null) {
+                throw new BaseException("参数错误, 游戏支付配置信息不存在");
+            }
+            if (!Objects.equals(gamePayStrategy.getName(), param.getName())) {
+                this.gamePayStrategyNameCheck(param.getName());
+            }
+            gamePayStrategy.setName(param.getName());
+            gamePayStrategy.setType(param.getType());
+            gamePayStrategy.setGameId(param.getGameId());
+            gamePayStrategy.setTotalPayAmount(param.getTotalPayAmount());
+            gamePayStrategy.setMouthPayAmount(param.getMouthPayAmount());
+            gamePayStrategy.setWeakerPayAmount(param.getWeakerPayAmount());
+            gamePayStrategy.setDayPayAmount(param.getDayPayAmount());
+            gamePayStrategy.setUpdateTime(LocalDateTime.now());
+        }
+        return super.saveOrUpdate(gamePayStrategy);
+    }
+
+    private void gamePayStrategyNameCheck(String name) {
+        int count = super.count(new LambdaQueryWrapper<GamePayStrategy>()
+                .eq(GamePayStrategy::getName, name));
+        if (count > 0) {
+            throw new BaseException("策略名称重复");
+        }
+    }
+
     @Override
     public IPage<GamePayStrategyListVO> pageList(GamePayStrategyListParam param) {
         Map<Long, GameCategoryDTO> gameCategoryMap = gameCategoryService.gameCategoryMap();