package cn.com.ctop.toutiao.modules.agent.controller;


import cn.com.ctop.toutiao.modules.agent.service.AgentManagementService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

@RestController
@RequestMapping("/agent")
@Slf4j
public class AgentManagementController {

    @Autowired
    AgentManagementService agentManagementService;


    @RequestMapping("/queryAccountTransactionDetails")
    public void getList(@Param("starDate") String startDate, @Param("endDate") String endDate) {
        Result recharge = agentManagementService.synchronousAccountTransactionDetails(startDate, endDate);

    }

    @RequestMapping("/synchronousAccount")
    public void synchronousAccount() {
        Result recharge = agentManagementService.synchronousAccount();
    }


    @RequestMapping("/synchronousAccountTransactionDay")
    public void synchronousAccountTransactionDay(@Param("starDate") String startDate, @Param("endDate") String endDate) {
        Result recharge = agentManagementService.synchronousAccountTransactionDay(startDate, endDate);
    }

    @RequestMapping("/insertAccountTransactionDay")
    public void insertAccountTransactionDay(String startDate, String endDate) {
        agentManagementService.insertAccountTransactionDay(startDate, endDate);
    }


    @RequestMapping("/insertAccountTransactionDayByProjectId")
    public void insertAccountTransactionDayByProjectId(Long projectId, String startDate, String endDate) {
        agentManagementService.insertAccountTransactionDayByProjectId(projectId, startDate, endDate);
    }


    @RequestMapping("/synchronous")
    public void synchronous() throws ParseException {
        String date1 = "2021-05-01";
        String date2 = "2021-05-31";
        String date3 = "2021-06-01";
        String date4 = "2021-06-30";
        String date5 = "2021-07-01";
        String date6 = "2021-07-31";
        String date7 = "2021-08-01";
        String date8 = "2021-08-31";
        agentManagementService.synchronousAccount();
        //5月份
        agentManagementService.synchronousAccountTransactionDetails(date1, date2);
        agentManagementService.synchronousAccountTransactionDay(date1, date2);
        //6月份
        agentManagementService.synchronousAccountTransactionDetails(date3, date4);
        agentManagementService.synchronousAccountTransactionDay(date3, date4);
        //7月份
        agentManagementService.synchronousAccountTransactionDetails(date5, date6);
        agentManagementService.synchronousAccountTransactionDay(date5, date6);
        //8月份
        agentManagementService.synchronousAccountTransactionDetails(date7, date8);
        agentManagementService.synchronousAccountTransactionDay(date7, date8);
    }


}
