|
|
@@ -5,11 +5,13 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.util.Codec;
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.config.WeChatConfig;
|
|
|
import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.mapper.WxAppMapper;
|
|
|
import com.cyksj.mapper.WxSyncLogMapper;
|
|
|
import com.cyksj.mapper.gzh.UserGzhRelationMapper;
|
|
|
+import com.cyksj.model.dto.GzhBodyDto;
|
|
|
import com.cyksj.model.dto.GzhUnionidUserinfo;
|
|
|
import com.cyksj.model.dto.MsgEvent;
|
|
|
import com.cyksj.model.entity.User;
|
|
|
@@ -103,6 +105,18 @@ public class EventMsgService implements GzhMsgService {
|
|
|
|
|
|
User user = userService.getSyncUser(info.getOpenid(), info.getUnionid(), wxSyncLog);
|
|
|
|
|
|
+ String state = redisService.getStr(RedisService.key.WX_GZH_QRCODE_SHARED_LOGIN.getNameFormat(sceneKey));
|
|
|
+ GzhBodyDto gzhDto = null;
|
|
|
+ if (StrUtil.isNotEmpty(state)) {
|
|
|
+ // 转跳参数
|
|
|
+ String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
|
+ if (StrUtil.isNotEmpty(json)) {
|
|
|
+ try {
|
|
|
+ gzhDto = Jsons.parseObject(json, GzhBodyDto.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (user == null) {
|
|
|
user = new User();
|
|
|
user.setNickname(String.format("%s%s", Constant.DEFAULT_NAME, Codec.DoDigest.custom().setAlgorithm(Codec.DoDigest.Algorithm.MD5).setStringData(RandomUtil.randomString(10)).toHexString().substring(0, 6)))
|
|
|
@@ -115,10 +129,17 @@ public class EventMsgService implements GzhMsgService {
|
|
|
user.setUnionid(info.getUnionid());
|
|
|
userMapper.insert(user);
|
|
|
|
|
|
- Object sharedIdObj = redisService.get(RedisService.key.WX_GZH_QRCODE_SHARED_LOGIN.getNameFormat(sceneKey));
|
|
|
- if (sharedIdObj != null) {
|
|
|
- Long sharedId = Long.parseLong(sharedIdObj.toString());
|
|
|
- distributeService.saveDistributionInvitation(sharedId, user.getId());
|
|
|
+ if (gzhDto != null) {
|
|
|
+ Long sharedId = gzhDto.getSharedId();
|
|
|
+ if (sharedId != null) {
|
|
|
+ distributeService.saveDistributionInvitation(sharedId, user.getId());
|
|
|
+ }
|
|
|
+ Long popularizeId = gzhDto.getPopularizeId();
|
|
|
+ if (popularizeId != null) {
|
|
|
+ userMapper.update(null, Wrappers.lambdaUpdate(User.class)
|
|
|
+ .eq(User::getId, user.getId())
|
|
|
+ .set(User::getPopularizeId, popularizeId));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
saveGzhUserRelation(msgEvent, user.getId(), openId, info.getUnionid(), sceneKey);
|