|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.miaxis.common.constant.Constants;
|
|
|
import com.miaxis.common.core.domain.entity.SysDictData;
|
|
|
import com.miaxis.common.core.domain.entity.UserInfo;
|
|
|
+import com.miaxis.common.utils.ServletUtils;
|
|
|
import com.miaxis.common.utils.StringUtils;
|
|
|
import com.miaxis.common.utils.wx.MessageUtil;
|
|
|
import com.miaxis.feign.dto.WxMessageCusom;
|
|
@@ -111,12 +112,9 @@ public class WxGzhServiceImpl implements IWxGzhService {
|
|
|
cn.hutool.json.JSONObject decryptMap = XML.toJSONObject(IOUtils.toString(request.getInputStream()));
|
|
|
cn.hutool.json.JSONObject jsonObjectData = decryptMap.getJSONObject("xml");
|
|
|
|
|
|
-
|
|
|
// cn.hutool.json.JSONObject jsonObjectData = new cn.hutool.json.JSONObject("{\"CreateTime\":1666169539,\"ToUserName\":\"gh_8e0c71ce615b\",\"MsgType\":\"text\",\"MsgId\":23853813438069304,\"Content\":\"a12345\",\"FromUserName\":\"o_DwY68a6UHmFhmovdFB0gANaC_U\"}");
|
|
|
log.info("2-----jsonObjectData------"+jsonObjectData);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//开发者微信号
|
|
|
String toUserName = jsonObjectData.getStr("ToUserName");
|
|
|
//发送方帐号(一个OpenID)
|
|
@@ -129,20 +127,7 @@ public class WxGzhServiceImpl implements IWxGzhService {
|
|
|
|
|
|
// 普通消息
|
|
|
if (MessageUtil.MESSAGE_TEXT.equals(msgType)) { // 文本消息
|
|
|
- List<SysDictData> configs = dictTypeService.selectDictDataByType("partner_config");
|
|
|
- String parentUnionId = null ;
|
|
|
- for (SysDictData sysDictData:configs){
|
|
|
- String dictValue = sysDictData.getDictValue();
|
|
|
- String[] values = dictValue.split(",");
|
|
|
- String password = values[0];
|
|
|
- if (jsonObjectData.getStr("Content").equals(password)){
|
|
|
- parentUnionId = sysDictData.getDictLabel();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ return MessageUtil.initText(fromUserName, toUserName, "欢迎财仝驾助,右下角菜单可以理论训练,观看教学视频。");
|
|
|
} else if (MessageUtil.MESSAGE_IMAGE.equals(msgType)) { // 图片消息
|
|
|
log.info("2.2...");
|
|
|
return MessageUtil.initText(fromUserName, toUserName, "抱歉,暂时无法识别图片信息!");
|
|
@@ -153,20 +138,20 @@ public class WxGzhServiceImpl implements IWxGzhService {
|
|
|
String event = jsonObjectData.getStr("Event");
|
|
|
if (MessageUtil.MESSAGE_SUBSCRIBE.equals(event)) { // 关注事件 或 扫描二维码关注事件
|
|
|
log.info("3.1...");
|
|
|
-
|
|
|
String unionId = userInfoJson.getString("unionid");
|
|
|
- //如果是新用户,则保存用户
|
|
|
-// UserInfo user = userService.getStudentByUnionid(unionId);
|
|
|
-// if (user == null){
|
|
|
-// UserInfo userInfo = new UserInfo();
|
|
|
-// userInfo.setGzhOpenid(fromUserName);
|
|
|
-// userInfo.setUnionId(unionId);
|
|
|
-// userInfo.setThirdPlatform("weixin");
|
|
|
-// userInfoService.save(userInfo);
|
|
|
-// }else if(user.getGzhOpenid()==null){
|
|
|
-// user.setGzhOpenid(fromUserName);
|
|
|
-// userInfoService.updateById(user);
|
|
|
-// }
|
|
|
+ String openId = userInfoJson.getString("openid");
|
|
|
+ UserInfo userInfoDB = userService.getStudentByUnionId(unionId);
|
|
|
+ if (userInfoDB == null) {
|
|
|
+ UserInfo userInfo = new UserInfo();
|
|
|
+ userInfo.setUnionId(unionId);
|
|
|
+ userInfo.setGzhOpenid(openId);
|
|
|
+ userInfo.setIsVip(0);
|
|
|
+ userService.saveUserInfo(userInfo);
|
|
|
+ }else {
|
|
|
+ userInfoDB.setUnionId(unionId);
|
|
|
+ userInfoDB.setGzhOpenid(openId);
|
|
|
+ userService.updateStudent(userInfoDB);
|
|
|
+ }
|
|
|
|
|
|
//存在Ticket为扫码关注
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotEmpty(jsonObjectData.getStr("Ticket"))){
|
|
@@ -176,15 +161,14 @@ public class WxGzhServiceImpl implements IWxGzhService {
|
|
|
}else {
|
|
|
result = MessageUtil.initText(fromUserName, toUserName, "欢迎关注财仝驾考,您的学车好伙伴!");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
return result;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
} else if (MessageUtil.MESSAGE_UNSUBSCRIBE.equals(event)) { // 取消订阅事件
|
|
|
- // todo 处理取消订阅事件
|
|
|
-
|
|
|
+ log.info("3.2...");
|
|
|
+ UserInfo userInfoDB = userService.getStudentByOpenId(fromUserName);
|
|
|
+ if (userInfoDB == null) {
|
|
|
+ userInfoDB.setGzhOpenid(null);
|
|
|
+ userService.updateStudent(userInfoDB);
|
|
|
+ }
|
|
|
} else if (MessageUtil.MESSAGE_SCAN.equals(event)) { // 已关注扫描二维码事件
|
|
|
|
|
|
|