SELECT client_id FROM sys_client_upay_profile AS cardFlow
WHERE cardFlow.upay_approve_result = 4 or upay_approve_result = 1
))
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)
)
</if>
<iftest="card_approving">
AND (c.client_id NOT IN (
SELECT client_id FROM sys_client_upay_profile
AND c.client_id IN (
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