package com.muchinfo.mtp3century.controller;

import com.muchinfo.mtp3century.service.IQueryService;
import com.muchinfo.mtp3century.utils.AjaxResult;
import com.muchinfo.mtp3common.vo.PageResult;
import com.muchinfo.mtp3pojos.vo.common.OrganSelectResult;
import com.muchinfo.mtp3pojos.vo.query.accounttransaction.AccountTransactionQueryParam;
import com.muchinfo.mtp3pojos.vo.query.accounttransaction.AccountTransactionQueryResult;
import com.muchinfo.mtp3pojos.vo.query.commission.CommissionSheetParam;
import com.muchinfo.mtp3pojos.vo.query.commission.CommissionSheetResult;
import com.muchinfo.mtp3pojos.vo.query.commission.CommissionSheetResultDetail;
import com.muchinfo.mtp3pojos.vo.query.contract.ContractSheetParam;
import com.muchinfo.mtp3pojos.vo.query.contract.ContractSheetResult;
import com.muchinfo.mtp3pojos.vo.query.contract.ContractSheetResultDetail;
import com.muchinfo.mtp3pojos.vo.query.deliveryorder.*;
import com.muchinfo.mtp3pojos.vo.query.goodstrade.GoodsTradeQueryParam;
import com.muchinfo.mtp3pojos.vo.query.goodstrade.GoodsTradeQueryResult;
import com.muchinfo.mtp3pojos.vo.query.investorsum.InvestorSumQueryParam;
import com.muchinfo.mtp3pojos.vo.query.investorsum.InvestorSumQueryResult;
import com.muchinfo.mtp3pojos.vo.query.other.*;
import com.muchinfo.mtp3pojos.vo.query.position.*;
import com.muchinfo.mtp3pojos.vo.query.tradesum.TradeSumQueryParam;
import com.muchinfo.mtp3pojos.vo.query.tradesum.TradeSumQueryResult;
import com.muchinfo.mtp3pojos.vo.query.warehouse.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/query")
@Api(value = "查询API", description = "查询管理")
public class QueryController {

    @Resource
    private IQueryService iQueryService;

