package com.palmnest.application;

import com.palmnest.application.core.util.PropertiesKit;
import org.apache.http.client.CookieStore;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Constant values used throughout the application.
 *
 * @author <a href="mailto:chasel.java@gmail.com">Chasel Li</a>
 */
public class Constants {
	/**
	 * The name of the ResourceBundle used in this application
	 */
	public static final String BUNDLE_KEY = "ApplicationResources";

	/**
	 * File separator from System properties
	 */
	public static final String FILE_SEP = System.getProperty("file.separator");

	/**
	 * User home from System properties
	 */
	public static final String USER_HOME = System.getProperty("user.home") + FILE_SEP;

	/**
	 * The name of the configuration hashmap stored in application scope.
	 */
	public static final String CONFIG = "appConfig";

	/**
	 * Session scope attribute that holds the locale set by the user. By setting this key
	 * to the same one that Struts uses, we get synchronization in Struts w/o having
	 * to do extra work or have two session-level variables.
	 */
	public static final String PREFERRED_LOCALE_KEY = "org.apache.struts2.action.LOCALE";

	/**
	 * The request scope attribute under which an editable user form is stored
	 */
	public static final String USER_KEY = "userForm";

	/**
	 * The request scope attribute that holds the user list
	 */
	public static final String USER_LIST = "userList";

	/**
	 * The request scope attribute for indicating a newly-registered user
	 */
	public static final String REGISTERED = "registered";

	/**
	 * The name of the Administrator role, as specified in web.xml
	 */
	public static final String ADMIN_ROLE = "ROLE_ADMIN";

	/**
	 * The name of the User role, as specified in web.xml
	 */
	public static final String USER_ROLE = "ROLE_USER";

	/**
	 * The name of the user's role list, a request-scoped attribute
	 * when adding/editing a user.
	 */
	public static final String USER_ROLES = "userRoles";

	/**
	 * The name of the available roles list, a request-scoped attribute
	 * when adding/editing a user.
	 */
	public static final String AVAILABLE_ROLES = "availableRoles";

	/**
	 * The name of the CSS Theme setting.
	 *
	 * @deprecated No longer used to set themes.
	 */
	public static final String CSS_THEME = "csstheme";

	public static final int LIMIT_PAGESIZE = 10;

	//获取消息令牌URL--有效期-2个小时
	public static final String ACCESSTOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential";

	public static final String STABLE_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/stable_token";
	// 下载多媒体接口URL
	public static final String GET_MEDIA_URL   = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=";

	//发送客户消息服务地址
	public static final String MESSAGE_URL = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=";

	//创建自定义菜单服务地址
	public static final String CREATEMENU_URL = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=";

	//查询自定义菜单服务地址
	public static final String GETMENU_URL = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=";

	//删除自定义菜单服务地址
	public static final String DELEMENU_URL = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=";

	//用户基本资料
	public static final String USER_INFO_URI = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=";

	//网页授权获取用户信息
	public static final String OATH2_URL = "https://api.weixin.qq.com/sns/oauth2/access_token";

	//jsapi_ticket
	public static final String JSAPI_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=";

	//模板消息发送
	public static final String TEMPLATE_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";

	//客服消息
	public static final String SERVICE_URL = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=";

	/**
	 * 获取富士康的openId的接口
	 */
	public static final String FOXCONN_URL = "http://civetInterface.foxconn.com/open/access_token";

	public static final String FOXCONN_APPID = "CBac1EORQqU1";
	public static final String REPAIR_TYPE_CODE = "repairTypeGroup";

//	public static Map<String, String>      CacheMap                 = new ConcurrentHashMap<String, String>(); //内存缓存集合
	public static Map<String, Object>      WechatPropertiesCacheMap = new ConcurrentHashMap<String, Object>(); //内存缓存集合
	public static Map<String, CookieStore> FaceMap                  = new ConcurrentHashMap<String, CookieStore>(); //内存缓存集合
//
	public static Map<String, Integer> CacheNeigouOrderMap = new ConcurrentHashMap<String, Integer>(); //内存缓存集合 保存内购订单数据
	
