From c15e67c83394c1734eb4e9802d8f343c6076efc1 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 13 五月 2026 16:16:45 +0800
Subject: [PATCH] Merge branch 'dev_New_pro' into dev_宁夏_英泽防锈

---
 src/main/resources/mapper/sales/ShippingInfoMapper.xml |   71 +++++++++++++++--------------------
 1 files changed, 30 insertions(+), 41 deletions(-)

diff --git a/src/main/resources/mapper/sales/ShippingInfoMapper.xml b/src/main/resources/mapper/sales/ShippingInfoMapper.xml
index cd7dc3e..762c2d4 100644
--- a/src/main/resources/mapper/sales/ShippingInfoMapper.xml
+++ b/src/main/resources/mapper/sales/ShippingInfoMapper.xml
@@ -19,14 +19,22 @@
         s.update_user,
         s.tenant_id,
         sl.sales_contract_no,
-        slp.specification_model,
+        pm.model as specification_model,
+        pm.unit,
         p.product_name,
-        sl.customer_name
+        sl.customer_name,
+        spd.totalQuantity,
+        sor.outboundBatches
         FROM shipping_info s
+        LEFT JOIN (select shipping_info_id,sum(quantity) totalQuantity from shipping_product_detail GROUP BY shipping_info_id) spd ON spd.shipping_info_id = s.id
         LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
         LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1
         left join product_model pm on slp.product_model_id = pm.id
         left join product p on pm.product_id = p.id
+        left join (select record_id,GROUP_CONCAT(outbound_batches SEPARATOR ',') AS outboundBatches
+                   from stock_out_record
+                   where record_type='13'and approval_status=1
+                   group by record_id)sor on sor.record_id= s.id
         WHERE 1=1
         <if test="req.salesContractNo != null and req.salesContractNo != ''">
             AND sl.sales_contract_no LIKE CONCAT('%',#{req.salesContractNo},'%')
@@ -58,62 +66,43 @@
         FROM shipping_info s
                  LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
     </select>
-    <select id="getReturnManagementDtoById" resultType="com.ruoyi.sales.dto.SalesLedgerProductDto">
-        SELECT
-        slp.*,
-        si.shipping_no,
-        GREATEST(slp.quantity - COALESCE(rs.total_return_num, 0), 0) AS un_quantity,
-        COALESCE(rs.total_return_num, 0) AS total_return_num
+    <select id="getReturnManagementDtoById" resultType="com.ruoyi.procurementrecord.bean.vo.ShippingProductVo">
+        SELECT distinct
+            sor.id,
+            slp.product_category,
+            slp.specification_model,
+            slp.unit,
+            slp.product_model_id,
+            sor.outbound_batches,
+            sor.stock_out_num,
+            sor.batch_no,
+            slp.tax_inclusive_unit_price,
+            GREATEST(sor.stock_out_num - COALESCE(rs.total_return_num, 0), 0) AS un_quantity,
+            COALESCE(rs.total_return_num, 0) AS total_return_num
         FROM shipping_info si
+        LEFT JOIN shipping_product_detail spd ON spd.shipping_info_id = si.id
+        LEFT JOIN stock_out_record sor ON sor.record_id = si.id and sor.record_type = '13'
         LEFT JOIN sales_ledger_product slp ON si.sales_ledger_product_id = slp.id and slp.type = 1
         LEFT JOIN (
         SELECT
-        return_sales_ledger_product_id,
+        stock_out_record_id,
         SUM(num) AS total_return_num
         FROM return_sale_product rsp
         left join return_management rm on rm.id = rsp.return_management_id
         left join shipping_info si on si.id = rm.shipping_id
         WHERE 1=1
-        GROUP BY return_sales_ledger_product_id
-        ) rs ON rs.return_sales_ledger_product_id = slp.id
+        GROUP BY stock_out_record_id
+        ) rs ON rs.stock_out_record_id = sor.id
         <where>
             <if test="shippingId != null">
                 si.id = #{shippingId}
             </if>
         </where>
+        order by sor.id
     </select>
     <select id="getShippingInfoByCustomerName" resultType="com.ruoyi.sales.pojo.ShippingInfo">
         select * from shipping_info si
         left join sales_ledger sl on si.sales_ledger_id = sl.id
-        where si.status = '宸插彂璐�' and sl.customer_name = #{customerName}
-    </select>
-    <select id="listPageByOutbound" resultType="com.ruoyi.account.bean.vo.SalesOutboundVo">
-         SELECT
-        sor.id,
-        sor.outbound_batches,
-        sl.customer_name,
-        s.shipping_date,
-        p.product_name,
-        slp.specification_model,
-        slp.stock_out_num,
-        s.shipping_no,
-        sl.sales_contract_no
-        FROM shipping_info s
-        LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
-        LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1
-        left join product_model pm on slp.product_model_id = pm.id
-        left join product p on pm.product_id = p.id
-        left join stock_out_record sor on sor.record_id = s.id and sor.record_type='13'
-        WHERE s.status='宸插彂璐�'
-        <if test="req.outboundBatches != null and req.outboundBatches != ''">
-            AND sor.outbound_batches LIKE CONCAT('%',#{req.outboundBatches},'%')
-        </if>
-        <if test="req.customerName != null and req.customerName != ''">
-            AND sl.customer_name LIKE CONCAT('%',#{req.customerName},'%')
-        </if>
-        <if test="req.startDate != null and req.endDate != null">
-            AND s.shipping_date BETWEEN #{startDate} AND #{endDate}
-        </if>
-        order by sor.id DESC
+        where  sl.customer_name = #{customerName}
     </select>
 </mapper>

--
Gitblit v1.9.3