package cn.superdesk.uniorder.dubbo.consumer.accounting.operator;

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.unified.operator.AccountingUnifiedOperatorQueryParam;
import cn.superdesk.uniorder.dto.vo.accounting.unified.operator.*;
import cn.superdesk.uniorder.dubbo.facade.accounting.operator.DubboAccountingUnifiedOperatorService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.*;

@Slf4j
@Component
public class AccountingUnifiedOperatorDubboConsumerService {

    @Reference(version = "1.0.1", timeout = 60000, retries = -1)
    private DubboAccountingUnifiedOperatorService dubboAccountingUnifiedOperatorService;

    public R<List<AccountingUnifiedOperatorVo>> getList(AccountingUnifiedOperatorQueryParam param){
        return dubboAccountingUnifiedOperatorService.getList(param);
    }

    public R<AccountingBillVo> getById(Long id){
        return dubboAccountingUnifiedOperatorService.getById(id);
    }

    public String exportList(AccountingUnifiedOperatorQueryParam param, LoginSysUser loginSysUser){
        return dubboAccountingUnifiedOperatorService.exportList(param,loginSysUser);
    }

    public String exportAccountList(AccountingUnifiedOperatorQueryParam param, LoginSysUser loginSysUser){
        return dubboAccountingUnifiedOperatorService.exportAccountList(param,loginSysUser);
    }

    public String exportAccountSupplierList(AccountingUnifiedOperatorQueryParam param, LoginSysUser loginSysUser){
        return dubboAccountingUnifiedOperatorService.exportAccountSupplierList(param,loginSysUser);
    }

    public R<AccountingBillBaseVo> getBaseBillInfo(AccountingUnifiedOperatorQueryParam param) {
       return dubboAccountingUnifiedOperatorService.getBaseBillInfo(param.getBillId());
    }

    public R<String> confirmBill(AccountingUnifiedOperatorQueryParam param,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboAccountingUnifiedOperatorService.confirmBill(param.getBillId(),param.getAccountingOrderSn(),loginSysUser.getSysUserId());
    }

    public R<String> cancelBill(AccountingUnifiedOperatorQueryParam param, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboAccountingUnifiedOperatorService.cancelBill(param,loginSysUser.getSysUserId());
    }

    public R<String> rejectBill(AccountingUnifiedOperatorQueryParam param, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboAccountingUnifiedOperatorService.rejectBill(param,loginSysUser.getSysUserId());
    }

    public R<String> saveRemark(AccountingUnifiedOperatorQueryParam param, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboAccountingUnifiedOperatorService.saveRemark(param,loginSysUser.getSysUserId());
    }

    public R<String> agreeReject(AccountingUnifiedOperatorQueryParam param, String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboAccountingUnifiedOperatorService.agreeReject(param,loginSysUser.getSysUserId());
    }
}
