From 8d350f76d9b8ca447f8eef680745cea2b3ec61d8 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 25 六月 2026 09:09:17 +0800
Subject: [PATCH] fix: 报价、审核、采购台账、供应商往来、销售台账、客户往来小数点保留6位小数

---
 src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java |   59 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 43 insertions(+), 16 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 8872e88..e847384 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesQuotationServiceImpl.java
@@ -4,17 +4,20 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 import com.ruoyi.approve.pojo.ApproveProcess;
-import com.ruoyi.approve.service.IApproveProcessService;
 import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl;
-import com.ruoyi.approve.vo.ApproveGetAndUpdateVo;
-import com.ruoyi.approve.vo.ApproveProcessVO;
+import com.ruoyi.approve.bean.vo.ApproveGetAndUpdateVo;
+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.AmountUtils;
 import com.ruoyi.common.utils.OrderUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
-import com.ruoyi.common.utils.uuid.UUID;
 import com.ruoyi.framework.security.LoginUser;
 import com.ruoyi.sales.dto.SalesQuotationDto;
 import com.ruoyi.sales.mapper.SalesQuotationMapper;
@@ -23,8 +26,7 @@
 import com.ruoyi.sales.pojo.SalesQuotationProduct;
 import com.ruoyi.sales.service.SalesQuotationProductService;
 import com.ruoyi.sales.service.SalesQuotationService;
-import org.springframework.beans.factory.annotation.Autowired;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -35,16 +37,15 @@
 
 @Service
 @Transactional(rollbackFor = Exception.class)
+@RequiredArgsConstructor
 public class SalesQuotationServiceImpl extends ServiceImpl<SalesQuotationMapper, SalesQuotation> implements SalesQuotationService {
-    @Autowired
-    private SalesQuotationMapper salesQuotationMapper;
-    @Autowired
-    private SalesQuotationProductMapper salesQuotationProductMapper;
-    @Autowired
-    private SalesQuotationProductService salesQuotationProductService;
+    private final SalesQuotationProductMapper salesQuotationProductMapper;
+    private final SalesQuotationMapper salesQuotationMapper;
+    private final SalesQuotationProductService salesQuotationProductService;
 
-    @Autowired
-    private ApproveProcessServiceImpl approveProcessService;
+    private final ApproveProcessServiceImpl approveProcessService;
+    private final CustomerMapper customerMapper;
+
     @Override
     public IPage<SalesQuotationDto> listPage(Page page, SalesQuotationDto salesQuotationDto) {
         IPage<SalesQuotationDto> salesQuotationDtoIPage = salesQuotationMapper.listPage(page, salesQuotationDto);
@@ -52,17 +53,41 @@
             return salesQuotationDtoIPage;
         }
         salesQuotationDtoIPage.getRecords().forEach(record -> {
+            record.setTotalAmount(AmountUtils.scaleAmount(record.getTotalAmount()));
             List<SalesQuotationProduct> products = salesQuotationProductMapper.selectBySalesQuotationId(record.getId());
+            if (!CollectionUtils.isEmpty(products)) {
+                products.forEach(product -> {
+                    product.setUnitPrice(AmountUtils.scaleAmount(product.getUnitPrice()));
+                    product.setAmount(AmountUtils.scaleAmount(product.getAmount()));
+                });
+            }
             record.setProducts(products);
         });
         return salesQuotationDtoIPage;
     }
 
+    private void normalizeAmounts(SalesQuotationDto salesQuotationDto) {
+        salesQuotationDto.setTotalAmount(AmountUtils.scaleAmount(salesQuotationDto.getTotalAmount()));
+        if (CollectionUtils.isEmpty(salesQuotationDto.getProducts())) {
+            return;
+        }
+        salesQuotationDto.getProducts().forEach(product -> {
+            product.setUnitPrice(AmountUtils.scaleAmount(product.getUnitPrice()));
+            product.setAmount(AmountUtils.scaleAmount(product.getAmount()));
+        });
+    }
+
     @Override
     public boolean add(SalesQuotationDto salesQuotationDto) {
+        normalizeAmounts(salesQuotationDto);
         LoginUser loginUser = SecurityUtils.getLoginUser();
         SalesQuotation salesQuotation = new SalesQuotation();
         BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
+        salesQuotation.setId(null);
+        Customer customer = customerMapper.selectById(Long.valueOf(salesQuotationDto.getCustomerId()));
+        if (ObjectUtils.isNotEmpty(customer))  {
+            salesQuotation.setCustomer(customer.getCustomerName());
+        }
         String quotationNo = OrderUtils.countTodayByCreateTime(salesQuotationMapper, "QT","quotation_no");
         salesQuotation.setQuotationNo(quotationNo);
         salesQuotation.setStatus("寰呭鎵�");
@@ -90,12 +115,13 @@
             approveProcessService.addApprove(approveProcessVO);
         }catch (Exception e){
             log.error("SalesQuotationServiceImpl error:{}", e);
-            throw new RuntimeException("瀹℃壒澶辫触");
+            throw                                new RuntimeException("瀹℃壒澶辫触");
         }
         return true;
     }
     @Override
     public boolean edit(SalesQuotationDto salesQuotationDto) {
+        normalizeAmounts(salesQuotationDto);
         SalesQuotation salesQuotation = new SalesQuotation();
         BeanUtils.copyProperties(salesQuotationDto, salesQuotation);
         ApproveGetAndUpdateVo vo = new ApproveGetAndUpdateVo();
@@ -134,6 +160,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()));

--
Gitblit v1.9.3