	public static String JSAPI="jsapi_";
	public static String JSAPI_ACCESS_TOKEN="jsapi_access_token";
	public static int TOKEN_TIME=7200;
	public static       String IMAGE_ROOT        = PropertiesKit.readPropertiesValue("attachment.root", "wechat.properties"); // 前端访问路径
	public static final String SERVER_ADDRESS    = PropertiesKit.readPropertiesValue("webUrl", "wechat.properties");
	public static final String SERVER_SINGLE_URL = PropertiesKit.readPropertiesValue("serverKey", "wechat.properties");
	public static final String IMAGE_ADDRESS     = PropertiesKit.readPropertiesValue("image_server", "wechat.properties");
	
	public static final String DATABASE    = PropertiesKit.readPropertiesValue("database", "wechat.properties");

	/*系统业务类型，目前这里统一定义控制*/
	public static final String AccountType_USER    = "1";                //业主
	public static final String AccountType_EMP     = "2";                //员工
	public static final String AccountType_AFFAIRS = "3";                //商户

	/**
	 * 用户类型
	 */
	public static final String USER_TYPE                = "userType";    //用户类型
	public static final int    USER_TYPE_ADMIN          = 1; //admin
	public static final int    USER_TYPE_SYSTEM_MANAGE  = 2; //系统管理员
	public static final int    USER_TYPE_PROJECT_MANAGE = 3; //项目管理员
	public static final int    USER_TYPE_GENERAL_MANAGE = 4; //普通管理员
	public static final int    USER_TYPE_GENERAL_USER   = 5; //普通用户

	/**
	 * 数据来源
	 */
	public static final String FROM_TYPE = "fromType";    //数据来源


	/**
	 * 是否确认
	 */
	public static final String IS_CONFIRM = "isConfirm";    //是否确认

	/**
	 * 是否绑定
	 */
	public static final String IS_BIND = "ISBIND_TYPE";

	/**
	 * 未绑定
	 */
	public static final String UNBINDING = "0";                //未绑定
	/**
	 * 已绑定
	 */
	public static final String BINDING   = "1";                //已绑定

	/**
	 * 公众号类型(订阅号与服务号)
	 */
	public static final String DevelopType = "DevelopType";    //信息类型

	/**
	 * 公众号状态
	 */
	public static final String STATE_TYPE = "STATE_TYPE";


	/**
	 * 单条图片/文字/语音
	 */
	public static final String PIC_TEXT_VOICE_TYPE = "1";                //单条图片/文字/语音
	/**
	 * 图文
	 */
	public static final String PIC_AND_WORD        = "2";                //图文


	public static final String TB_DICTIONARY_GROUP = "tb_dictionary_group";// 数据字典组
	public static final String TB_DICTIONARY_ITEM  = "tb_dictionary_item";// 数据字典项

	public static final String ADMIN_NAME = "admin";

	public static final String NOTICETYPE_NOTICE   = "1";
	public static final String NOTICETYPE_ACTIVITY = "2";

	public static int PAGELIMIT = 6;    //翻页默认条数 客户端

	//菜单EventKey值
	public static final String Key_Repairs  = "V1001_1002";        //报修
	public static final String Key_Complain = "V1001_1003";        //投诉

	public static final String InFo_TYPE_NORMAL = "1";                //普通消息
	public static final String InFo_TYPE_EVENT  = "2";                //事件消息

	public static final String Event_TYPE_SUBSCRIBE = "1";                //关注
	public static final String Event_TYPE_SCAN      = "2";                //二维码
	public static final String Event_TYPE_MENU      = "3";                //下拉菜单

	public static final int MAX_TEXT_LEN = 15; //列表中字符串显示字数，大于此字数用“...”代替

	public static String IMAGE_SERVER = PropertiesKit.readPropertiesValue("image_server", "wechat.properties"); // 前端访问路径

	public static String FACE_PLUS_USER = PropertiesKit.readPropertiesValue("facePlusUser", "app.properties");//face++授权用户

	public static String FACE_PLUS_PASSWORD = PropertiesKit.readPropertiesValue("facePlusPassword", "app.properties");//face++授权密码
	
