From cd0984bff3ac9c4480685671d4e033c8b082bfed Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期四, 04 六月 2026 17:04:39 +0800
Subject: [PATCH] 发货去除库存数量限制,产品库存不足也可以发货,库存数量可以展示为负

---
 src/main/resources/mapper/sales/SalesQuotationMapper.xml |   40 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/sales/SalesQuotationMapper.xml b/src/main/resources/mapper/sales/SalesQuotationMapper.xml
index a39cd45..dcd1c19 100644
--- a/src/main/resources/mapper/sales/SalesQuotationMapper.xml
+++ b/src/main/resources/mapper/sales/SalesQuotationMapper.xml
@@ -4,16 +4,48 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.sales.mapper.SalesQuotationMapper">
     <select id="listPage" resultType="com.ruoyi.sales.dto.SalesQuotationDto">
-        SELECT * FROM sales_quotation
+        SELECT t1.id,
+        t1.quotation_no,
+        COALESCE(merged_customer.customer_name, t1.customer) AS customer,
+        t1.salesperson,
+        t1.quotation_date,
+        t1.valid_date,
+        t1.payment_method,
+        t1.delivery_period,
+        t1.status,
+        t1.total_amount,
+        t1.remark,
+        t1.create_time,
+        t1.update_time,
+        t1.create_user,
+        t1.update_user,
+        t1.tenant_id,
+        t1.dept_id,
+        t2.approve_user_ids
+        FROM sales_quotation t1
+        LEFT JOIN approve_process t2 ON t1.quotation_no = t2.approve_reason and t2.approve_type = 6
+        LEFT JOIN (
+        SELECT cpp.id, cpp.type, cpp.customer_id,
+        CASE
+        WHEN cpp.type = 0 THEN cp.customer_name
+        WHEN cpp.type = 1 THEN c.customer_name
+        ELSE NULL
+        END AS customer_name
+        FROM customer_private_pool cpp
+        LEFT JOIN customer_private cp ON cpp.type = 0 AND cpp.customer_id = cp.id
+        LEFT JOIN customer c ON cpp.type = 1 AND cpp.customer_id = c.id
+        ) merged_customer ON t1.customer = merged_customer.id
         WHERE 1=1
         <if test="salesQuotationDto.quotationNo != null and salesQuotationDto.quotationNo != '' ">
-            AND quotation_no LIKE CONCAT('%',#{salesQuotationDto.quotationNo},'%')
+            AND t1.quotation_no LIKE CONCAT('%',#{salesQuotationDto.quotationNo},'%')
         </if>
         <if test="salesQuotationDto.customer != null and salesQuotationDto.customer != '' ">
-            AND customer = #{salesQuotationDto.customer}
+            AND t1.customer = #{salesQuotationDto.customer}
         </if>
         <if test="salesQuotationDto.status != null and salesQuotationDto.status != '' ">
-            AND status = #{salesQuotationDto.status}
+            AND t1.status = #{salesQuotationDto.status}
         </if>
+        order by t1.create_time desc
     </select>
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3