diff --git a/blade-biz-common/src/main/java/org/springblade/common/annotations/RepeatSubmit.java b/blade-biz-common/src/main/java/org/springblade/common/annotations/RepeatSubmit.java new file mode 100644 index 000000000..28f0a4827 --- /dev/null +++ b/blade-biz-common/src/main/java/org/springblade/common/annotations/RepeatSubmit.java @@ -0,0 +1,11 @@ +package org.springblade.common.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface RepeatSubmit { +} diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/WaybillDetailDTO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/WaybillDetailDTO.java index ee94aeb16..68474e618 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/WaybillDetailDTO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/WaybillDetailDTO.java @@ -20,5 +20,7 @@ public class WaybillDetailDTO implements Serializable { private BigDecimal volume;//体积 private BigDecimal price ;//单价 private BigDecimal subtotalFreight;//小计运费 + private BigDecimal deliveryPrice;//配送单价 + private BigDecimal subtotalDeliveryFee;//小计配送费用 } diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWayBillDetail.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWayBillDetail.java index 94479c10c..63b62707e 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWayBillDetail.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseWayBillDetail.java @@ -53,4 +53,13 @@ public class WarehouseWayBillDetail extends BaseEntity { @ApiModelProperty(name = "计价方式 1件 2方 3公斤",notes = "") private Integer chargeType; + /** 单价 */ + @ApiModelProperty(name = "配送单价",notes = "") + private BigDecimal deliveryPrice; + + /** 小计运费 */ + @ApiModelProperty(name = "小计配送费用",notes = "") + private BigDecimal subtotalDeliveryFee; + + } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/InterceptorAdapterConfig.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/InterceptorAdapterConfig.java new file mode 100644 index 000000000..952ec1ba7 --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/config/InterceptorAdapterConfig.java @@ -0,0 +1,18 @@ +package com.logpm.trunkline.config; + +import com.logpm.trunkline.interceptor.ParameterCombinationInterceptor; +import lombok.AllArgsConstructor; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@AllArgsConstructor +public class InterceptorAdapterConfig implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry interceptorRegistry) { + interceptorRegistry.addInterceptor(new ParameterCombinationInterceptor()) + .addPathPatterns("/**"); + } +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/interceptor/ParameterCombinationInterceptor.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/interceptor/ParameterCombinationInterceptor.java new file mode 100644 index 000000000..2d33c9e4e --- /dev/null +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/interceptor/ParameterCombinationInterceptor.java @@ -0,0 +1,66 @@ +package com.logpm.trunkline.interceptor; + +import org.apache.commons.codec.digest.DigestUtils; +import org.springblade.common.annotations.RepeatSubmit; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; +import java.util.stream.Collectors; + +@Component +public class ParameterCombinationInterceptor implements HandlerInterceptor { + + private static final ThreadLocal PROCESSED_REQUEST_HASH = new ThreadLocal<>(); + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + if (handler instanceof HandlerMethod) { + HandlerMethod hm = (HandlerMethod) handler; + RepeatSubmit annotation = hm.getMethodAnnotation(RepeatSubmit.class); + if (annotation != null) { + // 计算当前请求参数的MD5哈希值 + String currentRequestHash = calculateRequestHash(request.getParameterMap()); + // 检查是否已处理过相同参数组合的请求 + if (PROCESSED_REQUEST_HASH.get() != null && PROCESSED_REQUEST_HASH.get().equals(currentRequestHash)) { + // 阻止重复提交 + response.sendError(HttpServletResponse.SC_CONFLICT, "Duplicate submit detected"); + return false; + } + // 保存当前请求的哈希值 + PROCESSED_REQUEST_HASH.set(currentRequestHash); + } + } + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + // 清理当前请求的哈希值 + PROCESSED_REQUEST_HASH.remove(); + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + // 可选清理操作,postHandle中已处理 + } + + /** + * 计算请求参数的MD5哈希值。 + * @param parameters 请求参数Map + * @return 参数哈希值字符串 + */ + private String calculateRequestHash(Map parameters) { + // 将参数按key排序并拼接为字符串 + String sortedParams = parameters.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .map(entry -> entry.getKey() + "=" + String.join(",", entry.getValue())) + .collect(Collectors.joining("&")); + // 计算并返回MD5摘要 + return DigestUtils.md5Hex(sortedParams); + } +} diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml index e37b7acf9..e346aac38 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml @@ -354,6 +354,7 @@ #{item} + and ltad.is_deleted = 0 diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml index 48d0f7a44..07d37c13a 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml @@ -15,7 +15,7 @@ select lta.*, lbc.client_name htMallName from logpm_trunkline_advance lta - left join logpm_basicdata_tripartite_mall lbtm on lbtm.tripartite_mall = lta.dealer_name and lbtm.brand_name = lta.brand and lta.dealer_code = lbtm.tripartite_coding + left join logpm_basicdata_tripartite_mall lbtm on lbtm.tripartite_mall = lta.dealer_name and lbtm.brand_name = lta.brand and IFNULL(lta.dealer_code,'') = IFNULL(lbtm.tripartite_coding,'') left join logpm_basicdata_client lbc on lbc.id = lbtm.client_id where lta.is_deleted = 0 and lta.waybill_status = 0 diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index 10819599f..fb6c723db 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -30,9 +30,9 @@ import com.logpm.warehouse.entity.WarehouseWaybillEntity; import com.logpm.warehouse.feign.IWarehouseWaybillClient; import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient; import com.logpm.warehouse.vo.WarehouseWaybillVO; -import io.seata.spring.annotation.GlobalTransactional; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.common.annotations.RepeatSubmit; import org.springblade.common.constant.CodeNumConstant; import org.springblade.common.constant.DictBizConstant; import org.springblade.common.constant.IncomingTypeEnum; @@ -193,10 +193,16 @@ public class OpenOrderServiceImpl implements IOpenOrderService { BasicdataClientVO basicdataClientEntity = basicdataClientClient.findEntityVoById(clientId); if (!Objects.isNull(basicdataClientEntity)) { openOrderVO.setConsigneeClientId(clientId); + TrunklineAdvanceEntity advanceEntity = list.get(0); openOrderVO.setConsignee(basicdataClientEntity.getClientName()); openOrderVO.setConsigneeName(basicdataClientEntity.getLinkman()); openOrderVO.setConsigneeMobile(basicdataClientEntity.getPhone()); openOrderVO.setConsigneeAddress(basicdataClientEntity.getDetailedly()); + if(!Objects.isNull(advanceEntity)){ + openOrderVO.setConsigneeName(advanceEntity.getConsigneePerson()); + openOrderVO.setConsigneeMobile(advanceEntity.getConsigneeMobile()); + openOrderVO.setConsigneeAddress(advanceEntity.getConsigneeAddress()); + } List destinationArray = new ArrayList<>(); String badeRegionAreaId = basicdataClientEntity.getBladeRegionAreaId(); @@ -332,6 +338,7 @@ public class OpenOrderServiceImpl implements IOpenOrderService { return R.success("验证成功"); } + @RepeatSubmit @Transactional(rollbackFor = Exception.class) @Override public R openWaybill(OpenOrderDTO openOrderDTO) { @@ -503,6 +510,8 @@ public class OpenOrderServiceImpl implements IOpenOrderService { warehouseWayBillDetail.setPrice(waybillDetailDTO.getPrice()); warehouseWayBillDetail.setSubtotalFreight(waybillDetailDTO.getSubtotalFreight()); warehouseWayBillDetail.setChargeType(waybillDetailDTO.getChargeType()); + warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice()); + warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee()); details.add(warehouseWayBillDetail); } warehouseWaybillDetailClient.addList(details); @@ -631,6 +640,8 @@ public class OpenOrderServiceImpl implements IOpenOrderService { return R.data(map); } + @RepeatSubmit + @Transactional(rollbackFor = Exception.class) @Override public R openZeroWaybill(OpenOrderDTO openOrderDTO) { log.info("############openZeroWaybill: 开零担单开始 openOrderDTO={}", openOrderDTO); @@ -783,6 +794,8 @@ public class OpenOrderServiceImpl implements IOpenOrderService { warehouseWayBillDetail.setPrice(waybillDetailDTO.getPrice()); warehouseWayBillDetail.setSubtotalFreight(waybillDetailDTO.getSubtotalFreight()); warehouseWayBillDetail.setChargeType(waybillDetailDTO.getChargeType()); + warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice()); + warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee()); details.add(warehouseWayBillDetail); } warehouseWaybillDetailClient.addList(details); @@ -3879,6 +3892,9 @@ public class OpenOrderServiceImpl implements IOpenOrderService { warehouseWayBillDetail.setSubtotalFreight(newSubtotalFreight); } + warehouseWayBillDetail.setDeliveryPrice(waybillDetailDTO.getDeliveryPrice()); + warehouseWayBillDetail.setSubtotalDeliveryFee(waybillDetailDTO.getSubtotalDeliveryFee()); + warehouseWaybillDetailClient.updateEntityById(warehouseWayBillDetail); } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 4422b23b6..da85017c3 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -45,6 +45,7 @@ import com.logpm.warehouse.feign.IWarehouseWaybillDetailClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringEscapeUtils; +import org.springblade.common.annotations.RepeatSubmit; import org.springblade.common.constant.*; import org.springblade.common.constant.carsload.CarsLoadLogTypeConstant; import org.springblade.common.exception.CustomerException; @@ -233,7 +234,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl