package com.muchinfo.mtp3century.controller;

import com.muchinfo.mtp3century.service.ISettlementService;
import com.muchinfo.mtp3century.utils.AjaxResult;
import com.muchinfo.mtp3common.vo.PageResult;
import com.muchinfo.mtp3pojos.entity.ReckonDaydividecount;
import com.muchinfo.mtp3pojos.vo.settlement.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartHttpServletRequest;

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

@RestController
@RequestMapping("/settlement")
@Api(value = "结算API", description = "结算管理")
public class SettlementController {

    @Resource
    private ISettlementService iSettlementService;

    @ApiOperation("结算管理-->二级分润付款确认-->获取列表(tradedate时间格式yyyymmdd,reletype = 1 areatype传null)")
    @RequestMapping(method = RequestMethod.GET, value = "/sharedayquery")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    private PageResult<SecondProfitSharResult> sharedayquery(String tradedate, Integer areatype, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        return iSettlementService.sharedayquery(tradedate, areatype, pageNum, pageSize, request);
    }

    @ApiOperation("结算管理-->二级分润付款确认-->导出(交易所管理员才有此功能)")
    @RequestMapping(method = RequestMethod.GET, value = "/export")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    private AjaxResult export(String tradedate, HttpServletRequest request) {
        return iSettlementService.export(tradedate, request);
    }

    @ApiOperation("结算管理-->二级分润付款确认-->查看交易日详情")
    @RequestMapping(method = RequestMethod.GET, value = "/viewTradingDay")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    private PageResult<SecondProfitSharDetailResult> view(SecondProfitSharDetailParam param, HttpServletRequest request) {
        return iSettlementService.view(param, request);
    }

    @ApiOperation("结算管理-->二级分润付款确认-->查看交易日详情-->详情")
    @RequestMapping(method = RequestMethod.GET, value = "/detail")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    private AjaxResult<ReckonDaydividecount> detail(String tradedate, Integer areatype, Long areaid, HttpServletRequest request) {
        return iSettlementService.detail(tradedate, areatype, areaid, request);
    }

    @ApiOperation("结算管理-->二级分润付款确认-->查看交易日详情-->批量确认")
    @RequestMapping(method = RequestMethod.GET, value = "/batchPay")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    private AjaxResult batchPay(String areaids, Integer tradedate, HttpServletRequest request) {
        return iSettlementService.batchPay(areaids, tradedate, request);
    }

    @ApiOperation("结算管理-->持仓过户-->获取列表")
    @RequestMapping(method = RequestMethod.GET, value = "/positiontransferquery")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    private PageResult<PositionTransferQueryResult> positiontransferquery(PositionTransferQueryParam param, HttpServletRequest request) {
        return iSettlementService.positiontransferquery(param, request);
    }

    @ApiOperation("结算管理-->持仓过户-->详情")
    @RequestMapping(method = RequestMethod.GET, value = "/positiontransferdetail")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    private AjaxResult<PositionTransferQueryResult> positiontransferdetail(String applyid, HttpServletRequest request) {
        return iSettlementService.positiontransferdetail(applyid, request);
    }

    @ApiOperation("结算管理-->持仓过户-->批量导入-->导入")
    @RequestMapping(method = RequestMethod.GET, value = "/batchimport")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    private AjaxResult<PositionTransferImport> batchimport(MultipartHttpServletRequest request) {
        return iSettlementService.batchimport(request);
    }

    @ApiOperation("结算管理-->持仓过户-->批量导入-->保存")
    @RequestMapping(method = RequestMethod.POST, value = "/saveimport")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    private AjaxResult saveimport(@RequestBody List<PositionTransferImport> param, HttpServletRequest request) {
        return iSettlementService.saveimport(param,request);
    }
}
