Ver código fonte

优化代码

18782137998 1 ano atrás
pai
commit
2f2dded9e9

+ 7 - 10
src/main/java/com/sckw/freight/service/freight/impl/KwpLedgerLogisticsServiceImpl.java

@@ -30,7 +30,6 @@ import com.sckw.freight.util.SnowflakeIdUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
@@ -271,7 +270,7 @@ public class KwpLedgerLogisticsServiceImpl extends ServiceImpl<KwpLedgerLogistic
      * @since 2025-01-09
      */
     @Override
-    @Transactional
+    //@Transactional
     public R<String> saveLedgerLogistics(RequestSaveLedgerLogisticsInfo requestSaveLedgerSettlementInfo) {
         /**
          * 1:数据验证
@@ -306,7 +305,7 @@ public class KwpLedgerLogisticsServiceImpl extends ServiceImpl<KwpLedgerLogistic
         if (requestSaveLedgerSettlementInfo == null) {
             throw new RuntimeException("对账单参数为空");
         }
-        if (requestSaveLedgerSettlementInfo.getOrderIds() == null || requestSaveLedgerSettlementInfo.getOrderIds().size() == 0) {
+        if (requestSaveLedgerSettlementInfo.getOrderIds() == null || requestSaveLedgerSettlementInfo.getOrderIds().isEmpty()) {
             throw new RuntimeException("对账单的订单为空");
         }
         if (requestSaveLedgerSettlementInfo.getEntId() == null) {
@@ -329,13 +328,11 @@ public class KwpLedgerLogisticsServiceImpl extends ServiceImpl<KwpLedgerLogistic
         wrapper.eq(KllOrder::getExecutionStatus, KllOrderExecutionStatusEnum.Finished.getCode());
         wrapper.eq(KllOrder::getLedgerStatus, KllOrderLedgerStatusEnum.NoLedger.getCode());
         List<KllOrder> list = iKllOrderService.list(wrapper);
-        if (list == null || list.size() == 0 || list.size() != requestSaveLedgerSettlementInfo.getOrderIds().size()) {
-            if (list.size() == 0) {
-                throw new RuntimeException("保存对账单的物流订单不存在,请检查物流单状态。");
-            }
-            if (list.size() != requestSaveLedgerSettlementInfo.getOrderIds().size()) {
-                throw new RuntimeException("保存对账单的物流订单数量和参数数量不一致,请检查物流单所属企业和状态。");
-            }
+        if (list == null || list.isEmpty()) {
+            throw new RuntimeException("保存对账单的物流订单不存在,请检查物流单状态。");
+        }
+        if (list.size() != requestSaveLedgerSettlementInfo.getOrderIds().size()) {
+            throw new RuntimeException("保存对账单的物流订单数量和参数数量不一致,请检查物流单所属企业和状态。");
         }
         //扣减金额不能大于 总金额
         if (requestSaveLedgerSettlementInfo.getDeductPrice().compareTo(list.stream().map(KllOrder::getTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add)) > 0) {

+ 1 - 2
src/main/java/com/sckw/freight/service/freight/impl/KwpSettlementLogisticsServiceImpl.java

@@ -18,7 +18,6 @@ import com.sckw.freight.util.R;
 import com.sckw.freight.util.SnowflakeIdUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
@@ -60,7 +59,7 @@ public class KwpSettlementLogisticsServiceImpl extends ServiceImpl<KwpSettlement
      * @param: userid 操作用户id
      * @return: void
      **/
-    @Transactional
+    //@Transactional
     public void addSettlementLogistics(Long lLedgerId, BigDecimal price, String slOrderNo, LocalDateTime payTime, Long userid) {
         //先进性数据验证
         KwpLedgerLogistics logistics = verifySettlementLogistics(lLedgerId, price, payTime, userid);