<if test="flag != null and flag!='' and flag=='1'.toString()">
sql语句
</if>
<if test="warehousingType!= null and warehousingType!='' and warehousingType=='0'.toString()"> and a.id in(SELECT return_order_id FROM dwd_return_order_detail GROUP BY return_order_id HAVING SUM(storage_quantity) = 0) < /if> <if test="warehousingType!= null and warehousingType!='' and warehousingType=='1'.toString()"> and a.id in(SELECT return_order_id FROM dwd_return_order_detail GROUP BY return_order_id HAVING SUM(storage_quantity) > 0 AND SUM(保管数量) < SUM(数量) </if> <if test="warehousingType!= null and warehousingType!='' and warehousingType=='2'.toString()"> and a.id in( SELECT return_order_id FROM dwd_return_order_detail GROUP BY return_order_id HAVING SUM(storage_quantity) = SUM(quantity )) </if>
完全なSQL
<select id="queryAfterSalesOrderInfos" resultMap="DwdReturnOrderMap"> 選択 a.id、a.create_date、a.create_user_name、a.code、a.approve_user、a.approve_date、a.audit_user、a.audit_date、a.express_no、a.express_name、a.member_name、a.member_code、a. store_name、a.warehouse_in_code、a.warehouse_in_name、a.warehouse_out_code、a.warehouse_out_name、a.status、a.trade_id、a.sales_order_code、a.return_order_type_code、a.return_order_type_name、a.mobile、a.consignee_name、a.consignee_address、 a.tag_name、a.dispatch_order_id、a.dispatch_order_code、a.is_obsolete、a.amount_actual、a.is_cod、a.is_abnormal、a.is_quick_refund、a.is_refund、a.cai_niao_order_id、a.note、a.message、a. return_style、a.offset_amount、a.notice_code、a.sales_order_id、a.is_prime、a.is_create_noticed、a.distribution_trade_id、a.is_replace、ali_pay_no、a.quantity、a.is_electronicInvoice_created、a.is_push、a.shopping_guide、a.払い戻し方法、a.scan_time、a.scan_user、a.province_name、a.city_name、a.county_name、a.national_name、a.national_code、a.province_code、a.city_code、a.county_code、a.storage_status、a.version、a.expense_sales_order_id、a.expense_sales_order_code、 a.out_code、a.is_accounted、a.out_sales_order_code、a.trade_status、a.complete_date、a.modify_date、a.is_create_out_bound、a.is_associated、a.quality_status、a.is_repair、a.manual_association、a.is_modification_address、a.通り、a.is_receipt_association、a.relation_status、a.carton_number、a.quality_status、a.is_repair、a.manual_association、a.is_modification_address、a.street、a.is_receipt_association、a.relation_status、a.carton_number、a.quality_status、a.is_repair、a.manual_association、a.is_modification_address、a.street、a.is_receipt_association、a.relation_status、a.carton_number、 CASE WHEN ( SELECT count(*) FROM dwd_return_order_detail WHERE return_order_id = a.id GROUP BY return_order_id HAVING SUM( storage_quantity ) = 0 ) > 0 THEN '0' WHEN ( SELECT count(*) FROM dwd_return_order_detail WHERE return_order_id = a.id GROUP BY return_order_id HAVING SUM(storage_quantity) > 0 AND SUM(storage_quantity) < SUM(quantity) ) > 0 THEN '1' WHEN ( SELECT count(*) FROM dwd_return_order_detail WHERE return_order_id = a.id GROUP BY return_order_id HAVING SUM(storage_quantity) = SUM(quantity) ) > 0 THEN '2' END warehousingType, b.refund_status,b.trans_type dwd_return_order a から a left join dwd_sales_order b on a.sales_order_id = b.order_id where 1=1 <if test="code != null and code != ''"> and a.code = #{code} </if> <if test="tradeIds !=null and tradeIds.size() > 0"> and a.trade_id in( <foreach item="item" index="index" collection="tradeIds" separator=","> #{item} </foreach> ) </if> <if test="salesOrderCode !=null and salesOrderCode !=''"> and a.sales_order_code = #{salesOrderCode} </if> <if test="expressNos !=null and expressNos.size() > 0"> and a.express_no in ( <foreach item="item" index="index" collection="expressNos" separator=","> #{item} </foreach> ) </if> <if test="storeNames !=null and storeNames.size() > 0"> および a.store_name in ( <foreach item="item" index="index" collection="storeNames" separator=","> #{item} </foreach> ) </if> <if test="note !=null and note != ''"> and a.note LIKE CONCAT ('%',#{note },'%') </if> <if test="sku !=null and sku != ''"> and a.id in(select distinct(n.return_order_id) from dwd_return_order_detail n where n.sku_code = #{ sku}) </if> <if test="refundStatus !=null and reductionStatus.size() > 0"> and b.refund_status in( <foreach item="item" index="index" collection="refundStatus" separator=","> #{item} </foreach> ) </if> <if test="warehousingStartTime !=null "> および a. modify_date >= #{warehousingStartTime} </if> <if test="warehousingEndTime !=null "> <![CDATA[AND a.modify_date <= #{warehousingEndTime}]]> </if> <if test="warehousingType != null および warehousingType!='' および warehousingType=='0'.toString()"> および a.ID in( return_order_id FROM dwd_return_order_detail GROUP BY return_order_id HAVING SUM(storage_quantity) = 0) </if> <if test="warehousingType!= null and warehousingType!='' and warehousingType=='1'.toString()"> and a.id in(SELECT return_order_id FROM dwd_return_order_detail GROUP BY return_order_id HAVING SUM(storage_quantity) > 0 AND SUM(storage_quantity) < SUM(quantity)) </if> <if test="warehousingType!= null and warehousingType!='' and warehousingType=='2'.toString ()"> および a.ID in( SELECT return_order_id FROM dwd_return_order_detail GROUP BY return_order_id HAVING SUM(storage_quantity) = SUM(quantity)) </if> order by a.create_date desc <if test="pageSize != 0"> LIMIT #{offset},#{pageSize} </if> </select>