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.settlement.CarrierSettlementManagementDTO;
import com.prolog.rdc.tms.model.dto.pay.BmsBillPayFeeDetailDTO;
import com.prolog.rdc.tms.model.dto.shipbill.BmsLogOperationDTO;
import com.prolog.rdc.tms.model.vo.carrier.settlement.CarrierSettlementManagementQueryVO;
import com.prolog.rdc.tms.model.vo.carrier.settlement.CarrierSettlementManagementUpdateVO;
import com.prolog.rdc.tms.service.BmsCarrierSettlementManagementService;
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/6/30
 */
@RestController
@Api(tags = "BMS-承运商应付管理-结算管理")
@RequestMapping("/carrierSettlementManagement")
public class BmsCarrierSettlementManagementController {

    @Autowired
    private BmsCarrierSettlementManagementService settlementManagementService;

    @UserLog("结算单信息")
    @ApiOperation(value = "结算单信息", notes = "结算单信息")
    @PostMapping("/findByCondition")
    public RestMessage<Page<CarrierSettlementManagementDTO>> findByCondition(@RequestBody CarrierSettlementManagementQueryVO vo) {
        return RestMessage.newInstance(true, "查询成功", settlementManagementService.findByCondition(vo));
    }

    @UserLog("结算单详情")
    @ApiOperation(value = "结算单详情", notes = "结算单详情")
    @PostMapping("/detail")
    public RestMessage<CarrierSettlementManagementDTO> detail(@RequestParam Long id) {
        return RestMessage.newInstance(true, "操作成功", settlementManagementService.detail(id));
    }

    @UserLog("结算单费用信息")
    @ApiOperation(value = "结算单费用信息", notes = "结算单费用信息")
    @PostMapping("/getFeeDetail")
    public RestMessage<List<BmsBillPayFeeDetailDTO>> getFeeDetail(@RequestParam Long id) {
        return RestMessage.newInstance(true, "操作成功", settlementManagementService.getFeeDetail(id));
    }

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

    @UserLog("结算单更新")
    @ApiOperation(value = "结算单更新", notes = "结算单更新")
    @PostMapping("/update")
    public RestMessage update(@RequestBody @Valid CarrierSettlementManagementUpdateVO vo) {
        settlementManagementService.update(vo);
        return RestMessage.newInstance(true, "操作成功", null);
    }

    @UserLog("结算单审核")
    @ApiOperation(value = "结算单审核", notes = "结算单审核")
    @PostMapping("/audit")
    public RestMessage audit(@RequestBody List<Long> idList) {
        settlementManagementService.audit(idList);
        return RestMessage.newInstance(true, "操作成功", null);
    }

    @UserLog("结算单作废")
    @ApiOperation(value = "结算单作废", notes = "结算单作废")
    @PostMapping("/invalid")
    public RestMessage invalid(@RequestBody List<Long> idList) {
        settlementManagementService.invalid(idList);
        return RestMessage.newInstance(true, "操作成功", null);
    }
}