You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-wms-java/src/main/resources/mybatis/mapper/inout/IoOrderDao.xml

758 lines
32 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glxp.api.dao.inout.IoOrderDao">
<select id="filterList" resultType="com.glxp.api.res.inout.IoOrderResponse">
SELECT io.*,
bus.name AS billTypeName,
ad.name AS deptName,
aw.name AS invName,
au.employeeName AS createUserName,
au2.employeeName AS updateUserName,
au3.employeeName AS reviewUserName,
au4.employeeName AS checkUserName,
ad2.name AS fromDeptName,
aw2.name AS fromInvName,
bc1.name AS fromCorpName,
bc2.name AS customerName,
sw.workplaceName AS workPlaceName,
swd.busName AS splitBusTypeName
FROM
io_order io
LEFT JOIN
basic_bussiness_type bus ON bus.action = io.action
LEFT JOIN
auth_dept ad ON ad.code = io.deptCode
LEFT JOIN
auth_warehouse aw ON aw.code = io.invCode
LEFT JOIN
auth_user au ON au.id = io.createUser
LEFT JOIN
auth_user au2 ON au2.id = io.updateUser
LEFT JOIN
auth_user au3 ON au3.id = io.reviewUser
LEFT JOIN
auth_user au4 ON au4.id = io.checkUser
LEFT JOIN
auth_dept ad2 ON ad2.code = io.fromDeptCode
LEFT JOIN
auth_warehouse aw2 ON aw2.code = io.fromInvCode
LEFT JOIN
basic_corp bc1 ON bc1.erpId = io.fromCorp
LEFT JOIN
basic_corp bc2 ON bc2.erpId = io.customerId
LEFT JOIN
io_order_invoice ioi ON ioi.orderIdFk = io.billNo
LEFT JOIN
sys_workplace sw ON sw.workplaceId = io.workPlaceCode
LEFT JOIN
sys_workplace_document swd ON swd.documentTypeCode = io.splitBusType
<if test="uploadKey != null and uploadKey != ''">
INNER JOIN io_unit_maintain_platform a2 on io.action = a2.sourceAction AND io.fromCorp = a2.unitId
</if>
<where>
<if test="id != null and id != ''">
AND id = #{id}
</if>
<if test="updateUser != null and updateUser != ''">
AND io.updateUser = #{updateUser}
</if>
<if test="productType != null and productType != ''">
AND io.productType = #{productType}
</if>
<!-- <if test="keyWords != null and keyWords != ''">-->
<!-- AND (aw.name like concat('%', #{keyWords}, '%') or bc.name like concat('%', #{keyWords}, '%'))-->
<!-- </if>-->
<if test="corpName != null and corpName != ''">
AND (SELECT NAME FROM auth_warehouse aw2 WHERE aw2.CODE = io.fromInvCode) like
concat('%', #{corpName}, '%')
</if>
<if test="action != null and action != ''">
AND io.action = #{action}
</if>
<if test="remark != null and remark != ''">
AND io.remark like concat('%', #{remark}, '%')
</if>
<if test="mainAction != null and mainAction != ''">
AND io.mainAction = #{mainAction}
</if>
<if test="billNo != null and billNo != ''">
AND io.billNo like concat('%', #{billNo}, '%')
</if>
<if test="corpOrderId != null and corpOrderId != ''">
AND io.corpOrderId = #{corpOrderId}
</if>
<if test="fromCorp != null and fromCorp != ''">
AND io.fromCorp = #{fromCorp}
</if>
11 months ago
<if test="workPlaceCode != null and workPlaceCode != ''">
AND io.workPlaceCode = #{workPlaceCode}
</if>
<if test="invoiceEncode != null and invoiceEncode != ''">
AND ioi.invoiceEncode like concat('%', #{invoiceEncode}, '%')
</if>
<if test="keyWord != null and keyWord != ''">
AND (
bc.name like concat('%', #{keyWord}, '%')
or io.remark like concat('%', #{keyWord}, '%')
or io.fromInvCode like concat('%', #{keyWord}, '%'))
</if>
<if test="deptCode != null and deptCode != ''">
AND io.deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND io.invCode = #{invCode}
</if>
<if test="busType != null">
10 months ago
AND io.busType = #{busType}
</if>
<if test="inCodeStatus != null">
AND inCodeStatus = #{inCodeStatus}
</if>
<if test="relKey != null">
AND relKey like concat('%', #{relKey}, '%')
</if>
<if test="filterSelected != null and filterSelected == true">
AND io.preInSelected is null
</if>
<if test="filterSelected != null and filterSelected == false">
AND io.preInSelected is not null
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(io.createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d')
</if>
<if test="startAduditTime != null and startAduditTime != '' and endAduditTime != null and endAduditTime != ''">
AND date_format(io.auditTime, '%Y-%m-%d') between date_format(#{startAduditTime}, '%Y-%m-%d') and
date_format(#{endAduditTime}, '%Y-%m-%d')
</if>
<if test="actions != null and actions.size() != 0">
AND io.`action` in
<foreach collection="actions" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="sourceTypes != null and sourceTypes.size() != 0">
AND io.fromType in
<foreach collection="sourceTypes" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="unionRemark != null and unionRemark != ''">
AND (io.remark like concat('%', #{unionRemark}, '%')
or io.outSickInfo like concat('%', #{unionRemark}, '%'))
</if>
<if test="statuses != null and statuses.size() != 0">
AND io.status in
<foreach collection="statuses" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="sickerAdNums != null and sickerAdNums.size() != 0">
AND io.sickerAdNum in
<foreach collection="sickerAdNums" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="dealStatuses != null and dealStatuses.size() != 0">
AND io.dealStatus in
<foreach collection="dealStatuses" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="fromCorpList != null and fromCorpList.size() != 0">
AND io.fromCorp in
<foreach collection="fromCorpList" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="inOrders != null and inOrders.size() != 0">
AND io.billNo in
<foreach collection="inOrders" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="orderIds != null and orderIds.size() != 0">
AND io.billNo in
<foreach collection="orderIds" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="status != null">
AND io.status = #{status}
</if>
<if test="sickerAdNum != null">
AND io.sickerAdNum = #{sickerAdNum}
</if>
<if test="orderType != null">
AND io.orderType = #{orderType}
</if>
<if test="fromPatientCode != null">
AND io.fromPatientCode = #{fromPatientCode}
</if>
10 months ago
<if test="keyWords != null and keyWords != ''">
and (io.billNo like concat('%', #{keyWords}, '%')
or io.fromCorp like concat('%', #{keyWords}, '%')
or io.workPlaceCode like concat('%', #{keyWords}, '%')
or io.busType like concat('%', #{keyWords}, '%')
or sw.workplaceName like concat('%', #{keyWords}, '%')
or swd.busName like concat('%', #{keyWords}, '%')
or io.fromType like concat('%', #{keyWords}, '%'))
</if>
<if test="supInoivceSearch != null">
<if test="invoiceActions1 != null and invoiceActions2 == null">
AND (io.`action` in
<foreach collection="invoiceActions1" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and io.status = 10)
</if>
<if test="invoiceActions1 == null and invoiceActions2 != null">
2 years ago
and (
io.`action` in
2 years ago
<foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and io.status = 7
)
2 years ago
</if>
<if test="invoiceActions1 != null and invoiceActions2 != null">
AND ((io.`action` in
2 years ago
<foreach collection="invoiceActions1" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and io.status = 10)
or (
`action` in
2 years ago
<foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and io.status = 7)
)
2 years ago
</if>
</if>
1 year ago
GROUP BY io.billNo
2 years ago
</where>
2 years ago
<choose>
<when test="(orderBy != null) and (sort == 'desc' or sort == 'asc')">
order by ${orderBy} ${sort}
2 years ago
</when>
<otherwise>
order by updateTime desc
</otherwise>
</choose>
2 years ago
</select>
<select id="getfilterList" resultType="com.glxp.api.res.inout.IoOrderResponse">
select io.*,
(select name from basic_bussiness_type bus where bus.action = io.action) billTypeName,
(select name from auth_dept ad where ad.code = io.deptCode) deptName,
(select name from auth_warehouse aw where aw.code = io.invCode) invName,
(select employeeName from auth_user au where au.id = io.createUser) createUserName,
(select employeeName from auth_user au2 where au2.id = io.updateUser) updateUserName,
(select employeeName from auth_user au3 where au3.id = io.reviewUser) reviewUserName,
(select employeeName from auth_user au4 where au4.id = io.checkUser) checkUserName,
(select name from auth_dept ad2 where ad2.code = io.fromDeptCode) fromDeptName,
(select name from auth_warehouse aw2 where aw2.code = io.fromInvCode) fromInvName,
(select name from basic_corp bc where bc.erpId = io.fromCorp) fromCorpName,
(select name from basic_corp bc where bc.erpId = io.customerId) customerName,
(SELECT count(*)
FROM io_order_detail_code
WHERE io_order_detail_code.orderIdFk = io.billNo
and io_order_detail_code.regStatus = 1
) AS allCout,
(SELECT count(*)
FROM io_order_detail_code
WHERE io_order_detail_code.orderIdFk = io.billNo
and io_order_detail_code.regStatus = 0
) As partCount
2 years ago
from io_order as io
<where>
<if test="id != null and id != ''">
AND id = #{id}
</if>
<if test="corpName != null and corpName != ''">
AND (SELECT NAME FROM auth_warehouse aw2 WHERE aw2.CODE = io.fromInvCode) like
concat('%', #{corpName}, '%')
2 years ago
</if>
<if test="action != null and action != ''">
AND action = #{action}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="billNo != null and billNo != ''">
AND billNo like concat('%', #{billNo}, '%')
</if>
<if test="corpOrderId != null and corpOrderId != ''">
AND corpOrderId = #{corpOrderId}
</if>
<if test="fromCorp != null and fromCorp != ''">
AND fromCorp = #{fromCorp}
</if>
<if test="deptCode != null and deptCode != ''">
AND deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="busType != null">
AND busType = #{busType}
</if>
<if test="inCodeStatus != null">
AND inCodeStatus = #{inCodeStatus}
</if>
<if test="relKey != null">
AND relKey like concat('%', #{relKey}, '%')
2 years ago
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d')
2 years ago
</if>
<if test="startAduditTime != null and startAduditTime != '' and endAduditTime != null and endAduditTime != ''">
AND date_format(auditTime, '%Y-%m-%d') between date_format(#{startAduditTime}, '%Y-%m-%d') and
date_format(#{endAduditTime}, '%Y-%m-%d')
2 years ago
</if>
<if test="actions != null and actions.size() != 0">
AND `action` in
<foreach collection="actions" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="sourceTypes != null and sourceTypes.size() != 0">
AND fromType in
<foreach collection="sourceTypes" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="statuses != null and statuses.size() != 0">
AND status in
<foreach collection="statuses" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="dealStatuses != null and dealStatuses.size() != 0">
AND dealStatus in
<foreach collection="dealStatuses" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="orderIds != null and orderIds.size() != 0">
AND io.billNo in
<foreach collection="orderIds" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="orderType != null">
AND orderType = #{orderType}
</if>
<if test="supInoivceSearch != null">
<if test="invoiceActions1 != null and invoiceActions2 == null">
AND (`action` in
<foreach collection="invoiceActions1" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and status = 10)
</if>
<if test="invoiceActions1 == null and invoiceActions2 != null">
and (
`action` in
<foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and (status = 7 or status = 10)
)
</if>
<if test="invoiceActions1 != null and invoiceActions2 != null">
AND ((`action` in
<foreach collection="invoiceActions1" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and status = 10)
or (
`action` in
<foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and (status = 7 or status = 10))
)
</if>
</if>
</where>
2 years ago
<choose>
<when test="(orderBy != null) and (sort == 'desc' or sort == 'asc')">
order by ${orderBy} ${sort}
2 years ago
</when>
<otherwise>
order by updateTime desc
</otherwise>
</choose>
</select>
<select id="filterOrderList" resultType="com.glxp.api.entity.inout.IoOrderEntity">
select *
from io_order
<where>
<if test="billNo != null and billNo != ''">
AND billNo like concat('%', #{billNo}, '%')
</if>
<if test="id != null and id != ''">
AND id = #{id}
</if>
<if test="action != null and action != ''">
AND action = #{action}
</if>
<if test="mainAction != null and mainAction != ''">
AND mainAction = #{mainAction}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="corpOrderId != null and corpOrderId != ''">
AND corpOrderId = #{corpOrderId}
</if>
<if test="fromCorp != null and fromCorp != ''">
AND fromCorp = #{fromCorp}
</if>
<if test="customerId != null and customerId != ''">
AND customerId = #{customerId}
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="deptCode != null and deptCode != ''">
AND deptCode = #{deptCode}
</if>
<if test="syncStatus != null">
AND syncStatus = #{syncStatus}
</if>
<if test="unionRemark != null and unionRemark != ''">
AND (io.remark like concat('%', #{unionRemark}, '%')
or io.outSickInfo like concat('%', #{unionRemark}, '%'))
</if>
<if test="busType != null">
AND busType = #{busType}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d')
</if>
<if test="lastUpdateTime != null and lastUpdateTime != ''">
<![CDATA[
and DATE_FORMAT(updateTime, '%Y-%m-%d %H:%i:%S') >= DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
</where>
order by createTime desc
</select>
<select id="selectSupplementOrderList" resultType="com.glxp.api.entity.inout.IoOrderEntity">
SELECT *
FROM io_order
WHERE (supplementNo IS NULL OR supplementNo = '')
AND `action` IN (SELECT `action`
FROM basic_bussiness_type
WHERE supplementOrderType IS NOT NULL
and supplementOrderType
!= '')
</select>
<select id="selectBillNos" resultType="com.glxp.api.res.inout.OrderNoResult">
select originUllageSupNo, ullageSupNo, supplementNo, replicateNo, preInBillNo, preOutBillNo
from io_order
where billNo = #{billNo}
</select>
<select id="selectUploadOrder" resultType="com.glxp.api.res.inout.IoOrderResponse">
select io.*,
ioul.result,
(select name from basic_bussiness_type bus where bus.action = io.action) billTypeName,
(select name from auth_dept ad where ad.code = io.deptCode) deptName,
(select name from auth_warehouse aw where aw.code = io.invCode) invName,
(select employeeName from auth_user au where au.id = io.createUser) createUserName,
(select employeeName from auth_user au2 where au2.id = io.updateUser) updateUserName,
(select employeeName from auth_user au3 where au3.id = io.reviewUser) reviewUserName,
(select employeeName from auth_user au4 where au4.id = io.checkUser) checkUserName,
(select name from auth_dept ad2 where ad2.code = io.fromDeptCode) fromDeptName,
(select name from auth_warehouse aw2 where aw2.code = io.fromInvCode) fromInvName,
(select name from basic_corp bc where bc.erpId = io.fromCorp) fromCorpName,
(select name from basic_corp bc where bc.erpId = io.customerId) customerName
from io_order as io
left join io_order_upload_log ioul on io.billNo = ioul.billNo
<where>
io.dealStatus = 3
<if test="billType != null and billType != ''">
AND action = #{billType}
</if>
<if test="billTypes != null and billTypes.size() != 0">
AND action in
<foreach collection="billTypes" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="billNo != null and billNo != ''">
AND io.billNo like concat('%', #{billNo}, '%')
</if>
<if test="invCode != null and invCode != ''">
AND invCode = #{invCode}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d')
</if>
<if test="startTime != null and startTime != '' and (endTime == null or endTime == '')">
AND date_format(createTime, '%Y-%m-%d') >= date_format(#{startTime}, '%Y-%m-%d')
</if>
<if test="endTime != null and endTime != '' and (startTime == null or startTime == '')">
AND date_format(createTime, '%Y-%m-%d') &lt;= date_format(#{endTime}, '%Y-%m-%d')
</if>
<if test="submitStatus != null and submitStatus != ''">
AND exportStatus = #{submitStatus}
</if>
<if test="busType != null">
AND busType = #{busType}
</if>
</where>
order by io.updateTime desc
</select>
<select id="selectActionByBillNo" resultType="java.lang.String">
select action
from io_order
where billNo = #{billNo}
</select>
2 years ago
<select id="selectWaitSubmitOrder" resultType="java.lang.String">
select t.billNo
from io_order t
left join thr_system_bus_api t1 on t.action = t1.code
<where>
t.status = 7
and exportStatus = 0
<if test="thirdSys != null and thirdSys != ''">
AND t1.thirdSys = #{thirdSys}
</if>
<if test="orderStartTime != null">
<![CDATA[
and updateTime >= DATE_FORMAT(#{orderStartTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
</where>
2 years ago
</select>
<update id="updateOrder" parameterType="com.glxp.api.entity.inout.IoOrderEntity">
UPDATE io_order
<trim prefix="set" suffixOverrides=",">
<if test="checkStatus != null">
checkStatus=#{checkStatus},
</if>
</trim>
WHERE billNo = #{billNo}
</update>
<select id="selectOrderIdList" resultType="java.lang.String">
SELECT billNo
FROM io_order
LEFT JOIN basic_bussiness_type ON io_order.action = basic_bussiness_type.action
WHERE basic_bussiness_type.inStock = 1
and io_order.`status` = 7
AND date_format(io_order.updateTime, '%Y-%m-%d') = date_format(#{data}, '%Y-%m-%d')
</select>
<select id="selectOrderfirstAndLastIdList" resultType="java.lang.String">
SELECT billNo
FROM io_order
LEFT JOIN basic_bussiness_type ON io_order.action = basic_bussiness_type.action
<where>
basic_bussiness_type.inStock = 1
and io_order.`status` = 7
AND date_format(io_order.updateTime, '%Y-%m-%d') between date_format(#{firstData}, '%Y-%m-%d') and
date_format(#{lastData}, '%Y-%m-%d')
<if test="invCode != null and invCode != ''">
AND io_order.invCode = #{invCode}
</if>
</where>
</select>
12 months ago
<!-- LEFT JOIN io_order_detail_code dc ON io.billNo = dc.orderIdFk-->
<select id="getfilterOrderList" resultType="com.glxp.api.res.inout.IoOrderResponse">
SELECT io.*,
bus.NAME AS billTypeName,
ad.NAME AS deptName,
aw.NAME AS invName,
bc.NAME AS fromCorpName
FROM io_order io
LEFT JOIN basic_bussiness_type bus ON io.action = bus.action
LEFT JOIN auth_dept ad ON io.deptCode = ad.CODE
LEFT JOIN auth_warehouse aw ON io.invCode = aw.CODE
LEFT JOIN basic_corp bc ON io.fromCorp = bc.erpId
left join io_order_invoice on io_order_invoice.orderIdFk = io.billNo
<where>
<if test="confirmStatus != null and confirmStatus != ''">
AND io.checkStatus = #{confirmStatus}
</if>
<if test="id != null and id != ''">
AND io.id = #{id}
</if>
<if test="corpName != null and corpName != ''">
AND (SELECT NAME FROM auth_warehouse aw2 WHERE aw2.CODE = io.fromInvCode) like
concat('%', #{corpName}, '%')
</if>
<if test="action != null and action != ''">
AND io.action = #{action}
</if>
<if test="mainAction != null and mainAction != ''">
AND io.mainAction = #{mainAction}
</if>
<if test="unionRemark != null and unionRemark != ''">
AND (io.remark like concat('%', #{unionRemark}, '%')
or io.outSickInfo like concat('%', #{unionRemark}, '%'))
</if>
<if test="billNo != null and billNo != ''">
AND io.billNo like concat('%', #{billNo}, '%')
</if>
<if test="corpOrderId != null and corpOrderId != ''">
AND io.corpOrderId = #{corpOrderId}
</if>
<if test="fromCorp != null and fromCorp != ''">
AND io.fromCorp = #{fromCorp}
</if>
<if test="deptCode != null and deptCode != ''">
AND io.deptCode = #{deptCode}
</if>
<if test="invCode != null and invCode != ''">
AND io.invCode = #{invCode}
</if>
<if test="busType != null">
AND io.busType = #{busType}
</if>
<if test="inCodeStatus != null">
AND io.inCodeStatus = #{inCodeStatus}
</if>
12 months ago
<if test="invoiceRegStatus != null and invoiceRegStatus == 1">
AND io_order_invoice.id IS NULL
</if>
<if test="invoiceRegStatus != null and invoiceRegStatus == 2">
AND io_order_invoice.id IS not NULL
</if>
<if test="relKey != null">
AND io.relKey like concat('%', #{relKey}, '%')
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND date_format(io.createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and
date_format(#{endTime}, '%Y-%m-%d')
</if>
<if test="startAduditTime != null and startAduditTime != '' and endAduditTime != null and endAduditTime != ''">
AND date_format(io.auditTime, '%Y-%m-%d') between date_format(#{startAduditTime}, '%Y-%m-%d') and
date_format(#{endAduditTime}, '%Y-%m-%d')
</if>
<if test="actions != null and actions.size() != 0">
AND io.`action` in
<foreach collection="actions" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="sourceTypes != null and sourceTypes.size() != 0">
AND io.fromType in
<foreach collection="sourceTypes" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="statuses != null and statuses.size() != 0">
AND io.status in
<foreach collection="statuses" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="dealStatuses != null and dealStatuses.size() != 0">
AND io.dealStatus in
<foreach collection="dealStatuses" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="orderIds != null and orderIds.size() != 0">
AND io.billNo in
<foreach collection="orderIds" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
<if test="status != null">
AND io.status = #{status}
</if>
<if test="orderType != null">
AND io.orderType = #{orderType}
</if>
<if test="supInoivceSearch != null">
<if test="invoiceActions1 != null and invoiceActions2 == null">
AND (io.`action` in
<foreach collection="invoiceActions1" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and io.status = 10)
</if>
<if test="invoiceActions1 == null and invoiceActions2 != null">
and (
io.`action` in
<foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and io.status = 7
)
</if>
<if test="invoiceActions1 != null and invoiceActions2 != null">
AND ((io.`action` in
<foreach collection="invoiceActions1" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and io.status = 10)
or (
io.`action` in
<foreach collection="invoiceActions2" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
and io.status = 7)
)
</if>
</if>
</where>
GROUP BY io.id
<choose>
<when test="(orderBy != null) and (sort == 'desc' or sort == 'asc')">
order by ${orderBy} ${sort}
</when>
<otherwise>
order by checkStatus asc, updateTime desc
</otherwise>
</choose>
</select>
</mapper>