Althars123 3 жил өмнө
parent
commit
57b330392d

+ 6 - 1
twzd-service/src/main/java/com/miaxis/wx/service/impl/WxGzhServiceImpl.java

@@ -64,6 +64,7 @@ public class WxGzhServiceImpl implements IWxGzhService {
 
     private final WxService wxService;
 
+
     @Value("${app.appid}")
     private String appid;
 
@@ -176,9 +177,13 @@ public class WxGzhServiceImpl implements IWxGzhService {
                 String event = jsonObjectData.getStr("Event");
                 if (MessageUtil.MESSAGE_SUBSCRIBE.equals(event)) { // 关注事件 或 扫描二维码关注事件
                     log.info("3.1...");
-                    UserInfo user = userService.getStudentByOpenId(fromUserName);
+                    String res = wxSendService.userInfo( this.getGzhToken(), fromUserName, "zh_CN");
+                    JSONObject jsonObject = JSONObject.parseObject(res);
+                    String unionId = jsonObject.getString("unionid");
+                    UserInfo user = userService.getStudentByUnionid(unionId);
                     UserInfo userInfo = new UserInfo();
                     userInfo.setOpenid(fromUserName);
+                    userInfo.setUnionId(unionId);
 
                     //存在Ticket为扫码关注
                     if (org.apache.commons.lang3.StringUtils.isNotEmpty(jsonObjectData.getStr("Ticket"))){