|
@@ -54,6 +54,9 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
@Autowired
|
|
|
private IKafkaService kafkaService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserAppletService userAppletService;
|
|
|
+
|
|
|
@Override
|
|
|
public void userAgentUpdate(User user, String channel) {
|
|
|
log.error("用户登录接收到的渠道参数 userId : {}, channel : {}", user.getId(), channel);
|
|
@@ -108,23 +111,30 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
public Tuple3<Long, Map<String, String>, String> getUserAgentId(UserData userData) {
|
|
|
log.error("用户注册接收到的渠道参数 userData : {}", JsonUtil.toString(userData));
|
|
|
|
|
|
- GameExt gameExt = gameExtService.getByGameId(userData.getGameId());
|
|
|
Game game = gameService.getById(userData.getGameId());
|
|
|
-
|
|
|
- if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_APP.getId())
|
|
|
- && !Objects.equals(gameExt.getAdCallBackSwitch(), Boolean.TRUE)) {
|
|
|
- UserVisitLog userVisitLog = this.getUserVisitLog(userData);
|
|
|
- if (userVisitLog == null) {
|
|
|
- return Tuples.of(0L, Collections.emptyMap(), Strings.EMPTY);
|
|
|
- }
|
|
|
- return Tuples.of(userVisitLog.getAgentId(), Collections.emptyMap(), Strings.EMPTY);
|
|
|
+
|
|
|
+ if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_WX_APPLET.getId())) {
|
|
|
+ return this.appletChannelTransform(userData.getChannel());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_APP.getId())) {
|
|
|
+ return this.appChannelTransform(game, userData);
|
|
|
}
|
|
|
+
|
|
|
+ if (Objects.equals(game.getCategory(), GameCategoryEnum.CATEGORY_H5.getId())) {
|
|
|
+ return this.h5ChannelTransform(userData.getChannel());
|
|
|
+ }
|
|
|
+
|
|
|
+ return Tuples.of(0L, Collections.emptyMap(), Strings.EMPTY);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Tuple3<Long, Map<String, String>, String> appletChannelTransform(String channel) {
|
|
|
|
|
|
- if (Strings.isBlank(userData.getChannel())) {
|
|
|
+ if (Strings.isBlank(channel)) {
|
|
|
return Tuples.of(0L, Collections.emptyMap(), Strings.EMPTY);
|
|
|
}
|
|
|
|
|
|
- Map<String, String> urlParamMap = this.channelTransform(userData.getChannel());
|
|
|
+ Map<String, String> urlParamMap = this.channelTransform(channel);
|
|
|
String shareUserId = urlParamMap.get("shareUserId");
|
|
|
|
|
|
Agent agent = null;
|
|
@@ -142,6 +152,48 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
return Tuples.of(agent.getId(), urlParamMap, Strings.isBlank(shareUserId) ? Strings.EMPTY : shareUserId);
|
|
|
}
|
|
|
|
|
|
+ private Tuple3<Long, Map<String, String>, String> appChannelTransform(Game game, UserData userData) {
|
|
|
+
|
|
|
+ GameExt gameExt = gameExtService.getByGameId(userData.getGameId());
|
|
|
+
|
|
|
+ if (Objects.equals(game.getIsPut(), Boolean.FALSE) && Objects.equals(gameExt.getAdCallBackSwitch(), Boolean.FALSE)) {
|
|
|
+
|
|
|
+ UserVisitLog userVisitLog = this.getUserVisitLog(userData);
|
|
|
+
|
|
|
+ return Tuples.of(userVisitLog == null ? 0L : userVisitLog.getAgentId(), Collections.emptyMap(), Strings.EMPTY);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.equals(game.getIsPut(), Boolean.TRUE) && Objects.equals(gameExt.getAdCallBackSwitch(), Boolean.TRUE)) {
|
|
|
+
|
|
|
+ UserVisitLog userVisitLog = this.getUserVisitLog(userData);
|
|
|
+ if (userVisitLog == null) {
|
|
|
+
|
|
|
+ return Tuples.of(0L, Collections.emptyMap(), Strings.EMPTY);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, String> urlParamMap = this.channelTransform(userVisitLog.getChannel());
|
|
|
+
|
|
|
+ Agent agent = this.getAgentByKey(urlParamMap);
|
|
|
+
|
|
|
+ return Tuples.of(agent == null ? 0L : agent.getId(), urlParamMap, Strings.EMPTY);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Tuples.of(0L, Collections.emptyMap(), Strings.EMPTY);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Tuple3<Long, Map<String, String>, String> h5ChannelTransform(String channel) {
|
|
|
+
|
|
|
+ if (Strings.isBlank(channel)) {
|
|
|
+ return Tuples.of(0L, Collections.emptyMap(), Strings.EMPTY);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, String> urlParamMap = this.channelTransform(channel);
|
|
|
+
|
|
|
+ Agent agent = this.getAgentByKey(urlParamMap);
|
|
|
+
|
|
|
+ return Tuples.of(agent == null ? 0L : agent.getId(), urlParamMap, Strings.EMPTY);
|
|
|
+ }
|
|
|
+
|
|
|
private UserVisitLog getUserVisitLog(UserData userData) {
|
|
|
|
|
|
LocalDateTime regTime = LocalDateTime.now();
|
|
@@ -236,6 +288,26 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
|
|
|
|
|
@Override
|
|
|
public Map<String, String> channelTransform(String channel) {
|
|
|
+ if (Strings.isBlank(channel) || Strings.isBlank(channel.trim())) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, String> paramMap = this.channelToMap(channel);
|
|
|
+
|
|
|
+ String callState = "callState";
|
|
|
+
|
|
|
+ if (!paramMap.containsKey(callState)) {
|
|
|
+ return paramMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserApplet userApplet = userAppletService.getById(Integer.valueOf(paramMap.get(callState)));
|
|
|
+ if (userApplet != null && Strings.isNotBlank(userApplet.getChannel())) {
|
|
|
+ paramMap.putAll(this.channelToMap(userApplet.getChannel()));
|
|
|
+ }
|
|
|
+ return paramMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, String> channelToMap(String channel) {
|
|
|
if (Strings.isBlank(channel) || Strings.isBlank(channel.trim())) {
|
|
|
return Collections.emptyMap();
|
|
|
}
|