package com.ssj.framework.weixin.util;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;


/**
 * 微信小程序发送模板实体类
 *  * @param accessToken  token
 	 * @param openId  接收者（用户）的 openid
 	 * @param template_id   所需下发的模板消息的id
 	 * @param page  点击模板卡片后的跳转页面，仅限本小程序内的页面。支持带参数,（示例index?foo=bar）。该字段不填则模板无跳转
 	 * @param form_id  表单提交场景下，为 submit 事件带上的 formId；支付场景下，为本次支付的 prepay_id
 	 * @param data    data": {
						      "keyword1": {
						          "value": "339208499", 
						          "color": "#173177"
						      }, 
						      "keyword2": {
						          "value": "2015年01月05日 12:30", 
						          "color": "#173177"
						      }, 
						      "keyword3": {
						          "value": "粤海喜来登酒店", 
						          "color": "#173177"
						      } , 
						      "keyword4": {
						          "value": "广州市天河区天河路208号", 
						          "color": "#173177"
						      } 
						     } 
 	 * @param emphasis_keyword   模板需要放大的关键词，不填则默认无放大
 * @author DELL
 *
 */
public class WxSendTemplate implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3281036322452286238L;
	private String touser;  //OPENID 推送给用户 openid
	private String template_id; //模板ID
	private String page;//点击模板卡片后的跳转页面，仅限本小程序内的页面。支持带参数,（示例index?foo=bar）。该字段不填则模板无跳转
	private String form_id;//表单提交场景下，为 submit 事件带上的 formId；支付场景下，为本次支付的 prepay_id
	private String emphasis_keyword;//模板需要放大的关键词，不填则默认无放大
	
	private Map<String ,WxSendTemplateData> data;
	
	public WxSendTemplate() {
		super();
	}
	public WxSendTemplate(String touser, String template_id, String page,String emphasis_keyword,String form_id,Map<String,String> data) {
		super();
		this.touser = touser;
		this.template_id = template_id;
		this.page = page;
		this.form_id = form_id;
		this.emphasis_keyword = emphasis_keyword;
		Map<String, WxSendTemplateData>  map  =new  HashMap<String, WxSendTemplateData>();
		for (Map.Entry<String, String> entry : data.entrySet()) {
			String key = entry.getKey().toString();
			String value = entry.getValue().toString();
			WxSendTemplateData templateData = new WxSendTemplateData();
			templateData.setValue(value);
			templateData.setColor("#173177");
			map.put(key, templateData);
		 }
		this.data = map;
	}
	public WxSendTemplate(String touser, String template_id, String page,String form_id,Map<String,String> data,Map<String,String> valueAndColor) {
		super();
		this.touser = touser;
		this.template_id = template_id;
		this.page = page;
		this.form_id = form_id;
		Map<String, WxSendTemplateData>  map  =new  HashMap<String, WxSendTemplateData>();
		for (Map.Entry<String,String> entry : data.entrySet()) {
			String key = entry.getKey().toString();
			String value = entry.getValue().toString();
			WxSendTemplateData templateData = new WxSendTemplateData();
			templateData.setValue(value);
			templateData.setColor(valueAndColor.get(key)!=null ? valueAndColor.get(key):"#173177");
			map.put(key, templateData);
		}
		this.data = map;
	}
	
	public String getTouser() {
		return touser;
	}
	public void setTouser(String touser) {
		this.touser = touser;
	}
	public String getTemplate_id() {
		return template_id;
	}
	public void setTemplate_id(String template_id) {
		this.template_id = template_id;
	}
	public String getPage() {
		return page;
	}
	public void setPage(String page) {
		this.page = page;
	}
	public String getForm_id() {
		return form_id;
	}
	public void setForm_id(String form_id) {
		this.form_id = form_id;
	}
	public String getEmphasis_keyword() {
		return emphasis_keyword;
	}
	public void setEmphasis_keyword(String emphasis_keyword) {
		this.emphasis_keyword = emphasis_keyword;
	}
	public Map<String, WxSendTemplateData> getData() {
		return data;
	}
	public void setData(Map<String, WxSendTemplateData> data) {
		this.data = data;
	}
	
	

}
