package cn.superdesk.uniorder.dubbo.consumer.operationCenter.customer;

import cn.superdesk.uniorder.common.exception.UnifiedOrderRuntimeException;
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.operationCenter.customer.OpCenterCustomerOperatorOrgParam;
import cn.superdesk.uniorder.dto.param.operationCenter.customer.OperationCenterCustomerParam;
import cn.superdesk.uniorder.dto.param.operationCenter.customer.OperationCenterCustomerSaveParam;
import cn.superdesk.uniorder.dto.vo.operationCenter.base.OperationCenterVo;
import cn.superdesk.uniorder.dto.vo.operationCenter.customer.OperationCenterCustomerVo;
import cn.superdesk.uniorder.dto.vo.operationCenter.customer.OperationCenterPaymentCustomerVo;
import cn.superdesk.uniorder.dubbo.facade.operationCenter.customer.DubboOperationCenterCustomerService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Author : zx
 * @Create : 2023/4/11 09:46
 * Description :
 */
@Slf4j
@Component
public class OperationCenterCustomerDubboService {
    @Reference(version = "1.0.0", timeout = 30000, retries = -1)
    private DubboOperationCenterCustomerService dubboOperationCenterCustomerService;

    public R<List<OperationCenterCustomerVo>> getOperationCenterCustomerList(OperationCenterCustomerParam param) {
        return dubboOperationCenterCustomerService.getOperationCenterCustomerList(param);
    }

    public R<String> saveOperationCenterCustomer(OperationCenterCustomerSaveParam param,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboOperationCenterCustomerService.saveOperationCenterCustomer(param,loginSysUser.getSysUserId());
    }

    public R<OperationCenterCustomerVo> getOperationCenterCustomerById(Long id) {
        R<OperationCenterCustomerVo> result=new R<>();
         result.setData(dubboOperationCenterCustomerService.getOperationCenterCustomerById(id));
         return result;
    }

    public R<String> deleteOperationCenterCustomerById(Long id) {
        return dubboOperationCenterCustomerService.deleteOperationCenterCustomerById(id);
    }

    public R<List<OperationCenterVo>> selectAllCustomerIdAndName() {
        return dubboOperationCenterCustomerService.selectAllCustomerIdAndName();
    }

    public R<List<OperationCenterPaymentCustomerVo>> findAll(OperationCenterCustomerParam param) {
        return dubboOperationCenterCustomerService.findAll(param);
    }

    public R<String> linkOperatorAndOrg(OpCenterCustomerOperatorOrgParam param,String token) {
        LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
        return dubboOperationCenterCustomerService.linkOperatorAndOrg(param,loginSysUser.getSysUserId());
    }

    public R<OpCenterCustomerOperatorOrgParam> linkOperatorAndOrgByCustomerId(String customerId)  {
        return dubboOperationCenterCustomerService.linkOperatorAndOrgByCustomerId(customerId);
    }
}
