فهرست منبع

feat: 区分白标注册用户

max 7 ماه پیش
والد
کامیت
3913b310b9

+ 2 - 2
src/modules/api/service/customer.ts

@@ -37,13 +37,13 @@ export class CustomerService extends BaseService {
       this.individualService.setIsOpenApi(true)
       return await this.individualService.add({
         ...params,
-        ...params.individual,
+        // ...params.individual,
       });
     }
     this.businessService.setIsOpenApi(true)
     return await this.businessService.add({
       ...params,
-      ...params.company,
+      // ...params.company,
     });
     // TODO 过滤sunpay返回
   }

+ 5 - 1
src/modules/payment/adapter/sunpay.adapter.ts

@@ -19,6 +19,8 @@ export class SunPayAdapter implements ChannelAdapter {
   customerEntity: Repository<CustomerEntity>;
   @Config(ALL)
   globalConfig;
+  @Inject()
+  ctx;
   private config: {
     apiKey: string;
     apiSecret: string;
@@ -371,6 +373,8 @@ export class SunPayAdapter implements ChannelAdapter {
    * @returns
    */
   async setCustomerInfo(params: any = {}) {
+    const { merchant } = this.ctx.admin;
+    const merchantId = merchant.mchId;
     // 兼容 白标 和 va平台的身份认证, 根据 openApi 判断
     // 保存客户信息
     const customer = await this.customerEntity.findOne({
@@ -400,7 +404,7 @@ export class SunPayAdapter implements ChannelAdapter {
       status: res.data.status,
       webhook_url: params.webhook_url,
       beneficiary_id: res.data.beneficiary_id,
-      out_user_id: params.openApi ? params.out_user_id : null // 白标用户是有 out_user_id , va商户没有
+      out_user_id: params.openApi ? merchantId : null // 白标用户是有 out_user_id , va商户没有
     });
 
     return res;

+ 3 - 6
src/modules/payment/service/business.ts

@@ -39,19 +39,16 @@ export class BusinessService extends BaseService {
    * @param params
    * @returns
    */
-  async add(params) {
+  async add(params) {    
     const { merchant } = this.ctx.admin;
     const merchantId = merchant.mchId;
-    if (!params?.registration_date) {
-      params.registration_date = this.utils.getNewTime()
-    }
     const custom = {
       ...params,
-      out_user_id: merchantId,
+      out_user_id: this.ctx.admin?.openApi ? params.out_user_id : merchantId,
       webhook_url: this.getWebhook_url(params),
       customer_type: 'COMPANY',
       openApi: this.ctx.admin?.openApi || false
-    };
+    };    
     let res = await this.paymentService
       .setChannel('SUNPAY')
       .setCustomerInfo(custom);

+ 1 - 4
src/modules/payment/service/individual.ts

@@ -43,12 +43,9 @@ export class IndividualService extends BaseService {
   async add(params) {
     const { merchant } = this.ctx.admin;
     const merchantId = merchant.mchId;
-    if (!params?.registration_date) {
-      params.registration_date = this.utils.getNewTime()
-    }
     const custom = {
       ...params,
-      out_user_id: merchantId,
+      out_user_id: this.ctx.admin?.openApi ? params.out_user_id : merchantId,
       webhook_url: this.getWebhook_url(params),
       customer_type: 'INDIVIDUAL',
       openApi: this.ctx.admin?.openApi || false

+ 1 - 1
src/modules/payment/service/payment.ts

@@ -54,7 +54,7 @@ export class PaymentService extends BaseService {
     };
     delete params.merchantId;
     delete params.webhook_url;
-    custom[params.customer_type === 'COMPANY' ? 'company' : 'individual'] = {
+    custom[params.customer_type === 'COMPANY' ? 'company' : 'individual'] = params?.openApi ?  params[params.customer_type === 'COMPANY' ? 'company' : 'individual'] : {
       ...params,
     };
     delete custom[params.customer_type === 'COMPANY' ? 'company' : 'individual'].customer_type;