From e7a970151c40925eefa1fe837ac06e93594fcf82 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 26 五月 2026 09:56:17 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_pro_娌冲崡楣ゅ' into dev_pro_娌冲崡楣ゅ

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java |   64 ++++++++++++++++++++++++-------
 1 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index a76b149..6303b04 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -8,6 +8,10 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.account.mapper.sales.AccountInvoiceApplicationMapper;
+import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper;
+import com.ruoyi.account.pojo.sales.AccountInvoiceApplication;
+import com.ruoyi.account.pojo.sales.AccountSalesCollection;
 import com.ruoyi.basic.enums.ApplicationTypeEnum;
 import com.ruoyi.basic.enums.RecordTypeEnum;
 import com.ruoyi.basic.mapper.CustomerMapper;
@@ -26,7 +30,9 @@
 import com.ruoyi.framework.security.LoginUser;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.other.mapper.TempFileMapper;
-import com.ruoyi.production.mapper.*;
+import com.ruoyi.production.mapper.ProductionProductInputMapper;
+import com.ruoyi.production.mapper.ProductionProductMainMapper;
+import com.ruoyi.production.mapper.ProductionProductOutputMapper;
 import com.ruoyi.production.service.ProductionProductMainService;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.domain.SysUser;
@@ -36,8 +42,14 @@
 import com.ruoyi.purchase.mapper.PurchaseReturnOrderProductsMapper;
 import com.ruoyi.quality.mapper.QualityInspectMapper;
 import com.ruoyi.sales.dto.*;
-import com.ruoyi.sales.mapper.*;
-import com.ruoyi.sales.pojo.*;
+import com.ruoyi.sales.mapper.CommonFileMapper;
+import com.ruoyi.sales.mapper.SalesLedgerMapper;
+import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
+import com.ruoyi.sales.mapper.ShippingInfoMapper;
+import com.ruoyi.sales.pojo.CommonFile;
+import com.ruoyi.sales.pojo.SalesLedger;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.sales.pojo.ShippingInfo;
 import com.ruoyi.sales.service.ISalesLedgerService;
 import com.ruoyi.sales.vo.SalesLedgerVo;
 import lombok.RequiredArgsConstructor;
@@ -93,6 +105,8 @@
     private final QualityInspectMapper qualityInspectMapper;
     private final RedisTemplate<String, String> redisTemplate;
     private final FileUtil fileUtil;
+    private final AccountInvoiceApplicationMapper accountInvoiceApplicationMapper;
+    private final AccountSalesCollectionMapper accountSalesCollectionMapper;
 
     @Autowired
     private SysDeptMapper sysDeptMapper;
@@ -171,7 +185,11 @@
                     .orderByDesc(ShippingInfo::getCreateTime)
                     .last("limit 1"));
             if (shippingInfo != null) {
+                product.setShippingCarNumber(shippingInfo.getShippingCarNumber());
+                product.setShippingDate(shippingInfo.getShippingDate());
                 product.setShippingStatus(shippingInfo.getStatus());
+                product.setExpressCompany(shippingInfo.getExpressCompany());
+                product.setExpressNumber(shippingInfo.getExpressNumber());
             }
         }
 
@@ -263,23 +281,37 @@
 
     @Override
     public List<MonthlyAmountDto> getAmountHalfYear(Integer type) {
-
         LocalDate now = LocalDate.now();
         List<MonthlyAmountDto> result = new ArrayList<>();
-
         for (int i = 5; i >= 0; i--) {
             YearMonth yearMonth = YearMonth.from(now.minusMonths(i));
-            LocalDateTime startTime = yearMonth.atDay(1).atStartOfDay();
-            LocalDateTime endTime = yearMonth.atEndOfMonth().atTime(23, 59, 59);
-
+            LocalDate startTime = yearMonth.atDay(1);
+            LocalDate endTime = yearMonth.atEndOfMonth();
             MonthlyAmountDto dto = new MonthlyAmountDto();
             dto.setMonth(yearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM")));
-            dto.setReceiptAmount(BigDecimal.ZERO);
-            dto.setInvoiceAmount(BigDecimal.ZERO);
-
+            //鍥炴閲戦
+            List<AccountSalesCollection> accountSalesCollections = accountSalesCollectionMapper.selectList(new LambdaQueryWrapper<AccountSalesCollection>()
+                    .between(AccountSalesCollection::getCollectionDate, startTime, endTime));
+            BigDecimal totalIncome = Optional.of(
+                    accountSalesCollections.stream()
+                            .map(AccountSalesCollection::getCollectionAmount)
+                            .filter(Objects::nonNull)
+                            .reduce(BigDecimal.ZERO, BigDecimal::add)
+            ).orElse(BigDecimal.ZERO);
+            dto.setReceiptAmount(totalIncome);
+            //寮�绁ㄩ噾棰�
+            List<AccountInvoiceApplication> accountInvoiceApplications = accountInvoiceApplicationMapper.selectList(new LambdaQueryWrapper<AccountInvoiceApplication>()
+                            .eq(AccountInvoiceApplication::getStatus,1)
+                    .between(AccountInvoiceApplication::getApplyDate, startTime, endTime));
+            BigDecimal totalInvoiceAmount = Optional.of(
+                    accountInvoiceApplications.stream()
+                            .map(AccountInvoiceApplication::getInvoiceAmount)
+                            .filter(Objects::nonNull)
+                            .reduce(BigDecimal.ZERO, BigDecimal::add)
+            ).orElse(BigDecimal.ZERO);
+            dto.setInvoiceAmount(totalInvoiceAmount);
             result.add(dto);
         }
-
         return result;
     }
 
@@ -424,14 +456,16 @@
                         .eq(ShippingInfo::getSalesLedgerProductId, product.getId())
                         .orderByDesc(ShippingInfo::getCreateTime)
                         .last("limit 1"));
-                product.setShippingCarNumber(shippingInfo.getShippingCarNumber());
-                product.setShippingDate(shippingInfo.getShippingDate());
                 if (shippingInfo != null) {
+                    product.setShippingCarNumber(shippingInfo.getShippingCarNumber());
+                    product.setShippingDate(shippingInfo.getShippingDate());
                     product.setShippingStatus(shippingInfo.getStatus());
+                    product.setExpressCompany(shippingInfo.getExpressCompany());
+                    product.setExpressNumber(shippingInfo.getExpressNumber());
                 }
             }
             // 杩囨护鍙繚鐣欏彂璐ц褰�
-            products = products.stream().filter(product -> "宸插彂璐�".equals(product.getShippingStatus())).collect(Collectors.toList());
+            products = products.stream().filter(product -> "瀹℃牳閫氳繃".equals(product.getShippingStatus())).collect(Collectors.toList());
             if (!products.isEmpty()) {
                 salesLedger.setHasChildren(true);
                 salesLedger.setProductData(products);

--
Gitblit v1.9.3