| | |
| | | ) t4 ON t4.sales_ledger_product_id = T1.id |
| | | left join product_model pm ON T1.product_model_id = pm.id |
| | | left join product p ON pm.product_id = p.id |
| | | LEFT JOIN ( |
| | | SELECT product_model_id, MAX(create_time) AS last_stock_in_time |
| | | FROM stock_in_record |
| | | GROUP BY product_model_id |
| | | ) t5 ON t5.product_model_id = T1.product_model_id |
| | | <where> |
| | | <if test="salesLedgerProduct.salesLedgerId != null"> |
| | | AND T1.sales_ledger_id = #{salesLedgerProduct.salesLedgerId} |
| | |
| | | AND T1.type = #{salesLedgerProduct.type} |
| | | </if> |
| | | </where> |
| | | ORDER BY T1.register_date DESC |
| | | ORDER BY t5.last_stock_in_time DESC, T1.id DESC |
| | | </select> |
| | | |
| | | <select id="selectSalesLedgerProductByMainId" resultType="com.ruoyi.sales.pojo.SalesLedgerProduct"> |