# Dedupe Logic Backup This document contains the removed dedupe logic blocks from `ssejson.json` for the `createCustomer` API payload validation schema. You can restore this logic in the future by adding these arrays back into the `CF200` actions block. ## 1. First Dedupe Logic Block (Main `CF200` Actions) This dedupe check runs queries against the `consumer_application` and `merchant` tables to find an existing applicant/co-applicant within the last 3 months. ```json "dedupe": [ { "operation": "query", "name": "isExistingapplicant", "queryType": "raw", "dbRaw": "SELECT ca.id,ca.name,ca.mobile_number,ca.state,ca.applicant_id,UNIX_TIMESTAMP(ca.created_at),ca.merchant_id AS created_at FROM consumer_application ca INNER JOIN merchant m ON ca.merchant_id = m.id WHERE (ca.pan_card = %s OR ca.email = %s OR ca.mobile_number = %s)AND ca.is_deleted IS NULL AND m.status != 'bre' ORDER BY ca.created_at DESC;", "queryParams": [ "encrypt->$request.panNumber", "encrypt->$request.email", "encrypt->$request.communicationMobileNumber" ], "stateKey": "r" }, { "conditions": [ "$r", "isNotNull" ], "true": { "operation": "returnResponse", "return_code": "401005", "CF_code": "CF300", "message": "It seems like it has been less than 3 months since you applied to Credit Fair . We'll be happy to serve you after 3 months" } }, { "conditions": [ "$request.coApplicant.name", "isNotNull" ], "true": { "operation": "query", "name": "isExistingcoapplicant", "queryType": "raw", "dbRaw": "SELECT ca.id, ca.co_applicant_name as name, ca.co_applicant_mobile_number as mobile_number, UNIX_TIMESTAMP(ca.created_at) as created_at, ca.merchant_id, ca.state, ca.co_applicant_id as applicant_id FROM consumer_application ca INNER JOIN merchant m ON ca.merchant_id = m.id WHERE (ca.co_applicant_pan_card = %s or ca.co_applicant_email = %s or ca.co_applicant_mobile_number = %s) AND ca.is_deleted is null AND m.status != 'bre' ORDER BY created_at DESC", "queryParams": [ "encrypt->$request.coApplicant.panNumber", "encrypt->$request.coApplicant.email", "encrypt->$request.coApplicant.phone" ], "stateKey": "rcoapp" } }, { "conditions": [ "$rcoapp", "isNotNull" ], "true": { "operation": "returnResponse", "return_code": "401005", "CF_code": "CF300", "message": "It seems like it has been less than 3 months since you applied to Credit Fair . We'll be happy to serve you after 3 months" } } ] ``` ## 2. Second Dedupe Logic Block This alternative dedupe logic array executes slightly different DB queries without joining on the `merchant` table. ```json "dedupe": [ { "operation": "query", "name": "isExistingapplicant", "queryType": "raw", "dbRaw": "SELECT id, name, mobile_number, state, applicant_id, UNIX_TIMESTAMP(created_at) as created_at FROM consumer_application WHERE (pan_card = %s or email = %s or mobile_number = %s) AND is_deleted is null ORDER BY created_at DESC", "queryParams": [ "encrypt->$request.coApplicant.panNumber", "encrypt->$request.coApplicant.email", "encrypt->$request.coApplicant.phone" ], "stateKey": "r" }, { "conditions": [ "$r", "isNotNull" ], "true": { "operation": "returnResponse", "return_code": "401005", "CF_code": "CF300", "message": "It seems like it has been less than 3 months since you applied to Credit Fair . We'll be happy to serve you after 3 months" } }, { "conditions": [ "$request.coApplicant.name", "isNotNull" ], "true": { "operation": "query", "name": "isExistingcoapplicant", "queryType": "raw", "dbRaw": "SELECT id, co_applicant_name as name, co_applicant_mobile_number as mobile_number, UNIX_TIMESTAMP(created_at) as created_at, state, co_applicant_id as applicant_id FROM consumer_application WHERE (co_applicant_pan_card = %s or co_applicant_email = %s or co_applicant_mobile_number = %s) AND is_deleted is null ORDER BY created_at DESC", "queryParams": [ "encrypt->$request.coApplicant.panNumber", "encrypt->$request.coApplicant.email", "encrypt->$request.coApplicant.phone" ], "stateKey": "rcoapp" } }, { "conditions": [ "$rcoapp", "isNotNull" ], "true": { "operation": "returnResponse", "return_code": "401005", "CF_code": "CF300", "message": "It seems like it has been less than 3 months since you applied to Credit Fair . We'll be happy to serve you after 3 months" } } ] ```