|
@@ -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();
|