From 3c8fa3452ed9fb41ce9d3f68c81bcc4b38d19612 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期一, 31 八月 2026 20:14:41 +0800
Subject: [PATCH] fix: 统一销售和采购相关页面金额、单价、数量、总价保留6位小数

---
 src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java b/src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java
index 5f328bc..20374ae 100644
--- a/src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java
+++ b/src/main/java/com/ruoyi/account/service/impl/sales/AccountSalesCollectionServiceImpl.java
@@ -1,5 +1,6 @@
 package com.ruoyi.account.service.impl.sales;
 
+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.Wrappers;
@@ -16,15 +17,20 @@
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.sales.dto.SaveReceiptPaymentDto;
+import com.ruoyi.sales.mapper.SalesLedgerMapper;
+import com.ruoyi.sales.pojo.SalesLedger;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Random;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -40,6 +46,7 @@
 
     private final AccountSalesCollectionMapper accountSalesCollectionMapper;
     private final AccountStatementDetailsMapper accountStatementDetailsMapper;
+    private final SalesLedgerMapper salesLedgerMapper;
     private static final DateTimeFormatter CODE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss");
 
 
@@ -90,6 +97,46 @@
         return accountSalesCollectionMapper.getOutboundBatchesByCustomer(customerId);
     }
 
+    @Override
+    public boolean saveReceiptPayment(SaveReceiptPaymentDto dto) {
+        if (dto.getPaymentDate() == null) {
+            throw new ServiceException("璇烽�夋嫨鍥炴鏃ユ湡");
+        }
+        if (dto.getPaymentAmount() == null || dto.getPaymentAmount().compareTo(new BigDecimal("0.000001")) < 0) {
+            throw new ServiceException("璇疯緭鍏ュ洖娆鹃噾棰�");
+        }
+        if (StringUtils.isEmpty(dto.getSalesContractNo())) {
+            throw new ServiceException("閿�鍞悎鍚屽彿涓嶈兘涓虹┖");
+        }
+        if (dto.getCustomerId() == null) {
+            throw new ServiceException("瀹㈡埛涓嶈兘涓虹┖");
+        }
+
+        SalesLedger salesLedger = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>()
+                .eq(SalesLedger::getSalesContractNo, dto.getSalesContractNo()));
+        if (salesLedger == null) {
+            throw new ServiceException("閿�鍞悎鍚屼笉瀛樺湪");
+        }
+        if (salesLedger.getCustomerId() == null || salesLedger.getCustomerId().longValue() != dto.getCustomerId().longValue()) {
+            throw new ServiceException("瀹㈡埛涓庡悎鍚屼笉鍖归厤");
+        }
+
+        List<Long> stockOutRecordIds = accountSalesCollectionMapper.selectStockOutRecordIdsBySalesLedgerId(salesLedger.getId());
+        if (CollectionUtils.isEmpty(stockOutRecordIds)) {
+            throw new ServiceException("璇ュ悎鍚屾殏鏃犲彲鍥炴鐨勯攢鍞嚭搴撹褰�");
+        }
+
+        AccountSalesCollection collection = new AccountSalesCollection();
+        collection.setCustomerId(dto.getCustomerId().intValue());
+        collection.setStockOutRecordIds(stockOutRecordIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
+        collection.setCollectionDate(dto.getPaymentDate());
+        collection.setCollectionAmount(dto.getPaymentAmount());
+        collection.setCollectionMethod(dto.getPaymentMethod());
+        collection.setCollectionNumber(genAccountSalesCollectionNo());
+        collection.setRemark(dto.getRemark());
+        return save(collection);
+    }
+
     private String genAccountSalesCollectionNo() {
         return "SK" + LocalDateTime.now().format(CODE_TIME_FORMATTER) + new Random().nextInt(10);
     }

--
Gitblit v1.9.3