|
|
@@ -27,20 +27,39 @@ public class WeChatUtils {
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
- //待审核通知
|
|
|
- private static final String sptz="j7WH3EwQnxGxwuV2HwmJhryxySPE8vOiV5cVOpp-42I";
|
|
|
- //审核结通知
|
|
|
- private static final String jgtz="pWia-KJPFwDM8ReDu_BOa9FJn31VFc81bp3yxfBmIRI";
|
|
|
+ /**
|
|
|
+ * 公出待审核通知
|
|
|
+ */
|
|
|
+ private static final String PUBLIC_RELEASE_EXAMINE ="j7WH3EwQnxGxwuV2HwmJhryxySPE8vOiV5cVOpp-42I";
|
|
|
+ /**
|
|
|
+ * 公出审核结果通知
|
|
|
+ */
|
|
|
+ private static final String PUBLIC_RELEASE_EXAMINE_RESULT="pWia-KJPFwDM8ReDu_BOa9FJn31VFc81bp3yxfBmIRI";
|
|
|
+ /**
|
|
|
+ * 公出待审核通知
|
|
|
+ */
|
|
|
+ private static final String EXPENSE_RELEASE_EXAMINE ="0e2Te3WUa0fDPQnyE8TLmN_K06WLsB4fqm5qpo6npNo";
|
|
|
+ /**
|
|
|
+ * 公出审核结果通知
|
|
|
+ */
|
|
|
+ private static final String EXPENSE_RELEASE_EXAMINE_RESULT="rRPWzRcGY8BGwlk0xyjwR1RKdv3iRFXaU3bcK1300gw";
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推送地址
|
|
|
+ */
|
|
|
private static String send_url="https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param openid
|
|
|
+ * 推送微信订阅信息,跳转为公出信息
|
|
|
+ * @param openid 发送对象微信openid
|
|
|
* @param type 状态 0驳回 1发起 2同意
|
|
|
- * @param date
|
|
|
+ * @param date 日期
|
|
|
+ * @param aname 发送者名称
|
|
|
+ * @param remarks 发送信息,不能大于十五个字
|
|
|
*/
|
|
|
public Integer addNotice(String openid ,Integer type,Integer id, Date date, String aname,String remarks) {
|
|
|
Map<String, Object> map=new HashMap<String, Object>();
|
|
|
@@ -51,11 +70,43 @@ public class WeChatUtils {
|
|
|
map.put("page", "pages/egressDetails/index?id="+id);
|
|
|
map.put("miniprogram_state", wxState);
|
|
|
if (type==1) {
|
|
|
- map.put("template_id", sptz);
|
|
|
- map.put("data",getData(type,date, aname,remarks));
|
|
|
+ map.put("template_id", PUBLIC_RELEASE_EXAMINE);
|
|
|
+ map.put("data",getPublicData(type,date, aname,remarks));
|
|
|
+ }else {
|
|
|
+ map.put("template_id", PUBLIC_RELEASE_EXAMINE_RESULT);
|
|
|
+ map.put("data",getPublicData(type,date, aname,remarks));
|
|
|
+ }
|
|
|
+ JSONObject res=HttpUtils.httpPost(url, map);
|
|
|
+ if (res.get("errcode")!=null) {
|
|
|
+ return res.getInteger("errcode");
|
|
|
+ }else {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 推送微信订阅信息,跳转为报销信息
|
|
|
+ * @param openid 发送对象微信openid
|
|
|
+ * @param type 状态 0驳回 1发起 2同意
|
|
|
+ * @param date 日期
|
|
|
+ * @param aname 发送者名称
|
|
|
+ * @param remarks 发送信息,不能大于十五个字
|
|
|
+ */
|
|
|
+ public Integer addExpenseAccountWeChatNotice(String openid ,Integer type,Integer id, Date date, String aname,String remarks) {
|
|
|
+ Map<String, Object> map=new HashMap<String, Object>();
|
|
|
+ String accessToken=getAccessToken();
|
|
|
+ String url=send_url.replace("ACCESS_TOKEN", accessToken);
|
|
|
+ map.put("access_token", accessToken);
|
|
|
+ map.put("touser", openid);
|
|
|
+ //这里要替换成当前的
|
|
|
+ map.put("page", "pages/egressDetails/index?id="+id);
|
|
|
+ map.put("miniprogram_state", wxState);
|
|
|
+ if (type==1) {
|
|
|
+ map.put("template_id", EXPENSE_RELEASE_EXAMINE);
|
|
|
+ map.put("data",getExpenseData(type,date, aname,remarks));
|
|
|
}else {
|
|
|
- map.put("template_id", jgtz);
|
|
|
- map.put("data",getData(type,date, aname,remarks));
|
|
|
+ map.put("template_id", EXPENSE_RELEASE_EXAMINE_RESULT);
|
|
|
+ map.put("data",getExpenseData(type,date, aname,remarks));
|
|
|
}
|
|
|
JSONObject res=HttpUtils.httpPost(url, map);
|
|
|
if (res.get("errcode")!=null) {
|
|
|
@@ -65,9 +116,19 @@ public class WeChatUtils {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- private Map<String, Object> getData(Integer type,Date date, String aname, String remarks) {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 公出订阅消息组装
|
|
|
+ * @param type
|
|
|
+ * @param date
|
|
|
+ * @param aname
|
|
|
+ * @param remarks
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, Object> getPublicData(Integer type,Date date, String aname, String remarks) {
|
|
|
Map<String, Object> we=new HashMap<String, Object>();
|
|
|
String strDate=DateUtils.formatDate(date, AFTConstants.YMDHMS_CHINESE);
|
|
|
+ if (remarks.length()>20)remarks=remarks.substring(0,17)+"...";
|
|
|
if (type==1) {
|
|
|
Map<String, Object> v1=new HashMap<String, Object>();
|
|
|
v1.put("value",strDate);
|
|
|
@@ -99,6 +160,49 @@ public class WeChatUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 报销订阅消息组装
|
|
|
+ * @param type
|
|
|
+ * @param date
|
|
|
+ * @param aname
|
|
|
+ * @param remarks
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, Object> getExpenseData(Integer type,Date date, String aname, String remarks) {
|
|
|
+ Map<String, Object> we=new HashMap<String, Object>();
|
|
|
+ String strDate=DateUtils.formatDate(date, AFTConstants.YMDHMS_CHINESE);
|
|
|
+ if (remarks.length()>20)remarks=remarks.substring(0,17)+"...";
|
|
|
+ if (type==1) {
|
|
|
+ Map<String, Object> v2=new HashMap<String, Object>();
|
|
|
+ we.put("thing4", v2);
|
|
|
+ v2.put("value", aname);
|
|
|
+ Map<String, Object> v1=new HashMap<String, Object>();
|
|
|
+ we.put("time6", v1);
|
|
|
+ v1.put("value",strDate);
|
|
|
+ Map<String, Object> v3=new HashMap<String, Object>();
|
|
|
+ we.put("thing2", v3);
|
|
|
+ v3.put("value", remarks);
|
|
|
+ }else {
|
|
|
+ String thing5="";
|
|
|
+ if (type==0){
|
|
|
+ thing5="报销驳回";
|
|
|
+ }else if (type==2){
|
|
|
+ thing5="报销通过";
|
|
|
+ }
|
|
|
+ Map<String, Object> v1=new HashMap<String, Object>();
|
|
|
+ we.put("time3", v1);
|
|
|
+ v1.put("value",strDate);
|
|
|
+ Map<String, Object> v2=new HashMap<String, Object>();
|
|
|
+ we.put("thing5", v2);
|
|
|
+ v2.put("value", thing5);
|
|
|
+ Map<String, Object> v3=new HashMap<String, Object>();
|
|
|
+ we.put("thing4", v3);
|
|
|
+ v3.put("value", remarks);
|
|
|
+ }
|
|
|
+ return we;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
public String getAccessToken() {
|