package org.jeecg.ctop.finance.settlement.controller;

import cn.com.ctop.common.module.service.ISysUserService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.entity.SysUser;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.DateUtils;
import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;


/**
 * 导出 结算单 利润表
 * Administrator
 * 2021/7/28
 **/

@Slf4j
@RestController
@RequestMapping("/exportReportController")
public class ExportReportController {

    @Autowired
    private IReportSettlementService reportSettlementService;
    @Autowired
    private ISysUserService userService;

    //结算单-日期修改-master
    @ApiOperation(value = "财务结算-结算单导出-头条", notes = "财务结算-结算单导出-头条")
    @GetMapping(value = "/settlementReportBytedance")
    public Result settlementReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) throws Exception {
        SysUser user = userService.getById(paramsVo.getUserId());
        String date = paramsVo.getStartTime();
        if (null == date || date.equals("")) {
            return Result.errorMsg("请选择日期");
        }
        return reportSettlementService.settlementReportBytedance(paramsVo, response, user);
    }


    @ApiOperation(value = "财务结算-结算单导出-快手", notes = "财务结算-结算单导出-快手")
    @GetMapping(value = "/settlementReportKuaiShou")
    public Result settlementReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
        SysUser user = userService.getById(paramsVo.getUserId());
        String date = paramsVo.getStartTime();
        if (null == date || date.equals("")) {
            return Result.errorMsg("请选择日期");
        }
        return reportSettlementService.settlementReportKuaiShou(paramsVo, response, user);
    }


    @ApiOperation(value = "财务结算-利润表导出-头条", notes = "财务结算-利润表导出-头条")
    @GetMapping(value = "/porfitReportBytedance")
    public Result porfitReportBytedance(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
        return reportSettlementService.porfitReportBytedance(paramsVo, response);
    }


    @ApiOperation(value = "财务结算-利润表导出-快手", notes = "财务结算-利润表导出-快手")
    @GetMapping(value = "/porfitReportKuaiShou")
    public Result porfitReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
        return reportSettlementService.porfitReportKuaiShou(paramsVo, response);
    }


    @ApiOperation(value = "财务结算-给运营发送消息", notes = "财务结算-给运营发送消息")
    @GetMapping(value = "/sendMessageToOperate")
    public Result sendMessageToOperate() {
        return reportSettlementService.sendMessageToOperate();
    }

    @ApiOperation(value = "财务结算-给运营发送消息-demo", notes = "财务结算-给运营发送消息-demo")
    @GetMapping(value = "/sendMessageToOperateDemo")
    public Result sendMessageToOperateDemo(@RequestParam(value = "userId", required = false) String userId) {
        return reportSettlementService.sendMessageToOperateDemo(userId);

    }


}