12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { BaseService, CoolCommException } from '@cool-midway/core';
- import { Provide } from '@midwayjs/core';
- import { Inject } from '@midwayjs/decorator';
- import { BusinessService } from '../../payment/service/business';
- import { SunPayAdapter } from '../../payment/adapter/sunpay.adapter';
- import { IndividualService } from '../../payment/service/individual';
- /**
- * 描述
- */
- @Provide()
- export class CustomerService extends BaseService {
- @Inject()
- sunPayAdapter: SunPayAdapter;
- @Inject()
- businessService: BusinessService; // 公司
- @Inject()
- individualService: IndividualService; // 个人
- 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 (isIndividual) {
- return await this.individualService.add(params);
- }
- return await this.businessService.add(params);
- // TODO 过滤sunpay返回
- }
- async updateCustomer(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 (isIndividual) {
- return await this.individualService.update(params);
- }
- return await this.businessService.update(params);
- // TODO 过滤sunpay返回
- }
- }
|