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.carrier.reconciliation.CarrierReconciliationFeeDetailDTO;
import com.prolog.rdc.tms.model.dto.carrier.reconciliation.CarrierReconciliationShipBillDTO;
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.BmsShipBillDetailDTO;
import com.prolog.rdc.tms.model.vo.carrier.reconciliation.CarrierReconciliationOperateVO;
import com.prolog.rdc.tms.model.vo.carrier.reconciliation.CarrierReconciliationQueryVO;
import com.prolog.rdc.tms.service.BmsCarrierReconciliationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author hongbo.pan
 * @date 2023/4/13
 */
@RestController
@Api(tags = "BMS-承运商应付管理-对账管理")
@RequestMapping("/carrierreconciliation")
public class BmsCarrierReconciliationController {

    @Autowired
    private BmsCarrierReconciliationService service;

    @UserLog("运单模式查询")
    @ApiOperation(value = "运单模式查询", notes = "运单模式查询")
    @PostMapping("/findReconciliationShipBill")
    public RestMessage<Page<CarrierReconciliationShipBillDTO>> findReconciliationShipBill(@RequestBody @Valid CarrierReconciliationQueryVO vo) {
        return RestMessage.newInstance(true, "操作成功", service.findReconciliationShipBill(vo));
    }

    @UserLog("费用模式查询")
    @ApiOperation(value = "费用模式查询", notes = "费用模式查询")
    @PostMapping("/findReconciliationFeeDetail")
    public RestMessage<Page<CarrierReconciliationFeeDetailDTO>> findReconciliationFeeDetail(@RequestBody @Valid CarrierReconciliationQueryVO vo) {
        return RestMessage.newInstance(true, "操作成功", service.findReconciliationFeeDetail(vo));
    }

    @UserLog("商品明细查询")
    @ApiOperation(value = "商品明细查询", notes = "商品明细查询")
    @PostMapping("/getItem")
    public RestMessage<List<BmsShipBillDetailDTO>> getItem(@RequestParam("id") Long id) {
        return RestMessage.newInstance(true, "操作成功", service.getItem(id));
    }

    @UserLog("审核日志")
    @ApiOperation(value = "审核日志", notes = "审核日志")
    @PostMapping("/getAudit")
    public RestMessage<List<Object>> getAudit(@RequestParam("id") Long id) {
        return RestMessage.newInstance(true, "操作成功", service.getAudit(id));
    }

    @UserLog("费用明细")
    @ApiOperation(value = "费用明细", notes = "费用明细")
    @PostMapping("/getDetail")
    public RestMessage<List<BmsBillPayFeeDetailDTO>> getDetail(@RequestParam("id") Long id) {
        return RestMessage.newInstance(true, "操作成功", service.getDetail(id));
    }

    @UserLog("操作日志")
    @ApiOperation(value = "操作日志", notes = "操作日志")
    @PostMapping("/getLog")
    public RestMessage<List<BmsLogOperationDTO>> getLog(@RequestParam("id") Long id) {
        return RestMessage.newInstance(true, "操作成功", service.getLog(id));
    }

    @UserLog("对账提交")
    @ApiOperation(value = "对账提交", notes = "对账提交")
    @PostMapping("/submit")
    public RestMessage<Object> submit(@RequestBody @Valid CarrierReconciliationOperateVO vo) {
        service.submit(vo);
        return RestMessage.newInstance(true, "操作成功", null);
    }

    @UserLog("对账确认")
    @ApiOperation(value = "对账确认", notes = "对账确认")
    @PostMapping("/confirm")
    public RestMessage<Object> confirm(@RequestBody @Valid CarrierReconciliationOperateVO vo) {
        service.confirm(vo);
        return RestMessage.newInstance(true, "操作成功", null);
    }
}