|
@@ -1,18 +1,16 @@
|
|
|
-import {CreateCustomerDTO} from "../dto/customer";
|
|
|
import { CoolController, BaseController } from '@cool-midway/core';
|
|
|
import {
|
|
|
ALL,
|
|
|
Body,
|
|
|
Get,
|
|
|
- Inject, Param,
|
|
|
+ Inject,
|
|
|
Post,
|
|
|
Provide,
|
|
|
Put,
|
|
|
} from '@midwayjs/decorator';
|
|
|
-import { BusinessEntity } from '../../payment/entity/business';
|
|
|
-import {Validate} from "@midwayjs/validate";
|
|
|
-import {BusinessService} from "../../payment/service/business";
|
|
|
-import {PaymentService} from "../../payment/service/payment";
|
|
|
+import { IndividualEntity } from '../../payment/entity/individual';
|
|
|
+import { CustomerService } from '../service/customer';
|
|
|
+import {SunPayAdapter} from "../../payment/adapter/sunpay.adapter";
|
|
|
|
|
|
/**
|
|
|
* 客户管理
|
|
@@ -20,77 +18,54 @@ import {PaymentService} from "../../payment/service/payment";
|
|
|
@Provide()
|
|
|
@CoolController('/api/v1/Fiat')
|
|
|
export class CustomerController extends BaseController {
|
|
|
+ @Inject()
|
|
|
+ customerService: CustomerService;
|
|
|
|
|
|
@Inject()
|
|
|
- businessService: BusinessService;
|
|
|
+ sunPayAdapter: SunPayAdapter;
|
|
|
/**
|
|
|
* 创建客户
|
|
|
*/
|
|
|
@Post('/CreateCustomer', { summary: '创建客户' })
|
|
|
- @Validate({
|
|
|
- errorStatus: 422,
|
|
|
- })
|
|
|
- async createCustomer(@Body() params: CreateCustomerDTO) {
|
|
|
- return this.ok(params);
|
|
|
- // return this.ok(await this.businessService.add(params));
|
|
|
- }
|
|
|
- /**
|
|
|
- * 获取创建客户必填字段
|
|
|
- */
|
|
|
- @Get('/CustomerRequiredFields', { summary: '获取创建客户必填字段' })
|
|
|
- async getCustomerRequiredFields(@Body(ALL) business: BusinessEntity) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
- }
|
|
|
- /**
|
|
|
- * 验证客户必填字段
|
|
|
- * /api/v3/Fiat/Customer/Validate
|
|
|
- */
|
|
|
- @Post('/Customer/Validate', { summary: '验证客户必填字段' })
|
|
|
- async param(@Body(ALL) business: BusinessEntity) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
+ async createCustomer(@Body() params: IndividualEntity) {
|
|
|
+ return this.ok(await this.customerService.createCustomer(params));
|
|
|
}
|
|
|
+ // /**
|
|
|
+ // * 获取创建客户必填字段
|
|
|
+ // */
|
|
|
+ // @Get('/CustomerRequiredFields', { summary: '获取创建客户必填字段' })
|
|
|
+ // async getCustomerRequiredFields(@Body(ALL) params: CreateUserParams) {
|
|
|
+ // return this.ok(await this.sunPayAdapter.validateCustomerInfo(params));
|
|
|
+ // }
|
|
|
+ // /**
|
|
|
+ // * 验证客户必填字段
|
|
|
+ // * /api/v3/Fiat/Customer/Validate
|
|
|
+ // */
|
|
|
+ // @Post('/Customer/Validate', { summary: '验证客户必填字段' })
|
|
|
+ // async param(@Body(ALL) business: CreateUserParams) {
|
|
|
+ // return this.ok(await this.sunPayAdapter.validateCustomerInfo(params));
|
|
|
+ // }
|
|
|
/**
|
|
|
* 修改客户
|
|
|
* /api/v3/Fiat/Customer
|
|
|
*/
|
|
|
@Put('/updateCustomer', { summary: '修改客户' })
|
|
|
- async updateCustomer(@Body(ALL) business: BusinessEntity) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
- }
|
|
|
- /**
|
|
|
- * TODO 创建客户回调通知
|
|
|
- *
|
|
|
- */
|
|
|
- @Post('/callback', { summary: '创建客户回调通知' })
|
|
|
- async createCustomerCallback(@Body(ALL) business: BusinessEntity) {
|
|
|
- // if (!this.allowKeys.includes(key)) {
|
|
|
- // return this.fail('非法操作');
|
|
|
- // }
|
|
|
- // 关键参数校验
|
|
|
- // 数据落库
|
|
|
- // 回调
|
|
|
- console.log(business);
|
|
|
- return this.ok('hello, cool-admin!!!');
|
|
|
+ async updateCustomer(@Body() params: IndividualEntity) {
|
|
|
+ return await this.customerService.updateCustomer(params);
|
|
|
}
|
|
|
+ // /**
|
|
|
+ // * TODO 创建客户回调通知
|
|
|
+ // *
|
|
|
+ // */
|
|
|
+ // @Post('/callback', { summary: '创建客户回调通知' })
|
|
|
+ // async createCustomerCallback(@Body(ALL) business: BusinessEntity) {
|
|
|
+ // // if (!this.allowKeys.includes(key)) {
|
|
|
+ // // return this.fail('非法操作');
|
|
|
+ // // }
|
|
|
+ // // 关键参数校验
|
|
|
+ // // 数据落库
|
|
|
+ // // 回调
|
|
|
+ // console.log(business);
|
|
|
+ // return this.ok('hello, cool-admin!!!');
|
|
|
+ // }
|
|
|
}
|