    @RequestMapping(method = RequestMethod.GET, value = "/commissionSheet")
    @ResponseBody
    @ApiOperation("内部订单查询--> 委托单查询、斩仓记录查询")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<CommissionSheetResult> commissionSheetQuery(CommissionSheetParam commissionSheetParam, HttpServletRequest request) {
        return iQueryService.commissionSheetQuery(commissionSheetParam, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/commissionExport")
    @ResponseBody
    @ApiOperation("内部订单查询--> 委托单导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult commissionExport(CommissionSheetParam commissionSheetParam, HttpServletRequest request) {
        return iQueryService.commissionExport(commissionSheetParam, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/commissionSheetDetail")
    @ResponseBody
    @ApiOperation("内部订单查询--> 委托单详情查询")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<CommissionSheetResultDetail> commissionSheetQueryDetail(String orderId, Integer isHis, String tradeDate, HttpServletRequest request) {
        return iQueryService.commissionSheetQueryDetail(orderId, isHis, tradeDate, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/contractSheet")
    @ResponseBody
    @ApiOperation("内部订单查询--> 成交单查询")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<ContractSheetResult> contractSheetQuery(ContractSheetParam contractSheetParam, HttpServletRequest request) {
        return iQueryService.contractSheetQuery(contractSheetParam, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/contractExport")
    @ResponseBody
    @ApiOperation("内部订单查询--> 成交单导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult contractExport(ContractSheetParam contractSheetParam, HttpServletRequest request) {
        return iQueryService.contractExport(contractSheetParam, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/contractSheetDetail")
    @ResponseBody
    @ApiOperation("内部订单查询--> 成交单详情查询")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<ContractSheetResultDetail> contractSheetQueryDetail(String tradeid, Integer buyorsell, Integer ishis, HttpServletRequest request) {
        return iQueryService.contractSheetQueryDetail(tradeid, buyorsell, ishis, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/positionSheet")
    @ResponseBody
    @ApiOperation("内部订单查询--> 持仓单查询")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<PositionSheetResult> positionSheetQuery(PositionSheetParam positionSheetParam, HttpServletRequest request) {
        return iQueryService.positionSheetQuery(positionSheetParam, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/positionExport")
    @ResponseBody
    @ApiOperation("内部订单查询--> 持仓单导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult positionExport(PositionSheetParam positionSheetParam, HttpServletRequest request) {
        return iQueryService.positionExport(positionSheetParam, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/positionSheetDetail")
    @ResponseBody
    @ApiOperation("内部订单查询--> 持仓单详情查询")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<PositionSheetResultDetail> positionSheetDetail(String tradeid, Integer buyorsell, Integer ishis, String histradedate, HttpServletRequest request) {
        return iQueryService.positionSheetDetail(tradeid, buyorsell, ishis, histradedate, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/positionSumSheet")
    @ResponseBody
    @ApiOperation("内部订单查询--> 持仓单汇总查询")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<PositionSumSheetResult> positionSumSheet(PositionSumSheetParam param, HttpServletRequest request) {
        return iQueryService.positionSumSheet(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/positionSumSheetExport")
    @ResponseBody
    @ApiOperation("内部订单查询--> 持仓单汇总导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult positionSumSheetExport(PositionSumSheetParam param, HttpServletRequest request) {
        return iQueryService.positionSumSheetExport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/warehouseQuery")
    @ResponseBody
    @ApiOperation("仓单类订单查询--> 委托单查询 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<WarehouseCommissionResult> warehouseQuery(WarehouseCommissionParam param, HttpServletRequest request) {
        return iQueryService.warehouseQuery(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/warehouseExport")
    @ResponseBody
    @ApiOperation("仓单类订单查询--> 委托单查询 --> 导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult warehouseExport(WarehouseCommissionParam param, HttpServletRequest request) {
        return iQueryService.warehouseExport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/tradeOrderView")
    @ResponseBody
    @ApiOperation("仓单类订单查询--> 委托单查询 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<WarehouseCommissionResultDetail> tradeOrderView(Long wrtradeorderid, Integer ishis, HttpServletRequest request) {
        return iQueryService.tradeOrderView(wrtradeorderid, ishis, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryTradeOrder")
    @ResponseBody
    @ApiOperation("仓单类订单查询--> 成交单查询 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<WarehouseContractResult> queryTradeOrder(WarehouseContractParam param, HttpServletRequest request) {
        return iQueryService.queryTradeOrder(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/tradeOrderExport")
    @ResponseBody
    @ApiOperation("仓单类订单查询--> 成交单查询 --> 导出")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult tradeOrderExport(WarehouseContractParam param, HttpServletRequest request) {
        return iQueryService.tradeOrderExport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/tradeTradedView")
    @ResponseBody
    @ApiOperation("仓单类订单查询--> 成交单查询 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<WarehouseContractDetailParam> tradeTradedView(Long wrtradeorderid, Integer ishis, Integer wrtradetype, HttpServletRequest request) {
        return iQueryService.tradeTradedView(wrtradeorderid, ishis, wrtradetype, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/initWarehouse")
    @ResponseBody
    @ApiOperation("仓单查询--> 仓单汇总查询查询 --> 初始化仓单标准以及仓库")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<WarehouseInitResult> initWarehouse(HttpServletRequest request) {
        return iQueryService.initWarehouse(request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/summaryQuery")
    @ResponseBody
    @ApiOperation("仓单查询--> 仓单汇总查询查询 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<WarehouseSumResult> warehouseSum(WarehouseSumParam param, HttpServletRequest request) {
        return iQueryService.warehouseSum(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/summaryQueryInit")
    @ResponseBody
    @ApiOperation("仓单查询--> 仓单汇总查询查询 --> 详情 --> 初始化持有人")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<OrganSelectResult> summaryQueryInit(HttpServletRequest request) {
        return iQueryService.summaryQueryInit(request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/summaryQueryDetail")
    @ResponseBody
    @ApiOperation("仓单查询--> 仓单汇总查询查询 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<WarehouseSumDetailResult> summaryQueryDetail(WarehouseSumDetailParam param, HttpServletRequest request) {
        return iQueryService.summaryQueryDetail(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/accountTransactions")
    @ResponseBody
    @ApiOperation("内部订单查询--> 账户成交汇总 --> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<AccountTransactionQueryResult> accountTransactions(AccountTransactionQueryParam param, HttpServletRequest request) {
        return iQueryService.accountTransactions(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/accountExport")
    @ResponseBody
    @ApiOperation("内部订单查询--> 账户成交汇总 --> 导出 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult accountExport(AccountTransactionQueryParam param, HttpServletRequest request) {
        return iQueryService.accountExport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryInvestor")
    @ResponseBody
    @ApiOperation("内部订单查询--> 机构成交汇总 --> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<InvestorSumQueryResult> queryInvestorSum(InvestorSumQueryParam param, HttpServletRequest request) {
        return iQueryService.queryInvestorSum(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryGoodsTrade")
    @ResponseBody
    @ApiOperation("内部订单查询--> 商品成交汇总 --> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<GoodsTradeQueryResult> queryGoodsTrade(GoodsTradeQueryParam param, HttpServletRequest request) {
        return iQueryService.queryGoodsTrade(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryGoodsTradeExport")
    @ResponseBody
    @ApiOperation("内部订单查询--> 商品成交汇总 --> 导出 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult queryGoodsTradeExport(GoodsTradeQueryParam param, HttpServletRequest request) {
        return iQueryService.queryGoodsTradeExport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryTradeSum")
    @ResponseBody
    @ApiOperation("内部订单查询--> 成交汇总查询 --> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<TradeSumQueryResult> queryTradeSum(TradeSumQueryParam param, HttpServletRequest request) {
        return iQueryService.queryTradeSum(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/exportTradeSum")
    @ResponseBody
    @ApiOperation("内部订单查询--> 成交汇总查询 --> 导出列表 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult exportTradeSum(TradeSumQueryParam param, HttpServletRequest request) {
        return iQueryService.exportTradeSum(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryDeliveryOrder")
    @ResponseBody
    @ApiOperation("内部订单查询--> 交收委托查询 --> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<DeliveryOrderEntrustResult> queryDeliveryOrder(DeliveryOrderEntrustParam param, HttpServletRequest request) {
        return iQueryService.queryDeliveryOrder(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryWRStandard")
    @ResponseBody
    @ApiOperation("内部订单查询--> 交收委托查询 --> 获取现货商品 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<DeliveryOrderWrsResult> queryWRStandard(DeliveryOrderWrsParam param, HttpServletRequest request) {
        return iQueryService.queryWRStandard(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/deliveryOrderDetail")
    @ResponseBody
    @ApiOperation("内部订单查询--> 交收委托查询 --> 交收委托详情 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<DeliveryOrderDetailResult> deliveryOrderDetail(String deliveryorderid, String histradedate, HttpServletRequest request) {
        return iQueryService.deliveryOrderDetail(deliveryorderid, histradedate, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/querySettlementDeal")
    @ResponseBody
    @ApiOperation("内部订单查询--> 交收成交 --> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<SettlementDealResult> querySettlementDeal(SettlementDealParam param, HttpServletRequest request) {
        return iQueryService.querySettlementDeal(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/settlementDealDetail")
    @ResponseBody
    @ApiOperation("内部订单查询--> 交收成交 --> 交收成交详情 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<SettlementDealDetailResult> settlementDealDetail(SettlementDealDetailParam param, HttpServletRequest request) {
        return iQueryService.settlementDealDetail(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/applyOrderDetail")
    @ResponseBody
    @ApiOperation("内部订单查询--> 交收成交 --> 交收成交详情 --> 申报式委托单详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<ApplyOrderDetailResult> applyOrderDetail(String deliveryorderid ,String histradedate, HttpServletRequest request) {
        return iQueryService.applyOrderDetail(deliveryorderid,histradedate, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryoffline")
    @ResponseBody
    @ApiOperation("内部订单查询--> 线下交收单查询 --> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<OfflineDeliveryResult> queryoffline(OfflineDeliveryParam param, HttpServletRequest request) {
        return iQueryService.queryoffline(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/offlinedetail")
    @ResponseBody
    @ApiOperation("内部订单查询--> 线下交收单查询 --> 详情 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<OfflineDeliveryDetailResult> offlineDetail(String deliveryorderid, HttpServletRequest request) {
        return iQueryService.offlineDetail(deliveryorderid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/offlineclose")
    @ResponseBody
    @ApiOperation("内部订单查询--> 线下交收单查询 --> 确认交收 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult offlineclose(String deliveryorderid,Long marketid, HttpServletRequest request) {
        return iQueryService.offlineclose(deliveryorderid, marketid,request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/offlinefail")
    @ResponseBody
    @ApiOperation("内部订单查询--> 线下交收单查询 --> 交收失败 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult offlinefail(String deliveryorderid,Long marketid,String auditremark, HttpServletRequest request) {
        return iQueryService.offlinefail(deliveryorderid, marketid, auditremark,request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/sellGoods")
    @ResponseBody
    @ApiOperation("内部订单查询--> 线下交收单查询 --> 交收付款 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult sellGoods(String deliveryorderid,Long marketid, HttpServletRequest request) {
        return iQueryService.sellGoods(deliveryorderid, marketid,request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/offlineexport")
    @ResponseBody
    @ApiOperation("内部订单查询--> 线下交收单查询 --> 导出 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult offlineexport(OfflineDeliveryParam param, HttpServletRequest request) {
        return iQueryService.offlineexport(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryesignrecord")
    @ResponseBody
    @ApiOperation("内部订单查询--> 电子协议管理 --> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<EsignrecordQueryResult> queryesignrecord(EsignrecordQueryParam param, HttpServletRequest request) {
        return iQueryService.queryesignrecord(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/resetStatus")
    @ResponseBody
    @ApiOperation("其他查询--> 电子协议管理 --> 重新签署 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult resetStatus(Long recordid, HttpServletRequest request) {
        return iQueryService.changeStatus(recordid ,1, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/hasSigned")
    @ResponseBody
    @ApiOperation("其他查询--> 电子协议管理 --> 线下已签署 ")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult hasSigned(Long recordid, HttpServletRequest request) {
        return iQueryService.changeStatus(recordid,3, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryinvestor")
    @ResponseBody
    @ApiOperation("其他查询--> 交易商资金查询、机构资金查询--> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<InvestorQueryResult> queryinvestor(InvestorQueryParam param, HttpServletRequest request) {
        return iQueryService.queryinvestor(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryinvestortradeposition")
    @ResponseBody
    @ApiOperation("其他查询--> 交易商资金查询、机构资金查询- --> 持仓汇总 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<PositionSumSheetResult> queryinvestortradeposition(PositionSumSheetParam param, HttpServletRequest request) {
        return iQueryService.queryinvestortradeposition(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/holdtransferquery")
    @ResponseBody
    @ApiOperation("运营查询--> 协议转让--> 获取列表 ")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<HoldtransferQueryResult> holdtransferquery(HoldtransferQueryParam param, HttpServletRequest request) {
        return iQueryService.holdtransferquery(param, request);
    }
}
