SELECT client_id FROM sys_client_upay_profile AS cardFlow
SELECT client_id FROM sys_client_upay_profile scup
WHERE cardFlow.upay_approve_result = 4 or upay_approve_result = 1
WHERE ((scup.upay_approve_result=4 and scup.upay_open_status is null) or scup.upay_open_status=1 or scup.upay_open_status=2 or scup.upay_open_status=4)
))
)
</if>
</if>
<iftest="card_approving">
<iftest="card_approving">
AND (c.client_id NOT IN (
AND c.client_id IN (
SELECT client_id FROM sys_client_upay_profile
SELECT client_id FROM sys_client_upay_profile scup
WHERE ((scup.upay_approve_result=4 and scup.upay_open_status is null) or scup.upay_open_status=1 or scup.upay_open_status=2 or scup.upay_open_status=4)
)
)
OR c.client_id IN (
SELECT client_id FROM sys_client_upay_profile AS cardFlow
WHERE cardFlow.upay_approve_result = 4 or upay_approve_result = 1