1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import { BaseService, CoolCommException } from '@cool-midway/core';
- import { Provide } from '@midwayjs/core';
- 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";
- /**
- * 描述
- */
- @Provide()
- 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必须传一个');
- // }
- if (isIndividual) {
- this.individualService.setIsOpenApi(true)
- return await this.individualService.add(params);
- }
- this.businessService.setIsOpenApi(true)
- 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必须传一个');
- }
- if (isIndividual) {
- this.individualService.setIsOpenApi(true)
- return await this.individualService.update(params);
- }
- this.businessService.setIsOpenApi(true)
- return await this.businessService.update(params);
- // TODO 过滤sunpay返回
- }
- }
|