import { CoolController, BaseController } from '@cool-midway/core'; import { ALL, Body, Get, Inject, Post, Provide,Query,Param } from '@midwayjs/decorator'; import { BusinessEntity } from '../../payment/entity/business'; import { OrderService } from "../../payment/service/order"; /** * 入金 */ @Provide() @CoolController('/api/v1/Fiat') export class PayInController extends BaseController { @Inject() orderService: OrderService; /** * 创建订单 * /api/v3/Fiat/PayIn */ @Post('/PayIn', { summary: '创建订单' }) async createPayInOrder(@Body(ALL) business: BusinessEntity) { // if (!this.allowKeys.includes(key)) { // return this.fail('非法操作'); // } // 关键参数校验 // 数据落库 // 回调 console.log('createPayInOrder-=-=payIn-=-=000',business); return this.ok(await this.orderService.recharge(business)); } /** * 查询订单 * /api/v3/Fiat/PayIn/{orderNo} */ @Get('/PayIn/', { summary: '查询订单' }) async getPayInForOrderNo(@Query('orderNo') orderNo: string,) { // if (!this.allowKeys.includes(key)) { // return this.fail('非法操作'); // } // 关键参数校验 // 数据落库 // 回调 console.log('getPayInForOrderNo-=-=-=-111',orderNo); return this.ok(await this.orderService.rechargeOrder({ orderNo: orderNo,channel:'SUNPAY'})); } /** * 取消订单 * /api/v3/Fiat/PayIn/{orderNo}/Cancel */ @Post('/PayIn/:orderNo/Cancel', { summary: '取消订单' }) async cancelPayInOrderForOrderNo(@Param('orderNo') orderNo: string) { // if (!this.allowKeys.includes(key)) { // return this.fail('非法操作'); // } // 关键参数校验 // 数据落库 // 回调 console.log('cancelPayInOrderForOrderNo-=-=-=111',orderNo); return this.ok(await this.orderService.rechargeOrderCancel({orderNo:orderNo})); } // /** // * TODO 创建订单回调通知 // * /api/v3/Fiat/PayIn/{orderNo}/Cancel // */ // @Post('Fiat/PayIn/orderNo/Cancel', { summary: '创建订单回调通知' }) // async createPayInOrderForCallback(@Body(ALL) business: BusinessEntity) { // // if (!this.allowKeys.includes(key)) { // // return this.fail('非法操作'); // // } // // 关键参数校验 // // 数据落库 // // 回调 // console.log(business); // return this.ok('hello, cool-admin!!!'); // } }