| | |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.sales.mapper.ShippingInfoMapper"> |
| | | |
| | | <select id="listPage" resultType="com.ruoyi.sales.pojo.ShippingInfo"> |
| | | <select id="listPage" resultType="com.ruoyi.sales.dto.ShippingInfoDto"> |
| | | SELECT |
| | | s.id, |
| | | s.sales_ledger_id, |
| | | s.shipping_date, |
| | | s.shipping_car_number, |
| | | s.express_number, |
| | | s.express_company, |
| | | s.shipping_no, |
| | | s.type, |
| | | s.status, |
| | | s.create_time, |
| | | s.update_time, |
| | | s.create_user, |
| | | s.update_user, |
| | | s.tenant_id, |
| | | sl.sales_contract_no, |
| | | slp.specification_model, |
| | | p.product_name, |
| | | sl.customer_name |
| | | FROM shipping_info s |
| | | LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id |
| | | LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1 |
| | | left join product_model pm on slp.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | WHERE 1=1 |
| | | <if test="req.salesContractNo != null and req.salesContractNo != ''"> |
| | | AND sl.sales_contract_no LIKE CONCAT('%',#{req.salesContractNo},'%') |
| | |
| | | <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> |
| | | order by create_time DESC |
| | | </select> |
| | | <select id="listAll" resultType="com.ruoyi.sales.pojo.ShippingInfo"> |
| | | SELECT |
| | |
| | | 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 |
| | | slp.*, |
| | | GREATEST(slp.quantity - 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 sales_ledger_product slp ON si.sales_ledger_product_id = slp.id and slp.type = 1 |
| | | LEFT JOIN ( |
| | | SELECT |
| | | return_sale_ledger_product_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_sale_ledger_product_id |
| | | ) rs ON rs.return_sale_ledger_product_id = slp.id |
| | | <where> |
| | | <if test="shippingId != null"> |
| | | si.id = #{shippingId} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="getShippingInfoByCustomerName" resultType="com.ruoyi.sales.pojo.ShippingInfo"> |
| | | select * from shipping_info si |
| | | left join sales_ledger sl on si.sales_ledger_id = sl.id |
| | | where si.status = '已发货' and sl.customer_name = #{customerName} |
| | | </select> |
| | | </mapper> |