package cn.superdesk.uniorder.dubbo.consumer.statistics;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dto.param.accounting.statistics.PayableBalanceQueryParam;
import cn.superdesk.uniorder.dto.param.accounting.statistics.ReceivableBalanceQueryParam;
import cn.superdesk.uniorder.dto.vo._statistics.ReceivableBalanceVO;
import cn.superdesk.uniorder.dto.vo._statistics.payable.PayableBalanceVO;
import cn.superdesk.uniorder.dubbo.facade.thirdpart.qchjc.statistics.DubboStatisticsBalanceService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author xc
 * @description
 * @date 2022/6/22 09:28
 */
@Slf4j
@Component
public class StatisticsBalanceDubboService {

    @Reference(version = "1.0.0", timeout = 30000, retries = -1)
    private DubboStatisticsBalanceService dubboStatisticsBalanceService;


    /**
     * 应收余额列表查询
     * @param param
     * @return
     */
    public R<ReceivableBalanceVO> getReceivableBalanceVOList(ReceivableBalanceQueryParam param) {
        return dubboStatisticsBalanceService.getReceivableBalanceVOList(param);
    }

    /**
     * 应付余额列表查询
     * @param param
     * @return
     */
    public R<PayableBalanceVO> getPayableBalanceVOList(PayableBalanceQueryParam param) {
        return dubboStatisticsBalanceService.getPayableBalanceVOList(param);
    }

    /**
     * 导出应收余额报表
     * @param param
     * @param token
     * @return
     */
    public String exportExcelReceivableBalance(ReceivableBalanceQueryParam param, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboStatisticsBalanceService.exportExcelReceivableBalance(param,loginSysUser);
    }

    /**
     * 导出应付余额报表
     * @param param
     * @param token
     * @return
     */
    public String exportExcelPayableBalance(PayableBalanceQueryParam param, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboStatisticsBalanceService.exportExcelPayableBalance(param,loginSysUser);
    }
}
