Browse Source

feat(all): 增加配送费附加费价格查询

master
zhaoqiaobo 9 months ago
parent
commit
cbbfd26770
  1. 7
      blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java
  2. 50
      blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/PriceDispatchAddClientVO.java
  3. 8
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java
  4. 12
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java
  5. 159
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java

7
blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java

@ -18,11 +18,14 @@ package com.logpm.basicdata.feign;
import com.logpm.basicdata.vo.BasicdatPriceApiVO;
import com.logpm.basicdata.vo.PriceClientVO;
import com.logpm.basicdata.vo.PriceDispatchAddClientVO;
import org.springblade.common.constant.ModuleNameConstant;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* 基础价格体系 Feign接口类
*
@ -36,8 +39,12 @@ public interface IBasicdataPriceClient {
String API_PREFIX = "/basicdataPrice/client";
String PRICE = API_PREFIX + "/pirce";
String DISPATCH_ADD_PRICE = API_PREFIX + "/dispatchAddPrice";
@PostMapping(PRICE)
PriceClientVO price(@RequestBody BasicdatPriceApiVO param);
@PostMapping(DISPATCH_ADD_PRICE)
List<PriceDispatchAddClientVO> dispatchAddPrice(@RequestBody BasicdatPriceApiVO param);
}

50
blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/PriceDispatchAddClientVO.java

@ -0,0 +1,50 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package com.logpm.basicdata.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
/**
* 基础价格按品类计费 视图实体类
*
* @author zqb
* @since 2024-04-02
*/
@Builder
@Data
public class PriceDispatchAddClientVO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "品类id")
private Long categoryId;
@ApiModelProperty(value = "分货费")
private Double sortPrice;
@ApiModelProperty(value = "装卸费")
private Double handlingPrice;
@ApiModelProperty(value = "平移费")
private Double relocationPrice;
@ApiModelProperty(value = "上楼费")
private Double upstairsDeliveryPrice;
@ApiModelProperty(value = "配送-上楼费免费楼层")
private Integer dispatchStairsCarryingCharge;
}

8
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java

@ -19,10 +19,13 @@ package com.logpm.basicdata.feign;
import com.logpm.basicdata.service.IBasicdataPriceService;
import com.logpm.basicdata.vo.BasicdatPriceApiVO;
import com.logpm.basicdata.vo.PriceClientVO;
import com.logpm.basicdata.vo.PriceDispatchAddClientVO;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
* 基础价格 Feign实现类
*
@ -41,4 +44,9 @@ public class BasicdataPriceClient implements IBasicdataPriceClient {
return basicdataPriceService.price(param);
}
@Override
public List<PriceDispatchAddClientVO> dispatchAddPrice(BasicdatPriceApiVO param) {
return basicdataPriceService.dispatchAddPrice(param);
}
}

12
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java

@ -16,19 +16,17 @@
*/
package com.logpm.basicdata.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.basicdata.entity.BasicdataPriceEntity;
import com.logpm.basicdata.excel.BasicdataPriceExcel;
import com.logpm.basicdata.vo.BasicdatPriceApiVO;
import com.logpm.basicdata.vo.BasicdataPriceBasicUpdateVO;
import com.logpm.basicdata.vo.BasicdataPricePageVO;
import com.logpm.basicdata.vo.PriceClientVO;
import com.logpm.basicdata.vo.PriceDispatchAddClientVO;
import com.logpm.basicdata.vo.PriceVO;
import org.springblade.core.mp.base.BaseService;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.util.List;
/**
@ -80,4 +78,12 @@ public interface IBasicdataPriceService extends BaseService<BasicdataPriceEntity
* @return
*/
Boolean deletePrice(String id);
/**
* 根据客户品牌获取配送附加费
* @param param
* @Return com.logpm.basicdata.vo.PriceDispatchAddClientVO
* @Author zqb 2024/7/3
**/
List<PriceDispatchAddClientVO> dispatchAddPrice(BasicdatPriceApiVO param);
}

