import { CoolController, BaseController } from '@cool-midway/core'; import { ALL, Body, Get, Inject, Post, Provide, Query } from '@midwayjs/decorator'; import { BusinessEntity } from '../../payment/entity/business'; import { WalletService } from "../../payment/service/wallet"; /** * 钱包 */ @Provide() @CoolController('/api/v1/Fiat') export class WalletController extends BaseController { @Inject() walletService: WalletService; /** * 创建钱包 * /api/v3/Fiat/Wallet */ @Post('/Wallet', { summary: '创建钱包' }) async createWallet(@Body(ALL) business: BusinessEntity) { // if (!this.allowKeys.includes(key)) { // return this.fail('非法操作'); // } // 关键参数校验 // 数据落库 // 回调 console.log(business); return this.ok(await this.walletService.add(business)); } /** * TODO 创建钱包回调通知 * */ @Post('/wallet/callback', { summary: '创建钱包回调通知' }) async createWalletCallback(@Body(ALL) business: BusinessEntity) { // if (!this.allowKeys.includes(key)) { // return this.fail('非法操作'); // } // 关键参数校验 // 数据落库 // 回调 console.log(business); return this.ok('hello, cool-admin!!!'); } /** * 获取钱包信息 * */ @Get('/GetWalletAccounts', { summary: '获取钱包信息' }) async GetWalletAccounts(@Query('customer_id') customer_id: string,) { // if (!this.allowKeys.includes(key)) { // return this.fail('非法操作'); // } // 关键参数校验 // 数据落库 // 回调 console.log('GetWalletAccounts', customer_id); return this.ok(await this.walletService.getWallet(customer_id)); } /** * 获取账户币种余额 */ @Get('/AccountBalance', { summary: '获取账户币种余额' }) async AccountBalance( @Query('customer_id') customer_id: string, @Query('currency') currency: string,) { // if (!this.allowKeys.includes(key)) { // return this.fail('非法操作'); // } // 关键参数校验 // 数据落库 // 回调 console.log(customer_id,currency); return this.ok(await this.walletService.getWalletBalance({ customer_id: customer_id, currency: currency })); } }