| | |
| | | GROUP BY T1.id, T1.sales_contract_no, T1.contract_amount, T2.receipt_payment_date |
| | | </select> |
| | | |
| | | <select id="customerSalesInteractions" resultType="com.ruoyi.sales.dto.InvoiceLedgerDto"> |
| | | SELECT |
| | | wr.receive_unit, |
| | | wr.goods_name, |
| | | wr.specification, |
| | | wr.shippedQuantity, |
| | | SUM(slp.quantity) AS totalQuantity, |
| | | SUM(IFNULL(slp.quantity, 0)) - wr.shippedQuantity AS unshippedQuantity |
| | | FROM |
| | | (SELECT receive_unit, goods_name, specification, SUM(net_weight) AS shippedQuantity FROM weighing_record GROUP BY receive_unit, goods_name, specification) wr |
| | | LEFT JOIN sales_ledger sl ON sl.customer_name = wr.receive_unit |
| | | LEFT JOIN sales_ledger_product slp ON slp.sales_ledger_id = sl.id |
| | | AND slp.product_category = wr.goods_name |
| | | AND slp.specification_model = wr.specification |
| | | WHERE |
| | | sl.customer_id = #{ew.customerId} |
| | | GROUP BY |
| | | wr.receive_unit, |
| | | wr.goods_name, |
| | | wr.specification, |
| | | wr.shippedQuantity |
| | | </select> |
| | | </mapper> |