	public static String KOALOA_PLUS_URL = "http://skaola.superdesk.cn:8888";//face++授权用户
	
	public static String KOALOA_PLUS_USER = "qingzhangyin@avic-s.com";//face++授权用户

	public static String KOALOA_PLUS_PASSWORD = "Ac123456";//face++授权密码

	public static String FACE_PLUS_CLIENT_URL = PropertiesKit.readPropertiesValue("facePlusClientUrl", "app.properties");//face++授权密码

	public static String FACE_PLUS_CLIENT_IMAGE_URL = PropertiesKit.readPropertiesValue("facePlusClientImageUrl", "app.properties");//face++授权密码

	/**
	 * 客户端接口请求 状态
	 */
	public static final String RESULT_FIAL = "0"; // 请求失败
	public static final String RESULT_SUCC = "1"; // 请求成功

	public static final String RESULTCODE_SUCC         = "200";// 成功码
	public static final String RESULTCODE_EXCEPTION    = "505";// 系统异常
	public static final String RESULTCODE_NODATA       = "101";// 无数据
	public static final String RESULTCODE_PARAMINVALID = "202";// 无效参数
	public static final String RESULTCODE_ILLEGAL      = "503"; // 非法请求(安全验证，参数验证)
	public static final String RESULTCODE_LG_FAILED    = "1000";// 登录失败码（用户名或者密码错误）
	public static final String RESULTCODE_MOBILE_EXIST = "1001";// 该用户号码已经注册过

	public static String SSOID = "SSOID_";

	/**
	 * HTTP 提交方式 "post"
	 */
	public static final String METHOD_POST = "POST";
	/**
	 * HTTP 提交方式 "get"
	 */
	public static final String METHOD_GET  = "GET";

	public static final Integer DOOR_ID                    = 6;//门禁ID  1
	public static final String  VISITOR_ORDER_TYPE_USER    = "1";//员工
	public static final String  VISITOR_ORDER_TYPE_VISTOR  = "2";//访客
	public static final String  VISITOR_ORDER_TYPE_THREE   = "3";// 访客自己在公众号发起的预约
	public static final String  VISITOR_ORDER_TYPE_MACHINE = "4";// 访客机预约
	public static final String  VISITOR_ORDER_TYPE_PC = "5";// pc访客登记
	public static final Integer VISITOR_ORDER_STATUS_OK    = 1;//正常
	public static final Integer VISITOR_ORDER_STATUS_ZEROR = 0;//未授权
	public static final Integer VISITOR_ORDER_STATUS_ERROR = 2;//通过
	public static final String  VISITOR_ORDER_STATUS       = "1";//通过
	public static final String  VISITOR_ONE_STATUS         = "1";//审核中
	public static final String  VISITOR_TWO_STATUS         = "2";//通过
	public static final String  VISITOR_TREE_STATUS        = "3";//失败

	public static String OAUTHOR_OPENID_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=val1&secret=val2&code=val3&grant_type=authorization_code";

	/**
	 * 接收 facePlus 登录返回的结果
	 */
	public static CookieStore COOKIE_STORE = null;


	/**
	 * 流量充值用户编号
	 */
	public static String NAME = "10212";

	/**
	 * 流量充值用户编号
	 */
	public static String VERSION = "1.7";

	/**
	 * 流量充值用户编号
	 */
	public static String ASK_URL = "http://120.76.98.95/";

	/**
	 * 流量充值签名
	 */
	public static String SIGN = "yP91KGfdxy2+QyP5l/aRR8+R97M=";

	/**
	 * 流量充值端口
	 */
	public static String PORT = "80";

	/**
	 * 请求方式
	 */
	public static String POST = "POST";

	/**
	 * 失败标示code
	 */
	public static String FAIL_FLAG    = "fail";
	/**
	 * 成功标示code
	 */
	public static String SUCCESS_FLAG = "success";

	/**
	 * 服务模块活跃
	 */
	public static final String MODULE_ACTIVE = "moduleActive";

	/**
	 * 用户活跃
	 */
	public static final String USER_ACTIVE = "userActive";
}