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

import com.alibaba.fastjson.JSON;
import com.yifu.cloud.plus.v1.ekp.vo.EkpSocialPushInfoVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprEkpProperties;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpPushFundParam;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpPushSocialParam;
import com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpSalaryParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import java.util.List;

/**
 * @Author huyc
 * @Date 2024-02-28
 * @Description
 * @Version 1.0
 */
@Log4j2
@EnableConfigurationProperties(DaprEkpProperties.class)
public class EkpDaprUtils {

	@Autowired
	private DaprEkpProperties daprProperties;

	/**
	 * @Author huyc
	 * @Description 新增社保明细数据
	 * @Date 16:18 2024/02/28
	 * @Param
	 * @return
	 **/
	public R<EkpSocialPushInfoVo> pushSocialInfoToEkp(List<EkpPushSocialParam> unPushList) {
		return HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/ekpSocialPush/inner/pushSocialInfoToEkp", JSON.toJSONString(unPushList), EkpSocialPushInfoVo.class, SecurityConstants.FROM_IN);
	}

	/**
	 * @Author huyc
	 * @Description 新增公积金明细数据
	 * @Date 10:22 2024/03/06
	 * @Param
	 * @return
	 **/
	public R<EkpSocialPushInfoVo> pushFundInfoToEkp(List<EkpPushFundParam> unPushList) {
		return HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/ekpFundPush/inner/pushFundInfoToEkp", JSON.toJSONString(unPushList), EkpSocialPushInfoVo.class, SecurityConstants.FROM_IN);
	}

	/**
	 * @Author huyc
	 * @Description 新增工资明细数据
	 * @Date 10:23 2024/03/11
	 * @Param
	 * @return
	 **/
	public R<Boolean> pushSalaryInfoToEkp(List<EkpSalaryParam> unPushList) {
		return HttpDaprUtil.invokeMethodPost(daprProperties.getAppUrl(),daprProperties.getAppId(),"/ekpSalaryPush/inner/pushSalaryInfoToEkp", JSON.toJSONString(unPushList), Boolean.class, SecurityConstants.FROM_IN);
	}
}
