import { Inject, Post, Provide, Body, ALL } from '@midwayjs/decorator';
import { CoolController, BaseController } from '@cool-midway/core';
import { DashboardService } from '../../service/dashboard';
import { BaseSysConfService } from '../../../base/service/sys/conf';
import { CurrencyService } from '../../service/currency';
import { MerchantService } from '../../service/merchant';
import { PayTypeService } from '../../service/payType';
import { ChannelService } from '../../service/channel';
import { WithdrawChannelService } from '../../service/withdrawChannel';

@Provide()
@CoolController()
export class OrdertController extends BaseController {
  @Inject()
  dashboardService: DashboardService;

  @Inject()
  currencyService: CurrencyService;

  @Inject()
  merchantService: MerchantService;
  
  @Inject()
  payTypeService: PayTypeService;
    
  @Inject()
  channelService: ChannelService;

  @Inject()
  withdrawChannelService: WithdrawChannelService;

  @Inject()
  baseSysConfService: BaseSysConfService;

  @Post('/dashboard', { summary: '统计' })
  async dashboard(@Body(ALL) payload: any) {
    return this.ok(await this.dashboardService.dashboard(payload));
  }


  @Post('/chartData', { summary: '报表' })
  async chartData(@Body(ALL) payload: any) {
    return this.ok(await this.dashboardService.chartData(payload));
  }

  @Post('/getCurrency', { summary: '货币列表' })
  async getCurrency() {
    return this.ok(await this.currencyService.getCurrencyList());
  }

  @Post('/getMerchants', { summary: '商户列表' })
  async getMerchants() {
    return this.ok(await this.merchantService.getMerchantList());
  }

  @Post('/getPayTypes', { summary: '支付类型列表' })
  async getPayTypes(@Body('type') type) {
    return this.ok(await this.payTypeService.getPayTypeList(type));
  }

  @Post('/getChannels', { summary: '支付通道列表' })
  async getChannels() {
    return this.ok(await this.channelService.getChannelList());
  }

  @Post('/getWithdrawChannels', { summary: '代付通道列表' })
  async getWithdrawChannels() {
    return this.ok(await this.withdrawChannelService.getWithdrawChannelList());
  }
}
