From cbbfd26770c2f4eed53b9d088c55de584ae7a08a Mon Sep 17 00:00:00 2001 From: zhaoqiaobo <583671871@qq.com> Date: Wed, 3 Jul 2024 15:18:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E5=A2=9E=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E9=80=81=E8=B4=B9=E9=99=84=E5=8A=A0=E8=B4=B9=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/IBasicdataPriceClient.java | 7 + .../vo/PriceDispatchAddClientVO.java | 50 ++++++ .../basicdata/feign/BasicdataPriceClient.java | 8 + .../service/IBasicdataPriceService.java | 12 +- .../impl/BasicdataPriceServiceImpl.java | 159 ++++++++++++------ 5 files changed, 181 insertions(+), 55 deletions(-) create mode 100644 blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/PriceDispatchAddClientVO.java diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java index d96d55c4c..44ac0cef9 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataPriceClient.java +++ b/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 dispatchAddPrice(@RequestBody BasicdatPriceApiVO param); + } diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/PriceDispatchAddClientVO.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/vo/PriceDispatchAddClientVO.java new file mode 100644 index 000000000..3cac4285a --- /dev/null +++ b/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; + +} diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java index 7ab497112..c786df678 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataPriceClient.java +++ b/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 dispatchAddPrice(BasicdatPriceApiVO param) { + return basicdataPriceService.dispatchAddPrice(param); + } + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java index 904e2e9b8..4e217179b 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataPriceService.java +++ b/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 dispatchAddPrice(BasicdatPriceApiVO param); } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java index b885ed845..e07873f02 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataPriceServiceImpl.java +++ b/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 dispatchAddPrice(BasicdatPriceApiVO param) { + BasicdataPriceEntity priceEntity = getBasicdataPriceEntityByParam(param); + if (ObjectUtil.isEmpty(priceEntity)) { + return null; + } + BasicdataPriceTemplateEntity templateEntity = getBasicdataPriceTemplateEntityByPrice(priceEntity); + if (ObjectUtil.isEmpty(templateEntity)) { + return null; + } + Map> 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 priceDispatchAdditionalVOS = buildDispatchAddFee(dispatchMap); + List 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 wrapper = Wrappers.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 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 wrapper = Wrappers.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 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 dispatchList = categoryDispatchService.list(Wrappers.lambdaQuery() - .eq(BasicdataPriceCategoryDispatchEntity::getBoId, priceEntity.getId())); - if (CollUtil.isNotEmpty(dispatchList)) { - // 按类型分组放到dispatchMap中 - dispatchList.forEach(item -> { - Integer type = item.getCostType(); - List collect = dispatchMap.get(type); - if (ObjectUtil.isEmpty(collect)) { - collect = new ArrayList<>(); - } - collect.add(item); - dispatchMap.put(type, collect); - }); - } + initDispatchMap(priceEntity, dispatchMap); // 获取一般费用 List generalList = generalService.list(Wrappers.lambdaQuery() @@ -3566,6 +3599,23 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl> dispatchMap) { + List dispatchList = categoryDispatchService.list(Wrappers.lambdaQuery() + .eq(BasicdataPriceCategoryDispatchEntity::getBoId, priceEntity.getId())); + if (CollUtil.isNotEmpty(dispatchList)) { + // 按类型分组放到dispatchMap中 + dispatchList.forEach(item -> { + Integer type = item.getCostType(); + List 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 fullVehicleEntities, Map> dispatchMap, List generalEntities, List generalEntities1) { PriceDispatchVO priceDispatchVO = new PriceDispatchVO(); String dispatchPricingType = templateEntity.getDispatchPricingType(); @@ -3678,16 +3728,7 @@ public class BasicdataPriceServiceImpl extends BaseServiceImpl dispatchEntities1 = dispatchMap.get(CostTypeEnums.ADD.getCode()); - if (CollUtil.isNotEmpty(dispatchEntities1)) { - List 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 buildDispatchAddFee(Map> dispatchMap) { + List dispatchEntities1 = dispatchMap.get(CostTypeEnums.ADD.getCode()); + if (CollUtil.isNotEmpty(dispatchEntities1)) { + List 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> warehouseMap) { PriceWarehouseVO priceWarehouseVO = new PriceWarehouseVO(); Integer warehousePricingType = templateEntity.getWarehousePricingType();