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.CarrierSettlementFeeDetailDTO;
import com.prolog.rdc.tms.model.entity.BmsPaySettlementModel;
import com.prolog.rdc.tms.model.vo.carrier.settlement.CarrierSettlementQueryVO;
import com.prolog.rdc.tms.model.vo.carrier.settlement.CarrierSettlementVO;
import com.prolog.rdc.tms.service.BmsCarrierSettlementService;
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.RestController;

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

/**
 * @author hongbo.pan
 * @date 2023/5/4
 */
@RestController
@Api(tags = "BMS-承运商应付管理-费用结算")
@RequestMapping("/carrierSettlement")
public class BmsCarrierSettlementController {

    @Autowired
    private BmsCarrierSettlementService settlementService;

    @UserLog("费用信息")
    @ApiOperation(value = "费用信息", notes = "费用信息")
    @PostMapping("/findSettlementFeeDetail")
    public RestMessage<Page<CarrierSettlementFeeDetailDTO>> findSettlementFeeDetail(@RequestBody CarrierSettlementQueryVO vo) {
        return RestMessage.newInstance(true, "查询成功", settlementService.findSettlementFeeDetail(vo));
    }

    @UserLog("费用结算")
    @ApiOperation(value = "费用结算", notes = "费用结算")
    @PostMapping("/feeSettlement")
    public RestMessage<Object> feeSettlement(@RequestBody @Valid CarrierSettlementVO vo) {
        settlementService.feeSettlement(vo);
        return RestMessage.newInstance(true, "操作成功", null);
    }

    @UserLog("结算单初始化")
    @ApiOperation(value = "结算单初始化", notes = "结算单初始化")
    @PostMapping("/initPaySettlement")
    public RestMessage<BmsPaySettlementModel> initPaySettlement(@RequestBody List<Long> feeDetailIdList) {
        return RestMessage.newInstance(true, "操作成功", settlementService.initPaySettlement(feeDetailIdList));
    }

}