ソースを参照

kyc增加邮箱限制

test 7 ヶ月 前
コミット
9d4033f360

+ 3 - 0
src/modules/dj/entity/kyc.ts

@@ -21,6 +21,9 @@ export class KycEntity extends BaseEntity {
   @Column({ comment: 'KYC_ID' })
   customerId: string;
 
+  @Column({ comment: 'email' })
+  email: string;
+
   @Column({ comment: 'country' })
   country: string;
 

+ 3 - 1
src/modules/dj/service/channels/sunpay.ts

@@ -23,6 +23,7 @@ const QUERY_REFUND_URL = HOST + '/api/v3-2/Fiat/x/Refund'
 const KYC_QUERY = HOST + '/api/v3-2/Fiat/Kyc/GetCustomer'
 
 // const API_KEY = '08dcd396-a91a-486a-8ca5-02150819d7ae';
+// const API_SERECT = 'e0ce942cc6255e31578a753a4b0bfc2a7b9200837371cfa47c0c89ec143386e0';
 const API_KEY = '08dd0477-8676-4f68-83c1-215dceeffa2e';
 const API_SERECT = 'c87e8df7bfd93887c2c0f8dfa2e9190ef1d010fb0de5bca0615138e318767b36';
 const NOTIFY_HOST = `http://157.175.73.225/api/admin/dj/open/SunCard/notifyOrder`;
@@ -381,7 +382,8 @@ export class SunPayService extends BaseService {
       return {
         customerId: res.data.data.customer_id,
         kycUserId: res.data.data.out_user_id,
-        countryCode: res.data.data.country_code
+        countryCode: res.data.data.country_code,
+        customerEmail: res.data.data.customer_email
       };
     } else {
       throw new Error(msg);

+ 5 - 0
src/modules/dj/service/kyc.ts

@@ -81,6 +81,10 @@ export class KycService extends BaseService {
     if (!orderNo || !order) {
       throw new CoolCommException('Order does not exist');
     }
+    const kyc = await this.kycEntity.findOneBy({ email: payload.email });
+    if(kyc) {
+      throw new CoolCommException('This email has already been used');
+    }
     const { customerId } = await this.sunPayService.createBasic(payload);
     if (customerId) {
       await this.kycEntity.insert({
@@ -90,6 +94,7 @@ export class KycService extends BaseService {
         kycUserId: payload.outUserId,
         customerId: customerId,
         level: '1',
+        email: payload.email,
         country: payload.countryCode
       })
       return { customerId }

+ 9 - 2
src/modules/dj/service/openKyc.ts

@@ -50,7 +50,8 @@ export class KycOpenService extends BaseService {
           userId: kyc.mchId,
           kycUserId: kyc.userId,
           country: kyc.country,
-          level: kyc.level
+          level: kyc.level,
+          email: kyc.email
         }
       }
       const outUserId = md5(payload.mchId + '_' + payload.userId + 'v2');
@@ -62,7 +63,8 @@ export class KycOpenService extends BaseService {
         kycUserId: data.kycUserId,
         customerId: data.customerId,
         level: '1',
-        country: data.countryCode
+        country: data.countryCode,
+        email: data.customerEmail
       }
       await this.kycEntity.insert(kyc)
       return {
@@ -70,6 +72,7 @@ export class KycOpenService extends BaseService {
         userId: newKyc.mchId,
         kycUserId: newKyc.userId,
         country: newKyc.country,
+        email: newKyc.email,
         level: newKyc.level
       }
     } catch (err) {
@@ -229,6 +232,10 @@ export class KycOpenService extends BaseService {
       if (kyc) {
         throw new Error('当前客户ID已存在,请勿重复提交');
       }
+      const emailKyc = await this.kycEntity.findOneBy({ email: payload.email });
+      if (emailKyc) {
+        throw new CoolCommException('邮箱已被使用');
+      }
       const outUserId = md5(payload.mchId + '_' + payload.userId + 'v2');
       const { customerId } = await this.sunPayService.createBasic({
         outUserId,