fix
parent
f130cd708e
commit
366a1959da
|
|
@ -3,17 +3,14 @@ package com.ruoyi.web.controller.xkt;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.ruoyi.common.core.controller.XktBaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.web.controller.xkt.vo.express.ExpressAddressParseReqVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.express.ExpressRegionTreeNodeVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.express.ExpressStructAddressVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.express.*;
|
||||
import com.ruoyi.xkt.dto.express.ExpressFeeDTO;
|
||||
import com.ruoyi.xkt.dto.express.ExpressRegionTreeNodeDTO;
|
||||
import com.ruoyi.xkt.dto.express.ExpressStructAddressDTO;
|
||||
import com.ruoyi.xkt.manager.ExpressManager;
|
||||
import com.ruoyi.xkt.service.IExpressService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
|
@ -30,10 +27,21 @@ public class ExpressController extends XktBaseController {
|
|||
|
||||
@Autowired
|
||||
private IExpressService expressService;
|
||||
@Autowired
|
||||
private List<ExpressManager> expressManagers;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:express:query')")
|
||||
@ApiOperation("全部物流")
|
||||
@GetMapping("allExpress")
|
||||
public R<List<ExpressVO>> allExpress() {
|
||||
return success(BeanUtil.copyToList(expressService.allExpress(), ExpressVO.class));
|
||||
}
|
||||
|
||||
@ApiOperation("下单时物流选择列表 - 含快递费")
|
||||
@PostMapping("listExpressFee")
|
||||
public R<List<ExpressFeeVO>> listExpressFee(@Valid @RequestBody ExpressFeeReqVO vo) {
|
||||
List<ExpressFeeDTO> dtoList = expressService.listExpressFee(vo.getGoodsQuantity(), vo.getProvinceCode(),
|
||||
vo.getCityCode(), vo.getCountyCode());
|
||||
return success(BeanUtil.copyToList(dtoList, ExpressFeeVO.class));
|
||||
}
|
||||
|
||||
@ApiOperation("获取行政规划树")
|
||||
@GetMapping("getRegionTree")
|
||||
public R<List<ExpressRegionTreeNodeVO>> getRegionTree() {
|
||||
|
|
@ -41,7 +49,6 @@ public class ExpressController extends XktBaseController {
|
|||
return success(BeanUtil.copyToList(dtoList, ExpressRegionTreeNodeVO.class));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:express:query')")
|
||||
@ApiOperation("智能解析 - 对地址、姓名、电话等,进行智能识别")
|
||||
@PostMapping("parseNamePhoneAddress")
|
||||
public R<ExpressStructAddressVO> parseNamePhoneAddress(@Valid @RequestBody ExpressAddressParseReqVO vo) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.express;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 物流信息
|
||||
*
|
||||
* @author liangyq
|
||||
* @date 2025-04-01 11:57:52.434
|
||||
**/
|
||||
@ApiModel
|
||||
@Data
|
||||
public class ExpressFeeReqVO {
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer goodsQuantity;
|
||||
|
||||
@NotEmpty
|
||||
@ApiModelProperty(value = "省编码")
|
||||
private String provinceCode;
|
||||
|
||||
@NotEmpty
|
||||
@ApiModelProperty(value = "市编码")
|
||||
private String cityCode;
|
||||
|
||||
@NotEmpty
|
||||
@ApiModelProperty(value = "区县编码")
|
||||
private String countyCode;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.express;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 物流信息
|
||||
*
|
||||
* @author liangyq
|
||||
* @date 2025-04-01 11:57:52.434
|
||||
**/
|
||||
@ApiModel
|
||||
@Data
|
||||
public class ExpressFeeVO {
|
||||
/**
|
||||
* 物流ID
|
||||
*/
|
||||
@ApiModelProperty(value = "物流ID")
|
||||
private Long id;
|
||||
/**
|
||||
* 物流编码
|
||||
*/
|
||||
@ApiModelProperty(value = "物流编码")
|
||||
private String expressCode;
|
||||
/**
|
||||
* 物流名称
|
||||
*/
|
||||
@ApiModelProperty(value = "物流名称")
|
||||
private String expressName;
|
||||
|
||||
@ApiModelProperty(value = "快递费")
|
||||
private BigDecimal expressFee;
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.express;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 物流信息
|
||||
*
|
||||
* @author liangyq
|
||||
* @date 2025-04-01 11:57:52.434
|
||||
**/
|
||||
@ApiModel
|
||||
@Data
|
||||
public class ExpressVO {
|
||||
/**
|
||||
* 物流ID
|
||||
*/
|
||||
@ApiModelProperty(value = "物流ID")
|
||||
private Long id;
|
||||
/**
|
||||
* 物流编码
|
||||
*/
|
||||
@ApiModelProperty(value = "物流编码")
|
||||
private String expressCode;
|
||||
/**
|
||||
* 物流名称
|
||||
*/
|
||||
@ApiModelProperty(value = "物流名称")
|
||||
private String expressName;
|
||||
/**
|
||||
* 系统发货可选
|
||||
*/
|
||||
@ApiModelProperty(value = "系统发货可选")
|
||||
private Boolean systemDeliverAccess;
|
||||
/**
|
||||
* 档口发货可选
|
||||
*/
|
||||
@ApiModelProperty(value = "档口发货可选")
|
||||
private Boolean storeDeliverAccess;
|
||||
/**
|
||||
* 用户退货可选
|
||||
*/
|
||||
@ApiModelProperty(value = "用户退货可选")
|
||||
private Boolean userRefundAccess;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.ruoyi.xkt.dto.express;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 物流信息
|
||||
*
|
||||
* @author liangyq
|
||||
* @date 2025-04-01 11:57:52.434
|
||||
**/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ExpressFeeDTO extends ExpressDTO{
|
||||
|
||||
private BigDecimal expressFee;
|
||||
}
|
||||
|
|
@ -31,6 +31,24 @@ public interface IExpressService {
|
|||
*/
|
||||
Express getById(Long expressId);
|
||||
|
||||
/**
|
||||
* 获取所有物流
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<ExpressDTO> allExpress();
|
||||
|
||||
/**
|
||||
* 快递费
|
||||
*
|
||||
* @param goodsQuantity
|
||||
* @param provinceCode
|
||||
* @param cityCode
|
||||
* @param countyCode
|
||||
* @return
|
||||
*/
|
||||
List<ExpressFeeDTO> listExpressFee(Integer goodsQuantity, String provinceCode, String cityCode, String countyCode);
|
||||
|
||||
/**
|
||||
* 获取快递费配置
|
||||
*
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -74,6 +74,35 @@ public class ExpressServiceImpl implements IExpressService {
|
|||
return expressMapper.selectById(expressId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExpressDTO> allExpress() {
|
||||
return BeanUtil.copyToList(expressMapper.selectList(Wrappers.lambdaQuery(Express.class)
|
||||
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED)), ExpressDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExpressFeeDTO> listExpressFee(Integer goodsQuantity, String provinceCode, String cityCode, String countyCode) {
|
||||
Assert.notNull(goodsQuantity);
|
||||
Assert.isTrue(goodsQuantity > 0);
|
||||
List<Express> expresses = expressMapper.selectList(Wrappers.lambdaQuery(Express.class)
|
||||
.eq(Express::getSystemDeliverAccess, true)
|
||||
.eq(SimpleEntity::getDelFlag, Constants.UNDELETED));
|
||||
return expresses.stream().map(e -> {
|
||||
ExpressFeeDTO dto = BeanUtil.toBean(e, ExpressFeeDTO.class);
|
||||
ExpressFeeConfig feeConfig = getExpressFeeConfig(e.getId(), provinceCode, cityCode, countyCode);
|
||||
Assert.notNull(feeConfig, "获取快递费用异常");
|
||||
BigDecimal fee;
|
||||
if (goodsQuantity == 1) {
|
||||
fee = feeConfig.getFirstItemAmount();
|
||||
} else {
|
||||
fee = feeConfig.getFirstItemAmount()
|
||||
.add(feeConfig.getNextItemAmount().multiply(BigDecimal.valueOf(goodsQuantity - 1)));
|
||||
}
|
||||
dto.setExpressFee(fee);
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressFeeConfig getExpressFeeConfig(Long expressId, String provinceCode, String cityCode,
|
||||
String countyCode) {
|
||||
|
|
@ -81,28 +110,33 @@ public class ExpressServiceImpl implements IExpressService {
|
|||
Assert.notEmpty(provinceCode);
|
||||
Assert.notEmpty(cityCode);
|
||||
Assert.notEmpty(countyCode);
|
||||
Map<String, ExpressFeeConfig> map = expressFeeConfigMapper.selectList(Wrappers.lambdaQuery(ExpressFeeConfig.class)
|
||||
.eq(ExpressFeeConfig::getExpressId, expressId)
|
||||
.in(ExpressFeeConfig::getRegionCode, Arrays.asList(provinceCode, cityCode, countyCode)))
|
||||
.stream()
|
||||
//过滤掉已被删除的配置
|
||||
.filter(BeanValidators::exists)
|
||||
.collect(Collectors.toMap(o -> o.getRegionCode(), o -> o, (n, o) -> n));
|
||||
ExpressFeeConfig expressFeeConfig = null;
|
||||
if (CollUtil.isNotEmpty(map)) {
|
||||
if (map.size() == 1) {
|
||||
expressFeeConfig = CollUtil.getFirst(map.values());
|
||||
} else {
|
||||
expressFeeConfig = map.get(countyCode);
|
||||
//按区市省从小到大去匹配
|
||||
if (expressFeeConfig == null) {
|
||||
expressFeeConfig = map.get(cityCode);
|
||||
if (expressFeeConfig == null) {
|
||||
expressFeeConfig = map.get(provinceCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO mock
|
||||
// Map<String, ExpressFeeConfig> map = expressFeeConfigMapper.selectList(Wrappers.lambdaQuery(ExpressFeeConfig.class)
|
||||
// .eq(ExpressFeeConfig::getExpressId, expressId)
|
||||
// .in(ExpressFeeConfig::getRegionCode, Arrays.asList(provinceCode, cityCode, countyCode)))
|
||||
// .stream()
|
||||
// //过滤掉已被删除的配置
|
||||
// .filter(BeanValidators::exists)
|
||||
// .collect(Collectors.toMap(o -> o.getRegionCode(), o -> o, (n, o) -> n));
|
||||
// ExpressFeeConfig expressFeeConfig = null;
|
||||
// if (CollUtil.isNotEmpty(map)) {
|
||||
// if (map.size() == 1) {
|
||||
// expressFeeConfig = CollUtil.getFirst(map.values());
|
||||
// } else {
|
||||
// expressFeeConfig = map.get(countyCode);
|
||||
// //按区市省从小到大去匹配
|
||||
// if (expressFeeConfig == null) {
|
||||
// expressFeeConfig = map.get(cityCode);
|
||||
// if (expressFeeConfig == null) {
|
||||
// expressFeeConfig = map.get(provinceCode);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
ExpressFeeConfig expressFeeConfig = new ExpressFeeConfig();
|
||||
expressFeeConfig.setExpressId(expressId);
|
||||
expressFeeConfig.setFirstItemAmount(BigDecimal.valueOf(5));
|
||||
expressFeeConfig.setNextItemAmount(BigDecimal.valueOf(5));
|
||||
return expressFeeConfig;
|
||||
}
|
||||
|
||||
|
|
@ -188,12 +222,12 @@ public class ExpressServiceImpl implements IExpressService {
|
|||
JSONObject rtn = ztoExpressManager.structureNamePhoneAddress(str);
|
||||
JSONObject address = rtn.getJSONObject("address");
|
||||
Assert.notNull(address, "获取行政区划失败");
|
||||
String provinceCode = address.getStr("province");
|
||||
String provinceCode = address.getStr("provinceId");
|
||||
String cityCode = address.getStr("cityId");
|
||||
String countyCode = address.getStr("countyId");
|
||||
String name = rtn.getStr("name");
|
||||
String phone = rtn.getStr("phone");
|
||||
String detailAddress = rtn.getStr("detail");
|
||||
String detailAddress = address.getStr("detail");
|
||||
// Assert.notEmpty(provinceCode, "获取省失败");
|
||||
// Assert.notEmpty(cityCode, "获取市失败");
|
||||
// Assert.notEmpty(countyCode, "获取区县失败");
|
||||
|
|
|
|||
Loading…
Reference in New Issue