|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import shop.alien.entity.analytics.dto.AnalyticsUserRegisterDTO;
|
|
|
import shop.alien.entity.result.R;
|
|
import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.second.LifeUserLog;
|
|
import shop.alien.entity.second.LifeUserLog;
|
|
|
import shop.alien.entity.second.SecondRiskControlRecord;
|
|
import shop.alien.entity.second.SecondRiskControlRecord;
|
|
@@ -25,6 +27,7 @@ import shop.alien.entity.store.vo.LifeUserVo;
|
|
|
import shop.alien.gateway.config.BaseRedisService;
|
|
import shop.alien.gateway.config.BaseRedisService;
|
|
|
import shop.alien.gateway.config.RiskControlProperties;
|
|
import shop.alien.gateway.config.RiskControlProperties;
|
|
|
import shop.alien.gateway.feign.SecondServiceFeign;
|
|
import shop.alien.gateway.feign.SecondServiceFeign;
|
|
|
|
|
+import shop.alien.gateway.feign.StoreServiceFeign;
|
|
|
import shop.alien.gateway.mapper.LifeUserLogGatewayMapper;
|
|
import shop.alien.gateway.mapper.LifeUserLogGatewayMapper;
|
|
|
import shop.alien.gateway.mapper.LifeUserGatewayMapper;
|
|
import shop.alien.gateway.mapper.LifeUserGatewayMapper;
|
|
|
import shop.alien.mapper.second.SecondRiskControlRecordMapper;
|
|
import shop.alien.mapper.second.SecondRiskControlRecordMapper;
|
|
@@ -41,10 +44,13 @@ import java.util.stream.Collectors;
|
|
|
/**
|
|
/**
|
|
|
* 用户
|
|
* 用户
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser> {
|
|
public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser> {
|
|
|
|
|
|
|
|
|
|
+ private static final String USER_REGISTER_CHANNEL = "app_user";
|
|
|
|
|
+
|
|
|
private final LifeUserGatewayMapper lifeUserMapper;
|
|
private final LifeUserGatewayMapper lifeUserMapper;
|
|
|
|
|
|
|
|
private final LifeUserLogGatewayMapper lifeUserLogMapper;
|
|
private final LifeUserLogGatewayMapper lifeUserLogMapper;
|
|
@@ -53,6 +59,8 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
|
|
|
|
|
|
|
|
private final SecondServiceFeign alienSecondFeign;
|
|
private final SecondServiceFeign alienSecondFeign;
|
|
|
|
|
|
|
|
|
|
+ private final StoreServiceFeign storeServiceFeign;
|
|
|
|
|
+
|
|
|
private final ActivityInviteConfigService activityInviteConfigService;
|
|
private final ActivityInviteConfigService activityInviteConfigService;
|
|
|
|
|
|
|
|
private final SecondRiskControlRecordMapper secondRiskControlRecordMapper;
|
|
private final SecondRiskControlRecordMapper secondRiskControlRecordMapper;
|
|
@@ -167,6 +175,7 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
|
|
|
addLifeUserSessionToken(phoneNum, token);
|
|
addLifeUserSessionToken(phoneNum, token);
|
|
|
// 二手平台登录log,同一个macip登录多账号记录
|
|
// 二手平台登录log,同一个macip登录多账号记录
|
|
|
addLifeUserLogInfo(user2, macIp);
|
|
addLifeUserLogInfo(user2, macIp);
|
|
|
|
|
+ trackNewUserRegister(user2);
|
|
|
userVo.setHasLoginPassword(StringUtils.isNotBlank(user2.getPassword()));
|
|
userVo.setHasLoginPassword(StringUtils.isNotBlank(user2.getPassword()));
|
|
|
fillLogoutEndTime(userVo, user2);
|
|
fillLogoutEndTime(userVo, user2);
|
|
|
|
|
|
|
@@ -194,6 +203,26 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 登录即注册:新用户创建成功后由后端上报注册埋点,避免前端无法区分登录/注册。
|
|
|
|
|
+ */
|
|
|
|
|
+ private void trackNewUserRegister(LifeUser user) {
|
|
|
|
|
+ if (user == null || user.getId() == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ AnalyticsUserRegisterDTO dto = new AnalyticsUserRegisterDTO();
|
|
|
|
|
+ dto.setEventId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
|
+ dto.setUserId(user.getId().longValue());
|
|
|
|
|
+ dto.setUserPhone(user.getUserPhone());
|
|
|
|
|
+ dto.setRegisterTime(user.getCreatedTime() != null ? user.getCreatedTime() : new Date());
|
|
|
|
|
+ dto.setChannel(USER_REGISTER_CHANNEL);
|
|
|
|
|
+ storeServiceFeign.trackUserRegister(dto);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("用户注册埋点上报失败: userId={}", user.getId(), e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private String getToken(String phoneNum, String userVo, Map<String, String> tokenMap) {
|
|
private String getToken(String phoneNum, String userVo, Map<String, String> tokenMap) {
|
|
|
int effectiveTimeInt = Integer.parseInt(effectiveTime.substring(0, effectiveTime.length() - 1));
|
|
int effectiveTimeInt = Integer.parseInt(effectiveTime.substring(0, effectiveTime.length() - 1));
|
|
|
String effectiveTimeUnit = effectiveTime.substring(effectiveTime.length() - 1);
|
|
String effectiveTimeUnit = effectiveTime.substring(effectiveTime.length() - 1);
|