zerogo 5 месяцев назад
Родитель
Сommit
be04840526

+ 1528 - 0
src/modules/api/controller/open_v4.ts

@@ -0,0 +1,1528 @@
+import {
+  All,
+  ALL,
+  Body,
+  Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+  Provide,
+  Put,
+  Query,
+  Controller
+} from '@midwayjs/decorator';
+import { BaseController, CoolController } from '@cool-midway/core';
+import { Context } from 'vm';
+import { IndividualEntity } from '../../payment/entity/individual';
+import { NoahPayAdapter } from '../../payment/adapter/noah.adapter';
+import { NoahOpenService } from '../service/open_v4';
+import { OrderType } from '../entity/open_payment_order';
+import * as crypto from 'crypto';
+
+/**
+ * 客户管理
+ */
+@Provide()
+@CoolController('/api/open/v4')
+export class OpenApiControllerV4 extends BaseController {
+  @Inject()
+  ctx: Context; // Inject the context
+
+  @Inject()
+  noahPayAdapter: NoahPayAdapter;
+
+  @Inject()
+  noahOpenService: NoahOpenService;
+
+  /**
+   * 生成sign
+   */
+  // @Post('/sign/v4', { summary: '创建sign' })
+  // async createSign(@Body(ALL) userBody: any) {
+  //   const { params, timestamp, nonce, secret } = userBody;
+  //   return this.noahOpenService.createSign(params, timestamp, nonce, secret);
+  // }
+
+    /**
+   * 查询大账户详情
+   */
+    @Get('/v1/balances', { summary: '查询余额' })
+    async getBalancesDetail(
+      @Query() params: any
+    ) {
+      //
+      const method = this.ctx.method;
+      const path = this.ctx.path;
+      return await this.noahPayAdapter.request(
+        method, path, params
+      );
+    }
+
+
+  /**
+   * 查询支持国家列表
+   */
+  @Get('/v1/channels/sell/countries', { summary: '查询支持国家列表' })
+    //
+  async getCountryList(@Query(ALL) params: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.noahPayAdapter.request(method, path, params);
+  }
+
+    /**
+   * 新增修改用户
+   */
+    @Put('/v1/customers/:id', { summary: '新增修改用户' })
+    //
+    async createCustomers(@Param('id') id: any,@Body() params: any) {
+      const method = this.ctx.method;
+      const path = this.ctx.path;
+      return await this.noahPayAdapter.request(method, path, params);
+    }
+
+
+  /**
+   * 查询用户详情
+   */
+  @Get('/v1/customers/:id', { summary: '查询用户信息' })
+    //
+  async getAccountsInfo(@Param('id') id: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.noahPayAdapter.request(
+      method,
+      `${path}`.replace(':id', id),
+      {}
+    );
+  }
+
+  /**
+   * 查询用户列表
+   */
+  @Get('/v1/customers', { summary: '查询用户信息' })
+  //
+  async getCustomersList(@Param('id') id: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.noahPayAdapter.request(
+      method,
+      `${path}`.replace(':id', id),
+      {}
+    );
+  }
+
+  /**
+   * 查询用户付款方式
+   */
+  @Get('/v1/payment-methods', { summary: '查询余额' })
+  async getPaymentMethods(
+    @Query() params: any
+  ) {
+    //
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.noahPayAdapter.request(
+      method, path, params
+    );
+  }
+
+  /**
+   * 查询费率
+   */
+  @Get('/v1/prices', { summary: '查询余额' })
+  async getPrices(
+    @Query() params: any
+  ) {
+    //
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.noahPayAdapter.request(method, path, params);
+  }
+
+    /**
+   * 查询支持的渠道
+   */
+    @Get('/v1/channels/sell', { summary: '查询余额' })
+    async getSupportChannels(
+      @Query() params: any
+    ) {
+      const method = this.ctx.method;
+      const path = this.ctx.path;
+      return await this.noahPayAdapter.request(method, path, params);
+    }
+
+  /**
+   * 用户法币转数字货币自动划转
+   */
+  @Post('/v1/workflows/bank-deposit-to-onchain-address', { summary: '申请收款账户' })
+  async workflowsBankDepositToOnchainAddress(@Body() params: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    const res = await this.noahPayAdapter.request(method, path, params);
+    this.noahOpenService.save_user_account(res, params);
+    return res;
+  }
+
+  /**
+   * 模拟用户触发法币转数字货币自动划转
+   */
+  @Post('/v1/sandbox/fiat-deposit/simulate', { summary: '申请收款账户' })
+  async fiatDepositSimulate(@Body() params: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    const res = await this.noahPayAdapter.request(method, path, params);
+    this.noahOpenService.save_user_account(res, params);
+    return res;
+  }
+
+    /**
+     * 查询订单列表
+     */
+      @Get('/v1/transactions', { summary: '查询订单列表' })
+    async getTransactions(@Query(ALL) params: any) {
+      const method = this.ctx.method;
+      const path = this.ctx.path;
+      return await this.noahPayAdapter.request(method, path, params);
+    }
+
+    /**
+   * 获取动态表单
+   */
+    @Get('/v1/channels/:ChannelID/form', { summary: '获取动态表单' })
+    async getChannelsForm(@Param('ChannelID') ChannelID: any,@Query(ALL) params: any) {
+      const method = this.ctx.method;
+      const path = this.ctx.path;
+      return await this.noahPayAdapter.request(
+        method,
+        `${path}`.replace(':ChannelID', ChannelID),
+        params
+      );
+    }
+
+
+  /**
+   * 给用户创建规则
+   */
+  @Post('/v1/beta1/rule', { summary: '给用户创建规则' })
+    async beta1RuleForCustomer(@Body() params: any) {
+      const method = this.ctx.method;
+      const path = this.ctx.path;
+      const res = await this.noahPayAdapter.request(method, path, params);
+      this.noahOpenService.save_user_account(res, params);
+      return res;
+    }
+
+
+  // webhook
+
+    // NOAH 提供的公钥(根据环境选择 Sandbox 或 Production 公钥)
+    private publicKey = `-----BEGIN PUBLIC KEY-----
+    MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEm8yBiD+kmVJ1Xc9sfRkDx0yo9+u8yiAD
+    PngI20KoEswz0gflp8o/z66Abqz/m9A1CBecixWdeT72pA8NZBJI6L6Osd8RV+yx
+    QArxeGKEVX/2QNrfPqeAKODHT5LdStGT
+    -----END PUBLIC KEY-----`;
+
+    // 验证 Webhook 签名
+    private verifySignature(rawBody: string, signatureHeader: string): boolean {
+      try {
+        const verifier = crypto.createVerify('SHA384');
+        verifier.update(rawBody);
+        verifier.end();
+        return verifier.verify(this.publicKey, signatureHeader, 'base64');
+      } catch (error) {
+        console.error('Error verifying signature:', error);
+        return false;
+      }
+    }
+
+
+  /**
+   * FiatDeposit 通知您客户已向其分配的银行账户号码发送了法币付款。
+   */
+  @Post('/v1/webhooks/fiat/deposit', { summary: 'Webhook 发送法币收款' })
+  async webhooksFiatDeposit(@Body() body: any, ctx: any) {
+    // Access the request method and path
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+
+    console.log('Request Method:webhooks/fiat/deposit-=-=', method);
+    console.log('Request Path:webhooks/fiat/deposit-=-=', path);
+    console.log('Request params:webhooks/fiat/deposit-=-=', body);
+    // 获取原始请求体和签名头
+    const rawBody = JSON.stringify(body); // 原始请求体
+    const signatureHeader = ctx.headers['webhook-signature']; // 签名头
+
+    // 验证签名
+    if (!signatureHeader || !this.verifySignature(rawBody, signatureHeader)) {
+      console.log('Invalid webhook signature');
+      ctx.status = 400;
+      return { message: 'Invalid signature' };
+    }
+
+    // 处理 Webhook 数据
+    const event = body;
+    console.log('Received webhook event webhooksFiatDeposit:', event);
+
+    // 返回 200 状态码确认接收
+    ctx.status = 200;
+    return { message: 'Webhook received' };
+  }
+  /**
+   * Transaction 通知您法币已被转换为您选择的加密货币,并记入您的 NOAH 账户。
+   * 通知您资金已提现到客户的 DestinationAddress
+   */
+  @Post('/v1/webhooks/transaction', { summary: 'Webhook 发送法币收款' })
+  async webhooksTransaction(@Body() body: any, ctx: any) {
+    // Access the request method and path
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+
+    console.log('Request Method:webhooks/transaction-=-', method);
+    console.log('Request Path:webhooks/transaction-=-=', path);
+    console.log('Request params:webhooks/transaction-=-', body);
+
+     // 获取原始请求体和签名头
+     const rawBody = JSON.stringify(body); // 原始请求体
+     const signatureHeader = ctx.headers['webhook-signature']; // 签名头
+
+     // 验证签名
+     if (!signatureHeader || !this.verifySignature(rawBody, signatureHeader)) {
+       console.log('Invalid webhook signature');
+       ctx.status = 400;
+       return { message: 'Invalid signature' };
+     }
+
+     // 处理 Webhook 数据
+     const event = body;
+     console.log('Received webhook event webhooksTransaction:', event);
+
+     // 返回 200 状态码确认接收
+     ctx.status = 200;
+     return { message: 'Webhook received' };
+  }
+  // /**
+  //  * FiatDeposit 通知您客户已向其分配的银行账户号码发送了法币付款。
+  //  */
+  // @Post('/v1/webhooks/fiat/deposit', { summary: 'Webhook 发送法币收款' })
+  // async createdWebhooks(@Body(ALL) params: any) {
+  //   // Access the request method and path
+  //   const method = this.ctx.method;
+  //   const path = this.ctx.path;
+
+  //   console.log('Request Method:', method);
+  //   console.log('Request Path:', path);
+  //   console.log('Request params:', params);
+
+  //   // console.log(typeof params)
+  //   return
+  // }
+  // /**
+  //  * 查询 Webhook
+  //  */
+  // @Get('/v3/webhooks', { summary: '查询 Webhook' })
+  // async getWebhooks(@Query(ALL) params: any) {
+  //   // Access the request method and path
+  //   const method = this.ctx.method;
+  //   const path = this.ctx.path;
+
+  //   console.log('Request Method:', method);
+  //   console.log('Request Path:', path);
+
+  //   // console.log(typeof params)
+  //   // return `${method}, ${path}, ${params}`
+  //   return await this.noahPayAdapter.request(method, path, params);
+  // }
+  // /**
+  //  * 修改 Webhook
+  //  */
+  // @Put('/v3/webhooks/:id', { summary: '修改 Webhook' })
+  // async putWebhooks(@Param('id') id: any, @Body() params: any) {
+  //   // Access the request method and path
+  //   const method = this.ctx.method;
+  //   const path = this.ctx.path;
+
+  //   console.log('Request Method:', method);
+  //   console.log('Request Path:', path);
+
+  //   // console.log(typeof params)
+  //   // return `${method}, ${path}, ${params}`
+  //   return await this.noahPayAdapter.request(method, path, params);
+  // }
+  // /**
+  //  * 删除 Webhook
+  //  */
+  // @Del('/v3/webhooks/:id', { summary: '修改 Webhook' })
+  // async delWebhooks(@Param('id') id: any) {
+  //   // Access the request method and path
+  //   const method = this.ctx.method;
+  //   const path = this.ctx.path;
+
+  //   console.log('Request Method:', method);
+  //   console.log('Request Path:', path);
+
+  //   // console.log(typeof params)
+  //   // return `${method}, ${path}, ${params}`
+  //   return await this.noahPayAdapter.request(method, path, {});
+  // }
+  // /**
+  //  * 创建 Webhook HMAC Key
+  //  */
+  // @Post('/v3/webhook_hmac_key', { summary: '创建 Webhook HMAC Key' })
+  // async createWebhook_hmac_key(@Body(ALL) params: any) {
+  //   // Access the request method and path
+  //   const method = this.ctx.method;
+  //   const path = this.ctx.path;
+
+  //   console.log('Request Method:', method);
+  //   console.log('Request Path:', path);
+
+  //   // console.log(typeof params)
+  //   // return `${method}, ${path}, ${params}`
+  //   return await this.noahPayAdapter.request(method, path, params);
+  // }
+
+
+  //000000000
+
+
+//   /**
+//    * 查询订单详情
+//    */
+//   @Get('/v1/transactions/:id', { summary: '查询订单详情' })
+//     //
+//   async getTransactionsById(@Param('id') id: any) {
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+//     return await this.noahPayAdapter.request(
+//       method,
+//       `${path}`.replace(':id', id),
+//       {}
+//     );
+//   }
+
+//   /**
+//    * 申请收款账户
+//    */
+//   @Post('/v3/applications', { summary: '申请收款账户' })
+//   async applications(@Body() params: any) {
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+//     const res = await this.noahPayAdapter.request(method, path, params);
+//     this.noahOpenService.save_user_account(res, params);
+//     return res;
+//   }
+
+//   /**
+//    * 查询申请列表
+//    */
+//   @Get('/v3/applications', { summary: '查询申请列表' })
+//   async getApplications(@Query() params: any) {
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 查询申请
+//    */
+//   @Get('/v3/applications/:id', { summary: '查询申请' })
+//   async getApplicationsInfo(@Param('id') id: string) {
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 查询收款账户列表
+//    */
+//   @Get('/v1/bank_accounts', { summary: '查询收款账户列表' })
+//   async getBank_accounts(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 查询收款账户
+//    */
+//   @Get('/v1/bank_accounts/:id', { summary: '查询收款账户' })
+//   async getBank_accountsInfo(@Param('id') id: any) {
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 创建支付订单
+//    */
+//   @Post('/v3/acquiring/payments', { summary: '创建支付订单' })
+//   async CreatedAcquiringPayments(@Body() params: any) {
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+//     const res = await this.noahPayAdapter.request(method, path, params);
+//     this.noahOpenService.save_user_order(res, params, OrderType.ACQUIRING_PAYMENT);
+//     return res;
+//   }
+
+//   /**
+//    * 查询支付单
+//    */
+//   @Get('/v3/acquiring/payments/:id', { summary: '查询支付单' })
+//   async getAcquiringPaymentsInfo(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 取消支付单
+//    */
+//   @Post('/v3/acquiring/payments/:id/cancel', { summary: '取消支付单' })
+//   async cancelAcquiringPayments(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+//   /**
+//    * 查询支付单列表
+//    */
+//   @Get('/v3/acquiring/payments', { summary: '查询支付单列表' })
+//   async getAcquiringPayments(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+//     console.log('Request params:', params);
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 退款
+//    */
+//   @Post('/v3/acquiring/refunds', { summary: '退款' })
+//   async acquiringRefunds(@Body() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+//     console.log('Request params:', params);
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     const res = await this.noahPayAdapter.request(method, path, params);
+//     this.noahOpenService.save_user_order(res, params, OrderType.ACQUIRING_REFUND);
+//     return res;
+//   }
+//   /**
+//    * 查询退款
+//    */
+//   @Get('/v3/acquiring/refunds/:id', { summary: '查询退款' })
+//   async acquiringRefundsInfo(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+//   /**
+//    * 查询退款单列表
+//    */
+//   @Get('/v3/acquiring/refunds', { summary: '查询退款单列表' })
+//   async acquiringRefundsList(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 查询对账单列表
+//    */
+//   @Get('/v3/acquiring/statements', { summary: '查询对账单列表' })
+//   async acquiringStatements(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 查询结算单列表
+//    */
+//   @Get('/v3/acquiring/settlements', { summary: '查询结算单列表' })
+//   async acquiringSettlements(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 查询结算单列表
+//    */
+//   @Get('/v3/acquiring/settlements/:id', { summary: '查询结算单列表' })
+//   async acquiringSettlementsInfo(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+//   /**
+//    * 查询渠道汇率
+//    */
+//   @Get('/v3/acquiring/exchange_rates', { summary: '查询渠道汇率' })
+//   async acquiringExchange_rates(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 查询入账列表
+//    */
+//   @Get('/v1/deposits', { summary: '查询入账列表' })
+//   async depositsList(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+//     console.log('Request params:', params);
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 查询入账
+//    */
+//   @Get('/v1/deposits/:id', { summary: '查询入账' })
+//   async depositsInfo(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 入账凭证下载
+//    */
+//   @Get('/v1/deposits/:id/proof', { summary: '入账凭证下载' })
+//   async depositsProofInfo(@Param('id') id: any, @Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 查询汇率
+//    */
+//   @Get('/v1/exchange_rates', { summary: '入账凭证下载' })
+//   async exchange_ratesInfo(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 创建换汇订单
+//    */
+//   @Post('/v1/exchanges', { summary: '创建换汇订单' })
+//   async createdExchanges(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     const res = await this.noahPayAdapter.request(method, path, params);
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+//     this.noahOpenService.save_user_order(res, params, OrderType.CURRENCY_EXCHANGE);
+//     return res;
+//   }
+
+//   /**
+//    * 查询换汇订单列表
+//    */
+//   @Get('/v1/exchanges', { summary: '查询换汇订单列表' })
+//   async exchangesList(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 查询换汇订单
+//    */
+//   @Get('/v1/exchanges/:id', { summary: '查询换汇订单' })
+//   async exchangesInfo(@Param() id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 付款
+//    */
+//   @Post('/v1/payments', { summary: '付款' })
+//   async createdPayments(@Body() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+//     const res = await this.noahPayAdapter.request(method, path, params);
+//     this.noahOpenService.save_user_order(res, params, OrderType.PAYMENT);
+//     return res;
+//   }
+
+//   /**
+//    * 查询付款列表
+//    */
+//   @Get('/v1/payments', { summary: '查询付款列表' })
+//   async getPaymentsList(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 查询付款
+//    */
+//   @Get('/v1/payments/:id', { summary: '查询付款' })
+//   async paymentsInfo(@Param() id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 补充材料
+//    */
+//   @Post('/v1/payments/:id/documents', { summary: '补充材料' })
+//   async putPaymentsDocuments(@Param() id: any, @Body() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 付款凭证下载
+//    */
+//   @Get('/v1/payments/proof', { summary: '付款凭证下载' })
+//   async paymentsProof(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 转账
+//    */
+//   @Post('/v1/transfers', { summary: '转账' })
+//   async transfers(@Body() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     const res = await this.noahPayAdapter.request(method, path, params);
+//     this.noahOpenService.save_user_order(res, params, OrderType.TRANSFER);
+//     return res;
+//   }
+
+//   /**
+//    * 查询转账列表
+//    */
+//   @Get('/v1/transfers', { summary: '查询转账列表' })
+//   async transfersList(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+//     console.log('Request params:', params);
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 查询转账
+//    */
+//   @Get('/v1/transfers/:id', { summary: '查询转账' })
+//   async transfersInfo(@Param() id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 查询账户流水
+//    */
+//   @Get('/v3/accounts/:account_id/transactions', { summary: '查询账户流水' })
+//   async accountsTransactionsInfo(
+//     @Param() account_id: any,
+//     @Query() params: any
+//   ) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 根据 transaction ID 查询
+//    */
+//   @Get('/v3/accounts/:account_id/transactions/:id', {
+//     summary: '根据 transaction ID 查询',
+//   })
+//   async accountsTransactionsInfoByAccount_id(
+//     @Param() account_id: any,
+//     @Param() id: any
+//   ) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 查询实名更新请求列表
+//    */
+//   @Get('/v3/legal_entity_requests', { summary: '查询实名更新请求列表' })
+//   async legal_entity_requestslist(@Query() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 提交实名更新
+//    */
+//   @Post('/v3/legal_entity_requests/:id/submit', { summary: '提交实名更新' })
+//   async legal_entity_requestsSubmit(@Param() id: any, @Body() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 收款人信息校验
+//    */
+//   @Post('/v3/beneficiaries/validate', { summary: '收款人信息校验' })
+//   async beneficiariesValidate(@Body() params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 通过实名
+//    */
+//   @Post('/v3/simulate/accounts/:id/approve', { summary: '通过实名' })
+//   async simulateAccountsApprove(@Param() id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 通过实名更新
+//    */
+//   @Post('/v3/simulate/legal_entity_requests/:id/confirm', {
+//     summary: '通过实名更新',
+//   })
+//   async simulateLegal_entity_requestsConfirm(@Param() id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 驳回实名
+//    */
+//   @Post('/v3/simulate/accounts/:id/reject', { summary: '驳回实名' })
+//   async simulateAccountsReject(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 创建实名更新
+//    */
+//   @Post('/v3/simulate/legal_entity_requests', { summary: '创建实名更新' })
+//   async simulateLegal_entity_requests(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 入账
+//    */
+//   @Post('/v1/simulate/deposits', { summary: '入账' })
+//   async simulateDeposits(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 拒绝更新请求
+//    */
+//   @Post('/v3/simulate/legal_entity_requests/:id/reject', {
+//     summary: '拒绝更新请求',
+//   })
+//   async simulateLegal_entity_requestsReject(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 收款账户审核通过
+//    */
+//   @Post('/v3/simulate/applications/:id/confirm', {
+//     summary: '收款账户审核通过',
+//   })
+//   async simulateApplicationsConfirm(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 收款账户审核驳回
+//    */
+//   @Post('/v3/simulate/applications/:id/reject', { summary: '收款账户审核驳回' })
+//   async simulateApplicationsReject(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 通过付款
+//    */
+//   @Post('/v1/simulate/payments/:id/confirm', { summary: '通过付款' })
+//   async simulatePaymentsConfirm(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 拒绝付款
+//    */
+//   @Post('/v1/simulate/payments/:id/reject', { summary: '拒绝付款' })
+//   async simulatePaymentsReject(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 通过换汇
+//    */
+//   @Post('/v1/simulate/exchanges/:id/confirm', { summary: '通过换汇' })
+//   async simulateExchangesConfirm(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+//   /**
+//    * 拒绝换汇
+//    */
+//   @Post('/v1/simulate/exchanges/:id/reject', { summary: '拒绝换汇' })
+//   async simulateExchangesReject(@Param('id') id: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, {});
+//   }
+
+
+//   /**
+//    * 账户审核通过
+//    */
+//   @Post('/account_approved', { summary: '账户审核通过' })
+//   async account_approved(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 账户审核驳回
+//    */
+//   @Post('/account_rejected', { summary: '账户审核驳回' })
+//   async account_rejected(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 实名待更新
+//    */
+//   @Post('/legal_entity_request_created', { summary: '实名待更新' })
+//   async legal_entity_request_created(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 实名更新审核通过
+//    */
+//   @Post('/legal_entity_request_success', { summary: '实名更新审核通过' })
+//   async legal_entity_request_success(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+//   /**
+//    * 实名更新审核驳回
+//    */
+//   @Post('/legal_entity_request_rejected', { summary: '实名更新审核驳回 ' })
+//   async legal_entity_request_rejected(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 收款账户申请成功
+//    */
+//   @Post('/application_success', { summary: '收款账户申请成功' })
+//   async application_success(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 收款账户申请失败
+//    */
+//   @Post('/application_failed', { summary: '收款账户申请失败' })
+//   async application_failed(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 收款账户信息变更
+//    */
+//   @Post('/bank_account_updated', { summary: '收款账户信息变更' })
+//   async bank_account_updated(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 收单支付成功通知
+//    */
+//   @Post('/acquiring_payment_success', { summary: '收单支付成功通知' })
+//   async acquiring_payment_success(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 收单退款成功通知
+//    */
+//   @Post('/acquiring_refund_success', { summary: '收单退款成功通知' })
+//   async acquiring_refund_success(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 收单退款失败通知
+//    */
+//   @Post('/acquiring_refund_failed', { summary: '收单退款失败通知' })
+//   async acquiring_refund_failed(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 入账成功
+//    */
+//   @Post('/deposit_success', { summary: '入账成功' })
+//   async deposit_success(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 换汇成功
+//    */
+//   @Post('/exchange_success', { summary: '换汇成功' })
+//   async exchange_success(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 换汇失败
+//    */
+//   @Post('/exchange_failed', { summary: '换汇失败' })
+//   async exchange_failed(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 收款账户已下发
+//    */
+//   @Post('/bank_account_created', { summary: '收款账户已下发' })
+//   async bank_account_created(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 付款成功
+//    */
+//   @Post('/payment_success', { summary: '付款成功' })
+//   async payment_success(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 付款失败
+//    */
+//   @Post('/payment_failed', { summary: '付款失败' })
+//   async payment_failed(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 付款银行退回
+//    */
+//   @Post('/payment_refunded', { summary: '付款银行退回' })
+//   async payment_refunded(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 转账成功
+//    */
+//   @Post('/transfer_success', { summary: '转账成功' })
+//   async transfer_success(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+
+//   /**
+//    * 转账失败
+//    */
+//   @Post('/transfer_failed', { summary: '转账失败' })
+//   async transfer_failed(@Body(ALL) params: any) {
+//     // Access the request method and path
+//     const method = this.ctx.method;
+//     const path = this.ctx.path;
+
+//     console.log('Request Method:', method);
+//     console.log('Request Path:', path);
+
+//     // console.log(typeof params)
+//     // return `${method}, ${path}, ${params}`
+//     return await this.noahPayAdapter.request(method, path, params);
+//   }
+}
+

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

