Jelajahi Sumber

Merge pull request #2 from maxVaJp/easypay

Easypay
maxAdolphJp 5 bulan lalu
induk
melakukan
a97e98f9bc

+ 1 - 1
nginxConf/nginxSandbox.conf

@@ -2,7 +2,7 @@ server
 {
     listen 80;
     listen 443 ssl;
-    server_name sandbox-va.fusionpay.one;
+      server_name sandbox-va.fusionpay.one sandbox-va.galaxypay.asia;
     index index.html index.htm default.htm default.html;
     root /www/wwwroot/va/admin_test/dist;
 

+ 1 - 1
package.json

@@ -86,6 +86,6 @@
   "author": "COOL",
   "license": "MIT",
   "volta": {
-    "node": "22.12.0"
+    "node": "22.13.1"
   }
 }

+ 1361 - 0
src/modules/api/controller/open.ts

@@ -0,0 +1,1361 @@
+import {
+  All,
+  ALL,
+  Body, Del,
+  Get,
+  Inject,
+  Param,
+  Post,
+  Provide,
+  Put,
+  Query,
+} from '@midwayjs/decorator';
+import { BaseController, CoolController } from '@cool-midway/core';
+import { Context } from 'vm';
+import { IndividualEntity } from '../../payment/entity/individual';
+import { EasyPayAdapter } from '../../payment/adapter/easypay.adapter';
+
+/**
+ * 客户管理
+ */
+@Provide()
+@CoolController('/api/open')
+export class OpenApiController extends BaseController {
+  @Inject()
+  ctx: Context; // Inject the context
+
+  @Inject()
+  easyPayAdapter: EasyPayAdapter;
+
+  /**
+   * 创建账户
+   */
+  @Post('/v3/accounts', { summary: '创建账户' })
+  async createPayInOrder(@Body(ALL) params: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.easyPayAdapter.request(method, path, params);
+  }
+
+  /**
+   * 查询账户列表
+   */
+  @Get('/v3/accounts', { summary: '查询账户列表' })
+  async getAccounts(@Query(ALL) params: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.easyPayAdapter.request(method, path, params);
+  }
+
+  /**
+   * 查询账户
+   */
+  @Get('/v3/accounts/:id', { summary: '查询账户' })
+  async getAccountsInfo(@Param('id') id: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.easyPayAdapter.request(
+      method,
+      `${path}`.replace(':id', id),
+      {}
+    );
+  }
+
+  /**
+   * 修改账户实名
+   */
+  @Put('/v3/accounts/:id', { summary: '修改账户实名' })
+  async putAccountsInfo(@Param('id') id: any, @Body() params: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.easyPayAdapter.request(
+      method,
+      `${path}`.replace(':id', id),
+      params
+    );
+  }
+
+  /**
+   * 查询余额
+   */
+  @Get('/v3/accounts/:account_id/balances', { summary: '查询余额' })
+  async getAccountsBalances(
+    @Param('account_id') account_id: any,
+    @Body() params: any
+  ) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.easyPayAdapter.request(
+      method,
+      `${path}`.replace(':account_id', account_id),
+      params
+    );
+  }
+
+  /**
+   * 申请收款账户
+   */
+  @Post('/v3/applications', { summary: '申请收款账户' })
+  async applications(@Body() params: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.easyPayAdapter.request(method, path, params);
+  }
+
+  /**
+   * 查询申请列表
+   */
+  @Get('/v3/applications', { summary: '查询申请列表' })
+  async getApplications(@Query() params: any) {
+    const method = this.ctx.method;
+    const path = this.ctx.path;
+    return await this.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.request(method, path, {});
+  }
+
+  /**
+   * 创建支付订单
+   */
+  @Post('/v3/acquiring/payments', { summary: '创建支付订单' })
+  async CreatedAcquiringPayments(@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}`
+    return await this.easyPayAdapter.request(method, path, params);
+  }
+
+  /**
+   * 查询支付单
+   */
+  @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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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}`
+    return await this.easyPayAdapter.request(method, path, params);
+  }
+  /**
+   * 查询退款
+   */
+  @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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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('Request Method:', method);
+    console.log('Request Path:', path);
+
+    // console.log(typeof params)
+    // return `${method}, ${path}, ${params}`
+    return await this.easyPayAdapter.request(method, path, params);
+  }
+
+
+
+
+  /**
+   * 查询换汇订单列表
+   */
+  @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.easyPayAdapter.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.easyPayAdapter.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);
+
+    // console.log(typeof params)
+    // return `${method}, ${path}, ${params}`
+    return await this.easyPayAdapter.request(method, path, params);
+  }
+
+
+  /**
+   * 查询付款列表
+   */
+  @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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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}`
+    return await this.easyPayAdapter.request(method, path, params);
+  }
+
+
+
+  /**
+   * 查询转账列表
+   */
+  @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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.request(method, path, {});
+  }
+
+  /**
+   * 创建 Webhook
+   */
+  @Post('/v3/webhooks', { 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(typeof params)
+    // return `${method}, ${path}, ${params}`
+    return await this.easyPayAdapter.request(method, path, params);
+  }
+  /**
+   * 查询 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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.request(method, path, params);
+  }
+  /**
+   * 账户审核通过
+   */
+  @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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.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.easyPayAdapter.request(method, path, params);
+  }
+}

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

@@ -45,6 +45,10 @@ export class BaseAuthorityMiddleware
 
   resolve() {
     return async (ctx: Context, next: NextFunction) => {
+      if(ctx.url.includes('/api/open/')) {
+        await next();
+        return;
+      }
       // 签名校验
       let { header } = ctx;
       const {
@@ -146,7 +150,7 @@ export class BaseAuthorityMiddleware
 
   match(ctx: Context): boolean {
     // 下面的匹配到的路由会执行此中间件
-    if (ctx.url.includes('/api/v1/')) {
+    if (ctx.url.includes('/api/v1/') || ctx.url.includes('/api/open/')) {
       return true;
     }
   }

+ 181 - 0
src/modules/payment/adapter/easypay.adapter.ts

@@ -0,0 +1,181 @@
+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 qs = require('qs');
+
+class TokenManager {
+  authUrl = '' // 认证URL
+  clientId = '' // 客户端ID
+  clientSecret = '' // 客户端密钥
+  refreshToken = null // 刷新令牌
+  accessToken = null // 访问令牌
+  expiresIn = 0 // 令牌过期时间
+
+  constructor(authUrl, clientId, clientSecret) {
+    this.authUrl = authUrl; // 初始化认证URL
+    this.clientId = clientId; // 初始化客户端ID
+    this.clientSecret = clientSecret; // 初始化客户端密钥
+    this.accessToken = null; // 初始化访问令牌为空
+    this.refreshToken = null; // 初始化刷新令牌为空
+    this.expiresIn = 0; // 初始化过期时间为0
+  }
+
+  // 登录方法,用于获取访问令牌和刷新令牌
+  async login() {
+    try {
+      const dataString = qs.stringify({
+        client_id: this.clientId, // 传递客户端ID
+        client_secret: this.clientSecret, // 传递客户端密钥
+        grant_type: 'client_credentials' // 假设使用密码授权类型进行初始登录
+      });
+      const config = {
+        method: 'post',
+        url: this.authUrl,
+        data: dataString
+      };
+      const response = await axios(config);
+
+      const data = response.data;
+      this.accessToken = data.access_token; // 获取访问令牌
+      this.refreshToken = data.refresh_token; // 获取刷新令牌
+      this.expiresIn = Math.floor(Date.now() / 1000) + data.expires_in; // 计算令牌过期时间
+
+      console.log('Login successful. Access Token acquired.'); // 登录成功日志
+    } catch (error) {
+      console.error('Login failed:', error); // 登录失败日志
+      throw error; // 抛出错误
+    }
+  }
+
+  // 获取访问令牌的方法
+  async getAccessToken() {
+    const currentTime = Math.floor(Date.now() / 1000); // 获取当前时间戳
+    if (this.accessToken && this.expiresIn > currentTime) {
+      return this.accessToken; // 如果令牌有效,返回访问令牌
+    }
+
+    if (!this.refreshToken) {
+      throw new Error('No refresh token available. Please login first.'); // 如果没有刷新令牌,抛出错误
+    }
+
+    try {
+      const response = await axios.post(this.authUrl, {
+        client_id: this.clientId, // 传递客户端ID
+        client_secret: this.clientSecret, // 传递客户端密钥
+        refresh_token: this.refreshToken, // 传递刷新令牌
+        grant_type: 'refresh_token' // 使用刷新令牌授权类型
+      });
+
+      const data = response.data;
+      this.accessToken = data.access_token; // 更新访问令牌
+      this.expiresIn = currentTime + data.expires_in; // 更新过期时间
+      return this.accessToken; // 返回新的访问令牌
+    } catch (error) {
+      console.error('Error fetching access token:', error); // 获取令牌错误日志
+      throw error; // 抛出错误
+    }
+  }
+}
+
+@Provide()
+export class EasyPayAdapter {
+  @InjectEntityModel(PaymentChannelEntity)
+  channelEntity: Repository<PaymentChannelEntity>;
+  @InjectEntityModel(CustomerEntity)
+  customerEntity: Repository<CustomerEntity>;
+  @Config(ALL)
+  globalConfig;
+  @Inject()
+  ctx;
+  private config: {
+    apiKey: string;
+    apiSecret: string;
+    apiUrl: string;
+    chainApiKey: string;
+    chainApiSecret: string;
+    chainApiUrl: string;
+    tokenManager: TokenManager;
+  };
+
+  /**
+   * 初始化渠道配置
+   */
+  private async initConfig() {
+    if (!this.config) {
+      const channel = await this.channelEntity.findOne({
+        where: { code: 'EASYPAY', isEnabled: true },
+      });
+      if (!channel) {
+        throw new Error('FusionPay channel not found or disabled');
+      }
+      const tokenManager = new TokenManager(`${channel.apiUrl}/auth`, channel.apiKey, channel.apiSecret)
+      await tokenManager.login()
+      this.config = {
+        apiKey: channel.apiKey,
+        apiSecret: channel.apiSecret,
+        apiUrl: channel.apiUrl,
+        chainApiKey: channel.chainApiKey,
+        chainApiSecret: channel.chainApiSecret,
+        chainApiUrl: channel.chainApiUrl,
+        tokenManager: tokenManager
+      };
+    }
+  }
+
+  /**
+   * 发送请求到 EasyPay API
+   */
+  async request(method: string, endpoint: string, data?: any) {
+    await this.initConfig();
+    // return Promise.resolve(`https://api.easypayx.com${endpoint.replace('/api/open', '')}`);
+    let url= this.config.apiUrl;
+    try {
+      url = `${url}${endpoint.replace('/api/open', '')}`;
+      const accessToken = await this.config.tokenManager.getAccessToken();
+      const response = await axios({
+        method,
+        url,
+        data: method !== 'GET' ? data : undefined,
+        params: method === 'GET' ? data : undefined,
+        headers: {
+          'Content-Type': 'application/json',
+          'Authorization': `Bearer ${accessToken}`,
+        },
+      });
+      // 检查响应
+      // if (response.data.code !== 200) {
+      //   console.log(response.data);
+      //   throw new Error(`FusionPay API ${response.data.msg}`);
+      // }
+      // console.log('response', response.data.data);
+      return response.data.data;
+    } catch (error) {
+      // console.log(error.response.data);
+      if (axios.isAxiosError(error) && error.response) {
+        // console.log(error.response.data);
+        // throw new Error(`FusionPay API Network ${error.response.data.msg}`);
+        this.ctx.status = error.response.status; // 服务器错误
+        // this.ctx.body = error.response.data;
+        // return this.res.status(500).json({});
+        return error.response.data;
+        // throw this.ctx.body;
+      }
+      throw error;
+    }
+  }
+  // 获取签名
+  private async getAuthorization() {
+    await this.initConfig();
+    const res = await axios.post(`${this.config.apiUrl}/auth`, {
+      client_id: 'client_id',
+      client_secret: this.config.apiSecret,
+      grant_type: 'client_credentials'
+    })
+    return ''
+  }
+
+}