package com.gree.mall.miniapp.controller.settle;

import com.gree.mall.miniapp.bean.settle.repair.DailyReportBean;
import com.gree.mall.miniapp.bean.settle.repair.DailyWorkerIssueSalaryBean;
import com.gree.mall.miniapp.helper.ResponseHelper;
import com.gree.mall.miniapp.logic.settle.DailyMyWalletLogic;
import com.gree.mall.miniapp.plus.entity.SettleDailyIssueSummaryMonthRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(value = "维修日结算我的钱包", tags = {"维修日结算我的钱包"})
@RequestMapping(value = "/daily/mywallet", produces = "application/json; charset=utf-8")
public class DailyMyWalletController {

    @Autowired
    DailyMyWalletLogic dailyMyWalletLogic;

    @GetMapping("/issue/list")
    @ApiOperation(value = "已发放-日报")
    public ResponseHelper<List<DailyReportBean>> issueList(
            @ApiParam(required = true, value = "师傅编号") @RequestParam String workerNumber,
            @ApiParam(required = false, value = "查询日期") @RequestParam(required = false) String date,
            @ApiParam(required = false, value = "false=维修费用 true=安装费用") @RequestParam(required = false) Boolean install
    ) {
        List<DailyReportBean> list = dailyMyWalletLogic.issueList(workerNumber, date, install);
        return ResponseHelper.success(list);
    }

    @GetMapping("/repair/detail")
    @ApiOperation(value = "维修费用明细/详情")
    public ResponseHelper<List<DailyWorkerIssueSalaryBean>> queryMyOrderList(
            @ApiParam(required = true, value = "师傅编号") @RequestParam String workerNumber,
            @ApiParam(required = true, value = "工资条编号") @RequestParam String salaryNo,
            @ApiParam(value = "工单号、用户名称(模糊)") @RequestParam(required = false) String q,
            @ApiParam(value = "id") @RequestParam(required = false) String id
    ) {
        List<DailyWorkerIssueSalaryBean> list = dailyMyWalletLogic.queryMyOrderList(workerNumber, salaryNo, id, q);
        return ResponseHelper.success(list);
    }

    @GetMapping("/issue/monthlist")
    @ApiOperation(value = "已发放-月结")
    public ResponseHelper<List<SettleDailyIssueSummaryMonthRecord>> issueMonthList(
            @ApiParam(required = true, value = "师傅编号") @RequestParam String workerNumber,
            @ApiParam(value = "查询月份") @RequestParam(required = false) String date,
            @ApiParam(value = "false=维修费用 true=安装费用") @RequestParam(required = false) Boolean install
    ) {
        List<SettleDailyIssueSummaryMonthRecord> list = dailyMyWalletLogic.issueMonthList(workerNumber, date);
        return ResponseHelper.success(list);
    }

    @GetMapping("/not/issue/list")
    @ApiOperation(value = "未发放明细/详情-日报")
    public ResponseHelper<List<DailyWorkerIssueSalaryBean>> notIssueList(
            @ApiParam(required = true, value = "师傅编号") @RequestParam String workerNumber,
            @ApiParam(value = "id") @RequestParam(required = false) String id,
            @ApiParam(value = "工单号、用户名称") @RequestParam(required = false) String q,
            @ApiParam(value = "false=维修费用 true=安装费用") @RequestParam(required = false) Boolean install

    ) {
        List<DailyWorkerIssueSalaryBean> list = dailyMyWalletLogic.notIssueList(workerNumber, id, q, install);
        return ResponseHelper.success(list);
    }

    @GetMapping("/repair/month/detail")
    @ApiOperation(value = "维修费用月结明细/详情")
    public ResponseHelper<List<DailyWorkerIssueSalaryBean>> queryMyOrderMonthList(
            @ApiParam(required = true, value = "师傅编号") @RequestParam String workerNumber,
            @ApiParam(required = true, value = "月度汇总批次号") @RequestParam String summaryBatchNo,
            @ApiParam(value = "id") @RequestParam(required = false) String id,
            @ApiParam(value = "工单号、用户名称") @RequestParam(required = false) String q
    ) {
        List<DailyWorkerIssueSalaryBean> list = dailyMyWalletLogic.queryMyOrderMonthList(workerNumber, summaryBatchNo, id, q);
        return ResponseHelper.success(list);
    }

}
