|
@@ -1,6 +1,6 @@
|
|
|
import { IndividualEntity } from './../entity/individual';
|
|
|
import { BusinessEntity } from './../entity/business';
|
|
|
-import { Init, Provide } from '@midwayjs/decorator';
|
|
|
+import {ALL, Config, Init, Inject, Provide} from '@midwayjs/decorator';
|
|
|
import { BaseService } from '@cool-midway/core';
|
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
|
import { Repository } from 'typeorm';
|
|
@@ -22,6 +22,10 @@ export class CustomerService extends BaseService {
|
|
|
await super.init();
|
|
|
this.setEntity(this.customerEntity);
|
|
|
}
|
|
|
+ @Config(ALL)
|
|
|
+ config;
|
|
|
+ @Inject()
|
|
|
+ ctx;
|
|
|
|
|
|
/**
|
|
|
* 描述
|
|
@@ -113,6 +117,12 @@ export class CustomerService extends BaseService {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ private _isOpenApi: boolean = false
|
|
|
+
|
|
|
+ setIsOpenApi(payload = false) {
|
|
|
+ this._isOpenApi = payload
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 发送请求到 商户 API
|
|
|
*/
|
|
@@ -133,4 +143,24 @@ export class CustomerService extends BaseService {
|
|
|
// throw error;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async list(params: any = {}) {
|
|
|
+ const merchantId = await this.getMerchantId(params);
|
|
|
+ return await this.customerEntity.findBy({
|
|
|
+ merchantId: `${merchantId}`
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ private async getMerchantId(params) {
|
|
|
+ let merchantId;
|
|
|
+ if (this._isOpenApi) {
|
|
|
+ merchantId = params.out_user_id;
|
|
|
+ } else if (params?.mch_id || params?.mchId || params?.merchantId) {
|
|
|
+ merchantId = params?.mch_id || params?.mchId || params?.merchantId
|
|
|
+ } else {
|
|
|
+ const { merchant } = this.ctx.admin;
|
|
|
+ merchantId = merchant.mchId;
|
|
|
+ }
|
|
|
+ return merchantId
|
|
|
+ }
|
|
|
}
|