From 69e0f44e279f7763fa9c9a4d105f154db39ee1d8 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期六, 23 五月 2026 11:38:02 +0800
Subject: [PATCH] feat(sales): 添加每件数量字段支持及多业务流程优化
---
src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
index f06cad0..32359ec 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
@@ -13,6 +13,7 @@
import com.ruoyi.approve.bean.vo.ApproveProcessVO;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.pojo.Customer;
+import com.ruoyi.common.enums.IsDeleteEnum;
import com.ruoyi.common.utils.OrderUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
@@ -28,6 +29,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;
@@ -77,6 +79,7 @@
List<SalesQuotationProduct> products = salesQuotationDto.getProducts().stream().map(product -> {
SalesQuotationProduct salesQuotationProduct = new SalesQuotationProduct();
BeanUtils.copyProperties(product, salesQuotationProduct);
+ salesQuotationProduct.setSingleQuantity(normalizeSingleQuantity(salesQuotationProduct.getSingleQuantity()));
salesQuotationProduct.setSalesQuotationId(salesQuotation.getId());
return salesQuotationProduct;
}).collect(Collectors.toList());
@@ -86,7 +89,6 @@
approveProcessVO.setApproveType(6);
approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
approveProcessVO.setApproveReason(quotationNo);
- approveProcessVO.setApproveUserIds(salesQuotationDto.getApproveUserIds());
approveProcessVO.setApproveUser(loginUser.getUserId());
approveProcessVO.setApproveTime(LocalDate.now().toString());
approveProcessVO.setPrice(salesQuotationDto.getTotalAmount());
@@ -94,7 +96,7 @@
approveProcessService.addApprove(approveProcessVO);
}catch (Exception e){
log.error("SalesQuotationServiceImpl error:{}", e);
- throw new RuntimeException("瀹℃壒澶辫触");
+ throw new RuntimeException("瀹℃壒澶辫触");
}
return true;
}
@@ -117,13 +119,13 @@
List<SalesQuotationProduct> products = salesQuotationDto.getProducts().stream().map(product -> {
SalesQuotationProduct salesQuotationProduct = new SalesQuotationProduct();
BeanUtils.copyProperties(product, salesQuotationProduct);
+ salesQuotationProduct.setSingleQuantity(normalizeSingleQuantity(salesQuotationProduct.getSingleQuantity()));
salesQuotationProduct.setSalesQuotationId(salesQuotation.getId());
return salesQuotationProduct;
}).collect(Collectors.toList());
salesQuotationProductService.saveBatch(products);
// 淇敼鎶ヤ环瀹℃壒
- vo.setApproveUserIds(salesQuotationDto.getApproveUserIds());
vo.setApproveType(6);
vo.setApproveReason(salesQuotationDto.getQuotationNo());
approveProcessService.updateApproveUser(vo);
@@ -138,6 +140,7 @@
// 鍒犻櫎鎶ヤ环瀹℃壒
ApproveProcess one = approveProcessService.getOne(new LambdaQueryWrapper<ApproveProcess>()
.eq(ApproveProcess::getApproveType, 6)
+ .eq(ApproveProcess::getApproveDelete, IsDeleteEnum.NOT_DELETED)
.eq(ApproveProcess::getApproveReason, salesQuotation.getQuotationNo()));
if(one != null){
approveProcessService.delByIds(Collections.singletonList(one.getId()));
@@ -145,5 +148,12 @@
return true;
}
+ private BigDecimal normalizeSingleQuantity(BigDecimal singleQuantity) {
+ if (singleQuantity == null || singleQuantity.compareTo(BigDecimal.ZERO) <= 0) {
+ return BigDecimal.ONE;
+ }
+ return singleQuantity;
+ }
+
}
--
Gitblit v1.9.3