package com.prolog.rdc.tms.controller;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.DriverledgerBillDTO;
import com.prolog.rdc.tms.model.dto.pay.BmsBillPayFeeDetailDTO;
import com.prolog.rdc.tms.model.dto.shipbill.BmsLogOperationDTO;
import com.prolog.rdc.tms.model.dto.shipbill.BmsShipBillDTO;
import com.prolog.rdc.tms.model.dto.shipbill.BmsShipBillDetailDTO;
import com.prolog.rdc.tms.model.dto.shipbill.BmsShipBillPackageDTO;
import com.prolog.rdc.tms.model.vo.DriverledgerBillPageVO;
import com.prolog.rdc.tms.model.vo.pay.BmsPayFeeAddVO;
import com.prolog.rdc.tms.service.DriverledgerBillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * 费用管理-司机台账控制层
 *
 * @className    :DriverledgerBillController
 * @author       :fanzw
 * @date         :2023/4/25
 * @description  :
 *
 * @version      :1.2.1
 *
 */
@RestController
@Api(tags = "费用管理-司机台账")
@RequestMapping("/driverledgerBill")
public class DriverledgerBillController {

    @Resource
    private DriverledgerBillService driverledgerBillService;

    @UserLog("司机台账查询")
    @ApiOperation(value = "司机台账查询", notes = "司机台账查询")
    @PostMapping("/page")
    public RestMessage<Page<DriverledgerBillDTO>> pageDriverledgerBillExecute(@RequestBody DriverledgerBillPageVO driverledgerBillPageVO) {
        try {
            return RestMessage.newInstance(true, "查询成功", driverledgerBillService.pageDriverledgerBillDate(driverledgerBillPageVO));
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("司机台账查看")
    @ApiOperation(value = "司机台账查看", notes = "司机台账查看")
    @PostMapping("/view")
    public RestMessage<DriverledgerBillDTO> viewDriverledgerBillExecute(@RequestParam("id") Long id) {
        try {
            return RestMessage.newInstance(true, "查询成功", driverledgerBillService.viewDriverledgerBillDate(id));
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("费用录入")
    @ApiOperation(value = "费用录入", notes = "费用录入")
    @PostMapping("/addFee")
    public RestMessage<String> addFeeExecute(@RequestBody BmsPayFeeAddVO bmsPayFeeAddVO) {
        try {
            driverledgerBillService.addFeeData(bmsPayFeeAddVO);
            return RestMessage.newInstance(true, "录入成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("运单信息查询")
    @ApiOperation(value = "运单信息查询", notes = "运单信息查询")
    @PostMapping("/listShipBill")
    public RestMessage<List<BmsShipBillDTO>> listShipBillExecute(@RequestParam("id") Long id) {
        try {
            return RestMessage.newInstance(true, "查询成功", driverledgerBillService.listShipBillData(id));
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("运单商品信息查询")
    @ApiOperation(value = "运单商品信息查询", notes = "运单商品信息查询")
    @PostMapping("/listItem")
    public RestMessage<List<BmsShipBillDetailDTO>> listItemExecute(@RequestParam("id") Long id) {
        try {
            return RestMessage.newInstance(true, "查询成功", driverledgerBillService.listItemData(id));
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("运单包裹信息查询")
    @ApiOperation(value = "运单包裹信息查询", notes = "运单包裹信息查询")
    @PostMapping("/listPackage")
    public RestMessage<List<BmsShipBillPackageDTO>> listPackageExecute(@RequestParam("id") Long id) {
        try {
            return RestMessage.newInstance(true, "查询成功", driverledgerBillService.listPackageData(id));
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("审批信息查询")
    @ApiOperation(value = "审批信息查询", notes = "审批信息查询")
    @PostMapping("/listAudit")
    public RestMessage<List<Object>> listAuditExecute(@RequestParam("id") Long id) {
        try {
            return RestMessage.newInstance(true, "查询成功", driverledgerBillService.listAuditData(id));
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("费用信息查询")
    @ApiOperation(value = "费用信息查询", notes = "费用信息查询")
    @PostMapping("/listFee")
    public RestMessage<List<BmsBillPayFeeDetailDTO>> listFeeExecute(@RequestParam("id") Long id) {
        try {
            return RestMessage.newInstance(true, "查询成功", driverledgerBillService.listFeeData(id));
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("费用信息提交")
    @ApiOperation(value = "费用信息提交", notes = "费用信息提交")
    @PostMapping("/submitFee")
    public RestMessage<String> submitFeeExecute(@RequestBody List<Long> idList) {
        try {
            driverledgerBillService.submitFeeData(idList);
            return RestMessage.newInstance(true, "提交成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("操作日志查询")
    @ApiOperation(value = "操作日志查询", notes = "操作日志查询")
    @PostMapping("/listLog")
    public RestMessage<List<BmsLogOperationDTO>> listLogExecute(@RequestParam("id") Long id) {
        try {
            return RestMessage.newInstance(true, "查询成功", driverledgerBillService.listLogData(id));
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("司机费用查询")
    @ApiOperation(value = "司机费用查询", notes = "司机费用查询")
    @PostMapping("/driveFee")
    public RestMessage<List<DriverledgerBillDTO>> queryDriverFeeByBillExecute(@RequestBody DriverledgerBillPageVO driverledgerBillPageVO) {
        try {
            return RestMessage.newInstance(true, "查询成功", driverledgerBillService.queryDriverFeeByBillData(driverledgerBillPageVO));
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

}