|
@@ -1,9 +1,10 @@
|
|
|
import { BaseService, CoolCommException } from '@cool-midway/core';
|
|
|
import { Provide } from '@midwayjs/core';
|
|
|
-import { Inject } from '@midwayjs/decorator';
|
|
|
+import {ALL, Config, Inject} from '@midwayjs/decorator';
|
|
|
import { BusinessService } from '../../payment/service/business';
|
|
|
import { SunPayAdapter } from '../../payment/adapter/sunpay.adapter';
|
|
|
import { IndividualService } from '../../payment/service/individual';
|
|
|
+import {CustomerEntity} from "../../payment/entity/customer";
|
|
|
|
|
|
/**
|
|
|
* 描述
|
|
@@ -13,20 +14,25 @@ export class CustomerService extends BaseService {
|
|
|
@Inject()
|
|
|
sunPayAdapter: SunPayAdapter;
|
|
|
@Inject()
|
|
|
+ customerEntity: CustomerEntity;
|
|
|
+ @Inject()
|
|
|
businessService: BusinessService; // 公司
|
|
|
@Inject()
|
|
|
individualService: IndividualService; // 个人
|
|
|
+ @Config(ALL)
|
|
|
+ config;
|
|
|
|
|
|
async createCustomer(params) {
|
|
|
const isIndividual = params.customer_type === 'INDIVIDUAL';
|
|
|
// const isCompany = params.customer_type === 'COMPANY';
|
|
|
- if (!params?.individual && !params?.company) {
|
|
|
- throw new CoolCommException('company或individual必须传一个');
|
|
|
- }
|
|
|
- params.isOpenApi = true;
|
|
|
+ // if (!params?.individual && !params?.company) {
|
|
|
+ // throw new CoolCommException('company或individual必须传一个');
|
|
|
+ // }
|
|
|
if (isIndividual) {
|
|
|
+ this.individualService.setIsOpenApi(true)
|
|
|
return await this.individualService.add(params);
|
|
|
}
|
|
|
+ this.businessService.setIsOpenApi(true)
|
|
|
return await this.businessService.add(params);
|
|
|
// TODO 过滤sunpay返回
|
|
|
}
|
|
@@ -36,10 +42,11 @@ export class CustomerService extends BaseService {
|
|
|
if (!params?.individual && !params?.company) {
|
|
|
throw new CoolCommException('company或individual必须传一个');
|
|
|
}
|
|
|
- params.isOpenApi = true;
|
|
|
if (isIndividual) {
|
|
|
+ this.individualService.setIsOpenApi(true)
|
|
|
return await this.individualService.update(params);
|
|
|
}
|
|
|
+ this.businessService.setIsOpenApi(true)
|
|
|
return await this.businessService.update(params);
|
|
|
// TODO 过滤sunpay返回
|
|
|
}
|