select cr.jwcode,cr.name,cr.market,m.name as marketName,cr.order_code,r1.rate_name as paymentCurrency,cr.payment_amount,r2.rate_name as receivedCurrency,cr.received_amount,cr.handling_charge
from cash_record_collection cr
from cash_record_collection cr
left join admin a1 on cr.submitter_id = a1.id
left join admin a2 on cr.audit_id = a2.id
left join market m1 on m1.id = cr.market
left join market m2 on m2.id = cr.received_market
left join market m on m.id = cr.market
left join rate r1 on r1.id = cr.payment_currency
left join rate r1 on r1.id = cr.payment_currency
left join rate r2 on r2.id = cr.received_currency
left join rate r2 on r2.id = cr.received_currency
left join recharge_activity ra on ra.id = cr.activity
<where>
1 = 1
<iftest="cashCollection.market != null and cashCollection.market != ''">
AND cr.market = #{cashCollection.market}
</if>
<iftest="cashCollection.jwcode != null and cashCollection.jwcode!=''">
AND cr.jwcode = #{cashCollection.jwcode}
</if>
<iftest="cashCollection.name!=null and cashCollection.name !=''">
AND cr.name like concat('%',#{cashCollection.name},'%')
</if>
<iftest="cashCollection.submitterId!=null and cashCollection.submitterId !=''">
AND cr.submitter_id = #{cashCollection.submitterId}
<iftest="cashCollection.startTime!=null and cashCollection.endTime!=null">
AND cr.pay_time between #{cashCollection.startTime} and #{cashCollection.endTime}
</if>
and cr.order_type=1
</where>
<choose>
<whentest="cashCollection.sortField != null and cashCollection.sortField.length > 0 or cashCollection.sortOrder != null and cashCollection.sortOrder.length > 0">
ORDER BY ${cashCollection.sortField} ${cashCollection.sortOrder}