Commit 3b3ffcf8 authored by zhangfeng's avatar zhangfeng

获得目的仓树形列表返回优化

parent f9d6bf8f
......@@ -123,7 +123,9 @@ public interface WarehouseMapper extends BaseMapperX<WarehouseDO> {
@Select({
"SELECT w.*, ",
"r1.title_zh as guojiaName,",
"r2.title_zh as shiName ",
"r1.title_en as guojiaNameEn,",
"r2.title_zh as shiName, ",
"r2.title_en as shiNameEn ",
"FROM ecw_warehouse w ",
"LEFT JOIN ecw_region r1 ",
"ON w.guojia = r1.id ",
......
......@@ -9,8 +9,10 @@ import java.util.List;
public class WarehouseTreeRegionVO extends WarehouseRespVO{
private String guojiaName ;
private String guojiaNameEn ;
private String shiName;
private String shiNameEn;
private Long pid ;
......
......@@ -43,8 +43,6 @@ public class ScoreRuleController {
@Resource
private ScoreRuleService scoreRuleService;
@Resource
private WarehouseService warehouseService;
@Resource
private ApplicationContext applicationContext;
@Resource
private ScoreProducerApi scoreProducerApi;
......@@ -122,10 +120,8 @@ public class ScoreRuleController {
@GetMapping("/warehouse-tree-region-list")
@ApiOperation("获得目的国、目的城市、目的仓列表")
public CommonResult<List<WarehouseTreeRegionVO>> warehouseTreeRegionList() {
List<WarehouseTreeRegionVO> listIn = warehouseService.getWarehouseTreeRegionList(1);
List<WarehouseTreeRegionVO> listOut = warehouseService.getWarehouseTreeRegionList(2);
List<WarehouseTreeRegionVO> list = ListUtils.sum(listIn, listOut);
public CommonResult<List<WarehouseTreeRegionSimpleVO>> warehouseTreeRegionList() {
List<WarehouseTreeRegionSimpleVO> list= scoreRuleService.getWarehouseTreeRegionListSimple();
return success(list);
}
......
......@@ -119,4 +119,6 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
* @return
*/
ScoreRuleDO getEnableScoreRuleByType(ScoreRuleTypeEnum scoreRuleType, TransportTypeEnum transportType);
List<WarehouseTreeRegionSimpleVO> getWarehouseTreeRegionListSimple();
}
......@@ -9,6 +9,8 @@ import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.module.depository.service.warehouse.WarehouseService;
import cn.iocoder.yudao.module.depository.vo.warehouse.WarehouseTreeRegionVO;
import cn.iocoder.yudao.module.member.convert.scoreRule.ScoreRuleConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import cn.iocoder.yudao.module.member.dal.mysql.scoreRule.ScoreRuleMapper;
......@@ -22,6 +24,7 @@ import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO;
import cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleRegisterExtraVO;
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.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
......@@ -44,6 +47,8 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
private ScoreRuleMapper scoreRuleMapper;
@Resource
private ScoreRuleRedisDao scoreRuleRedisDao;
@Resource
private WarehouseService warehouseService;
@Override
public Long createScoreRule(ScoreRuleCreateReqVO createReqVO) {
......@@ -402,4 +407,44 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
}
return null;
}
@Override
public List<WarehouseTreeRegionSimpleVO> getWarehouseTreeRegionListSimple() {
List<WarehouseTreeRegionVO> listIn = warehouseService.getWarehouseTreeRegionList(1);
List<WarehouseTreeRegionVO> listOut = warehouseService.getWarehouseTreeRegionList(2);
List<WarehouseTreeRegionVO> list = ListUtils.sum(listIn, listOut);
ArrayList<WarehouseTreeRegionSimpleVO> warehouseTreeRegionSimpleVOS = new ArrayList<>();
for (WarehouseTreeRegionVO warehouseTreeRegionVO : list) {
WarehouseTreeRegionSimpleVO warehouseTreeRegionSimpleVO = new WarehouseTreeRegionSimpleVO();
warehouseTreeRegionSimpleVO.setCountryId(warehouseTreeRegionVO.getGuojia());
warehouseTreeRegionSimpleVO.setLabelZh(warehouseTreeRegionVO.getGuojiaName().replaceAll("\t", ""));
warehouseTreeRegionSimpleVO.setLabelEn(warehouseTreeRegionVO.getChildren().get(0).getGuojiaNameEn());
ArrayList<WarehouseTreeRegionSimpleVO.WarehouseCity> warehouseCitiesSimple = new ArrayList<>();
for (WarehouseTreeRegionVO warehouseTreeRegionVOChild : warehouseTreeRegionVO.getChildren()) {
WarehouseTreeRegionSimpleVO.WarehouseCity warehouseCity = new WarehouseTreeRegionSimpleVO.WarehouseCity();
warehouseCity.setCityId(warehouseTreeRegionVOChild.getShi());
warehouseCity.setLabelZh(warehouseTreeRegionVOChild.getShiName().replaceAll("\t", ""));
warehouseCity.setLabelEn(warehouseTreeRegionVOChild.getShiNameEn());
if (warehouseCitiesSimple.contains(warehouseCity)) {
WarehouseTreeRegionSimpleVO.Warehouse warehouse = new WarehouseTreeRegionSimpleVO.Warehouse();
warehouse.setWarehouseId(warehouseTreeRegionVOChild.getId());
warehouse.setLabelZh(warehouseTreeRegionVOChild.getTitleZh());
warehouse.setLabelEn(warehouseTreeRegionVOChild.getTitleEn());
warehouseCitiesSimple.get(warehouseCitiesSimple.indexOf(warehouseCity)).getChildren().add(warehouse);
continue;
}
ArrayList<WarehouseTreeRegionSimpleVO.Warehouse> warehouseSimples = new ArrayList<>();
WarehouseTreeRegionSimpleVO.Warehouse warehouse = new WarehouseTreeRegionSimpleVO.Warehouse();
warehouse.setWarehouseId(warehouseTreeRegionVOChild.getId());
warehouse.setLabelZh(warehouseTreeRegionVOChild.getTitleZh().replaceAll("\t", ""));
warehouse.setLabelEn(warehouseTreeRegionVOChild.getTitleEn());
warehouseSimples.add(warehouse);
warehouseCity.setChildren(warehouseSimples);
warehouseCitiesSimple.add(warehouseCity);
}
warehouseTreeRegionSimpleVO.setChildren(warehouseCitiesSimple);
warehouseTreeRegionSimpleVOS.add(warehouseTreeRegionSimpleVO);
}
return warehouseTreeRegionSimpleVOS;
}
}
package cn.iocoder.yudao.module.member.vo.scoreRule;
import cn.iocoder.yudao.module.depository.vo.warehouse.WarehouseRespVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
import java.util.Objects;
@Data
public class WarehouseTreeRegionSimpleVO {
@ApiModelProperty("国家id")
private Long countryId;
@ApiModelProperty("国家中文名")
private String labelZh;
@ApiModelProperty("国家英文名")
private String labelEn;
@ApiModelProperty("城市")
private List<WarehouseCity> children;
@Data
public static class WarehouseCity {
@ApiModelProperty("城市id")
private Long cityId;
@ApiModelProperty("城市中文名")
private String labelZh;
@ApiModelProperty("城市英文名")
private String labelEn;
@ApiModelProperty("仓库")
private List<Warehouse> children;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
WarehouseCity that = (WarehouseCity) o;
return Objects.equals(cityId, that.cityId);
}
@Override
public int hashCode() {
return Objects.hashCode(cityId);
}
}
@Data
public static class Warehouse {
@ApiModelProperty("仓库id")
private Long warehouseId;
@ApiModelProperty("仓库中文名")
private String labelZh;
@ApiModelProperty("仓库英文名")
private String labelEn;
}
}
......@@ -19,6 +19,8 @@ public class ScoreRuleOrderVExtraVO {
private String targetCity;
@ApiModelProperty(value = "提货点,可多选,逗号拼接", required = true)
private String receiveAddr;
@ApiModelProperty(value = "提货点列表(第一级提货点,第二级国家,城市,仓库id)", required = true)
private List<List<Integer>> 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