| | |
| | | <select id="selectSalesLedgerProductList" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct"> |
| | | SELECT |
| | | T1.*, |
| | | pl.stock_status AS purchase_stock_status, |
| | | CASE |
| | | WHEN (IFNULL(t2.qualitity, 0) - IFNULL(t2.locked_quantity, 0)) >= IFNULL(T1.quantity, 0) THEN 1 |
| | | ELSE 0 |
| | |
| | | FROM |
| | | sales_ledger_product T1 |
| | | LEFT JOIN stock_inventory t2 ON T1.product_model_id = t2.product_model_id |
| | | LEFT JOIN purchase_ledger pl ON T1.sales_ledger_id = pl.id AND T1.type = 2 |
| | | <where> |
| | | <if test="salesLedgerProduct.salesLedgerId != null"> |
| | | AND T1.sales_ledger_id = #{salesLedgerProduct.salesLedgerId} |
| | |
| | | <!-- 该产品大类下最后一个录入日期(取台账主表的entry_date) --> |
| | | 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 |
| | | COALESCE(SUM(t2.total_amount), 0) AS return_amount, |
| | | pm.thickness |
| | | FROM sales_ledger_product slp |
| | | <!-- 关联台账主表:获取录入日期entry_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 |
| | | left join product_model pm on pm.id = slp.product_model_id |
| | | WHERE slp.type = 2 <!-- 固定筛选:采购台账(type=2) --> |
| | | <!-- 采购日期筛选:可选条件 --> |
| | | <if test="req.entryDateStart != null and req.entryDateEnd != null"> |