|
@@ -7,6 +7,7 @@ import com.miaxis.common.constant.Constants;
|
|
|
import com.miaxis.common.core.domain.entity.UserInfo;
|
|
|
import com.miaxis.common.utils.StringUtils;
|
|
|
import com.miaxis.common.utils.wx.MessageUtil;
|
|
|
+import com.miaxis.common.utils.wx.SHA1Util;
|
|
|
import com.miaxis.feign.dto.WxMessageCusom;
|
|
|
import com.miaxis.feign.service.IWxSendService;
|
|
|
import com.miaxis.school.domain.SchoolInfo;
|
|
@@ -19,9 +20,11 @@ import com.miaxis.wx.dto.QueryParams;
|
|
|
import com.miaxis.wx.service.IWxForeverCodeService;
|
|
|
import com.miaxis.wx.service.IWxGzhService;
|
|
|
import com.miaxis.wx.service.IWxMessageEvenService;
|
|
|
+import com.miaxis.wx.service.WxService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
+import org.apache.commons.lang3.RandomStringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -60,6 +63,8 @@ public class WxGzhServiceImpl implements IWxGzhService {
|
|
|
|
|
|
private final ISchoolInfoService schoolInfoService;
|
|
|
|
|
|
+ private final WxService wxService;
|
|
|
+
|
|
|
@Value("${app.appid}")
|
|
|
private String appid;
|
|
|
|
|
@@ -278,6 +283,7 @@ public class WxGzhServiceImpl implements IWxGzhService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private String dealSchoolMsg(String bizmsgmenuid, String content, String fromUserName, String toUserName) throws Exception {
|
|
|
UserInfo userInfo = userInfoService.getOne(new QueryWrapper<UserInfo>().eq("openid", fromUserName));
|
|
|
// 1选择城市 2选择区 3选择学校
|
|
@@ -444,6 +450,36 @@ public class WxGzhServiceImpl implements IWxGzhService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public JSONObject getJspapi() {
|
|
|
+
|
|
|
+ //1、获取AccessToken
|
|
|
+ String gzhToken = this.getGzhToken();
|
|
|
+ //2、获取Ticket
|
|
|
+ String jsapiStr = wxService.getticket(gzhToken, "jsapi");
|
|
|
+ //3、时间戳和随机字符串
|
|
|
+ String nonce_str = RandomStringUtils.randomAlphanumeric(32);
|
|
|
+ long timestamp = System.currentTimeMillis()/1000;
|
|
|
+
|
|
|
+ //4、获取url
|
|
|
+ String url="https://jpcj-h51.zzxcx.net/mini";
|
|
|
+ String str = "jsapi_ticket="+jsapiStr+"&noncestr="+nonce_str+"×tamp="+timestamp+"&url="+url;
|
|
|
+
|
|
|
+ //6、将字符串进行sha1加密
|
|
|
+ String signature = SHA1Util.SHA1(str);
|
|
|
+
|
|
|
+ JSONObject jsapiData = JSONObject.parseObject(jsapiStr);
|
|
|
+ String ticket= jsapiData.getString("ticket");
|
|
|
+ JSONObject resultJSONObject = new JSONObject();
|
|
|
+ resultJSONObject.put("ticket",ticket);
|
|
|
+ resultJSONObject.put("appId",appid);
|
|
|
+ resultJSONObject.put("timestamp",timestamp);
|
|
|
+ resultJSONObject.put("nonceStr",nonce_str);
|
|
|
+ resultJSONObject.put("signature",signature);
|
|
|
+ return resultJSONObject;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|