Преглед на файлове

feat: 从商户角度添加筛选条件

max преди 7 месеца
родител
ревизия
c0088f51ac

+ 7 - 0
src/modules/payment/service/business.ts

@@ -98,4 +98,11 @@ export class BusinessService extends BaseService {
     }
     return this.config.callback.sunpay
   }
+
+
+  async page(params: any) {
+    const merchantId = await this.getMerchantId(params);
+    const query = `SELECT * FROM business WHERE merchantId = '${merchantId}' ORDER BY merchantId ASC`;
+    return this.sqlRenderPage(query, params, false);
+  }
 }

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

@@ -72,6 +72,12 @@ export class IndividualService extends BaseService {
     this._isOpenApi = payload
   }
 
+  async page(params: any) {
+    const merchantId = await this.getMerchantId(params);
+    const query = `SELECT * FROM individual WHERE merchantId = '${merchantId}' ORDER BY merchantId ASC`;
+    return this.sqlRenderPage(query, params, false);
+  }
+
   async getMerchantId(params) {
     let merchantId;
     if (this._isOpenApi) {

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

@@ -106,4 +106,26 @@ export class PayeeService extends BaseService {
     }
     return merchant
   }
+
+  async page(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 getMerchantId(params) {
+    let merchantId;
+    if (this._isOpenApi) {
+      merchantId = params.out_user_id;
+    } else if (params?.mch_id || params?.mchId) {
+      // const  merchantInfo = await this.merchantEntity.findOneBy({
+      //    mchId: params?.mch_id
+      //  })
+      merchantId = params?.mch_id || params?.mchId
+    } else {
+      const { merchant } = this.ctx.admin;
+      merchantId = merchant.mchId;
+    }
+    return merchantId
+  }
 }

+ 25 - 0
src/modules/payment/service/payee_address.ts

@@ -19,6 +19,13 @@ export class PayeeAddressService extends BaseService {
   paymentService: PaymentService;
   @Inject()
   ctx;
+
+  private _isOpenApi: boolean = false
+
+  setIsOpenApi(payload = false) {
+    this._isOpenApi = payload
+  }
+
   /**
    * 添加收款人
    * @param params
@@ -93,4 +100,22 @@ export class PayeeAddressService extends BaseService {
     });
     return res;
   }
+  async page(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 getMerchantId(params) {
+    let merchantId;
+    if (this._isOpenApi) {
+      merchantId = params.out_user_id;
+    } else if (params?.mch_id || params?.mchId) {
+      merchantId = params?.mch_id || params?.mchId
+    } else {
+      const { merchant } = this.ctx.admin;
+      merchantId = merchant.mchId;
+    }
+    return merchantId
+  }
 }