package com.yifu.cloud.plus.v1.yifu.common.dapr.util;

import com.alibaba.fastjson.JSON;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSocialProperties;
import com.yifu.cloud.plus.v1.yifu.salary.vo.HaveSalaryNoSocialSearchVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.HaveSalaryNoSocialVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.UpdateSocialFoundVo;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import java.util.List;

/**
 * @Author fxj
 * @Date 2022-07-18
 * @Description
 * @Version 1.0
 */
@Log4j2
@EnableConfigurationProperties(DaprSocialProperties.class)
public class SocialDaprUtils {

	@Autowired
	private DaprSocialProperties daprProperties;

	/**
	 * @Author fxj
	 * @Description 去缴费库查询查询这些人社保是否存在
	 * @Date 17:38 2022/8/16
	 * @Param
	 * @return
	**/
	public R<HaveSalaryNoSocialVo> getPaymentinfoListByEmpdIdCard(List<String> idCards, String settleMonth) {
		HaveSalaryNoSocialSearchVo searchVo = new HaveSalaryNoSocialSearchVo();
		searchVo.setIdCards(idCards);
		searchVo.setSettleMonth(settleMonth);
		R<HaveSalaryNoSocialVo> noSocialVoR = HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tpaymentinfo/inner/listByEmpdIdCard", JSON.toJSONString(searchVo), HaveSalaryNoSocialVo.class, SecurityConstants.FROM_IN);
		if (Common.isEmpty(noSocialVoR)){
			return R.failed("查询人员社保是否存在失败！");
		}
		return noSocialVoR;
	}

	/**
	 * @Author huyc
	 * @Description 去缴费库查询查询这些人社保是否存在
	 * @Date 17:38 2022/8/15
	 * @Param
	 * @return
	 **/
	public void updatePaymentSocialAndFound(UpdateSocialFoundVo infoVo) {
		HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tpaymentinfo/inner/updatePaymentSocialAndFound", JSON.toJSONString(infoVo), UpdateSocialFoundVo.class, SecurityConstants.FROM_IN);
	}

	/**
	 * @Author huyc
	 * @Description 去缴费库查询查询这些人社保是否存在
	 * @Date 17:38 2022/8/15
	 * @Param
	 * @return
	 **/
	public void updateForSocialAndFound(UpdateSocialFoundVo infoVo) {
		HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tpaymentinfo/inner/updateForSocialAndFound", JSON.toJSONString(infoVo), UpdateSocialFoundVo.class, SecurityConstants.FROM_IN);
	}

	/**
	 * @Author huyc
	 * @Description 去缴费库查询查询这些人社保是否存在
	 * @Date 17:38 2022/8/15
	 * @Param
	 * @return
	 **/
	public void updateSocialAndFoundInfo(UpdateSocialFoundVo infoVo) {
		HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/tsocialfundinfo/inner/updateSocialAndFoundInfo", JSON.toJSONString(infoVo), UpdateSocialFoundVo.class, SecurityConstants.FROM_IN);
	}
}
