|
@@ -21,6 +21,7 @@ import com.zanxiang.game.module.mybatis.mapper.GamePolicyConfigMapper;
|
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -51,9 +52,8 @@ public class GamePolicyConfigServiceImpl extends ServiceImpl<GamePolicyConfigMap
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean addOrUpdate(GamePolicyConfigAddOrUpdateParam param) {
|
|
|
- if (param.getAmount() == null && param.getTime() == null) {
|
|
|
- throw new BaseException("策略配置的金额和时间不能同时为空,请重新输入。");
|
|
|
- }
|
|
|
+ //检查输入的查询参数
|
|
|
+ checkParam(param);
|
|
|
//当前操作人员
|
|
|
Long sysUserId = SecurityUtil.getUserId();
|
|
|
//当前操作时间
|
|
@@ -62,7 +62,9 @@ public class GamePolicyConfigServiceImpl extends ServiceImpl<GamePolicyConfigMap
|
|
|
//生成配置json字符串
|
|
|
String configParam = JsonUtil.toString(GamePolicyConfigInnerObjVO.builder()
|
|
|
.amount(param.getAmount())
|
|
|
+ .amountCondition(param.getAmountCondition())
|
|
|
.time(param.getTime())
|
|
|
+ .timeCondition(param.getTimeCondition())
|
|
|
.build());
|
|
|
|
|
|
int count = this.count(new LambdaQueryWrapper<GamePolicyConfig>()
|
|
@@ -122,7 +124,9 @@ public class GamePolicyConfigServiceImpl extends ServiceImpl<GamePolicyConfigMap
|
|
|
//得到配置参数map
|
|
|
Map<String, String> configParam = JsonUtil.toMap(vo.getConfigParam(), Map.class, String.class);
|
|
|
String amount = configParam.get("amount");
|
|
|
+ String amountCondition = configParam.get("amountCondition");
|
|
|
String time = configParam.get("time");
|
|
|
+ String timeCondition = configParam.get("timeCondition");
|
|
|
GameSupper gameSupper = gameSupperService.getById(vo.getSuperGameId());
|
|
|
GameDTO game = gameService.getById(vo.getSuperGameId());
|
|
|
String superGameName = null == gameSupper ? (null == game ? null : game.getName()) : gameSupper.getName();
|
|
@@ -131,8 +135,10 @@ public class GamePolicyConfigServiceImpl extends ServiceImpl<GamePolicyConfigMap
|
|
|
.superGameId(vo.getSuperGameId())
|
|
|
.superGameName(superGameName)
|
|
|
.type(vo.getType())
|
|
|
- .amount(amount == null ? null : Long.valueOf(amount))
|
|
|
- .time(time == null ? null : Long.valueOf(time))
|
|
|
+ .amount(StringUtils.isBlank(amount) ? null : Long.valueOf(amount))
|
|
|
+ .amountCondition(StringUtils.isBlank(amountCondition) ? null : amountCondition)
|
|
|
+ .time(StringUtils.isBlank(time) ? null : Long.valueOf(time))
|
|
|
+ .timeCondition(StringUtils.isBlank(timeCondition) ? null : timeCondition)
|
|
|
.configExplain(vo.getConfigExplain())
|
|
|
.createBy(vo.getCreateBy())
|
|
|
.createName(sysUserRpc.getById(vo.getCreateBy()).getData().getNickname())
|
|
@@ -143,6 +149,27 @@ public class GamePolicyConfigServiceImpl extends ServiceImpl<GamePolicyConfigMap
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 检查查询参数的合法性
|
|
|
+ * @param param GamePolicyConfigAddOrUpdateParam
|
|
|
+ */
|
|
|
+ private void checkParam(GamePolicyConfigAddOrUpdateParam param) {
|
|
|
+ if (param.getAmount() == null && param.getTime() == null) {
|
|
|
+ throw new BaseException("策略配置的金额和时间不能同时为空,请重新输入。");
|
|
|
+ }
|
|
|
+ if (param.getAmount() != null && StringUtils.isBlank(param.getAmountCondition())) {
|
|
|
+ throw new BaseException("输入金额后,对应的金额条件不能为空。");
|
|
|
+ }
|
|
|
+ if (param.getAmount() == null && StringUtils.isNotBlank(param.getAmountCondition())) {
|
|
|
+ throw new BaseException("金额为空时,不能单独设置金额条件。");
|
|
|
+ }
|
|
|
+ if (param.getTime() != null && StringUtils.isBlank(param.getTimeCondition())) {
|
|
|
+ throw new BaseException("输入时间后,对应的时间条件不能为空");
|
|
|
+ }
|
|
|
+ if (param.getTime() == null && StringUtils.isNotBlank(param.getTimeCondition())) {
|
|
|
+ throw new BaseException("时间为空时,不能单独设置时间条件");
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|