Эх сурвалжийг харах

feat(): 增加获取国家列表接口

zerogo 6 сар өмнө
parent
commit
022bcbbfb4

+ 7 - 6
src/modules/api/controller/banks.ts

@@ -16,19 +16,20 @@ export class BanksController extends BaseController {
   trubitAdapter: TrubitAdapter;
 
   /**
-   * 获取银行列表
+   * 获取国家列表
    * /api/v3/Fiat/Banks
    */
-  @Get('/Banks', { summary: '获取银行列表' })
+  @Get('/country/list', { summary: '获取国家列表' })
   async getBanks(@Query(ALL) params: any) {
-    return await this.sunPayAdapter.getBanks(params)
+    return await this.trubitAdapter.getCountryListAsync(params)
   }
   /**
    * 获取银行列表
-   * /api/v3/Fiat/getSiginInTrubi
+   * /api/v3/Fiat/getSiginInTrubit
    */
-  @Post('/getSiginInTrubi', { summary: '获取银行列表' })
-  async getSiginInTrubi(@Body(ALL) params: any) {
+  @Post('/getSiginInTrubit', { summary: '获取银行列表' })
+  async getSiginInTrubit(@Body(ALL) params: any) {
+    console.log('params-=-=',params)
     return await this.trubitAdapter.testSigin(params)
   }
 }

+ 19 - 1
src/modules/payment/adapter/trubit.adapter.ts

@@ -81,12 +81,12 @@ export class TrubitAdapter implements ChannelAdapter {
     secret = ''
   ): string {
     const payload = `timestamp=${timestamp}${body}`;
+    // console.log('payload-=-==', payload)
     const signature = crypto
       .createHmac('sha256', secret)
       .update(payload)
       .digest('hex')
       .toUpperCase();
-
     return signature;
   }
 
@@ -103,6 +103,11 @@ export class TrubitAdapter implements ChannelAdapter {
     return sign;
   }
 
+  // 移除JSON Key 的引号
+  // removeJsonKeyMark(data) {
+
+  // }
+
   /**
    * 发送请求到 SunPay API
    */
@@ -157,6 +162,19 @@ export class TrubitAdapter implements ChannelAdapter {
     }
   }
 
+  /**
+   * 获取国家列表
+   */
+  async getCountryListAsync(params: any): Promise<any> {
+    console.log('getCountryListAsync-==-=-',params)
+    return await this.request(
+      'GET',
+      '/openapi/v1/otc/base/symbol_rate/country/list',
+      params
+    );
+  }
+
+
   /**
    * 验证用户信息
    */

+ 4 - 0
src/modules/payment/service/payment.ts

@@ -29,6 +29,8 @@ export class PaymentService extends BaseService {
 
   @Inject()
   easyPayXAdapter: TrubitAdapter;
+  @Inject()
+  trubitAdapter: TrubitAdapter;
   channel: string;
   /**
    * 获取渠道适配器
@@ -39,6 +41,8 @@ export class PaymentService extends BaseService {
         return this.sunPayAdapter;
       case 'EASYPAYX':
         return this.easyPayXAdapter;
+      case 'TRUBIT':
+        return this.trubitAdapter;
       default:
         throw new Error(`Unsupported channel: ${channelCode}`);
     }