|
|
@@ -13,7 +13,11 @@ import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import shop.alien.entity.second.LifeUserLog;
|
|
|
import shop.alien.entity.second.SecondRiskControlRecord;
|
|
|
+import shop.alien.entity.second.SecondUserCredit;
|
|
|
+import shop.alien.entity.second.SecondUserCreditRecord;
|
|
|
import shop.alien.entity.store.LifeUser;
|
|
|
+import shop.alien.entity.store.StoreImg;
|
|
|
+import shop.alien.entity.store.StoreUser;
|
|
|
import shop.alien.entity.store.vo.LifeUserVo;
|
|
|
import shop.alien.gateway.config.BaseRedisService;
|
|
|
import shop.alien.gateway.config.RiskControlProperties;
|
|
|
@@ -21,6 +25,8 @@ import shop.alien.gateway.feign.SecondServiceFeign;
|
|
|
import shop.alien.gateway.mapper.LifeUserLogGatewayMapper;
|
|
|
import shop.alien.gateway.mapper.LifeUserGatewayMapper;
|
|
|
import shop.alien.mapper.second.SecondRiskControlRecordMapper;
|
|
|
+import shop.alien.mapper.second.SecondUserCreditMapper;
|
|
|
+import shop.alien.mapper.second.SecondUserCreditRecordMapper;
|
|
|
import shop.alien.util.common.JwtUtil;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
@@ -50,6 +56,12 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
|
|
|
private final LifeUserLogTransactionService lifeUserLogTransactionService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private final SecondUserCreditMapper secondUserCreditMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private final SecondUserCreditRecordMapper secondUserCreditRecordMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private RiskControlProperties riskControlProperties;
|
|
|
|
|
|
@Value("${jwt.expiration-time}")
|
|
|
@@ -156,10 +168,35 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
|
|
|
List<LifeUserLog> lsit = lifeUserLogTransactionService.getLifeUserLogByDate(startDate, endDate, macIp);
|
|
|
|
|
|
if (lsit.size() > riskControlProperties.getAccountAbnormal().getRegCount24h() && !isViolation(startDate, endDate, macIp, user.getId())) {
|
|
|
- String detailInfo = lsit.stream()
|
|
|
- .map(row -> row.getUserId().toString())
|
|
|
- .collect(Collectors.joining(","));
|
|
|
- alienSecondFeign.recordRiskControlData(user.getId(), 2, "账号异常", macIp, detailInfo);
|
|
|
+
|
|
|
+ for (LifeUserLog row: lsit) {
|
|
|
+ List<SecondUserCreditRecord> num = secondUserCreditRecordMapper.selectList(new LambdaQueryWrapper<SecondUserCreditRecord>()
|
|
|
+ .eq(SecondUserCreditRecord::getUserId, row.getUserId())
|
|
|
+ .eq(SecondUserCreditRecord::getPointsType, 5)
|
|
|
+ .ge(SecondUserCreditRecord::getCreatedTime, startDate)
|
|
|
+ .le(SecondUserCreditRecord::getCreatedTime, endDate));
|
|
|
+
|
|
|
+ if (num.size() <= 0) {
|
|
|
+ SecondUserCreditRecord record = new SecondUserCreditRecord();
|
|
|
+ record.setUserId(row.getUserId());
|
|
|
+ record.setPointsType(5);
|
|
|
+ record.setPoints(-10);
|
|
|
+ record.setCreatedTime(new Date());
|
|
|
+ secondUserCreditRecordMapper.insert(record);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<SecondUserCredit> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SecondUserCredit::getUserId, row.getUserId())
|
|
|
+ .orderByDesc(SecondUserCredit::getCreatedTime).last("LIMIT 1");
|
|
|
+ SecondUserCredit secondUserCredit = secondUserCreditMapper.selectOne(queryWrapper);
|
|
|
+ secondUserCredit.setUserPoints(secondUserCredit.getUserPoints() - 10);
|
|
|
+ secondUserCreditMapper.updateById(secondUserCredit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// String detailInfo = lsit.stream()
|
|
|
+// .map(row -> row.getUserId().toString())
|
|
|
+// .collect(Collectors.joining(","));
|
|
|
+// alienSecondFeign.recordRiskControlData(user.getId(), 2, "账号异常", macIp, detailInfo);
|
|
|
}
|
|
|
}
|
|
|
// 第一次登录,添加用户基础积分
|