SELECT CC.CUSTOMER_ID AS customerId
FROM CAMPAIGN_CUSTOMER CC
    INNER JOIN CUSTOMER C ON CC.CUSTOMER_ID = C.CUSTOMER_ID
    LEFT JOIN RECEIVE_CUST_LOG CL ON CC.CUSTOMER_ID = CL.CUSTOMER_ID
WHERE CC.CAMPAIGN_ID = :campaignId
  AND CC.COMPANY_SITE_ID = :companySiteId
  AND CC.IN_CAMPAIGN_STATUS = 1
  AND CL.CUSTOMER_ID IS NULL
  AND CL.END_TIME IS NULL
  AND CC.STATUS = 0
  AND C.STATUS = 1
  AND C.CALL_ALLOWED = 1
  AND C.IPCC_STATUS = 'active'
