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

import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.marketing.department.UnifiedAreaCity;
import cn.superdesk.uniorder.dao.entity.marketing.department.UnifiedAreaCityVirt;
import cn.superdesk.uniorder.dto.vo._function.select.SelectOptionAreaItem;
import cn.superdesk.uniorder.dto.vo._function.select.SelectOptionVirt;
import cn.superdesk.uniorder.dto.vo.marketing.department.*;
import cn.superdesk.uniorder.dubbo.facade.marketing.department.DubboUnifiedAreaService;
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;


@Slf4j
@Component
public class UnifiedAreaDubboConsumerService {

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


	public List<UnifiedAreaWeb> getweb(String token, Map<String, Object> params) {

		return dubboUnifiedAreaService.getweb(params);
	}

	public Map<String, Object> addNew(String token, UnifiedAreaParam param) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		return dubboUnifiedAreaService.addNew(param, loginSysUser);
	}

	/**
	 * 区域管理-设定 区域 客户经理是谁,采购专家是谁？每月指标是怎样
	 *
	 * @param token
	 * @param param
	 * @return
	 */
	public Map<String, Object> updateNew(String token, UnifiedAreaParam param) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		return dubboUnifiedAreaService.updateNew(param, loginSysUser);
	}

	public List<UnifiedAreaCityTargetVo> getTargetAll(String token, Map<String, Object> params) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		return dubboUnifiedAreaService.getAreaCityTargetAll(params);
	}

	public List<SelectOptionVirt> getVirtNotInArea(Map<String, Object> params) {

		return dubboUnifiedAreaService.getVirtNotInArea(params);
	}

	public void updateAreaVirt(Long areaItemId, Long virtId, String type) {

		dubboUnifiedAreaService.updateAreaVirt(areaItemId, virtId, type);
	}

	public void delItemTran(Long areaItemId) {

		dubboUnifiedAreaService.delItemTran(areaItemId);
	}


	public List<SelectOptionAreaItem> findAreaItemSelect(Map<String, Object> params) {

		return dubboUnifiedAreaService.findAreaItemSelect(params);
	}

	public List<UnifiedAreaTJ> getareatj(Map<String, Object> params) {

		return dubboUnifiedAreaService.getareatj(params);
	}

	public UnifiedAreaCityWithVirt getAreaDetailByVirtId(Long virtId) {
		return dubboUnifiedAreaService.getAreaDetailByVirtId(virtId);
	}

	public List<UnifiedAreaCity> findAll(Map<String, Object> queryMap) {
		return dubboUnifiedAreaService.findAll(queryMap);
	}

	public UnifiedAreaCity addObj(UnifiedAreaCity areaCityAdd) {
		return dubboUnifiedAreaService.addObj(areaCityAdd);
	}

	public void addAreaVirt(UnifiedAreaCityVirt addareaCityVirt) {
		dubboUnifiedAreaService.addAreaVirt(addareaCityVirt);
	}
}