159
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java

@ -80,6 +80,7 @@ import com.logpm.basicdata.vo.BasicdataPriceImportVO;
import com.logpm.basicdata.vo.BasicdataPricePageVO;
import com.logpm.basicdata.vo.PriceBasicVO;
import com.logpm.basicdata.vo.PriceClientVO;
import com.logpm.basicdata.vo.PriceDispatchAddClientVO;
import com.logpm.basicdata.vo.PriceDispatchAdditionalVO;
import com.logpm.basicdata.vo.PriceDispatchBasicVO;
import com.logpm.basicdata.vo.PriceDispatchVO;
@ -92,6 +93,7 @@ import com.logpm.basicdata.vo.PriceWarehouseBasicVO;
import com.logpm.basicdata.vo.PriceWarehouseVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.Nullable;
import org.springblade.common.enums.BooleanZeroOneEnums;
import org.springblade.common.model.IDict;
import org.springblade.core.log.exception.ServiceException;
@ -228,6 +230,40 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
}
}
@Override
public List<PriceDispatchAddClientVO> dispatchAddPrice(BasicdatPriceApiVO param) {
BasicdataPriceEntity priceEntity = getBasicdataPriceEntityByParam(param);
if (ObjectUtil.isEmpty(priceEntity)) {
return null;
}
BasicdataPriceTemplateEntity templateEntity = getBasicdataPriceTemplateEntityByPrice(priceEntity);
if (ObjectUtil.isEmpty(templateEntity)) {
return null;
}
Map<Integer, List<BasicdataPriceCategoryDispatchEntity>> dispatchMap = new HashMap<>();
initDispatchMap(priceEntity, dispatchMap);
String serviceType = templateEntity.getServiceType();
// 配送费
if (StrUtil.contains(serviceType, ServiceTypeEnums.DISPATCH.getCode().toString())) {
Integer dispatchIsAddFee = templateEntity.getDispatchIsAddFee();
if (ObjectUtil.equals(dispatchIsAddFee, BooleanZeroOneEnums.YES.getCode())) {
List<PriceDispatchAdditionalVO> priceDispatchAdditionalVOS = buildDispatchAddFee(dispatchMap);
List<PriceDispatchAddClientVO> res = new ArrayList<>();
for (PriceDispatchAdditionalVO priceDispatchAdditionalVO : priceDispatchAdditionalVOS) {
res.add(PriceDispatchAddClientVO.builder()
.categoryId(priceDispatchAdditionalVO.getCategoryId())
.sortPrice(priceDispatchAdditionalVO.getSortPrice())
.handlingPrice(priceDispatchAdditionalVO.getHandlingPrice())
.relocationPrice(priceDispatchAdditionalVO.getRelocationPrice())
.upstairsDeliveryPrice(priceDispatchAdditionalVO.getUpstairsDeliveryPrice())
.dispatchStairsCarryingCharge(priceEntity.getDispatchStairsCarryingCharge()).build());
}
return res;
}
}
return null;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean basicUpdate(BasicdataPriceBasicUpdateVO vo) {
@ -411,38 +447,12 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
@Override
public PriceClientVO price(BasicdatPriceApiVO param) {
PriceClientVO priceClientVO = new PriceClientVO();
// 根据客户信息查找价格
String clientId = param.getClientId();
String brandId = param.getBrandId();
if (!ObjectUtil.isAllNotEmpty(clientId, brandId)) {
return null;
}
BasicdataPriceEntity priceEntity = null;
LambdaQueryWrapper<BasicdataPriceEntity> wrapper = Wrappers.<BasicdataPriceEntity>lambdaQuery()
.eq(BasicdataPriceEntity::getClientId, clientId)
.eq(BasicdataPriceEntity::getBrandId, brandId);
if (StrUtil.isNotEmpty(param.getTime())) {
wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd"))
.le(BasicdataPriceEntity::getEffectiveTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd"))
;
} else {
wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.beginOfDay(new Date()))
.le(BasicdataPriceEntity::getEffectiveTime, DateUtil.beginOfDay(new Date()))
;
}
List<BasicdataPriceEntity> priceEntities = this.list(wrapper);
if (CollUtil.isNotEmpty(priceEntities)) {
priceEntity = priceEntities.get(0);
}
BasicdataPriceEntity priceEntity = getBasicdataPriceEntityByParam(param);
if (ObjectUtil.isEmpty(priceEntity)) {
return priceClientVO;
}
// 根据价格获取模板
Long templateId = priceEntity.getTemplateId();
BasicdataPriceTemplateEntity templateEntity = null;
if (ObjectUtil.isNotEmpty(templateId)) {
templateEntity = templateService.getById(templateId);
}
BasicdataPriceTemplateEntity templateEntity = getBasicdataPriceTemplateEntityByPrice(priceEntity);
if (ObjectUtil.isEmpty(templateEntity)) {
return priceClientVO;
}
@ -523,6 +533,42 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
return priceClientVO;
}
private @Nullable BasicdataPriceTemplateEntity getBasicdataPriceTemplateEntityByPrice(BasicdataPriceEntity priceEntity) {
Long templateId = priceEntity.getTemplateId();
BasicdataPriceTemplateEntity templateEntity = null;
if (ObjectUtil.isNotEmpty(templateId)) {
templateEntity = templateService.getById(templateId);
}
return templateEntity;
}
private @Nullable BasicdataPriceEntity getBasicdataPriceEntityByParam(BasicdatPriceApiVO param) {
// 根据客户信息查找价格
String clientId = param.getClientId();
String brandId = param.getBrandId();
if (!ObjectUtil.isAllNotEmpty(clientId, brandId)) {
return null;
}
BasicdataPriceEntity priceEntity = null;
LambdaQueryWrapper<BasicdataPriceEntity> wrapper = Wrappers.<BasicdataPriceEntity>lambdaQuery()
.eq(BasicdataPriceEntity::getClientId, clientId)
.eq(BasicdataPriceEntity::getBrandId, brandId);
if (StrUtil.isNotEmpty(param.getTime())) {
wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd"))
.le(BasicdataPriceEntity::getEffectiveTime, DateUtil.parse(param.getTime(), "yyyy-MM-dd"))
;
} else {
wrapper.ge(BasicdataPriceEntity::getExpiryTime, DateUtil.beginOfDay(new Date()))
.le(BasicdataPriceEntity::getEffectiveTime, DateUtil.beginOfDay(new Date()))
;
}
List<BasicdataPriceEntity> priceEntities = this.list(wrapper);
if (CollUtil.isNotEmpty(priceEntities)) {
priceEntity = priceEntities.get(0);
}
return priceEntity;
}
@Override
@Transactional(rollbackFor = Exception.class)
public String upload(MultipartFile file) {
@ -3534,20 +3580,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
});
}
List<BasicdataPriceCategoryDispatchEntity> dispatchList = categoryDispatchService.list(Wrappers.<BasicdataPriceCategoryDispatchEntity>lambdaQuery()
.eq(BasicdataPriceCategoryDispatchEntity::getBoId, priceEntity.getId()));
if (CollUtil.isNotEmpty(dispatchList)) {
// 按类型分组放到dispatchMap中
dispatchList.forEach(item -> {
Integer type = item.getCostType();
List<BasicdataPriceCategoryDispatchEntity> collect = dispatchMap.get(type);
if (ObjectUtil.isEmpty(collect)) {
collect = new ArrayList<>();
}
collect.add(item);
dispatchMap.put(type, collect);
});
}
initDispatchMap(priceEntity, dispatchMap);
// 获取一般费用
List<BasicdataPriceGeneralEntity> generalList = generalService.list(Wrappers.<BasicdataPriceGeneralEntity>lambdaQuery()
@ -3566,6 +3599,23 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
}
}
private void initDispatchMap(BasicdataPriceEntity priceEntity, Map<Integer, List<BasicdataPriceCategoryDispatchEntity>> dispatchMap) {
List<BasicdataPriceCategoryDispatchEntity> dispatchList = categoryDispatchService.list(Wrappers.<BasicdataPriceCategoryDispatchEntity>lambdaQuery()
.eq(BasicdataPriceCategoryDispatchEntity::getBoId, priceEntity.getId()));
if (CollUtil.isNotEmpty(dispatchList)) {
// 按类型分组放到dispatchMap中
dispatchList.forEach(item -> {
Integer type = item.getCostType();
List<BasicdataPriceCategoryDispatchEntity> collect = dispatchMap.get(type);
if (ObjectUtil.isEmpty(collect)) {
collect = new ArrayList<>();
}
collect.add(item);
dispatchMap.put(type, collect);
});
}
}
private PriceDispatchVO initDispatch(BasicdataPriceEntity priceEntity, BasicdataPriceTemplateEntity templateEntity, List<BasicdataPriceFullVehicleEntity> fullVehicleEntities, Map<Integer, List<BasicdataPriceCategoryDispatchEntity>> dispatchMap, List<BasicdataPriceGeneralEntity> generalEntities, List<BasicdataPriceGeneralEntity> generalEntities1) {
PriceDispatchVO priceDispatchVO = new PriceDispatchVO();
String dispatchPricingType = templateEntity.getDispatchPricingType();
@ -3678,16 +3728,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
}
// 附加费
List<BasicdataPriceCategoryDispatchEntity> dispatchEntities1 = dispatchMap.get(CostTypeEnums.ADD.getCode());
if (CollUtil.isNotEmpty(dispatchEntities1)) {
List<PriceDispatchAdditionalVO> basicVOList = new ArrayList<>();
dispatchEntities1.forEach(item -> {
PriceDispatchAdditionalVO basicVO = new PriceDispatchAdditionalVO();
BeanUtil.copyProperties(item, basicVO);
basicVOList.add(basicVO);
});
priceDispatchVO.setAdditionalCategory(basicVOList);
}
priceDispatchVO.setAdditionalCategory(buildDispatchAddFee(dispatchMap));
// 一般费用 generalEntities
if (CollUtil.isNotEmpty(generalEntities)) {
BasicdataPriceGeneralEntity generalEntity = generalEntities.get(0);
@ -3712,6 +3753,20 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl<BasicdataPriceMap
return priceDispatchVO;
}
private static List<PriceDispatchAdditionalVO> buildDispatchAddFee(Map<Integer, List<BasicdataPriceCategoryDispatchEntity>> dispatchMap) {
List<BasicdataPriceCategoryDispatchEntity> dispatchEntities1 = dispatchMap.get(CostTypeEnums.ADD.getCode());
if (CollUtil.isNotEmpty(dispatchEntities1)) {
List<PriceDispatchAdditionalVO> basicVOList = new ArrayList<>();
dispatchEntities1.forEach(item -> {
PriceDispatchAdditionalVO basicVO = new PriceDispatchAdditionalVO();
BeanUtil.copyProperties(item, basicVO);
basicVOList.add(basicVO);
});
return basicVOList;
}
return null;
}
private PriceWarehouseVO initWarehouse(BasicdataPriceEntity priceEntity, BasicdataPriceTemplateEntity templateEntity, Map<Integer, List<BasicdataPriceCategoryWarehouseEntity>> warehouseMap) {
PriceWarehouseVO priceWarehouseVO = new PriceWarehouseVO();
Integer warehousePricingType = templateEntity.getWarehousePricingType();

Loading…
Cancel
Save