Commit 7ff95b93 authored by zhangfeng's avatar zhangfeng

订单V值VO调整

parent 3b3ffcf8
......@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.member.service.scoreRule;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import cn.hutool.core.collection.CollectionUtil;
......@@ -26,6 +27,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleShareExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRulerRecommendExtraVO;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
......@@ -33,6 +35,7 @@ import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
import static java.util.Arrays.stream;
/**
* 积分规则 Service 实现类
......@@ -148,7 +151,28 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if (extraOrderV.getTransportType() != TransportTypeEnum.OCEAN_LCL.getValue() && extraOrderV.getTransportType() != TransportTypeEnum.SPECIAL_LINE_AIR_FREIGHT.getValue()) {
throw exception(SCORE_RULE_FIELD_ERROR);
}
if (StringUtils.isAnyBlank(extraOrderV.getTargetCountry(), extraOrderV.getTargetCity(), extraOrderV.getReceiveAddr(), extraOrderV.getOrderEntry())) {
// 国家,城市,仓库id从receiveAddrList中获取
List<List<Long>> receiveAddrList = extraOrderV.getReceiveAddrList();
if (receiveAddrList == null || extraOrderV.getReceiveAddrList().isEmpty()) {
throw exception(SCORE_RULE_FIELD_ERROR);
}
StringBuilder targetCountry = new StringBuilder();
StringBuilder targetCity = new StringBuilder();
StringBuilder receiveAddr = new StringBuilder();
for (List<Long> integers : receiveAddrList) {
try {
targetCountry.append(integers.get(1)).append(",");
targetCity.append(integers.get(2)).append(",");
receiveAddr.append(integers.get(3)).append(",");
} catch (Exception e) {
throw exception(SCORE_RULE_FIELD_ERROR);
}
}
extraOrderV.setTargetCountry(targetCountry.toString());
extraOrderV.setTargetCity(targetCity.toString());
extraOrderV.setReceiveAddr(receiveAddr.toString());
extraOrderV.setReceiveAddrList(null);
if (StringUtils.isBlank(extraOrderV.getOrderEntry())) {
throw exception(SCORE_RULE_FIELD_ERROR);
}
verifyOrderVRule(extraOrderV.getOrderVRule());
......@@ -254,7 +278,10 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
*/
private void setExtraVO(ScoreRuleBackDetailVO scoreRuleBackDetailVO) {
if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.ORDER_V.getValue()) {
scoreRuleBackDetailVO.setExtraOrderV(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRuleOrderVExtraVO.class));
ScoreRuleOrderVExtraVO orderVExtraVO = JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRuleOrderVExtraVO.class);
List<List<Long>> receiveAddrList = getReceiveAddrList(orderVExtraVO);
orderVExtraVO.setReceiveAddrList(receiveAddrList);
scoreRuleBackDetailVO.setExtraOrderV(orderVExtraVO);
} else if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.REGISTER.getValue()) {
scoreRuleBackDetailVO.setExtraRegister(JSONUtil.toBean(scoreRuleBackDetailVO.getExtra(), ScoreRuleRegisterExtraVO.class));
} else if (scoreRuleBackDetailVO.getType() == ScoreRuleTypeEnum.RECOMMEND.getValue()) {
......@@ -266,6 +293,21 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
}
}
private @NotNull List<List<Long>> getReceiveAddrList(ScoreRuleOrderVExtraVO orderVExtraVO) {
List<List<Long>> receiveAddrList = new ArrayList<>();
String[] receiveAddrStrs = orderVExtraVO.getReceiveAddr().split(",");
String[] targetCityStrs = orderVExtraVO.getTargetCity().split(",");
String[] targetCountryStrs = orderVExtraVO.getTargetCountry().split(",");
for (int i = 0; i < receiveAddrStrs.length; i++) {
List<Long> list = new ArrayList<>();
list.add(Long.parseLong(targetCountryStrs[i]));
list.add(Long.parseLong(targetCityStrs[i]));
list.add(Long.parseLong(receiveAddrStrs[i]));
receiveAddrList.add(list);
}
return receiveAddrList;
}
@Override
public List<ScoreRuleDO> getScoreRuleList(ScoreRuleQueryVO query) {
return scoreRuleMapper.selectList(query);
......
......@@ -20,7 +20,7 @@ public class ScoreRuleOrderVExtraVO {
@ApiModelProperty(value = "提货点,可多选,逗号拼接", required = true)
private String receiveAddr;
@ApiModelProperty(value = "提货点列表(第一级提货点,第二级国家,城市,仓库id)", required = true)
private List<List<Integer>> receiveAddrList;
private List<List<Long>> receiveAddrList;
@ApiModelProperty(value = "渠道,运输方式选择海运时,渠道隐藏,可多选,逗号拼接")
private String channel;
@ApiModelProperty(value = "积分规则列表", required = true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment