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.ReceivableDetailDataQueryParam;
import cn.superdesk.uniorder.dto.param.accounting.statistics.ReceivableStatisticsPageQueryParam;
import cn.superdesk.uniorder.dto.vo._statistics.ReceivableStatisticsPageVo;
import cn.superdesk.uniorder.dto.vo._statistics.payable.PayableStatisticsPageVo;
import cn.superdesk.uniorder.dubbo.facade.thirdpart.qchjc.statistics.DubboReceivableStatisticsService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author xc
 * @description
 * @date 2022/4/14 20:07
 */
@Slf4j
@Component
public class ReceivableStatisticsDubboService {
    @Reference(version = "1.0.0", timeout = 30000, retries = -1)
    private DubboReceivableStatisticsService dubboReceivableStatisticsService;



    /**
     * 保存应用明细数据
     */
    public void saveReceivableDetailData(ReceivableDetailDataQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        dubboReceivableStatisticsService.saveReceivableDetailData(queryParam,loginSysUser);
    }

    /**
     * 应收明细数据定时任务到每日数据
     */
    public void saveReceivableDetailDataToDayData(ReceivableDetailDataQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        dubboReceivableStatisticsService.saveReceivableDetailDataToDayData(queryParam,loginSysUser);
    }

    public R<List<ReceivableStatisticsPageVo>> getReceivableStatisticsPageVoList(ReceivableStatisticsPageQueryParam queryParam) {
       return dubboReceivableStatisticsService.getReceivableStatisticsPageVoList(queryParam);
    }

    public String getReceivableStatisExcel(ReceivableStatisticsPageQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboReceivableStatisticsService.getReceivableStatisExcel(queryParam,loginSysUser);
    }



    /**
     * 保存应付明细数据
     */
    public void savePayableDetailData(ReceivableDetailDataQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        dubboReceivableStatisticsService.savePayableDetailData(queryParam,loginSysUser);
    }

    /**
     * 应付明细数据定时任务到每日数据
     */
    public void savePayableDetailDataToDayData(ReceivableDetailDataQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        dubboReceivableStatisticsService.savePayableDetailDataToDayData(queryParam,loginSysUser);
    }

    /**
     * 应付报表
     * @param queryParam
     * @return
     */
    public R<List<PayableStatisticsPageVo>> getPayableStatisticsPageVoList(ReceivableStatisticsPageQueryParam queryParam) {
        return dubboReceivableStatisticsService.getPayableStatisticsPageVoList(queryParam);
    }

    public String getPayableStatisExcel(ReceivableStatisticsPageQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboReceivableStatisticsService.getPayableStatisExcel(queryParam,loginSysUser);
    }




    /**
     * 积分结算_对账单状态变更为“已取消”时
     */
    public void receivableCancelAccounting(ReceivableDetailDataQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        dubboReceivableStatisticsService.receivableCancelAccounting(queryParam,loginSysUser);
    }


    /**
     * 实收_积分结算_对账单_回款状态变更为“已回款”时
     */
    public void receivableReturnedMoney(ReceivableDetailDataQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        dubboReceivableStatisticsService.receivableReturnedMoney(queryParam,loginSysUser);
    }






    /**
     * 实付_积分结算_对账单状态变更为“已取消”时
     */
    public void payableCancelAccounting(ReceivableDetailDataQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        dubboReceivableStatisticsService.payableCancelAccounting(queryParam,loginSysUser);
    }


    /**
     * 实付_积分结算_对账单_回款状态变更为“已回款”时
     */
    public void payableReturnedMoney(ReceivableDetailDataQueryParam queryParam,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        dubboReceivableStatisticsService.payableReturnedMoney(queryParam,loginSysUser);
    }


}
