package com.weaver.seconddev.chapanda.test;

import com.alibaba.fastjson.JSONObject;

import java.util.*;

public class test55 {

    public static void main(String[] args) {

        String template_id = "AAqzqvWng9VIK";
        String template_version_name = "1.0.2";
        String openId = "ou_8ff7816cfa8cda57643cac2a06fbdc7e";
        List<String> defaultList = new ArrayList<String>();
        defaultList.add("templateId");
        defaultList.add("templateVersionName");
        defaultList.add("receiveId");
        JSONObject templateVariable = new JSONObject();

        Map<String,Object> paraMap = new HashMap<String,Object>();
        paraMap.put("hr_gongsi","百茶百道");
        paraMap.put("hr_zzdate","2025-07-04");
        paraMap.put("hr_name","羊多多5");
        paraMap.put("hr_gongsi1","百茶百道");
        Iterator<Map.Entry<String, Object>> iterator = paraMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, Object> entry = iterator.next();
            String key = entry.getKey();
            String value = entry.getValue().toString();
            if(!defaultList.contains(key)){
                templateVariable.put(key,value);
            }
        }

//            templateVariable.put("name,","石磊");
//            templateVariable.put("current_date,",sdf.format(new Date()));

        JSONObject data_Json = new JSONObject();
        data_Json.put("template_id",template_id);
        data_Json.put("template_version_name",template_version_name);
        data_Json.put("template_variable",templateVariable);

        JSONObject contentJson = new JSONObject();
        contentJson.put("type","template");
        contentJson.put("data",data_Json);

        JSONObject bodyJson = new JSONObject();
        bodyJson.put("receive_id",openId);
        bodyJson.put("msg_type","interactive");
        bodyJson.put("content", contentJson.toJSONString());
        String uuid = UUID.randomUUID().toString();
        bodyJson.put("uuid", uuid);

       System.out.println("bodyJson:{}"+bodyJson.toJSONString());
    }
}
