|
|
@@ -12,9 +12,12 @@ import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.tuple.Triple;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import shop.alien.config.properties.RiskControlProperties;
|
|
|
+import shop.alien.entity.second.LifeUserLog;
|
|
|
import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.LifeFans;
|
|
|
import shop.alien.entity.store.LifeNotice;
|
|
|
@@ -22,16 +25,20 @@ import shop.alien.entity.store.LifeUser;
|
|
|
import shop.alien.entity.store.vo.LifeMessageVo;
|
|
|
import shop.alien.entity.store.vo.LifeUserVo;
|
|
|
import shop.alien.entity.store.vo.WebSocketVo;
|
|
|
+import shop.alien.mapper.second.LifeUserLogMapper;
|
|
|
+import shop.alien.store.config.BaseRedisService;
|
|
|
import shop.alien.mapper.LifeFansMapper;
|
|
|
import shop.alien.mapper.LifeMessageMapper;
|
|
|
import shop.alien.mapper.LifeNoticeMapper;
|
|
|
import shop.alien.mapper.LifeUserMapper;
|
|
|
-import shop.alien.store.config.BaseRedisService;
|
|
|
import shop.alien.store.config.WebSocketProcess;
|
|
|
+import shop.alien.store.feign.SecondServiceFeign;
|
|
|
import shop.alien.store.util.FunctionMagic;
|
|
|
import shop.alien.util.common.JwtUtil;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -56,6 +63,13 @@ public class LifeUserService extends ServiceImpl<LifeUserMapper, LifeUser> {
|
|
|
|
|
|
private final ActivityInviteConfigService activityInviteConfigService;
|
|
|
|
|
|
+ private final LifeUserLogMapper lifeUserLogMapper;
|
|
|
+
|
|
|
+ private final SecondServiceFeign alienSecondFeign;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RiskControlProperties riskControlProperties;
|
|
|
+
|
|
|
@Value("${jwt.expiration-time}")
|
|
|
private String effectiveTime;
|
|
|
|
|
|
@@ -139,7 +153,7 @@ public class LifeUserService extends ServiceImpl<LifeUserMapper, LifeUser> {
|
|
|
return voList;
|
|
|
}
|
|
|
|
|
|
- public LifeUserVo userLogin(String phoneNum, String inviteCode) {
|
|
|
+ public LifeUserVo userLogin(String phoneNum, String inviteCode, String macIp) {
|
|
|
LifeUser user = getUserByPhone(phoneNum);
|
|
|
if (user == null) {
|
|
|
LifeUser lifeUser = new LifeUser();
|
|
|
@@ -166,6 +180,12 @@ public class LifeUserService extends ServiceImpl<LifeUserMapper, LifeUser> {
|
|
|
if(StringUtils.isNotEmpty(inviteCode)){
|
|
|
activityInviteConfigService.bindInviteCode(lifeUser.getId(), inviteCode);
|
|
|
}
|
|
|
+
|
|
|
+ // 二手平台登录log,同一个macip登录多账号记录
|
|
|
+ addLifeUserLogInfo(user2, macIp);
|
|
|
+ // 第一次登录,添加用户基础积分
|
|
|
+ alienSecondFeign.createPointsRecord(user2.getId(), 300, 1);
|
|
|
+
|
|
|
return userVo;
|
|
|
} else {
|
|
|
return null;
|
|
|
@@ -186,6 +206,9 @@ public class LifeUserService extends ServiceImpl<LifeUserMapper, LifeUser> {
|
|
|
activityInviteConfigService.bindInviteCode(user.getId(), inviteCode);
|
|
|
}
|
|
|
|
|
|
+ // 二手平台登录log,同一个macip登录多账号记录
|
|
|
+ addLifeUserLogInfo(user, macIp);
|
|
|
+
|
|
|
return userVo;
|
|
|
}
|
|
|
}
|
|
|
@@ -341,4 +364,29 @@ public class LifeUserService extends ServiceImpl<LifeUserMapper, LifeUser> {
|
|
|
lifeUser.setPayPassword(payPassword);
|
|
|
return this.updateById(lifeUser);
|
|
|
}
|
|
|
+
|
|
|
+ public void addLifeUserLogInfo(LifeUser user, String macIp) {
|
|
|
+ try {
|
|
|
+ LifeUserLog lifeUserLog = new LifeUserLog();
|
|
|
+ lifeUserLog.setUserId(user.getId());
|
|
|
+ lifeUserLog.setUserName(user.getUserName());
|
|
|
+ lifeUserLog.setMacIp(macIp);
|
|
|
+ lifeUserLog.setCreatedTime(new Date());
|
|
|
+ lifeUserLogMapper.insert(lifeUserLog);
|
|
|
+
|
|
|
+ String startDate = LocalDateTime.now().minusHours(24L).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ String endDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ List<LifeUserLog> lsit = lifeUserLogMapper.getLifeUserLogByDate(startDate, endDate, macIp);
|
|
|
+
|
|
|
+ if (lsit.size() > riskControlProperties.getAccountAbnormal().getRegCount24h()) {
|
|
|
+ String detailInfo = lsit.stream()
|
|
|
+ .map(row -> row.getId().toString())
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ alienSecondFeign.recordRiskControlData(null, 2, "账号异常", macIp, detailInfo);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("用户登录log存放异常:{}");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|