|
@@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
import shop.alien.entity.SecondVideoTask;
|
|
import shop.alien.entity.SecondVideoTask;
|
|
@@ -105,6 +107,12 @@ public class SecondGoodsAuditServiceImpl implements SecondGoodsAuditService {
|
|
|
|
|
|
|
|
private final AiTaskUtils aiTaskUtil;
|
|
private final AiTaskUtils aiTaskUtil;
|
|
|
|
|
|
|
|
|
|
+ @Lazy
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SecondGoodsService secondGoodsService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 执行内容审核
|
|
* 执行内容审核
|
|
|
* @param goodsDTO 商品信息
|
|
* @param goodsDTO 商品信息
|
|
@@ -407,6 +415,43 @@ public class SecondGoodsAuditServiceImpl implements SecondGoodsAuditService {
|
|
|
operationName = "首次发布";
|
|
operationName = "首次发布";
|
|
|
}
|
|
}
|
|
|
operationRecordService.recordGoodsOperation(goods, operationName);
|
|
operationRecordService.recordGoodsOperation(goods, operationName);
|
|
|
|
|
+
|
|
|
|
|
+ // 审核通过
|
|
|
|
|
+// goods.setGoodsStatus(SecondGoodsStatusEnum.LISTED.getCode());
|
|
|
|
|
+// goods.setFailedReason("");
|
|
|
|
|
+// goods.setReleaseTime(new Date());
|
|
|
|
|
+// updateById(goods);
|
|
|
|
|
+//
|
|
|
|
|
+// // 更新审核记录
|
|
|
|
|
+// createGoodsAudit(goods, "", Constants.AuditStatus.PASSED);
|
|
|
|
|
+//
|
|
|
|
|
+// // 发送审核成功消息
|
|
|
|
|
+// sendMessage(goods);
|
|
|
|
|
+// // 审核成功,记录操作历史
|
|
|
|
|
+// // 审核成功,记录操作历史
|
|
|
|
|
+// String operationName = "";
|
|
|
|
|
+// QueryWrapper<SecondGoodsRecord> queryRecordWrapper = new QueryWrapper<>();
|
|
|
|
|
+// queryRecordWrapper.eq("goods_id", goods.getId());
|
|
|
|
|
+// log.info("查询操作记录开始 goods_id: {}", goods.getId());
|
|
|
|
|
+// List<SecondGoodsRecord> recordList = secondGoodsRecordMapper.selectList(queryRecordWrapper);
|
|
|
|
|
+// log.info("查询操作记录结束 recordList: {}", recordList);
|
|
|
|
|
+// if (CollectionUtil.isNotEmpty(recordList)){
|
|
|
|
|
+// operationName = "重新发布";
|
|
|
|
|
+// }else {
|
|
|
|
|
+// operationName = "首次发布";
|
|
|
|
|
+// }
|
|
|
|
|
+// recordGoodsOperation(goods, operationName);
|
|
|
|
|
+//
|
|
|
|
|
+// // 检查用户是否在24小时内发布同类商品超过阈值
|
|
|
|
|
+// if (!checkUserPublishSameCategoryLimit(goods)) {
|
|
|
|
|
+// log.warn("用户 {} 在24小时内发布同类商品次数超过限制", goods.getUserId());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// // 检查用户是否在24小时内发布商品超过阈值
|
|
|
|
|
+// if (!checkUserPublishLimit(goods)) {
|
|
|
|
|
+// log.warn("用户 {} 在24小时内发布商品次数超过限制", goods.getUserId());
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("商品上架过程中发生异常,执行回滚", e);
|
|
log.error("商品上架过程中发生异常,执行回滚", e);
|
|
|
// 如果通知已发送但后续操作失败,需要补偿
|
|
// 如果通知已发送但后续操作失败,需要补偿
|
|
@@ -640,14 +685,14 @@ public class SecondGoodsAuditServiceImpl implements SecondGoodsAuditService {
|
|
|
if ("pass".equals(result)) {
|
|
if ("pass".equals(result)) {
|
|
|
// 审核通过,上架商品
|
|
// 审核通过,上架商品
|
|
|
log.info("AI审核通过,商品ID: {}, taskId: {}", goods.getId(), task.getTaskId());
|
|
log.info("AI审核通过,商品ID: {}, taskId: {}", goods.getId(), task.getTaskId());
|
|
|
- approveAndListGoods(goods);
|
|
|
|
|
|
|
+ handleGoodsApprovalSuccess(goods);
|
|
|
return "success";
|
|
return "success";
|
|
|
- } else if ("reject".equals(result)) {
|
|
|
|
|
|
|
+ } else if ("reject".equals(result) || "suspect".equals(result)) {
|
|
|
// 审核拒绝,处理失败流程
|
|
// 审核拒绝,处理失败流程
|
|
|
String reason = dataJson.getString("reason");
|
|
String reason = dataJson.getString("reason");
|
|
|
String violation = dataJson.getString("violation");
|
|
String violation = dataJson.getString("violation");
|
|
|
String ruleHit = dataJson.getString("rule_hit");
|
|
String ruleHit = dataJson.getString("rule_hit");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 构建失败原因
|
|
// 构建失败原因
|
|
|
StringBuilder failReason = new StringBuilder("AI审核不通过");
|
|
StringBuilder failReason = new StringBuilder("AI审核不通过");
|
|
|
if (StringUtils.hasText(reason)) {
|
|
if (StringUtils.hasText(reason)) {
|
|
@@ -659,23 +704,23 @@ public class SecondGoodsAuditServiceImpl implements SecondGoodsAuditService {
|
|
|
if (StringUtils.hasText(ruleHit)) {
|
|
if (StringUtils.hasText(ruleHit)) {
|
|
|
failReason.append(",命中规则:").append(ruleHit);
|
|
failReason.append(",命中规则:").append(ruleHit);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
log.info("AI审核拒绝,商品ID: {}, taskId: {}, 原因: {}", goods.getId(), task.getTaskId(), failReason);
|
|
log.info("AI审核拒绝,商品ID: {}, taskId: {}, 原因: {}", goods.getId(), task.getTaskId(), failReason);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 更新商品状态为审核失败
|
|
// 更新商品状态为审核失败
|
|
|
goods.setGoodsStatus(SecondGoodsStatusEnum.REVIEW_FAILED.getCode());
|
|
goods.setGoodsStatus(SecondGoodsStatusEnum.REVIEW_FAILED.getCode());
|
|
|
goods.setFailedReason(failReason.toString());
|
|
goods.setFailedReason(failReason.toString());
|
|
|
secondGoodsMapper.updateById(goods);
|
|
secondGoodsMapper.updateById(goods);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 创建审核失败记录
|
|
// 创建审核失败记录
|
|
|
createGoodsAudit(goods, failReason.toString(), Constants.AuditStatus.FAILED);
|
|
createGoodsAudit(goods, failReason.toString(), Constants.AuditStatus.FAILED);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 记录操作历史
|
|
// 记录操作历史
|
|
|
operationRecordService.recordGoodsOperation(goods, "AI审核失败");
|
|
operationRecordService.recordGoodsOperation(goods, "AI审核失败");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 发送审核失败消息通知
|
|
// 发送审核失败消息通知
|
|
|
notificationService.sendFailedMsg(goods);
|
|
notificationService.sendFailedMsg(goods);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return "reject";
|
|
return "reject";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -685,5 +730,34 @@ public class SecondGoodsAuditServiceImpl implements SecondGoodsAuditService {
|
|
|
return "fail";
|
|
return "fail";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 商品审核通过后的上架处理(包含风控检查)
|
|
|
|
|
+ * @param goods 商品信息
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void handleGoodsApprovalSuccess(SecondGoods goods) {
|
|
|
|
|
+ // 审核通过,设置上架状态
|
|
|
|
|
+ goods.setGoodsStatus(SecondGoodsStatusEnum.LISTED.getCode());
|
|
|
|
|
+ goods.setFailedReason("");
|
|
|
|
|
+ goods.setReleaseTime(new Date());
|
|
|
|
|
+ secondGoodsMapper.updateById(goods);
|
|
|
|
|
+
|
|
|
|
|
+ // 更新审核记录
|
|
|
|
|
+ createGoodsAudit(goods, "", Constants.AuditStatus.PASSED);
|
|
|
|
|
+
|
|
|
|
|
+ // 发送审核成功消息
|
|
|
|
|
+ notificationService.sendMessage(goods);
|
|
|
|
|
+
|
|
|
|
|
+ // 记录操作历史
|
|
|
|
|
+ QueryWrapper<SecondGoodsRecord> queryRecordWrapper = new QueryWrapper<>();
|
|
|
|
|
+ queryRecordWrapper.eq("goods_id", goods.getId());
|
|
|
|
|
+ List<SecondGoodsRecord> recordList = secondGoodsRecordMapper.selectList(queryRecordWrapper);
|
|
|
|
|
+ String operationName = CollectionUtil.isNotEmpty(recordList) ? "重新发布" : "首次发布";
|
|
|
|
|
+ operationRecordService.recordGoodsOperation(goods, operationName);
|
|
|
|
|
+
|
|
|
|
|
+ // 执行风控检查
|
|
|
|
|
+ secondGoodsService.performPublishRiskCheck(goods);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|