import { WithdrawEntity } from '../../entity/withdraw';
import { Inject, Post, Provide, Body, ALL } from '@midwayjs/decorator';
import { CoolController, BaseController } from '@cool-midway/core';
import { WithdrawService } from '../../service/withdraw';

@Provide()
@CoolController({
  api: ['add', 'update', 'info', 'page'],
  entity: WithdrawEntity,
  service: WithdrawService,
})
export class WithdrawController extends BaseController {
  @Inject()
  withdrawService: WithdrawService;

  @Post('/summary', { summary: '统计' })
  async summary() {
    const { body } = this.baseCtx.request;
    return this.ok(await this.withdrawService.summary(body));
  }

  @Post('/query', { summary: '查单' })
  async query(@Body('id') id) {
    return this.ok(await this.withdrawService.queryByApi(id));
  }
  
  @Post('/notify', { summary: '通知' })
  async notify(@Body('id') id) {
    return this.ok(await this.withdrawService.notify(id));
  }

  @Post('/code', { summary: '获取订单通道编码' })
  async code(@Body('id') id) {
    return this.ok(id);
  }

  @Post('/mch', { summary: '获取订单商户编码' })
  async mch(@Body('id') id) {
    return this.ok(id);
  }

  // @Post('/withdraw', { summary: '发起代付' })
  // async withdraw(@Body(ALL) payload: any) {
  //   return this.ok(await this.withdrawService.withdraw(payload));
  // }
}
