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.ReceivableBalanceQueryParam;
import cn.superdesk.uniorder.dto.vo._statistics.ReceivableBalanceVO;
import cn.superdesk.uniorder.dubbo.consumer.statistics.StatisticsBalanceDubboService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * @author xc
 * @description
 * @date 2022/6/21 14:45
 */
@Api(value = "应收余额", tags = {"应收余额"})
@Slf4j
@RestController
@RequestMapping("/statistics/receivableBalance")
public class ReceivableBalanceController extends BaseController {

    @Autowired
    private StatisticsBalanceDubboService dubboStatisticsBalanceService;

    /**
     * 应收余额列表查询
     * @param param
     * @return
     */
    @PostMapping("/list")
    public R<ReceivableBalanceVO> getReceivableBalanceVOList(@RequestBody ReceivableBalanceQueryParam param) {
        log.info("应收余额列表查询, param: {}", param);

        return dubboStatisticsBalanceService.getReceivableBalanceVOList(param);
    }

    /**
     * 导出应收余额报表
     * @param param
     * @return
     */
    @PostMapping("/export")
    public R<String> exportExcelReceivableBalance(@RequestBody ReceivableBalanceQueryParam param) {
        log.info("导出应收余额报表, param : {}", param);
        return new R<>(dubboStatisticsBalanceService.exportExcelReceivableBalance(param,getToken()));
    }
}
