Browse Source

fix: 编辑受益人详情

max 7 months ago
parent
commit
64dd9efc86

+ 3 - 1
src/modules/api/controller/beneficiary.ts

@@ -53,7 +53,9 @@ export class BeneficiaryController extends BaseController {
   @Get('/Beneficiary', { summary: '获取受益人列表' })
   async getBeneficiary(@Query('customer_id') customerId: string,) {
     this.payeeService.setIsOpenApi(true);
-    return await this.beneficiaryService.getBeneficiaryList(customerId);
+    return await this.beneficiaryService.getBeneficiaryList({
+      customer_id: customerId
+    });
   }
   /**
    * 修改受益人

+ 2 - 11
src/modules/api/service/beneficiary.ts

@@ -34,17 +34,8 @@ export class BeneficiaryService extends BaseService {
     // });
     // return Promise.resolve(payee);
   }
-  async getBeneficiaryList(
-    customerId: string,
-  ): Promise<PayeeEntity[]> {
-    const whereParams = {
-      merchantId: customerId,
-    }
-    return await this.payeeEntity.find({
-      where: {
-        ...whereParams,
-      },
-    });
+  async getBeneficiaryList(params){
+    return  await this.sunPayAdapter.getBeneficiaryList(params);
   }
 }
 

+ 20 - 5
src/modules/payment/service/payee.ts

@@ -72,19 +72,34 @@ export class PayeeService extends BaseService {
   }
   async update(params: any) {
     let customer = await this.getCustomer(params);
-    const payee = await this.payeeEntity.findOneBy({
-      id: params.id,
-    });
+    let payee;
+    if(this.ctx.admin?.openApi) {
+      payee = await this.payeeEntity.findOneBy({
+        beneficiary_id: params.id,
+      });
+    } else {
+      payee = await this.payeeEntity.findOneBy({
+        id: params.id,
+      });
+    }
     const custom = {
       ...params,
       customer_id: customer.customer_id,
       beneficiary_type: customer.type ? 'COMPANY' : 'INDIVIDUAL',
-      id: payee.beneficiary_id,
     };
+    if(!this.ctx.admin?.openApi) {
+      custom.id = payee.beneficiary_id
+    }
     const res = await this.paymentService
       .setChannel(customer.channel)
       .updatePayee(custom);
-    await super.update(params);
+    await super.update({
+      ...params,
+      id: payee.id
+    });
+    if(this.ctx.admin?.openApi) {
+      return res
+    }
     return res;
   }
   async delete(params: any) {