package thyyxxk.webserver.controller.reports;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.datamodify.YzActOrder;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.reports.illegalchargesanalysis.IllegalChargeData;
import thyyxxk.webserver.entity.reports.illegalchargesanalysis.IllegalChargeTemplate;
import thyyxxk.webserver.entity.reports.illegalchargesanalysis.SearchChargeItem;
import thyyxxk.webserver.service.reports.IllegalChargesAnalysisService;

import java.math.BigDecimal;
import java.util.List;

/**
 * @description: 违规收费分析控制器
 * @author: DingJie
 * @create: 2021-04-15 16:45:08
 **/
@RestController
@RequestMapping("/illegalChargesAnalysis")
public class IllegalChargesAnalysisController {
    private final IllegalChargesAnalysisService service;

    @Autowired
    public IllegalChargesAnalysisController(IllegalChargesAnalysisService service) {
        this.service = service;
    }

    @GetMapping("/fetchMyTemplates")
    public ResultVo<List<IllegalChargeTemplate>> fetchMyTemplates() {
        return service.fetchMyTemplates();
    }

    @PostMapping("/insertNewTemplate")
    public ResultVo<String> insertNewTemplate(@RequestBody IllegalChargeTemplate template) {
        return service.insertNewTemplate(template);
    }

    @PostMapping("/deleteTemplate")
    public ResultVo<String> deleteTemplate(@RequestBody IllegalChargeTemplate template) {
        return service.deleteTemplate(template);
    }

    @PostMapping("/searchChargeItem")
    public ResultVo<List<CodeName>> searchChargeItem(@RequestBody SearchChargeItem param) {
        return service.searchChargeItem(param);
    }

    @PostMapping("/saveTemplateChanges")
    public ResultVo<String> saveTemplateChanges(@RequestBody IllegalChargeTemplate template) {
        return service.saveTemplateChanges(template);
    }

    @PostMapping("/analyzeTargetData")
    public ResultVo<List<IllegalChargeData>> analyzeTargetData(@RequestBody IllegalChargeTemplate template) {
        return service.analyzeTargetData(template);
    }

    @GetMapping("/selectOrderPair")
    public ResultVo<List<YzActOrder>> selectOrderPair(@RequestParam("orderNo") BigDecimal orderNo,
                                                      @RequestParam("conflictOrderNo") BigDecimal conflictOrderNo) {
        return service.selectOrderPair(orderNo, conflictOrderNo);
    }

    @PostMapping("/queryHuanZheLiangCiRuYuanRiQi")
    public ResultVo<List<IllegalChargeData>> queryHuanZheLiangCiRuYuanRiQi(@RequestBody IllegalChargeTemplate param) {
        return service.queryHuanZheLiangCiRuYuanRiQi(param);
    }

    @GetMapping("/chaXunHuanZheZhuYuanJianGe")
    public ResultVo<List<IllegalChargeData>> chaXunHuanZheZhuYuanJianGe(@RequestParam("startTime") String startTime,
                                                                        @RequestParam("endTime") String endTime,
                                                                        @RequestParam("tianShu") Integer tianShu) {
        return service.chaXunHuanZheZhuYuanJianGe(startTime, endTime, tianShu);
    }
}
