From a45c4fb6232faf2f23b7b2ba45416f11a5390d77 Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期六, 21 三月 2026 16:50:15 +0800
Subject: [PATCH] feat(purchase): 完善采购退货模块及关联退货数量统计
---
src/main/resources/mapper/sales/SalesLedgerProductMapper.xml | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 73026c8..712124a 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -114,10 +114,14 @@
<!-- 骞冲潎鍗曚环 = 鎬婚噰璐噾棰�/鎬婚噰璐暟閲忥紝淇濈暀2浣嶅皬鏁帮紝閬垮厤闄�0 -->
ROUND(IF(SUM(slp.quantity) = 0, 0, SUM(slp.tax_inclusive_total_price) / SUM(slp.quantity)), 2) AS averagePrice,
<!-- 璇ヤ骇鍝佸ぇ绫讳笅鏈�鍚庝竴涓綍鍏ユ棩鏈燂紙鍙栧彴璐︿富琛ㄧ殑entry_date锛� -->
- MAX(sl.entry_date) AS entryDate
+ MAX(sl.entry_date) AS entryDate,
+ COALESCE(NULLIF(SUM(t1.return_quantity), 0), 0) AS return_quantity,
+ COALESCE(SUM(t2.total_amount), 0) AS return_amount
FROM sales_ledger_product slp
<!-- 鍏宠仈鍙拌处涓昏〃锛氳幏鍙栧綍鍏ユ棩鏈焑ntry_date -->
LEFT JOIN purchase_ledger sl ON slp.sales_ledger_id = sl.id
+ left join purchase_return_order_products as t1 on t1.sales_ledger_product_id = slp.id
+ left join purchase_return_orders as t2 on t2.id = t1.purchase_return_order_id
WHERE slp.type = 2 <!-- 鍥哄畾绛涢�夛細閲囪喘鍙拌处锛坱ype=2锛� -->
<!-- 閲囪喘鏃ユ湡绛涢�夛細鍙�夋潯浠� -->
<if test="req.entryDateStart != null and req.entryDateEnd != null">
--
Gitblit v1.9.3