| | |
| | | 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 id="getReturnManagementDtoById" resultType="com.ruoyi.procurementrecord.bean.vo.ShippingProductVo"> |
| | | SELECT |
| | | slp.*, |
| | | si.shipping_no, |
| | | GREATEST(slp.quantity - COALESCE(rs.total_return_num, 0), 0) AS un_quantity, |
| | | sor.id, |
| | | slp.product_category, |
| | | slp.specification_model, |
| | | slp.unit, |
| | | 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} |