package com.muchinfo.mtp3century.controller;

import com.muchinfo.mtp3century.service.IReportFormService;
import com.muchinfo.mtp3century.utils.AjaxResult;
import com.muchinfo.mtp3common.vo.PageResult;
import com.muchinfo.mtp3pojos.entity.ReportPlateformpp;
import com.muchinfo.mtp3pojos.entity.ReportTaaccount;
import com.muchinfo.mtp3pojos.vo.reportform.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/reportForm")
@Api(value = "报表API", description = "报表管理")
public class ReportFormController {

    @Resource
    private IReportFormService iReportFormService;

    @RequestMapping(method = RequestMethod.GET, value = "/shareAmountQuery")
    @ApiOperation("报表管理-->分润报表(机构)")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<ShareAmountQueryResult> selectShareAmount(ShareAmountQueryParam param, HttpServletRequest request) {
        return iReportFormService.selectShareAmount(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/shareAmountQueryPlat")
    @ApiOperation("报表管理-->分润报表(平台)")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<ShareAmountQueryResult> shareAmountQueryPlat(ShareAmountQueryParam param, HttpServletRequest request) {
        return iReportFormService.shareAmountQueryPlat(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryDODPage")
    @ApiOperation("报表管理-->分润报表(机构)-->机构明细")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<ReckonDivideOrderDetailResult> queryDODPage(ReckonDivideOrderDetailParam param, HttpServletRequest request) {
        return iReportFormService.queryDODPage(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryRefUserSelect")
    @ApiOperation("报表管理-->推荐成交报表-->推荐人信息")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<RefUserResult> queryRefUserSelect(String searchcode, HttpServletRequest request) {
        return iReportFormService.queryRefUserSelect(searchcode, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/trade")
    @ApiOperation("报表管理-->推荐成交报表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<TradeQueryResult> queryTrade(TradeQueryParam param, HttpServletRequest request) {
        return iReportFormService.queryTrade(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/orgReportQuery")
    @ApiOperation("报表管理-->经纪会员报表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<OrgReportQueryResult> orgReportQuery(OrgReportQueryParam param, HttpServletRequest request) {
        return iReportFormService.orgReportQuery(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/orgReportQueryExport")
    @ApiOperation("报表管理-->经纪会员报表-->导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult orgReportQueryExport(OrgReportQueryParam param, HttpServletRequest request) {
        return iReportFormService.orgReportQueryExport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/investorReportQuery")
    @ApiOperation("报表管理-->交易商资金报表/机构资金报表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<InvestorReportQueryResult> investorReportQuery(InvestorReportQueryParam param, HttpServletRequest request) {
        return iReportFormService.investorReportQuery(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/investorReportExport")
    @ApiOperation("报表管理-->交易商资金报表 --> 导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult investorReportExport(InvestorReportQueryParam param, HttpServletRequest request) {
        return iReportFormService.investorReportExport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/investorReportOrgExport")
    @ApiOperation("报表管理-->机构资金报表 --> 导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult investorReportOrgExport(InvestorReportQueryParam param, HttpServletRequest request) {
        return iReportFormService.investorReportOrgExport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryTAAccountChildrenSelect")
    @ApiOperation("报表管理-->资金账户报表-->资金账户下拉列表")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<TAAccountChildrenSelect> queryTAAccountChildrenSelect(String searchcode, HttpServletRequest request) {
        return iReportFormService.queryTAAccountChildrenSelect(searchcode, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/taaccountReportQuery")
    @ApiOperation("报表管理-->资金账户报表-->资金信息")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<ReportTaaccount> taaccountReportQuery(TaAccountReportParam param, HttpServletRequest request) {
        return iReportFormService.taaccountReportQuery(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/holdertotalquery")
    @ApiOperation("报表管理-->资金账户报表-->持仓汇总表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<HolderTotalResult> holdertotalquery(TaAccountReportParam param, HttpServletRequest request) {
        return iReportFormService.holdertotalquery(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/wrpositionquery")
    @ApiOperation("报表管理-->资金账户报表-->仓单汇总表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<WrPositionResult> wrpositionquery(TaAccountReportParam param, HttpServletRequest request) {
        return iReportFormService.wrpositionquery(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/tradequery")
    @ApiOperation("报表管理-->资金账户报表-->成交汇总表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<TradeReportQueryResult> tradequery(TaAccountReportParam param, HttpServletRequest request) {
        return iReportFormService.tradequery(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/accountppquery")
    @ApiOperation("报表管理-->资金账户报表-->履约汇总表")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<ReportPlateformpp> accountppquery(TaAccountReportParam param, HttpServletRequest request) {
        return iReportFormService.accountppquery(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/cusbank")
    @ApiOperation("报表管理-->银行资金报表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<CusBankReportResult> cusbank(CusBankReportParam param, HttpServletRequest request) {
        return iReportFormService.cusbank(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/cusbankexport")
    @ApiOperation("报表管理-->银行资金报表-->导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult cusbankexport(CusBankReportParam param, HttpServletRequest request) {
        return iReportFormService.cusbankexport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/managediv")
    @ApiOperation("报表管理-->服务费分润报表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<ManageDivReportResult> managediv(CusBankReportParam param, HttpServletRequest request) {
        return iReportFormService.managediv(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/managedivexport")
    @ApiOperation("报表管理-->服务费分润报表-->导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult managedivexport(CusBankReportParam param, HttpServletRequest request) {
        return iReportFormService.managedivexport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/rerun")
    @ApiOperation("报表管理-->报表重算")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult rerun(String startDate, String endDate, HttpServletRequest request) {
        return iReportFormService.rerun(startDate, endDate, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/daygoodscount")
    @ApiOperation("报表管理-->商品交易报表")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<Map<Long, List<GoodsReportResult>>> daygoodscount(GoodsReportParam param, HttpServletRequest request) {
        return iReportFormService.daygoodscount(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/goodscountexport")
    @ApiOperation("报表管理-->商品交易报表-->导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult goodscountexport(GoodsReportParam param, HttpServletRequest request) {
        return iReportFormService.goodscountexport(param, request);
    }
}
