Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/main'

max 7 mēneši atpakaļ
vecāks
revīzija
0410f48ad9

+ 1 - 1
src/modules/api/middleware/authority.ts

@@ -54,7 +54,7 @@ export class BaseAuthorityMiddleware
         'fusionpay-sign': vaSign = '',
       } = header;
       const params =
-        ctx?.req.method === 'GET' ? ctx?.request.query : ctx?.request.body;
+        ctx?.req.method === 'GET' ? /* ctx?.request.query */ '' : ctx?.request.body;
       const merchantInfo = await this.merchantEntity.findOne({
         where: {
           apiSecret: `${vaKey}`,

+ 25 - 26
src/modules/payment/service/customer.ts

@@ -40,43 +40,40 @@ export class CustomerService extends BaseService {
         message: '不支持的类型',
       };
     }
+    // 白标用户
     const customer = await this.customerEntity.findOne({
       where: {
         customer_id: data.customer_id,
-        merchantId: data.out_user_id,
       },
     });
+    const isWhiteLabel = customer?.out_user_id.length > 0;
     if (!customer) {
-      // 获取商户的回调
-      await this.request(customer.webhook_url, {
-        biz_status: 'FAIL',
-        biz_type: 'CREATECUSTOMER',
-        data: data
-      })
       return {
         is_success: false,
         message: '客户不存在',
       };
     }
     if (customer.status == 'SUCCESS') {
-      // 获取商户的回调
-      await this.request(customer.webhook_url, {
-        biz_status: 'SUCCESS',
-        biz_type: 'CREATECUSTOMER',
-        data: data
-      })
+      if(isWhiteLabel) {
+        // 获取商户的回调
+        await this.request(customer?.webhook_url, {
+          biz_status: 'SUCCESS',
+          biz_type: 'CREATECUSTOMER',
+          data: data
+        })
+      }
       return {
         is_success: true,
         message: '成功',
       };
     }
+    
     const status = biz_status === 'FAIL' ? -1 : 1;
-    customer.status = biz_status;
+    customer.status = biz_status;    
+    // 平台用户
     const business = await this.businessEntity.findOne({
       where: {
-        merchant: {
-          id: data.out_user_id,
-        },
+        customer_id: data.customer_id,
       },
     });
     if (business) {
@@ -90,9 +87,7 @@ export class CustomerService extends BaseService {
     } else {
       const individual = await this.individualEntity.findOne({
         where: {
-          merchant: {
-            id: data.out_user_id,
-          },
+          customer_id: data.customer_id
         },
       });
       if (individual) {
@@ -106,12 +101,16 @@ export class CustomerService extends BaseService {
       }
     }
     await this.customerEntity.save(customer);
-    // 获取商户的回调
-    await this.request(customer.webhook_url, {
-      biz_status: 'SUCCESS',
-      biz_type: 'CREATECUSTOMER',
-      data: data
-    })
+    // 白标用户
+    if(isWhiteLabel) {
+      // 通知商户的回调
+      const whiteRes =  await this.request(customer?.webhook_url, {
+        biz_status: biz_status,
+        biz_type: 'CREATECUSTOMER',
+        data: data
+      })
+      // return whiteRes TODO Max 白标用户的回调是否通知到上游
+    }
     return {
       is_success: true,
       message: '成功',

+ 11 - 12
src/modules/payment/service/wallet.ts

@@ -89,25 +89,24 @@ export class WalletService extends BaseService {
         currency: data.currency,
       },
     });
-    if (!wallet) {
+    const isWhiteLabel = this.config.callback.sunpay != wallet.webhook_url;
+    if(isWhiteLabel) {
       // 获取商户的回调
-      await this.request(wallet.webhook_url, {
-        biz_status: 'FAIL',
-        biz_type: 'CREATECUSTOMER',
-        data: data
-      })
+      await this.request(wallet.webhook_url, params)
+    }
+    if (!wallet) {
+      // // 获取商户的回调
+      // await this.request(wallet.webhook_url, {
+      //   biz_status: 'FAIL',
+      //   biz_type: 'CREATECUSTOMER',
+      //   data: data
+      // })
       return {
         is_success: false,
         message: '钱包不存在',
       };
     }
     if (wallet.status == 'SUCCESS') {
-      // 获取商户的回调
-      await this.request(wallet.webhook_url, {
-        biz_status: 'SUCCESS',
-        biz_type: 'CREATECUSTOMER',
-        data: data
-      })
       return {
         is_success: true,
         message: '成功',