|
|
@@ -20,6 +20,7 @@ import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
+import shop.alien.config.properties.RiskControlProperties;
|
|
|
import shop.alien.entity.SecondVideoTask;
|
|
|
import shop.alien.entity.second.*;
|
|
|
import shop.alien.entity.second.SecondTradeRecord;
|
|
|
@@ -151,6 +152,9 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
*/
|
|
|
private final PlatformSecondTradeService platformSecondTradeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RiskControlProperties riskControlProperties;
|
|
|
+
|
|
|
@Override
|
|
|
public SecondGoodsRecordDetailVo getAdminGoodsRecordDetail(Integer recordId) {
|
|
|
// 1. 获取商品操作记录基本信息
|
|
|
@@ -550,6 +554,19 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
SecondGoods goods = new SecondGoods();
|
|
|
BeanUtils.copyProperties(goodsDTO, goods);
|
|
|
|
|
|
+ // 检查用户是否在24小时内发布商品超过阈值
|
|
|
+ if (!checkUserPublishLimit(goods)) {
|
|
|
+ log.warn("用户 {} 在24小时内发布商品次数超过限制", goodsDTO.getUserId());
|
|
|
+ // TODO 插入风控记录
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查用户是否在24小时内发布同类商品超过阈值
|
|
|
+ if (!checkUserPublishSameCategoryLimit(goods)) {
|
|
|
+ log.warn("用户 {} 在24小时内发布同类商品次数超过限制", goodsDTO.getUserId());
|
|
|
+ // TODO 插入风控记录
|
|
|
+ }
|
|
|
+
|
|
|
boolean saveResult;
|
|
|
if (editFlag == 1) {
|
|
|
goods.setId(goodsDTO.getId());
|
|
|
@@ -587,6 +604,62 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查用户在24小时内 频繁修改发布商品的数量是否超过限制
|
|
|
+ * @param goods 用户ID,商品ID
|
|
|
+ * @return 是否未超过限制
|
|
|
+ */
|
|
|
+ private boolean checkUserPublishLimit(SecondGoods goods) {
|
|
|
+ // 获取配置的阈值
|
|
|
+ int publishLimit = riskControlProperties.getTradeFraud().getPublishCount24h();
|
|
|
+
|
|
|
+ // 计算24小时前的时间
|
|
|
+ Date twentyFourHoursAgo = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000L);
|
|
|
+
|
|
|
+ // 查询用户在24小时内发布的商品数量
|
|
|
+ LambdaQueryWrapper<SecondGoodsRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SecondGoodsRecord::getUserId, goods.getUserId())
|
|
|
+ .eq(SecondGoodsRecord::getId, goods.getId())
|
|
|
+ .ge(SecondGoodsRecord::getReleaseTime, twentyFourHoursAgo)
|
|
|
+ .in(SecondGoodsRecord::getGoodsStatus,
|
|
|
+ SecondGoodsStatusEnum.LISTED.getCode(),
|
|
|
+ SecondGoodsStatusEnum.SOLD.getCode());
|
|
|
+
|
|
|
+ int publishCount = secondGoodsRecordMapper.selectCount(queryWrapper);
|
|
|
+
|
|
|
+ // 如果发布数量超过限制,返回false
|
|
|
+ return publishCount < publishLimit;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查用户在24小时内发布同类商品的数量是否超过限制
|
|
|
+ * @param goods 商品信息
|
|
|
+ * @return 是否未超过限制
|
|
|
+ */
|
|
|
+ private boolean checkUserPublishSameCategoryLimit(SecondGoods goods) {
|
|
|
+ // 获取配置的阈值
|
|
|
+ int sameCategoryLimit = riskControlProperties.getAbnormalPublish().getSameCategoryCount24h();
|
|
|
+
|
|
|
+ // 计算24小时前的时间
|
|
|
+ Date twentyFourHoursAgo = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000L);
|
|
|
+
|
|
|
+ // 查询用户在24小时内发布同类商品的数量
|
|
|
+ LambdaQueryWrapper<SecondGoodsRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SecondGoodsRecord::getUserId, goods.getUserId())
|
|
|
+ .eq(SecondGoodsRecord::getCategoryOneId, goods.getCategoryOneId())
|
|
|
+ .eq(SecondGoodsRecord::getCategoryTwoId, goods.getCategoryTwoId())
|
|
|
+ .ge(SecondGoodsRecord::getReleaseTime, twentyFourHoursAgo)
|
|
|
+ .in(SecondGoodsRecord::getGoodsStatus,
|
|
|
+ SecondGoodsStatusEnum.LISTED.getCode(),
|
|
|
+ SecondGoodsStatusEnum.SOLD.getCode());
|
|
|
+
|
|
|
+ int sameCategoryCount = secondGoodsRecordMapper.selectCount(queryWrapper);
|
|
|
+
|
|
|
+ // 如果发布数量超过限制,返回false
|
|
|
+ return sameCategoryCount < sameCategoryLimit;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 执行内容审核
|
|
|
* @param goodsDTO 商品信息
|