max 6 месяцев назад
Родитель
Сommit
4063ddfb2d

+ 8 - 17
src/modules/payment/adapter/trubit.adapter.ts

@@ -50,6 +50,7 @@ export class TrubitAdapter implements ChannelAdapter {
         chainApiUrl: channel.chainApiUrl,
       };
     }
+
   }
 
   /**
@@ -79,21 +80,12 @@ export class TrubitAdapter implements ChannelAdapter {
     body = '',
     secret = ''
   ): string {
-    // const payload = `timestamp=${timestamp}${body}`;
-    const payload = `timestamp=1538323200000{"id":0}`;
-    console.log(83, payload)
-    console.log(83, secret)
-    // 创建 HMAC 对象
-    const hmac = crypto.createHmac('sha256', secret);
-    // 更新数据
-    hmac.update(payload);
-    // 生成哈希值
-    const signature = hmac.digest('hex');
-    // const signature = crypto
-    //   .createHmac('sha256', secret)
-    //   .update(payload)
-    //   .digest('hex')
-    //   .toUpperCase();
+    const payload = `timestamp=${timestamp}${body}`;
+    const signature = crypto
+      .createHmac('sha256', secret)
+      .update(payload)
+      .digest('hex')
+      .toUpperCase();
 
     return signature;
   }
@@ -128,7 +120,7 @@ export class TrubitAdapter implements ChannelAdapter {
     }
     // 1. 准备请求参数
     const timestamp = Date.now().toString();
-    const nonce = this.generateNonce();
+    // const nonce = this.generateNonce();
     const body = method === 'GET' ? '' : JSON.stringify(data);
 
     // 2. 生成签名
@@ -145,7 +137,6 @@ export class TrubitAdapter implements ChannelAdapter {
           'Content-Type': 'application/json',
           'SunPay-Key': key,
           'SunPay-Timestamp': timestamp,
-          'SunPay-Nonce': nonce,
           'SunPay-Sign': sign,
         },
       });

+ 39 - 0
src/modules/payment/service/payee.ts

@@ -158,6 +158,38 @@ export class PayeeService extends BaseService {
     return merchant
   }
 
+  // async list(params: any) {
+  //   const merchantId = await this.getMerchantId(params);
+  //   const query = `SELECT * FROM payee WHERE merchantId = '${merchantId}' ORDER BY merchantId ASC`;
+  //   return this.sqlRenderPage(query, params, false);
+  // }
+
+  async list(query: any, option: any, connectionName?: any): Promise<any> {
+    const merchantId = await this.getMerchantId(query);
+    const res = await super.list(
+      {
+        ...query,
+        // merchantId: merchantId
+       
+      },
+      {
+        ...option,
+        where: [{
+          merchantId
+          // `merchantId=${merchantId}`
+        }]
+        // select: ['id', 'name', 'code', 'description', 'supportedCurrencies'],
+      },
+      connectionName
+    );
+    console.log(181, merchantId, query);
+    return res;
+    // const merchantId = await this.getMerchantId(params);
+    // const query = `SELECT * FROM payee WHERE merchantId = '${merchantId}' ORDER BY merchantId ASC`;
+    // return this.sqlRenderPage(query, params, false);
+  }
+
+
   async page(params: any) {
     const merchantId = await this.getMerchantId(params);
     const query = `SELECT * FROM payee WHERE merchantId = '${merchantId}' ORDER BY merchantId ASC`;
@@ -178,6 +210,13 @@ export class PayeeService extends BaseService {
     //   merchantId = merchant.mchId;
     // }
     const { merchant } = this.ctx.admin;
+    
+    const customer = await this.customerEntity.findOneBy({
+      merchantId: merchant.mchId,
+      out_user_id: null
+    });
+
+    console.log(209, customer);
     return merchant.mchId
   }
 }

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

@@ -11,6 +11,7 @@ import {
   CustomerInfo,
 } from '../interface/channel.adapter';
 import { SunPayAdapter } from '../adapter/sunpay.adapter';
+import {TrubitAdapter} from "../adapter/trubit.adapter";
 
 @Provide()
 export class PaymentService extends BaseService {
@@ -25,6 +26,9 @@ export class PaymentService extends BaseService {
 
   @Inject()
   sunPayAdapter: SunPayAdapter;
+
+  @Inject()
+  easyPayXAdapter: TrubitAdapter;
   channel: string;
   /**
    * 获取渠道适配器
@@ -33,6 +37,8 @@ export class PaymentService extends BaseService {
     switch (channelCode.toUpperCase()) {
       case 'SUNPAY':
         return this.sunPayAdapter;
+      case 'EASYPAYX':
+        return this.easyPayXAdapter;
       default:
         throw new Error(`Unsupported channel: ${channelCode}`);
     }