package cn.superdesk.uniorder.controller._statistics;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.controller.base.BaseController;
import cn.superdesk.uniorder.dto.param.accounting.statistics.PayableBalanceQueryParam;
import cn.superdesk.uniorder.dto.vo._statistics.payable.PayableBalanceVO;
import cn.superdesk.uniorder.dubbo.consumer.statistics.StatisticsBalanceDubboService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * @author xc
 * @description
 * @date 2022/6/21 14:47
 */
@Api(value = "应付余额", tags = {"应付余额"})
@Slf4j
@RestController
@RequestMapping("/statistics/payableBalance")
@RequiredArgsConstructor
public class PayableBalanceController extends BaseController {

    private final StatisticsBalanceDubboService statisticsBalanceDubboService;


    /**
     * 应付余额列表查询
     *
     * @param param
     * @return
     */
    @PostMapping("/list")
    public R<PayableBalanceVO> getPayableBalanceVOList(@RequestBody PayableBalanceQueryParam param) {
        log.info("应付余额列表查询, param: {}", param);

        return statisticsBalanceDubboService.getPayableBalanceVOList(param);
    }

    /**
     * 导出应付余额报表
     *
     * @param param
     * @return
     */
    @PostMapping("/export")
    public R<String> exportExcelPayableBalance(@RequestBody PayableBalanceQueryParam param) {
        log.info("应付余额列表查询, param: {}", param);
        return new R<>(statisticsBalanceDubboService.exportExcelPayableBalance(param, getToken()));
    }
}
