package com.qunzhixinxi.hnqz.common.ding.entity;


import com.qunzhixinxi.hnqz.common.ding.config.DingConfig;
import com.qunzhixinxi.hnqz.common.ding.sign.AccessSign;
import com.qunzhixinxi.hnqz.common.ding.utils.JsonUtils;
import com.qunzhixinxi.hnqz.common.ding.utils.SignUtils;
import lombok.Data;

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

@Data
public class EmployPayRequest extends CommonRequest{

	private static final String PATH = "/oapi/v1/employ/freelances/pay";


	/**
	 * bizType
	 *	79 软件开发服务
		66 信息系统服务
		77 技术咨询划服务
		30 市场推广服务
		70 其他咨询服务
		203 现场辅助服务
	 **/

	/**
	 *
	 * @param config
	 * @param subjectName
	 * @param statementNo
	 * @param statementName
	 * @param bizType
	 * @param list
	 */
	public EmployPayRequest(
			DingConfig config,
			String subjectName,
			String statementNo,
			String statementName,
			Integer bizType,
			List list) {

		Map<String,Object> map = new HashMap<>();
		map.put("subjectName",subjectName);
		map.put("statementNo",statementNo);
		map.put("statementName",statementName);
		map.put("bizType",bizType);
		map.put("freelances",list);
		String bodyStr = JsonUtils.serializer(map);
		String serviceSign = null;
		try {
			//签名
			serviceSign = SignUtils.serviceSign(PATH, config.getAppSecret(),
					"POST", new HashMap<>(), bodyStr.getBytes());
		} catch (Exception e) {
			e.printStackTrace();
		}

		this.body = bodyStr;
		this.sign = new AccessSign(config.getAppId(),serviceSign);
		this.queryUrl = String.format("%s%s", config.getQueryUrl(), PATH);
	}


}
