| | |
| | | s.create_user, |
| | | s.update_user, |
| | | s.tenant_id, |
| | | s.shipping_document, |
| | | s.is_reconciled, |
| | | s.statement_archiving_status, |
| | | s.is_settled, |
| | | s.settlement_archiving_status, |
| | | s.is_invoiced, |
| | | s.project_id, |
| | | sl.project_name as projectName, |
| | | sl.sales_contract_no, |
| | | pm.model as specification_model, |
| | | pm.unit, |
| | | p.product_name, |
| | | sl.customer_name, |
| | | spd.totalQuantity, |
| | | sor.outboundBatches |
| | | sor.outboundBatches, |
| | | rm_agg.returnNos |
| | | 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 |
| | |
| | | from stock_out_record |
| | | where record_type='13'and approval_status=1 |
| | | group by record_id)sor on sor.record_id= s.id |
| | | left join (select shipping_id, GROUP_CONCAT(DISTINCT return_no SEPARATOR ',') AS returnNos |
| | | from return_management |
| | | group by shipping_id) rm_agg on rm_agg.shipping_id = s.id |
| | | WHERE 1=1 |
| | | <if test="req.salesContractNo != null and req.salesContractNo != ''"> |
| | | AND sl.sales_contract_no LIKE CONCAT('%',#{req.salesContractNo},'%') |
| | |
| | | </if> |
| | | <if test="req.expressNumber != null and req.expressNumber != ''"> |
| | | AND s.express_number LIKE CONCAT('%',#{req.expressNumber},'%') |
| | | </if> |
| | | <if test="req.projectId != null"> |
| | | AND s.project_id = #{req.projectId} |
| | | </if> |
| | | <if test="req.beginShippingDate != null and req.beginShippingDate != ''"> |
| | | AND DATE(s.shipping_date) >= DATE(#{req.beginShippingDate}) |
| | | </if> |
| | | <if test="req.endShippingDate != null and req.endShippingDate != ''"> |
| | | AND DATE(s.shipping_date) <= DATE(#{req.endShippingDate}) |
| | | </if> |
| | | order by create_time DESC |
| | | </select> |
| | |
| | | s.create_user, |
| | | s.update_user, |
| | | s.tenant_id, |
| | | s.shipping_document, |
| | | s.is_reconciled, |
| | | s.statement_archiving_status, |
| | | s.is_settled, |
| | | s.settlement_archiving_status, |
| | | s.is_invoiced, |
| | | s.project_id, |
| | | sl.project_name as projectName, |
| | | sl.sales_contract_no, |
| | | sl.customer_name |
| | | FROM shipping_info s |
| | | LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id |
| | | WHERE 1=1 |
| | | <if test="req.salesContractNo != null and req.salesContractNo != ''"> |
| | | AND sl.sales_contract_no LIKE CONCAT('%',#{req.salesContractNo},'%') |
| | | </if> |
| | | <if test="req.shippingCarNumber != null and req.shippingCarNumber != ''"> |
| | | AND s.shipping_car_number LIKE CONCAT('%',#{req.shippingCarNumber},'%') |
| | | </if> |
| | | <if test="req.shippingNo != null and req.shippingNo != ''"> |
| | | AND s.shipping_no LIKE CONCAT('%',#{req.shippingNo},'%') |
| | | </if> |
| | | <if test="req.expressNumber != null and req.expressNumber != ''"> |
| | | AND s.express_number LIKE CONCAT('%',#{req.expressNumber},'%') |
| | | </if> |
| | | <if test="req.projectId != null"> |
| | | AND s.project_id = #{req.projectId} |
| | | </if> |
| | | <if test="req.beginShippingDate != null and req.beginShippingDate != ''"> |
| | | AND DATE(s.shipping_date) >= DATE(#{req.beginShippingDate}) |
| | | </if> |
| | | <if test="req.endShippingDate != null and req.endShippingDate != ''"> |
| | | AND DATE(s.shipping_date) <= DATE(#{req.endShippingDate}) |
| | | </if> |
| | | order by create_time DESC |
| | | </select> |
| | | <select id="getReturnManagementDtoById" resultType="com.ruoyi.procurementrecord.bean.vo.ShippingProductVo"> |
| | | SELECT distinct |
| | |
| | | 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 |
| | | COALESCE(rs.return_num, 0) AS total_return_num, |
| | | COALESCE(rs.pending_return_num, 0) AS pending_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 ( |
| | | SELECT |
| | | stock_out_record_id, |
| | | SUM(num) AS total_return_num |
| | | SUM(num) AS total_return_num, |
| | | SUM( CASE WHEN rsp.STATUS = 0 THEN rsp.num ELSE 0 END ) AS pending_return_num , |
| | | SUM( CASE WHEN rsp.STATUS = 1 THEN rsp.num ELSE 0 END ) AS 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 |
| | |
| | | si.id = #{shippingId} |
| | | </if> |
| | | </where> |
| | | order by sor.id |
| | | </select> |
| | | <select id="getShippingInfoByCustomerName" resultType="com.ruoyi.sales.pojo.ShippingInfo"> |
| | | select * from shipping_info si |
| | | select distinct si.* from shipping_info si |
| | | left join sales_ledger sl on si.sales_ledger_id = sl.id |
| | | where sl.customer_name = #{customerName} |
| | | inner join stock_out_record sor on sor.record_id = si.id and sor.record_type = '13' and sor.approval_status = 1 |
| | | where sl.customer_name = #{customerName} and si.status = '审核通过' |
| | | </select> |
| | | </mapper> |