|
@@ -95,6 +95,21 @@ public class WxLoginService implements IWxLoginService {
|
|
|
@Value("${wx.gzh.studyNoteTpId}")
|
|
|
private String studyNoteTpId;
|
|
|
|
|
|
+ @Value("${wx.gzh.qdyTpId}")
|
|
|
+ private String qdyTpId;
|
|
|
+
|
|
|
+ @Value("${wx.gzh.qdySubTpId}")
|
|
|
+ private String qdySubTpId;
|
|
|
+
|
|
|
+ @Value("${wx.gzh.qdySubStatusTpId}")
|
|
|
+ private String qdySubStatusTpId;
|
|
|
+
|
|
|
+ @Value("${wx.gzh.qdyExamTpId}")
|
|
|
+ private String qdyExamTpId;
|
|
|
+
|
|
|
+ @Value("${wx.gzh.qdyExamStatusTpId}")
|
|
|
+ private String qdyExamStatusTpId;
|
|
|
+
|
|
|
private String gzh_wxTokenUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
|
|
|
|
|
private String gzh_wxTokenParam = "grant_type=client_credential&appid=%s&secret=%s";
|
|
@@ -546,6 +561,256 @@ public class WxLoginService implements IWxLoginService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String sendQdyTpMsg(String openId, Map<String, String> paramMap) {
|
|
|
+ String accessToken = getWxSmallAccessToken();
|
|
|
+ if (Validator.isEmpty(accessToken)) {
|
|
|
+ throw new CustomException("小程序accessToken 错误");
|
|
|
+ }
|
|
|
+ String param = String.format(small_wxSendTpParam, accessToken);
|
|
|
+ String url = small_wxSendTpUrl + "?" + param;
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ JSONObject mp_template_msg = new JSONObject();
|
|
|
+ JSONObject miniprogram = new JSONObject();
|
|
|
+
|
|
|
+ obj.put("touser", openId);
|
|
|
+ paramMap.put("access_token", accessToken);
|
|
|
+ mp_template_msg.put("appid", gzh_appid);
|
|
|
+ mp_template_msg.put("template_id", qdyTpId);
|
|
|
+ mp_template_msg.put("url", "http://weixin.qq.com/download"); //公众号模板消息所要跳转的url
|
|
|
+ miniprogram.put("appid", appid); //公众号模板消息所要跳转的小程序appid,小程序的必须与公众号具有绑定关系
|
|
|
+ miniprogram.put("pagepath", paramMap.get("pagepath")); //公众号模板消息所要跳转的小程序页面
|
|
|
+ mp_template_msg.put("miniprogram", miniprogram);
|
|
|
+ Map<String, TemplatData> mapdata = new LinkedHashMap<>();
|
|
|
+ // 封装模板数据
|
|
|
+ TemplatData first = new TemplatData();
|
|
|
+ first.setValue(paramMap.get("first"));
|
|
|
+ first.setColor("#173177");
|
|
|
+ mapdata.put("first", first);
|
|
|
+
|
|
|
+ TemplatData keyword1 = new TemplatData();
|
|
|
+ keyword1.setValue(paramMap.get("keyword1"));
|
|
|
+ keyword1.setColor("#000000");
|
|
|
+ mapdata.put("keyword1", keyword1);
|
|
|
+
|
|
|
+ TemplatData keyword2 = new TemplatData();
|
|
|
+ keyword2.setValue(paramMap.get("keyword2"));
|
|
|
+ keyword2.setColor("#000000");
|
|
|
+ mapdata.put("keyword2", keyword2);
|
|
|
+
|
|
|
+ TemplatData remark = new TemplatData();
|
|
|
+ remark.setValue("↓点我去上课~");
|
|
|
+ remark.setColor("#173177");
|
|
|
+ mapdata.put("remark", remark);
|
|
|
+
|
|
|
+
|
|
|
+ mp_template_msg.put("data", mapdata);
|
|
|
+ obj.put("mp_template_msg", mp_template_msg);
|
|
|
+
|
|
|
+ String result = HttpUtils.sendPost(url, obj);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String sendQdySubTpMsg(String openId, Map<String, String> paramMap) {
|
|
|
+ String accessToken = getWxSmallAccessToken();
|
|
|
+ if (Validator.isEmpty(accessToken)) {
|
|
|
+ throw new CustomException("小程序accessToken 错误");
|
|
|
+ }
|
|
|
+ String param = String.format(small_wxSendTpParam, accessToken);
|
|
|
+ String url = small_wxSendTpUrl + "?" + param;
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ JSONObject mp_template_msg = new JSONObject();
|
|
|
+ JSONObject miniprogram = new JSONObject();
|
|
|
+
|
|
|
+ obj.put("touser", openId);
|
|
|
+ paramMap.put("access_token", accessToken);
|
|
|
+ mp_template_msg.put("appid", gzh_appid);
|
|
|
+ mp_template_msg.put("template_id", qdySubTpId);
|
|
|
+ mp_template_msg.put("url", "http://weixin.qq.com/download"); //公众号模板消息所要跳转的url
|
|
|
+ miniprogram.put("appid", appid); //公众号模板消息所要跳转的小程序appid,小程序的必须与公众号具有绑定关系
|
|
|
+ miniprogram.put("pagepath", paramMap.get("pagepath")); //公众号模板消息所要跳转的小程序页面
|
|
|
+ mp_template_msg.put("miniprogram", miniprogram);
|
|
|
+ Map<String, TemplatData> mapdata = new LinkedHashMap<>();
|
|
|
+ // 封装模板数据
|
|
|
+ TemplatData first = new TemplatData();
|
|
|
+ first.setValue(paramMap.get("first"));
|
|
|
+ first.setColor("#173177");
|
|
|
+ mapdata.put("first", first);
|
|
|
+
|
|
|
+ TemplatData keyword1 = new TemplatData();
|
|
|
+ keyword1.setValue(paramMap.get("keyword1"));
|
|
|
+ keyword1.setColor("#000000");
|
|
|
+ mapdata.put("keyword1", keyword1);
|
|
|
+
|
|
|
+ TemplatData keyword2 = new TemplatData();
|
|
|
+ keyword2.setValue(paramMap.get("keyword2"));
|
|
|
+ keyword2.setColor("#000000");
|
|
|
+ mapdata.put("keyword2", keyword2);
|
|
|
+
|
|
|
+ TemplatData remark = new TemplatData();
|
|
|
+ remark.setValue("↓点我去上课~");
|
|
|
+ remark.setColor("#173177");
|
|
|
+ mapdata.put("remark", remark);
|
|
|
+
|
|
|
+
|
|
|
+ mp_template_msg.put("data", mapdata);
|
|
|
+ obj.put("mp_template_msg", mp_template_msg);
|
|
|
+
|
|
|
+ String result = HttpUtils.sendPost(url, obj);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String sendQdySubStatusTpMsg(String openId, Map<String, String> paramMap) {
|
|
|
+ String accessToken = getWxSmallAccessToken();
|
|
|
+ if (Validator.isEmpty(accessToken)) {
|
|
|
+ throw new CustomException("小程序accessToken 错误");
|
|
|
+ }
|
|
|
+ String param = String.format(small_wxSendTpParam, accessToken);
|
|
|
+ String url = small_wxSendTpUrl + "?" + param;
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ JSONObject mp_template_msg = new JSONObject();
|
|
|
+ JSONObject miniprogram = new JSONObject();
|
|
|
+
|
|
|
+ obj.put("touser", openId);
|
|
|
+ paramMap.put("access_token", accessToken);
|
|
|
+ mp_template_msg.put("appid", gzh_appid);
|
|
|
+ mp_template_msg.put("template_id", qdySubStatusTpId);
|
|
|
+ mp_template_msg.put("url", "http://weixin.qq.com/download"); //公众号模板消息所要跳转的url
|
|
|
+ miniprogram.put("appid", appid); //公众号模板消息所要跳转的小程序appid,小程序的必须与公众号具有绑定关系
|
|
|
+ miniprogram.put("pagepath", paramMap.get("pagepath")); //公众号模板消息所要跳转的小程序页面
|
|
|
+ mp_template_msg.put("miniprogram", miniprogram);
|
|
|
+ Map<String, TemplatData> mapdata = new LinkedHashMap<>();
|
|
|
+ // 封装模板数据
|
|
|
+ TemplatData first = new TemplatData();
|
|
|
+ first.setValue(paramMap.get("first"));
|
|
|
+ first.setColor("#173177");
|
|
|
+ mapdata.put("first", first);
|
|
|
+
|
|
|
+ TemplatData keyword1 = new TemplatData();
|
|
|
+ keyword1.setValue(paramMap.get("keyword1"));
|
|
|
+ keyword1.setColor("#000000");
|
|
|
+ mapdata.put("keyword1", keyword1);
|
|
|
+
|
|
|
+ TemplatData keyword2 = new TemplatData();
|
|
|
+ keyword2.setValue(paramMap.get("keyword2"));
|
|
|
+ keyword2.setColor("#000000");
|
|
|
+ mapdata.put("keyword2", keyword2);
|
|
|
+
|
|
|
+ TemplatData remark = new TemplatData();
|
|
|
+ remark.setValue("↓点我去上课~");
|
|
|
+ remark.setColor("#173177");
|
|
|
+ mapdata.put("remark", remark);
|
|
|
+
|
|
|
+
|
|
|
+ mp_template_msg.put("data", mapdata);
|
|
|
+ obj.put("mp_template_msg", mp_template_msg);
|
|
|
+
|
|
|
+ String result = HttpUtils.sendPost(url, obj);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String sendQdyExamTpMsg(String openId, Map<String, String> paramMap) {
|
|
|
+ String accessToken = getWxSmallAccessToken();
|
|
|
+ if (Validator.isEmpty(accessToken)) {
|
|
|
+ throw new CustomException("小程序accessToken 错误");
|
|
|
+ }
|
|
|
+ String param = String.format(small_wxSendTpParam, accessToken);
|
|
|
+ String url = small_wxSendTpUrl + "?" + param;
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ JSONObject mp_template_msg = new JSONObject();
|
|
|
+ JSONObject miniprogram = new JSONObject();
|
|
|
+
|
|
|
+ obj.put("touser", openId);
|
|
|
+ paramMap.put("access_token", accessToken);
|
|
|
+ mp_template_msg.put("appid", gzh_appid);
|
|
|
+ mp_template_msg.put("template_id", qdyExamTpId);
|
|
|
+ mp_template_msg.put("url", "http://weixin.qq.com/download"); //公众号模板消息所要跳转的url
|
|
|
+ miniprogram.put("appid", appid); //公众号模板消息所要跳转的小程序appid,小程序的必须与公众号具有绑定关系
|
|
|
+ miniprogram.put("pagepath", paramMap.get("pagepath")); //公众号模板消息所要跳转的小程序页面
|
|
|
+ mp_template_msg.put("miniprogram", miniprogram);
|
|
|
+ Map<String, TemplatData> mapdata = new LinkedHashMap<>();
|
|
|
+ // 封装模板数据
|
|
|
+ TemplatData first = new TemplatData();
|
|
|
+ first.setValue(paramMap.get("first"));
|
|
|
+ first.setColor("#173177");
|
|
|
+ mapdata.put("first", first);
|
|
|
+
|
|
|
+ TemplatData keyword1 = new TemplatData();
|
|
|
+ keyword1.setValue(paramMap.get("keyword1"));
|
|
|
+ keyword1.setColor("#000000");
|
|
|
+ mapdata.put("keyword1", keyword1);
|
|
|
+
|
|
|
+ TemplatData keyword2 = new TemplatData();
|
|
|
+ keyword2.setValue(paramMap.get("keyword2"));
|
|
|
+ keyword2.setColor("#000000");
|
|
|
+ mapdata.put("keyword2", keyword2);
|
|
|
+
|
|
|
+ TemplatData remark = new TemplatData();
|
|
|
+ remark.setValue("↓点我去上课~");
|
|
|
+ remark.setColor("#173177");
|
|
|
+ mapdata.put("remark", remark);
|
|
|
+
|
|
|
+
|
|
|
+ mp_template_msg.put("data", mapdata);
|
|
|
+ obj.put("mp_template_msg", mp_template_msg);
|
|
|
+
|
|
|
+ String result = HttpUtils.sendPost(url, obj);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String sendQdyExamStatusTpMsg(String openId, Map<String, String> paramMap) {
|
|
|
+ String accessToken = getWxSmallAccessToken();
|
|
|
+ if (Validator.isEmpty(accessToken)) {
|
|
|
+ throw new CustomException("小程序accessToken 错误");
|
|
|
+ }
|
|
|
+ String param = String.format(small_wxSendTpParam, accessToken);
|
|
|
+ String url = small_wxSendTpUrl + "?" + param;
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ JSONObject mp_template_msg = new JSONObject();
|
|
|
+ JSONObject miniprogram = new JSONObject();
|
|
|
+
|
|
|
+ obj.put("touser", openId);
|
|
|
+ paramMap.put("access_token", accessToken);
|
|
|
+ mp_template_msg.put("appid", gzh_appid);
|
|
|
+ mp_template_msg.put("template_id", qdyExamStatusTpId);
|
|
|
+ mp_template_msg.put("url", "http://weixin.qq.com/download"); //公众号模板消息所要跳转的url
|
|
|
+ miniprogram.put("appid", appid); //公众号模板消息所要跳转的小程序appid,小程序的必须与公众号具有绑定关系
|
|
|
+ miniprogram.put("pagepath", paramMap.get("pagepath")); //公众号模板消息所要跳转的小程序页面
|
|
|
+ mp_template_msg.put("miniprogram", miniprogram);
|
|
|
+ Map<String, TemplatData> mapdata = new LinkedHashMap<>();
|
|
|
+ // 封装模板数据
|
|
|
+ TemplatData first = new TemplatData();
|
|
|
+ first.setValue(paramMap.get("first"));
|
|
|
+ first.setColor("#173177");
|
|
|
+ mapdata.put("first", first);
|
|
|
+
|
|
|
+ TemplatData keyword1 = new TemplatData();
|
|
|
+ keyword1.setValue(paramMap.get("keyword1"));
|
|
|
+ keyword1.setColor("#000000");
|
|
|
+ mapdata.put("keyword1", keyword1);
|
|
|
+
|
|
|
+ TemplatData keyword2 = new TemplatData();
|
|
|
+ keyword2.setValue(paramMap.get("keyword2"));
|
|
|
+ keyword2.setColor("#000000");
|
|
|
+ mapdata.put("keyword2", keyword2);
|
|
|
+
|
|
|
+ TemplatData remark = new TemplatData();
|
|
|
+ remark.setValue("↓点我去上课~");
|
|
|
+ remark.setColor("#173177");
|
|
|
+ mapdata.put("remark", remark);
|
|
|
+
|
|
|
+
|
|
|
+ mp_template_msg.put("data", mapdata);
|
|
|
+ obj.put("mp_template_msg", mp_template_msg);
|
|
|
+
|
|
|
+ String result = HttpUtils.sendPost(url, obj);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public Boolean subGzh(String openId) {
|
|
|
String unionId = getWxGzhUserCgiInfo(openId);
|
|
|
if (Validator.isNotEmpty(unionId)) {
|