|
|
@@ -58,7 +58,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
*/
|
|
|
@Value("${video.moderation.enabled}")
|
|
|
private boolean videoModerationEnabled;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 视频审核失败时是否阻塞商品发布的配置项
|
|
|
*/
|
|
|
@@ -129,7 +129,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
* 店铺服务Feign接口,用于跨服务调用
|
|
|
*/
|
|
|
private final AlienStoreFeign alienStoreFeign;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 商品操作历史记录Mapper,用于操作商品操作记录表
|
|
|
*/
|
|
|
@@ -145,7 +145,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
* 用户违规举报Mapper,用于操作用户举报记录表
|
|
|
*/
|
|
|
private final LifeUserViolationMapper lifeUserViolationMapper;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 字典Mapper,用于操作数据字典表
|
|
|
*/
|
|
|
@@ -166,7 +166,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
*/
|
|
|
@Autowired
|
|
|
private RiskControlProperties riskControlProperties;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 风控服务,提供风控相关业务逻辑处理
|
|
|
*/
|
|
|
@@ -222,7 +222,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
.eq(StoreImg::getDeleteFlag, Constants.DeleteFlag.NOT_DELETED)
|
|
|
.orderByAsc(StoreImg::getImgSort);
|
|
|
List<StoreImg> imageList = storeImgMapper.selectList(imageQueryWrapper);
|
|
|
-
|
|
|
+
|
|
|
// 4. 提取图片URL列表
|
|
|
if (CollectionUtil.isNotEmpty(imageList)) {
|
|
|
List<String> imageUrls = imageList.stream()
|
|
|
@@ -259,7 +259,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
.orderByDesc(SecondGoodsRecord::getCreatedTime);
|
|
|
List<SecondGoodsRecord> operationRecords = secondGoodsRecordMapper.selectdminGoodsList(recordQueryWrapper);
|
|
|
detailVo.setOperationRecords(operationRecords);
|
|
|
-
|
|
|
+
|
|
|
// 4. 获取商品交易记录集合
|
|
|
QueryWrapper<SecondTradeRecord> tradeQueryWrapper = new QueryWrapper<>();
|
|
|
tradeQueryWrapper.eq("goods_id", goodsId)
|
|
|
@@ -285,7 +285,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
}
|
|
|
}
|
|
|
detailVo.setTradeRecords(secondTradeRecordVos);
|
|
|
-
|
|
|
+
|
|
|
// 5. 获取商品举报集合
|
|
|
QueryWrapper<LifeUserViolation> reportQueryWrapper = new QueryWrapper<>();
|
|
|
reportQueryWrapper.lambda()
|
|
|
@@ -293,11 +293,11 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
.eq(LifeUserViolation::getReportContextType, "4") // 4:二手商品
|
|
|
.orderByDesc(LifeUserViolation::getCreatedTime);
|
|
|
List<LifeUserViolation> reports = lifeUserViolationMapper.selectList(reportQueryWrapper);
|
|
|
-
|
|
|
+
|
|
|
// 转换举报信息为SecondReportingVo
|
|
|
List<SecondReportingVo> reportingVos = convertReportsToVos(reports);
|
|
|
detailVo.setReports(reportingVos);
|
|
|
-
|
|
|
+
|
|
|
return detailVo;
|
|
|
}
|
|
|
|
|
|
@@ -413,7 +413,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
record.setUpdatedTime(goods.getUpdatedTime());
|
|
|
record.setUpdatedUserId(goods.getUpdatedUserId());
|
|
|
record.setAddressText(goods.getAddressText());
|
|
|
-
|
|
|
+
|
|
|
secondGoodsRecordMapper.insert(record);
|
|
|
log.warn("创建操作历史结束: {} ", record);
|
|
|
// 保存图片信息
|
|
|
@@ -473,18 +473,18 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
*/
|
|
|
private List<SecondReportingVo> convertReportsToVos(List<LifeUserViolation> reports) {
|
|
|
List<SecondReportingVo> reportingVos = new ArrayList<>();
|
|
|
-
|
|
|
+
|
|
|
// 获取所有相关的举报类型字典信息
|
|
|
List<String> dictTypes = reports.stream()
|
|
|
.map(LifeUserViolation::getDictType)
|
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
-
|
|
|
+
|
|
|
List<Integer> dictIds = reports.stream()
|
|
|
.map(LifeUserViolation::getDictId)
|
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
-
|
|
|
+
|
|
|
Map<String, StoreDictionary> dictMap = new HashMap<>();
|
|
|
if (!dictTypes.isEmpty() && !dictIds.isEmpty()) {
|
|
|
QueryWrapper<StoreDictionary> dictQueryWrapper = new QueryWrapper<>();
|
|
|
@@ -494,10 +494,10 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
List<StoreDictionary> dicts = storeDictionaryMapper.selectList(dictQueryWrapper);
|
|
|
dictMap = dicts.stream()
|
|
|
.collect(Collectors.toMap(
|
|
|
- d -> d.getTypeName() + "_" + d.getDictId(),
|
|
|
- d -> d));
|
|
|
+ d -> d.getTypeName() + "_" + d.getDictId(),
|
|
|
+ d -> d));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 转换每个举报信息
|
|
|
for (LifeUserViolation report : reports) {
|
|
|
SecondReportingVo reportingVo = new SecondReportingVo();
|
|
|
@@ -516,14 +516,14 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
reportingVo.setId(report.getId());
|
|
|
// 处理状态
|
|
|
reportingVo.setProcessingStatus(report.getProcessingStatus());
|
|
|
-
|
|
|
+
|
|
|
// 举报时间
|
|
|
reportingVo.setReportingTime(report.getCreatedTime());
|
|
|
// 举报内容补充
|
|
|
reportingVo.setReportingContext(report.getOtherReasonContent());
|
|
|
// reportingVo.setFeedbackTime(report.getCreatedTime());
|
|
|
// reportingVo.setFeedbackContext("平台已受理,感谢您的反馈!");
|
|
|
-
|
|
|
+
|
|
|
// 获取举报类型信息
|
|
|
StoreDictionary storeDictionary = dictMap.get(report.getDictType() + "_" + report.getDictId());
|
|
|
// 举报类型
|
|
|
@@ -550,10 +550,10 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
.collect(Collectors.toList());
|
|
|
reportingVo.setImgList(processReportImages(imgList,1));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
reportingVos.add(reportingVo);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return reportingVos;
|
|
|
}
|
|
|
|
|
|
@@ -578,7 +578,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
if (img == null || StringUtils.isBlank(img.getImgUrl())) {
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
String fileType = img.getImgUrl().substring(img.getImgUrl().lastIndexOf(".") + 1);
|
|
|
if (videoFileType.contains(fileType.toLowerCase())) {
|
|
|
@@ -650,7 +650,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
// 保存商品基本信息
|
|
|
saveResult = save(goods);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (!saveResult) {
|
|
|
return false; // 保存失败直接返回
|
|
|
}
|
|
|
@@ -770,10 +770,10 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
// 获取配置的阈值
|
|
|
int sameCategoryLimit = riskControlProperties.getAbnormalPublish().getSameCategoryCount24h();
|
|
|
int timeWindowHours = riskControlProperties.getAbnormalPublish().getTimeWindowHours();
|
|
|
-
|
|
|
+
|
|
|
// 计算时间窗口前的时间
|
|
|
Date timeWindowStart = new Date(System.currentTimeMillis() - timeWindowHours * 60 * 60 * 1000L);
|
|
|
-
|
|
|
+
|
|
|
// 查询用户在时间窗口内发布同类商品的数量
|
|
|
LambdaQueryWrapper<SecondGoods> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(SecondGoods::getUserId, goods.getUserId())
|
|
|
@@ -933,7 +933,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
// 插入审核记录
|
|
|
createGoodsAudit(goods, "", Constants.AuditStatus.PASSED);
|
|
|
// 发送审核成功消息
|
|
|
-// sendMessage(goods);
|
|
|
+ sendMessage(goods);
|
|
|
isNotified = true; // 标记通知已发送
|
|
|
// 上架 记录商品操作历史
|
|
|
String operationName = "";
|
|
|
@@ -1070,7 +1070,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
// 使用商品发布场景的审核服务
|
|
|
String test = goodsDTO.getDescription() + goodsDTO.getTitle() + goods.getLabel() + goods.getTopic();
|
|
|
TextModerationResultVO textCheckResult = textModerationUtil.invokeFunction(test, servicesList);
|
|
|
-
|
|
|
+
|
|
|
if ("high".equals(textCheckResult.getRiskLevel())) {
|
|
|
// 文本审核不通过或存在高风险
|
|
|
goods.setGoodsStatus(SecondGoodsStatusEnum.REVIEW_FAILED.getCode()); // 审核失败
|
|
|
@@ -1108,7 +1108,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 视频审核
|
|
|
if (videoModerationEnabled) {
|
|
|
List<String> videoUrls = extractVideoUrls(goodsDTO.getImgUrl());
|
|
|
@@ -1131,7 +1131,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 如果成功提交了视频审核任务,设置商品状态为审核中
|
|
|
if (!taskIds.isEmpty()) {
|
|
|
goods.setGoodsStatus(SecondGoodsStatusEnum.UNDER_REVIEW.getCode()); // 审核中
|
|
|
@@ -1154,7 +1154,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
// 插入审核记录
|
|
|
createGoodsAudit(goods, "", Constants.AuditStatus.PASSED);
|
|
|
// 发送审核成功消息
|
|
|
-// sendMessage(goods);
|
|
|
+ sendMessage(goods);
|
|
|
// 审核成功,记录操作历史
|
|
|
String operationName = "";
|
|
|
QueryWrapper<SecondGoodsRecord> queryWrapper = new QueryWrapper<>();
|
|
|
@@ -1168,7 +1168,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
recordGoodsOperation(goods, operationName);
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 从图片URL列表中提取视频URL
|
|
|
* @param imageUrls 图片URL列表
|
|
|
@@ -1178,7 +1178,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
if (CollectionUtil.isEmpty(imageUrls)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
List<String> videoUrls = new ArrayList<>();
|
|
|
for (String url : imageUrls) {
|
|
|
if (isVideoUrl(url)) {
|
|
|
@@ -1355,11 +1355,11 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
if (url == null) return false;
|
|
|
url = url.toLowerCase();
|
|
|
return url.endsWith(".mp4") ||
|
|
|
- url.endsWith(".avi") ||
|
|
|
- url.endsWith(".mov") ||
|
|
|
- url.endsWith(".flv") ||
|
|
|
- url.endsWith(".wmv") ||
|
|
|
- url.endsWith(".mkv");
|
|
|
+ url.endsWith(".avi") ||
|
|
|
+ url.endsWith(".mov") ||
|
|
|
+ url.endsWith(".flv") ||
|
|
|
+ url.endsWith(".wmv") ||
|
|
|
+ url.endsWith(".mkv");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1510,7 +1510,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
if (!StringUtils.isEmpty(secondGoodsVo.getSearchData())) {
|
|
|
String searchData = "%" + secondGoodsVo.getSearchData() + "%";
|
|
|
queryWrapper.and(wrapper -> wrapper
|
|
|
- .like("sg.title", searchData)
|
|
|
+ .like("sg.title", searchData)
|
|
|
// .or()
|
|
|
// .like("sg.label", searchData)
|
|
|
// .or()
|
|
|
@@ -1589,9 +1589,9 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
.eq(LifeCollect::getBusinessType, Constants.CollectBusinessType.DEFAULT)
|
|
|
.eq(LifeCollect::getDeleteFlag, Constants.DeleteFlag.NOT_DELETED)
|
|
|
.eq(LifeCollect::getBusinessId, goods.getId());
|
|
|
- if (lifeCollectMapper.selectCount(updateWrapper) > 0) {
|
|
|
- goods.setCollectStatus(1);
|
|
|
- }
|
|
|
+ if (lifeCollectMapper.selectCount(updateWrapper) > 0) {
|
|
|
+ goods.setCollectStatus(1);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -1741,9 +1741,9 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
QueryWrapper<SecondGoodsVo> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("sg.delete_flag", Constants.DeleteFlag.NOT_DELETED)
|
|
|
.eq("sg.user_id", userId) // 用户ID
|
|
|
- .in("sg.goods_status", SecondGoodsStatusEnum.REVIEW_FAILED.getCode(),
|
|
|
- SecondGoodsStatusEnum.DELISTED.getCode(),
|
|
|
- SecondGoodsStatusEnum.SOLD.getCode(),
|
|
|
+ .in("sg.goods_status", SecondGoodsStatusEnum.REVIEW_FAILED.getCode(),
|
|
|
+ SecondGoodsStatusEnum.DELISTED.getCode(),
|
|
|
+ SecondGoodsStatusEnum.SOLD.getCode(),
|
|
|
SecondGoodsStatusEnum.LISTED.getCode()) // 3-上架 5-已售出
|
|
|
.orderByAsc("FIELD(sg.goods_status, 2, 4, 5, 3)")
|
|
|
.orderByDesc("sg.release_time");
|
|
|
@@ -1845,12 +1845,12 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
QueryWrapper<SecondGoods> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("video_task_id", task.getTaskId());
|
|
|
SecondGoods goods = getOne(queryWrapper);
|
|
|
-
|
|
|
+
|
|
|
if (goods == null) {
|
|
|
log.warn("未找到关联的商品,任务ID: {}", task.getTaskId());
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 根据审核结果更新商品状态
|
|
|
if ("none".equals(task.getRiskLevel())) {
|
|
|
log.warn("视频审核通过,任务ID: {}", task.getTaskId());
|
|
|
@@ -1925,7 +1925,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
log.error("处理视频审核结果时发生异常,任务ID: {}", task.getTaskId(), e);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 解析视频审核失败原因
|
|
|
* @param task 视频审核任务
|
|
|
@@ -1933,13 +1933,13 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
*/
|
|
|
private String parseVideoModerationFailureReason(SecondVideoTask task) {
|
|
|
StringBuilder reasonBuilder = new StringBuilder("视频审核不通过,风险等级: " + task.getRiskLevel());
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
// 解析审核结果JSON
|
|
|
JSONObject resultJson = JSON.parseObject(task.getResult());
|
|
|
if (resultJson != null && resultJson.containsKey("data")) {
|
|
|
JSONObject data = resultJson.getJSONObject("data");
|
|
|
-
|
|
|
+
|
|
|
// 处理帧结果(视频画面)
|
|
|
if (data.containsKey("FrameResult")) {
|
|
|
JSONObject frameResult = data.getJSONObject("FrameResult");
|
|
|
@@ -1952,7 +1952,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
String label = summary.getString("Label");
|
|
|
String description = summary.getString("Description");
|
|
|
Integer labelSum = summary.getInteger("LabelSum");
|
|
|
-
|
|
|
+
|
|
|
if (label != null && !label.isEmpty()) {
|
|
|
reasonBuilder.append("[").append(description != null ? description : label)
|
|
|
.append("]出现").append(labelSum != null ? labelSum : 1).append("次;");
|
|
|
@@ -1961,7 +1961,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 处理音频结果
|
|
|
if (data.containsKey("AudioResult")) {
|
|
|
JSONObject audioResult = data.getJSONObject("AudioResult");
|
|
|
@@ -1974,7 +1974,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
String label = summary.getString("Label");
|
|
|
String description = summary.getString("Description");
|
|
|
Integer labelSum = summary.getInteger("LabelSum");
|
|
|
-
|
|
|
+
|
|
|
if (label != null && !label.isEmpty()) {
|
|
|
reasonBuilder.append("[").append(description != null ? description : label)
|
|
|
.append("]出现").append(labelSum != null ? labelSum : 1).append("次;");
|
|
|
@@ -1987,7 +1987,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
} catch (Exception e) {
|
|
|
log.warn("解析视频审核结果失败,使用默认原因,任务ID: {}", task.getTaskId(), e);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return reasonBuilder.toString();
|
|
|
}
|
|
|
|
|
|
@@ -1996,31 +1996,31 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
* @param searchGoodsList 搜索结果
|
|
|
*/
|
|
|
private void batchSetSearchUserInfo(IPage<SecondGoodsVo> searchGoodsList) {
|
|
|
- batchSetUserInfo(searchGoodsList,
|
|
|
- SecondGoodsVo::getUserId,
|
|
|
- (goods, userInfo) -> {
|
|
|
- goods.setUserName(userInfo.getUserName());
|
|
|
- goods.setRealName(userInfo.getRealName());
|
|
|
- goods.setUserImage(userInfo.getUserImage());
|
|
|
- goods.setUserId(userInfo.getId());
|
|
|
- goods.setUserPhone("user_"+userInfo.getUserPhone());
|
|
|
- });
|
|
|
+ batchSetUserInfo(searchGoodsList,
|
|
|
+ SecondGoodsVo::getUserId,
|
|
|
+ (goods, userInfo) -> {
|
|
|
+ goods.setUserName(userInfo.getUserName());
|
|
|
+ goods.setRealName(userInfo.getRealName());
|
|
|
+ goods.setUserImage(userInfo.getUserImage());
|
|
|
+ goods.setUserId(userInfo.getId());
|
|
|
+ goods.setUserPhone("user_"+userInfo.getUserPhone());
|
|
|
+ });
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 批量设置用户信息(用于SellGoodsVo列表)
|
|
|
* @param sellGoodsList 搜索结果
|
|
|
*/
|
|
|
private void batchSetSellUserInfo(IPage<SellGoodsVo> sellGoodsList) {
|
|
|
- batchSetUserInfo(sellGoodsList,
|
|
|
- SellGoodsVo::getUserId,
|
|
|
- (goods, userInfo) -> {
|
|
|
- goods.setUserName(userInfo.getUserName());
|
|
|
- goods.setRealName(userInfo.getRealName());
|
|
|
- goods.setUserImage(userInfo.getUserImage());
|
|
|
- goods.setUserId(userInfo.getId());
|
|
|
- goods.setUserPhone(userInfo.getUserPhone());
|
|
|
- });
|
|
|
+ batchSetUserInfo(sellGoodsList,
|
|
|
+ SellGoodsVo::getUserId,
|
|
|
+ (goods, userInfo) -> {
|
|
|
+ goods.setUserName(userInfo.getUserName());
|
|
|
+ goods.setRealName(userInfo.getRealName());
|
|
|
+ goods.setUserImage(userInfo.getUserImage());
|
|
|
+ goods.setUserId(userInfo.getId());
|
|
|
+ goods.setUserPhone(userInfo.getUserPhone());
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -2065,36 +2065,36 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
List<Integer> goodsIds = goodsList.getRecords().stream()
|
|
|
.map(SecondGoodsVo::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
- // 批量获取图片信息
|
|
|
- QueryWrapper<StoreImg> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda()
|
|
|
- .eq(StoreImg::getImgType, Constants.ImageType.SECOND_HAND_GOODS) // 商品 图片
|
|
|
- .eq(StoreImg::getDeleteFlag, Constants.DeleteFlag.NOT_DELETED)
|
|
|
- .in(StoreImg::getStoreId, goodsIds);
|
|
|
- List<StoreImg> imagesList= storeImgMapper.getImgsByGoodsIds(queryWrapper);
|
|
|
- // 集合根據商品id进行分组返回map
|
|
|
- Map<Integer, List<StoreImg>> imagesMap = imagesList.stream().collect(Collectors.groupingBy(StoreImg::getStoreId));
|
|
|
- // 遍历
|
|
|
- for (SecondGoodsVo goods : goodsList.getRecords()) {
|
|
|
- // 提取图片url
|
|
|
- List<StoreImg> images = imagesMap.get(goods.getId());
|
|
|
- if (images != null) {
|
|
|
- goods.setImgUrl(images.stream()
|
|
|
- .map(StoreImg::getImgUrl)
|
|
|
- .collect(Collectors.toList()));
|
|
|
+ // 批量获取图片信息
|
|
|
+ QueryWrapper<StoreImg> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(StoreImg::getImgType, Constants.ImageType.SECOND_HAND_GOODS) // 商品 图片
|
|
|
+ .eq(StoreImg::getDeleteFlag, Constants.DeleteFlag.NOT_DELETED)
|
|
|
+ .in(StoreImg::getStoreId, goodsIds);
|
|
|
+ List<StoreImg> imagesList= storeImgMapper.getImgsByGoodsIds(queryWrapper);
|
|
|
+ // 集合根據商品id进行分组返回map
|
|
|
+ Map<Integer, List<StoreImg>> imagesMap = imagesList.stream().collect(Collectors.groupingBy(StoreImg::getStoreId));
|
|
|
+ // 遍历
|
|
|
+ for (SecondGoodsVo goods : goodsList.getRecords()) {
|
|
|
+ // 提取图片url
|
|
|
+ List<StoreImg> images = imagesMap.get(goods.getId());
|
|
|
+ if (images != null) {
|
|
|
+ goods.setImgUrl(images.stream()
|
|
|
+ .map(StoreImg::getImgUrl)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- // 设置状态名称
|
|
|
- if (goods.getDeleteFlag() != null && goods.getDeleteFlag().equals(Constants.DeleteFlag.DELETED)) {
|
|
|
- goods.setGoodsStatusName("已删除");
|
|
|
- } else if (goods.getGoodsStatus() != null) {
|
|
|
- SecondGoodsStatusEnum statusEnum = SecondGoodsStatusEnum.fromCode(goods.getGoodsStatus());
|
|
|
- if (statusEnum != null) {
|
|
|
- goods.setGoodsStatusName(statusEnum.getDescription());
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置状态名称
|
|
|
+ if (goods.getDeleteFlag() != null && goods.getDeleteFlag().equals(Constants.DeleteFlag.DELETED)) {
|
|
|
+ goods.setGoodsStatusName("已删除");
|
|
|
+ } else if (goods.getGoodsStatus() != null) {
|
|
|
+ SecondGoodsStatusEnum statusEnum = SecondGoodsStatusEnum.fromCode(goods.getGoodsStatus());
|
|
|
+ if (statusEnum != null) {
|
|
|
+ goods.setGoodsStatusName(statusEnum.getDescription());
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2141,7 +2141,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
public IPage<SecondGoodsVo> getAdminGoodsList(IPage<SecondGoodsVo> page, SecondGoodsAdminQueryDTO queryDTO) {
|
|
|
// 构建查询条件
|
|
|
QueryWrapper<SecondGoodsVo> queryWrapper = new QueryWrapper<>();
|
|
|
-
|
|
|
+
|
|
|
// 商品名称模糊查询
|
|
|
queryWrapper.like(org.apache.commons.lang3.StringUtils.isNotBlank(queryDTO.getTitle()), "sg.title", queryDTO.getTitle());
|
|
|
// 过滤草稿
|
|
|
@@ -2157,17 +2157,17 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
.eq("sg.delete_flag", Constants.DeleteFlag.NOT_DELETED);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 发布时间范围查询
|
|
|
queryWrapper.ge(queryDTO.getReleaseStartTime() != null, "sg.release_time", queryDTO.getReleaseStartTime())
|
|
|
- .le(queryDTO.getReleaseEndTime() != null, "sg.release_time", queryDTO.getReleaseEndTime());
|
|
|
+ .le(queryDTO.getReleaseEndTime() != null, "sg.release_time", queryDTO.getReleaseEndTime());
|
|
|
queryWrapper.orderByDesc("sg.id");
|
|
|
// 查询数据
|
|
|
IPage<SecondGoodsVo> result = secondGoodsMapper.getAdminGoodsList(page, queryWrapper);
|
|
|
-
|
|
|
+
|
|
|
// 批量设置商品图片信息
|
|
|
batchSetGoodsImagesForAdmin(result);
|
|
|
-
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -2180,25 +2180,25 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
if (goodsIds == null || goodsIds.isEmpty()) {
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 批量更新商品状态为下架状态
|
|
|
LambdaUpdateWrapper<SecondGoods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.in(SecondGoods::getId, goodsIds)
|
|
|
.set(SecondGoods::getGoodsStatus, SecondGoodsStatusEnum.DELISTED.getCode());
|
|
|
-
|
|
|
+
|
|
|
boolean updateResult = update(updateWrapper);
|
|
|
-
|
|
|
+
|
|
|
if (updateResult) {
|
|
|
// 批量查询更新后的商品信息
|
|
|
Collection<SecondGoods> updatedGoodsList = listByIds(goodsIds);
|
|
|
-
|
|
|
+
|
|
|
// 为每个商品记录操作历史并发送通知
|
|
|
for (SecondGoods goods : updatedGoodsList) {
|
|
|
recordGoodsOperation(goods, "风控下架");
|
|
|
-// sendShelveMessage(goods);
|
|
|
+ sendShelveMessage(goods);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return updateResult;
|
|
|
}
|
|
|
|
|
|
@@ -2269,7 +2269,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
SecondGoods updatedGoods = getById(secondGoods.getId());
|
|
|
recordGoodsOperation(updatedGoods, "下架商品");
|
|
|
// 发送系统通知
|
|
|
-// sendShelveMessage(updatedGoods);
|
|
|
+ sendShelveMessage(updatedGoods);
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|