@@ -133,7 +133,8 @@ export class BaseAuthorityMiddleware
         JSON.stringify(params),
         `${merchantInfo.apiSecret}`
       );
-
+      console.log('9999-=-=',`${sign}`.toLocaleUpperCase())
+      console.log('1000-=-=',`${vaSign}`.toLocaleUpperCase())
       if (`${sign}`.toLocaleUpperCase() !== `${vaSign}`.toLocaleUpperCase()) {
         ctx.status = 401;
         ctx.body = {

+ 254 - 0
src/modules/api/service/open_v4.ts

@@ -0,0 +1,254 @@
+import { BaseService, CoolTransaction } from '@cool-midway/core';
+import { ILogger, Inject, Provide } from '@midwayjs/core';
+import { InjectEntityModel } from '@midwayjs/typeorm';
+import { OpenUserEntity } from '../entity/open_user';
+import * as crypto from 'crypto';
+import { In, LessThan, QueryRunner, Repository } from 'typeorm';
+import {
+  OpenPaymentOrderEntity,
+  OrderType,
+} from '../entity/open_payment_order';
+import { OpenPaymentAccountEntity } from '../entity/open_payment_account';
+import { NoahPayAdapter } from '../../payment/adapter/noah.adapter';
+
+/**
+ * 描述
+ */
+@Provide()
+export class NoahOpenService extends BaseService {
+  @InjectEntityModel(OpenUserEntity)
+  openUserEntity: Repository<OpenUserEntity>;
+
+  @InjectEntityModel(OpenPaymentOrderEntity)
+  openPaymentOrderEntity: Repository<OpenPaymentOrderEntity>;
+
+  @InjectEntityModel(OpenPaymentAccountEntity)
+  openPaymentAccountEntity: Repository<OpenPaymentAccountEntity>;
+
+  @Inject()
+  logger: ILogger;
+
+  @Inject()
+  noahPayAdapter: NoahPayAdapter;
+
+  @Inject()
+  ctx;
+
+  /*
+    记录用户的数据来源
+    */
+  async save_user(userInfo, params) {
+    try {
+      const openUserObj = {
+        mch_id: this.ctx.admin.merchant.mchId,
+        account_id: userInfo.data.id,
+        source: 'NOAHPAY',
+      };
+      await this.openUserEntity.insert(openUserObj);
+      this.logger.info(
+        `save_user 商户: ${this.ctx.admin.merchant.mchId}; userInfo${JSON.stringify(userInfo)} params${JSON.stringify(params)}`
+      );
+    } catch (error) {
+      this.logger.error('save_user:error: ', error);
+    }
+  }
+
+  /*
+    记录用户的收款账户数据来源
+    */
+  async save_user_account(userInfo, params) {
+    try {
+      const openUserObj = {
+        mch_id: this.ctx.admin.merchant.mchId,
+        account_id: params.account_id,
+        payment_account_id: userInfo.data?.id || '',
+        source: 'NOAHPAY',
+      };
+      await this.openPaymentAccountEntity.insert(openUserObj);
+      this.logger.info(
+        `save_user_account 商户: ${this.ctx.admin.merchant.mchId}; userInfo${JSON.stringify(userInfo)} params${JSON.stringify(params)}`
+      );
+    } catch (error) {
+      this.logger.error('save_user_account:error: ', error);
+    }
+  }
+
+  /*
+    记录用户的订单数据来源
+  */
+  async save_user_order(orderInfo, params, type: OrderType) {
+    try {
+      let openOrderObj: any = {
+        mch_id: this.ctx.admin.merchant.mchId,
+        account_id: params.account_id,
+        request_id: params.payment.request_id,
+        order_type: type,
+        additional_info: {
+          orderInfo,
+          params,
+          type,
+        },
+      };
+
+      // 收单支付订单
+      if (OrderType.ACQUIRING_PAYMENT === type) {
+        openOrderObj.amount = params.payment.amount;
+        openOrderObj.currency = params.payment.currency;
+      }
+
+      // 收单退款订单
+      if (OrderType.ACQUIRING_REFUND === type) {
+        openOrderObj.amount = params.refund.amount;
+        openOrderObj.currency = params.refund.currency;
+      }
+
+      // 换汇
+      if (OrderType.CURRENCY_EXCHANGE === type) {
+        openOrderObj.amount = params.sell_amount; // 卖出金额
+        openOrderObj.currency = params.sell_currency; // 卖出币种
+
+        openOrderObj.target_amount = params.buy_amount; // 买入金额
+        openOrderObj.target_currency = params.buy_currency; // 买入币种
+      }
+
+      // 付款
+      if (OrderType.PAYMENT === type) {
+        openOrderObj.amount = params.amount;
+        openOrderObj.currency = params.currency;
+      }
+
+      // 转账
+      if (OrderType.TRANSFER === type) {
+        openOrderObj.amount = params.amount;
+        openOrderObj.currency = params.currency;
+        openOrderObj.from_account_id = params.from_account_id;
+        openOrderObj.to_account_id = params.to_account_id;
+      }
+
+      // // 入账
+      // if (OrderType.DEPOSIT === type) {
+      //   openOrderObj.amount = params.payment.amount;
+      //   openOrderObj.currency = params.payment.currency;
+      // }
+
+      await this.openPaymentOrderEntity.insert(openOrderObj);
+
+      /* 更新相关订单信息 */
+
+      // 退款事件处理
+      if (OrderType.ACQUIRING_REFUND === type) {
+        const paymentOrder: any = {};
+        if (params.hasOwnProperty('payment_id')) {
+          paymentOrder.event_id = params.payment_id;
+        }
+        if (params.hasOwnProperty('payment_request_id')) {
+          paymentOrder.request_id = params.payment_request_id;
+        }
+        openOrderObj.currency = params.payment.currency;
+        await this.openPaymentOrderEntity.update(paymentOrder, {
+          status: 'REFUNDED',
+        });
+      }
+      this.logger.info(
+        `save_user_order 商户: ${this.ctx.admin.merchant.mchId}; userInfo${JSON.stringify(orderInfo)} params${JSON.stringify(params)}`
+      );
+    } catch (error) {
+      this.logger.error('save_user_order:error: ', error);
+    }
+  }
+
+  createSign(params, timestamp, nonce, secret) {
+    // 2. 生成签名
+    const sign = this.generateSignature(
+      `${timestamp}`,
+      `${nonce}`,
+      JSON.stringify(params),
+      `${secret}`
+    );
+    return sign;
+  }
+  /**
+   * 生成签名
+   * @see https://docs-merchant.sunpay.pro/guide
+   */
+  generateSignature(timestamp, nonce, body = '', secret = '') {
+    const payload = `${timestamp}${nonce}${body}`;
+    const signature = crypto
+      .createHmac('sha256', secret)
+      .update(payload)
+      .digest('hex')
+      .toUpperCase();
+    return signature;
+  }
+
+  /**
+   * 处理未完成的订单
+   */
+  @CoolTransaction({ isolation: 'SERIALIZABLE' })
+  async handleUnfinishedOrder(params, queryRunner?: QueryRunner) {
+    const orders = await this.openPaymentOrderEntity.find({
+      where: {
+        status: '',
+        // 1小时未完成的订单
+        createTime: LessThan(new Date(Date.now() - 1 * 60 * 60 * 1000)),
+      },
+    });
+    this.logger.info(`处理未完成的订单:${orders.length}`);
+    try {
+      for (const order of orders) {
+        const status = await this.thawed(order, queryRunner);
+        order.status = status;
+        await this.openPaymentOrderEntity.update(order.id, order);
+      }
+    } catch (err) {
+      this.logger.error(784, err);
+    }
+  }
+  /*
+   */
+  async thawed(order, queryRunner) {
+    // 收单支付订单
+    if (OrderType.ACQUIRING_PAYMENT === order.type) {
+      const res = await this.noahPayAdapter.request(
+        'GET',
+        `/v3/acgiinqru/payments/${order.event_id}`
+      );
+      return res.data.status;
+    }
+    // 收单退款订单
+    if (OrderType.ACQUIRING_REFUND === order.type) {
+      const res = await this.noahPayAdapter.request(
+        'GET',
+        `/v3/acquiring/refunds/${order.event_id}`
+      );
+      return res.data.status;
+    }
+
+    // 换汇
+    if (OrderType.CURRENCY_EXCHANGE === order.type) {
+      const res = await this.noahPayAdapter.request(
+        'GET',
+        `/v1/exchanges/${order.event_id}`
+      );
+      return res.data.status;
+    }
+
+    // 付款
+    if (OrderType.PAYMENT === order.type) {
+      const res = await this.noahPayAdapter.request(
+        'GET',
+        `/v1/payments/${order.event_id}`
+      );
+      return res.data.status;
+    }
+
+    // 转账
+    if (OrderType.TRANSFER === order.type) {
+      const res = await this.noahPayAdapter.request(
+        'GET',
+        `/v1/transfers/${order.event_id}`
+      );
+      return res.data.status;
+    }
+  }
+}

+ 168 - 0
src/modules/payment/adapter/noah.adapter.ts

@@ -0,0 +1,168 @@
+import { Provide, Inject, Config, ALL } from '@midwayjs/decorator';
+
+import { Repository } from 'typeorm';
+import { InjectEntityModel } from '@midwayjs/typeorm';
+import { PaymentChannelEntity } from '../entity/channel';
+import axios from 'axios';
+import { CustomerEntity } from '../entity/customer';
+import { ILogger } from '@midwayjs/core';
+
+import * as crypto from 'crypto';
+import * as jwt from 'jsonwebtoken';
+
+@Provide()
+export class NoahPayAdapter {
+  @InjectEntityModel(PaymentChannelEntity)
+  channelEntity: Repository<PaymentChannelEntity>;
+  @InjectEntityModel(CustomerEntity)
+  customerEntity: Repository<CustomerEntity>;
+  @Config(ALL)
+  globalConfig;
+  @Inject()
+  ctx;
+
+  @Inject()
+  logger: ILogger;
+
+  private config: {
+    apiKey: string;
+    apiSecret: string;
+    apiUrl: string;
+    chainApiKey: string;
+    chainApiSecret: string;
+    chainApiUrl: string;
+  };
+
+  /**
+   * 初始化渠道配置
+   */
+  private async initConfig() {
+    if (!this.config) {
+      const channel = await this.channelEntity.findOne({
+        where: { code: 'NOAHPAY', isEnabled: true },
+      });
+      if (!channel) {
+        throw new Error('FusionPay channel not found or disabled');
+      }
+      this.config = {
+        apiKey: channel.apiKey,
+        apiSecret: channel.apiSecret,
+        apiUrl: channel.apiUrl,
+        chainApiKey: channel.chainApiKey,
+        chainApiSecret: channel.chainApiSecret,
+        chainApiUrl: channel.chainApiUrl,
+      };
+    }
+  }
+
+  /**
+   * Creates a JWT token for authenticating API requests.
+   * https://docs.noah.com/api-concepts/signing
+   *
+   * @param opts - Options for JWT creation.
+   * @param opts.body - A buffer made from the body of the request. Important to use the exact same body buffer in the request.
+   * @param opts.method - The HTTP method of the request, e.g., GET, POST, PUT, DELETE.
+   * @param opts.path - The path of the request, e.g., /api/v1/customers.
+   * @param opts.privateKey - The private key used to sign the JWT, in PEM format.
+   * @param opts.queryParams - The query parameters of the request.
+   * @returns A signed JWT token as a string.
+   */
+  async createJwt(opts: {
+    body: Buffer | undefined;
+    method: string;
+    path: string;
+    privateKey: string;
+    queryParams: object | undefined;
+  }): Promise<string> {
+    const { body, method, path, privateKey, queryParams } = opts;
+    let bodyHash;
+
+    if (body) {
+      bodyHash = crypto.createHash('sha256').update(body).digest('hex');
+    }
+
+    const payload = {
+      bodyHash,
+      method,
+      path,
+      queryParams,
+    };
+
+    // apikey_sandbox_F8XfF9TwNj7ZB5YwCtd2L9K4zN7g6UZRiTQLSfAqCDKm
+
+    // ES384 is recommended but the algorithm can also be ES256
+    const privateKeyMock = '-----BEGIN EC PRIVATE KEY-----\n'+
+    'MIGkAgEBBDBgCvOnvqRgyWmdXDss+whk/lhHrCAOADqKtxm32KF76bDdiHI4JWwvPe1heRzDc3ugBwYFK4EEACKhZANiAASWmBOMkyHHq7cH9UMSnLbCPN4ikdgEsMaYGwN+2/5YMF22OwVeorF3+Pp15WYK1zvE4sqxBTqFWzGD/OoTx8RAhh0YIMXljyAtYlOpTLuIBMupVUJLtidqST71CyPpdYc=\n'+
+    '-----END EC PRIVATE KEY-----'
+    // console.log('payload-=-=-=',payload,privateKeyMock)
+    const token = jwt.sign(payload, privateKeyMock, {
+      algorithm: 'ES384',
+      audience: 'https://api.noah.com',
+      // use a short expiry time, less than 15m
+      expiresIn: '5m',
+    });
+    // console.log('token-=-=-',token)
+    return token;
+  }
+  async getAccessToken(method: string, path: string, data?: any) {
+    if (method === 'GET') {
+      const signature = await this.createJwt({
+        body: undefined,
+        method: 'GET',
+        path,
+        privateKey: this.config.apiSecret,
+        queryParams: data,
+      });
+      return signature;
+    }
+    const body = Buffer.from(JSON.stringify(data));
+    const signature = await this.createJwt({
+      body,
+      method: 'POST',
+      path,
+      privateKey: this.config.apiSecret,
+      queryParams: undefined,
+    });
+    return signature;
+  }
+  /**
+   * 发送请求到 NoahPay API
+   */
+  async request(method: string, endpoint: string, data?: any) {
+    // const xApiKey = 'apikey_sandbox_F8XfF9TwNj7ZB5YwCtd2L9K4zN7g6UZRiTQLSfAqCDKm'
+    const xApiKey = 'apikey_sandbox_EaSQLnyxzKkNsx5wQBWWazoqtwdMy4jXdGrV4qgdHqRH'
+    await this.initConfig();
+    let url = this.config.apiUrl;
+    try {
+      url = `${url}${endpoint.replace('/api/open/v4', '')}`;
+      const signature = await this.getAccessToken(method, endpoint.replace('/api/open/v4', ''), data);
+      console.log('signature-=-=',signature)
+      const axiosParams: any = {
+        method,
+        url,
+        data: method !== 'GET' ? data : undefined,
+        params: method === 'GET' ? data : undefined,
+        headers: {
+          'Content-Type': 'application/json',
+          // 'Api-Signature': signature,
+          'X-Api-Key': xApiKey
+        },
+      };
+      this.logger.info('向noahPay发送请求', axiosParams);
+      const response = await axios(axiosParams);
+      console.log('response-=-=-=',response)
+      return {
+        status: response.status,
+        statusText: response.statusText,
+        data: response.data
+      };
+    } catch (error) {
+      if (axios.isAxiosError(error) && error.response) {
+        this.ctx.status = error.response.status; // 服务器错误
+        this.logger.info('向noahPay发送请求失败了', error.response);
+        return error.response.data;
+      }
+      throw error;
+    }
+  }
+}

+ 1 - 0
src/modules/virtual/entity/order.ts

@@ -9,6 +9,7 @@ export enum OrderStatus {
   PROCESSING = 'PROCESSING', // 处理中
   COMPLETED = 'COMPLETED', // 交易完成
   FAILED = 'FAILED', // 交易失败
+  REJECTED = 'REJECTED', // 交易失败
 }
 
 /**