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.product.core.tools.util.JsonMapper;
import com.prolog.rdc.tms.model.dto.SettlementOrderDTO;
import com.prolog.rdc.tms.model.dto.ShipBillFeeDetail;
import com.prolog.rdc.tms.model.dto.ShipBillFeeDetailDTO;
import com.prolog.rdc.tms.model.entity.BmsLogOperationModel;
import com.prolog.rdc.tms.model.vo.PayAmountQueryVO;
import com.prolog.rdc.tms.service.PayAmountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

@RestController
@Api(tags = "付款管理")
@RequestMapping("/pay")
public class PayAmountController {

    private final Logger logger = LoggerFactory.getLogger(PayAmountController.class);

    @Autowired
    private PayAmountService payAmountService;

    @UserLog("付款管理-列表查询")
    @ApiOperation(value = "付款管理-列表查询", notes = "付款管理-列表查询")
    @PostMapping("/findList")
    public RestMessage<Page<SettlementOrderDTO>> findList(@RequestBody @Valid PayAmountQueryVO vo) {
        logger.info("- > findList vo={}", JsonMapper.toJsonString(vo));
        Page<SettlementOrderDTO> page = payAmountService.findList(vo);
        return RestMessage.newInstance(true, "操作成功", page);
    }

    @UserLog("付款管理-费用查询")
    @ApiOperation(value = "付款管理-费用查询", notes = "付款管理-费用查询")
    @PostMapping("/findListForFee")
    public RestMessage<List<ShipBillFeeDetailDTO>> findListForFee(@RequestParam("id") Long id) {
        logger.info("- > findListForFee vo={}", JsonMapper.toJsonString(id));
        List<ShipBillFeeDetailDTO> page = payAmountService.findListForFee(id);
        return RestMessage.newInstance(true, "操作成功", page);
    }

    @UserLog("付款管理-日志查询")
    @ApiOperation(value = "付款管理-日志查询", notes = "付款管理-日志查询")
    @PostMapping("/findListForLog")
    public RestMessage<List<BmsLogOperationModel>> findListForLog(@RequestParam("id") Long id) {
        logger.info("- > findListForLog vo={}", JsonMapper.toJsonString(id));
        List<BmsLogOperationModel> page = payAmountService.findListForLog(id);
        return RestMessage.newInstance(true, "操作成功", page);
    }
}