Browse Source

Merge remote-tracking branch 'origin/main'

max 4 tháng trước cách đây
mục cha
commit
0a22aa357f

+ 2 - 2
src/modules/api/entity/open_payment_order.ts

@@ -50,7 +50,7 @@ export class OpenPaymentOrderEntity extends BaseEntity {
 
   @Column({ comment: '手续费', type: 'decimal', precision: 20, scale: 6, default: 0 })
   fee?: number;
-  
+
   @Column({ comment: '渠道手续费', type: 'decimal', precision: 20, scale: 6, default: 0 })
   currency_fee?: number;
 
@@ -90,7 +90,7 @@ export enum OrderType {
   PAYMENT = 'PAYMENT', // 付款
   TRANSFER = 'TRANSFER', // 转账
   DEPOSIT = 'DEPOSIT', // 入账
-  EXCHANGE = 'DEPOSIT', // 换汇
+  EXCHANGE = 'EXCHANGE', // 换汇
   TRANSACTION_FEE_ORDER = 'TRANSACTION_FEE_ORDER', // 交易手续费订单
 }
 

+ 4 - 4
src/modules/api/service/admin/applications.ts

@@ -292,12 +292,12 @@ export class applicationsService extends BaseService {
   async payments(params) {
     // 余额 判断是否足以支持交易手续费
     // 获取指定币种的余额
-    /* 
+    /*
       amount : 12312
       beneficiary_id : 10
       comment : "123"
       currency : "AUD"
-      purpose : "123123" 
+      purpose : "123123"
     */
     const merchantInfo = await this.getMerchantInfo();
     // 获取收款地址
@@ -363,10 +363,10 @@ export class applicationsService extends BaseService {
   }
 
   // 获取商户信息
-  async getMerchantInfo(mch_id = 'ep001@fusion.com') {
+  async getMerchantInfo(mch_id = this.ctx.admin.merchant.mchId) {
     const merchantInfo = await this.openAccountEntity.findOne({
       where: {
-        mch_id: this.ctx.admin.merchant.mchId,
+        mch_id: mch_id,
         // mch_id: 'easypay@qq.com',
         // mch_id: 'ep001@fusion.com',
         // mch_id: 'easypay003@fusion.com',

+ 2 - 2
src/modules/api/service/webhook_utils/deposit_success.ts

@@ -38,7 +38,7 @@ export class DepositSuccessService extends BaseService {
     try {
       /*
         2025-03-11 16:58:09.069 INFO 113849 [-/::ffff:127.0.0.1/-/1ms POST /api/open/easypay-webhook/notification] easypay的webhook_notification: params{"type":"deposit_success","data":{"id":"85a2e73b90d94354b14b925c8e23b876","bank_account_id":"7021a5e645574004b5678213f94df8a5","order_no":"20250311165807046795","account_id":"590f080eb299590385c7aa628274e73c","bic_number":null,"account_number":"79765000168","inward_amount":90000,"fee":0,"amount":90000,"currency":"EUR","payer":"付款信息 格式:{sender.name};{sender.address};{sender.country};{sender.account_number} or {sender.iban};{sender.bic};{sender.routing_code};附言","comment":"附言","payment_type":"SWIFT","order_type":"DEPOSIT","payment_id":null,"clearing_system":null,"status":"SUCCESS","create_time":"2025-03-11T16:58:08+08:00","update_time":"2025-03-11T16:58:08+08:00","completed_time":"2025-03-11T16:58:08+08:00"}}
-    
+
         {
           "type": "deposit_success",
           "data": {
@@ -150,7 +150,7 @@ export class DepositSuccessService extends BaseService {
           account_id: params.data.account_id,
           from_account_id: params.data.account_id,
           to_account_id: this.easyPayAdapter.baseInfo.account_id,
-          event_id: params.data.id,
+          event_id: res.data.id,
           currency: params.data.currency,
           status: params.data.status,
           order_type: OrderType.TRANSACTION_FEE_ORDER,

+ 1 - 1
src/modules/api/service/webhook_utils/exchange_success.ts

@@ -148,7 +148,7 @@ export class ExchangeSuccessService extends BaseService {
           account_id: params.data.account_id,
           from_account_id: params.data.account_id,
           to_account_id: this.easyPayAdapter.baseInfo.account_id,
-          event_id: params.data.id,
+          event_id: res.data.id,
           currency: transfers_params.currency,
           status: params.data.status,
           order_type: OrderType.TRANSACTION_FEE_ORDER,

+ 1 - 1
src/modules/api/service/webhook_utils/payment_success.ts

@@ -155,7 +155,7 @@ export class PaymentSuccessService extends BaseService {
           account_id: params.data.account_id,
           from_account_id: params.data.account_id,
           to_account_id: this.easyPayAdapter.baseInfo.account_id,
-          event_id: params.data.id,
+          event_id: res.data.id,
           currency: params.data.currency,
           status: params.data.status,
           order_type: OrderType.TRANSACTION_FEE_ORDER,

+ 9 - 8
src/modules/api/service/webhook_utils/transfer_success.ts

@@ -62,7 +62,7 @@ export class TransferSuccessService extends BaseService {
         */
       // 获取回调用户的详情
       accountInfo = await this.webHookCommonService.getAccountInfo(
-        params.data.account_id
+        params.data.from_account_id
       );
       if (!accountInfo) {
         // 转账延迟4秒处理
@@ -75,7 +75,7 @@ export class TransferSuccessService extends BaseService {
       // 获取费率信息
       withdrawChannelFee =
         await this.webHookCommonService.getWithdrawChannelFee({
-          account_id: params.data.account_id,
+          account_id: params.data.from_account_id,
           currency: params.data.currency,
           order_type: OrderType.TRANSFER,
           channel: 'EASYPAY',
@@ -98,7 +98,7 @@ export class TransferSuccessService extends BaseService {
       // 获取余额
       const { before_balance, balance } =
         await this.webHookCommonService.getBalanceDiffByCurrency({
-          account_id: params.data.account_id,
+          account_id: params.data.from_account_id,
           currency: params.data.currency,
           amount: params.data.amount,
           order_type: OrderType.TRANSFER,
@@ -107,7 +107,7 @@ export class TransferSuccessService extends BaseService {
       const openPaymentOrderParams = {
         mch_id: accountInfo.mch_id,
         amount: params.data.amount / 100,
-        account_id: params.data.account_id,
+        account_id: params.data.from_account_id,
         from_account_id: params.data.from_account_id,
         to_account_id: params.data.to_account_id,
         event_id: params.data.id,
@@ -133,7 +133,7 @@ export class TransferSuccessService extends BaseService {
         // /v1/transfers
         const transfers_params = {
           request_id: md5(`${accountInfo.mch_id}_${params.data.id}`),
-          from_account_id: params.data.account_id,
+          from_account_id: params.data.from_account_id,
           to_account_id: this.easyPayAdapter.baseInfo.account_id,
           currency: params.data.currency,
           amount: withdrawChannelFee * 100,
@@ -153,10 +153,10 @@ export class TransferSuccessService extends BaseService {
           request_id: transfers_params.request_id,
           mch_id: accountInfo.mch_id,
           amount: withdrawChannelFee,
-          account_id: params.data.account_id,
-          from_account_id: params.data.account_id,
+          account_id: params.data.from_account_id,
+          from_account_id: params.data.from_account_id,
           to_account_id: this.easyPayAdapter.baseInfo.account_id,
-          event_id: params.data.id,
+          event_id: res.data.id,
           currency: params.data.currency,
           status: params.data.status,
           order_type: OrderType.TRANSACTION_FEE_ORDER,
@@ -180,6 +180,7 @@ export class TransferSuccessService extends BaseService {
     return await this.openPaymentOrderEntity.findOne({
       where: {
         event_id,
+        order_type: OrderType.TRANSACTION_FEE_ORDER
       },
     });
   }