|
|
@@ -9,21 +9,21 @@ import com.cyksj.common.util.Codec;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.config.WeChatConfig;
|
|
|
+import com.cyksj.dto.UserSharedDto;
|
|
|
import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.mapper.WxAppMapper;
|
|
|
import com.cyksj.mapper.gzh.UserGzhRelationMapper;
|
|
|
import com.cyksj.mapper.manage.cps.UserDistributePopularizeMapper;
|
|
|
-import com.cyksj.model.dto.GzhBodyDto;
|
|
|
-import com.cyksj.model.dto.GzhUnionidUserinfo;
|
|
|
-import com.cyksj.model.dto.MsgEvent;
|
|
|
-import com.cyksj.model.entity.User;
|
|
|
-import com.cyksj.model.entity.UserDistributePopularize;
|
|
|
-import com.cyksj.model.entity.UserGzhRelation;
|
|
|
-import com.cyksj.model.entity.WxApp;
|
|
|
+import com.cyksj.mapper.station.CollegeStudentStationUserRelateMapper;
|
|
|
+import com.cyksj.model.dto.*;
|
|
|
+import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.distribute.DistributeService;
|
|
|
import com.cyksj.service.distribute.equipment.EquipmentDistributeService;
|
|
|
import com.cyksj.service.market.task.BindTaskService;
|
|
|
+import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
+import com.cyksj.service.shop.YhShopDistributeService;
|
|
|
+import com.cyksj.service.user.UserLoginRecordService;
|
|
|
import com.cyksj.service.user.UserService;
|
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@@ -65,6 +65,14 @@ public class EventMsgService implements GzhMsgService {
|
|
|
|
|
|
private final BindTaskService bindTaskService;
|
|
|
|
|
|
+ private final UserLoginRecordService userLoginRecordService;
|
|
|
+
|
|
|
+ private final CollegeStudentStationUserRelateMapper collegeStudentStationUserRelateMapper;
|
|
|
+
|
|
|
+ private final GroupRelationFrontService groupRelationFrontService;
|
|
|
+
|
|
|
+ private final YhShopDistributeService yhShopDistributeService;
|
|
|
+
|
|
|
private static final GlobalThreadPoolTaskExecutor TASK_POOL = GlobalThreadPoolTaskExecutor.getInstance();
|
|
|
|
|
|
@Override
|
|
|
@@ -148,6 +156,8 @@ public class EventMsgService implements GzhMsgService {
|
|
|
if (!redisService.setNx(RedisService.key.REPEAT_USER_KEY.getNameFormat(user.getUnionid()), user.getUnionid(), RedisService.key.REPEAT_USER_KEY.getTimeout())) {
|
|
|
return false;
|
|
|
}
|
|
|
+ //pc网页扫码
|
|
|
+ user.setRegisterEnv(User.RegisterEnv.pc.name());
|
|
|
userMapper.insert(user);
|
|
|
Long userId = user.getId();
|
|
|
Long dsPopularizeId = null;
|
|
|
@@ -174,7 +184,7 @@ public class EventMsgService implements GzhMsgService {
|
|
|
if (sharedId != null) {
|
|
|
distributeService.saveDistributionInvitation(sharedId, user.getId(), dsPopularizeId);
|
|
|
}
|
|
|
- Long popularizeId = gzhDto.getPopularizeId();
|
|
|
+ Long popularizeId = gzhDto.getPid();
|
|
|
if (popularizeId != null) {
|
|
|
userMapper.update(null, Wrappers.lambdaUpdate(User.class)
|
|
|
.eq(User::getId, user.getId())
|
|
|
@@ -184,6 +194,21 @@ public class EventMsgService implements GzhMsgService {
|
|
|
});
|
|
|
}
|
|
|
userBind(user, sceneKey, gzhDto.getLoginPhone(), gzhDto.getLoginEmail());
|
|
|
+
|
|
|
+ String callback = gzhDto.getCk();
|
|
|
+ String callbackType = gzhDto.getCt();
|
|
|
+ //缓存用户注册 回传信息
|
|
|
+ if (StrUtil.isNotBlank(callback)) {
|
|
|
+ OrderDonPostDataDto orderDonPostDataDto = new OrderDonPostDataDto().setCallback(callback)
|
|
|
+ .setCallbackType(callbackType);
|
|
|
+ redisService.set(RedisService.key.ORDER_DON_POST_DATA_USER_KEY.getName() + user.getId(), Jsons.toJson(orderDonPostDataDto));
|
|
|
+ }
|
|
|
+
|
|
|
+ String customId = gzhDto.getCd();
|
|
|
+ //店铺注册用户 关联
|
|
|
+ if (isNewUser && StrUtil.isNotBlank(customId)) {
|
|
|
+ yhShopDistributeService.saveDistributionInvitation(customId, user.getId(), gzhDto.getCmt());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
saveGzhUserRelation(msgEvent, user.getId(), openId, info.getUnionid(), sceneKey, wxApp.getId());
|
|
|
@@ -200,15 +225,39 @@ public class EventMsgService implements GzhMsgService {
|
|
|
}
|
|
|
//场景值扫描公众号二维码 登录
|
|
|
if (StrUtil.isNotEmpty(sceneKey)) {
|
|
|
- redisService.set(RedisService.key.WX_GZH_QRCODE_LOGIN.getNameFormat(sceneKey), user.getId(), RedisService.key.WX_GZH_QRCODE_LOGIN.getTimeout());
|
|
|
+ WxUserSceneDto wxUserSceneDto = new WxUserSceneDto(user.getId(), openId);
|
|
|
+ redisService.set(RedisService.key.WX_GZH_QRCODE_LOGIN.getNameFormat(sceneKey), Jsons.toJson(wxUserSceneDto), RedisService.key.WX_GZH_QRCODE_LOGIN.getTimeout());
|
|
|
}
|
|
|
if (gzhDto != null) {
|
|
|
Long sharedId = gzhDto.getSharedId();
|
|
|
Integer dsType = gzhDto.getDsType();
|
|
|
+ String dsCode = gzhDto.getDsCode();
|
|
|
+ Long dsPopularizeId = null;
|
|
|
+ if (StrUtil.isNotBlank(dsCode)) {
|
|
|
+ UserSharedDto userSharedDto = getUserShredDtoByDsCode(dsCode);
|
|
|
+ sharedId = userSharedDto.getSharedId();
|
|
|
+ dsPopularizeId = userSharedDto.getDsPopularizeId();
|
|
|
+ }
|
|
|
//新旧用户都可实物分销
|
|
|
if (dsType != null && dsType == 2) {
|
|
|
equipDistributeService.saveDistributionInvitation(sharedId, isNewUser, user.getId());
|
|
|
}
|
|
|
+ //新用户推广
|
|
|
+ if (sharedId != null && isNewUser) {
|
|
|
+ if (dsType == null || dsType == 1) {
|
|
|
+ distributeService.saveDistributionInvitation(sharedId, user.getId(), dsPopularizeId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //每日活跃记录
|
|
|
+ userLoginRecordService.saveUserLoginDayRecord(user.getId());
|
|
|
+ //是否是大学生快递站进来的用户
|
|
|
+ Integer cst = gzhDto.getCst();
|
|
|
+ Long userId = user.getId();
|
|
|
+ if (cst != null) {
|
|
|
+ TASK_POOL.execute(() -> {
|
|
|
+ handlerCollegeStudentUser(userId, cst);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
@@ -262,4 +311,44 @@ public class EventMsgService implements GzhMsgService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public UserSharedDto getUserShredDtoByDsCode(String dsCode) {
|
|
|
+ Long sharedId = 0l;
|
|
|
+ Long dsPopularizeId = 0l;
|
|
|
+ dsCode = dsCode.trim();
|
|
|
+ User sharedUser = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
+ .eq(User::getShowId, dsCode).last("limit 1"));
|
|
|
+ if (sharedUser != null) {
|
|
|
+ sharedId = sharedUser.getId();
|
|
|
+ } else {
|
|
|
+ UserDistributePopularize distributePopularize = distributePopularizeMapper.selectOne(Wrappers.lambdaQuery(UserDistributePopularize.class)
|
|
|
+ .eq(UserDistributePopularize::getCode, dsCode)
|
|
|
+ .select(UserDistributePopularize::getUserId, UserDistributePopularize::getId).last("limit 1"));
|
|
|
+ if (distributePopularize != null) {
|
|
|
+ log.info("渠道sharedId:{}设置固定推广链接用户分销", distributePopularize.getUserId());
|
|
|
+ sharedId = distributePopularize.getUserId();
|
|
|
+ dsPopularizeId = distributePopularize.getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ UserSharedDto sharedDto = new UserSharedDto();
|
|
|
+ sharedDto.setSharedId(sharedId);
|
|
|
+ sharedDto.setDsPopularizeId(dsPopularizeId);
|
|
|
+ return sharedDto;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理大学生快递站用户
|
|
|
+ */
|
|
|
+ public void handlerCollegeStudentUser(Long userId, Integer cst) {
|
|
|
+ try {
|
|
|
+ CollegeStudentStationUserRelate cstRelate = new CollegeStudentStationUserRelate();
|
|
|
+ cstRelate.setType(cst);
|
|
|
+ cstRelate.setUserId(userId);
|
|
|
+ collegeStudentStationUserRelateMapper.insert(cstRelate);
|
|
|
+
|
|
|
+ //赠送1天的GPT镜像车票
|
|
|
+ groupRelationFrontService.getCollegeStudentUserGptTicket(userId);
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|