|
|
@@ -22,6 +22,7 @@ import org.springframework.util.StringUtils;
|
|
|
import shop.alien.entity.SecondVideoTask;
|
|
|
import shop.alien.entity.second.SecondGoods;
|
|
|
import shop.alien.entity.second.SecondGoodsAudit;
|
|
|
+import shop.alien.entity.second.SecondGoodsRecord;
|
|
|
import shop.alien.entity.second.enums.SecondGoodsStatusEnum;
|
|
|
import shop.alien.entity.second.vo.SecondGoodsVo;
|
|
|
import shop.alien.entity.second.vo.SellGoodsVo;
|
|
|
@@ -31,6 +32,7 @@ import shop.alien.entity.store.vo.WebSocketVo;
|
|
|
import shop.alien.mapper.*;
|
|
|
import shop.alien.mapper.second.SecondGoodsAuditMapper;
|
|
|
import shop.alien.mapper.second.SecondGoodsMapper;
|
|
|
+import shop.alien.mapper.second.SecondGoodsRecordMapper;
|
|
|
import shop.alien.second.feign.AlienStoreFeign;
|
|
|
import shop.alien.second.service.SecondGoodsService;
|
|
|
import shop.alien.second.service.VideoModerationService;
|
|
|
@@ -38,6 +40,7 @@ import shop.alien.util.common.Constants;
|
|
|
import shop.alien.util.common.VideoUtils;
|
|
|
import shop.alien.util.common.safe.*;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
@@ -122,6 +125,59 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
|
|
|
private final AlienStoreFeign alienStoreFeign;
|
|
|
/**
|
|
|
+ * 商品操作历史记录Mapper
|
|
|
+ */
|
|
|
+ private final SecondGoodsRecordMapper secondGoodsRecordMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 记录商品操作历史
|
|
|
+ * @param goods 商品信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void recordGoodsOperation(SecondGoods goods) {
|
|
|
+ try {
|
|
|
+ SecondGoodsRecord record = new SecondGoodsRecord();
|
|
|
+ record.setGoodsId(goods.getId());
|
|
|
+ record.setTitle(goods.getTitle());
|
|
|
+ record.setDescription(goods.getDescription());
|
|
|
+ // 价格转换
|
|
|
+ if (goods.getAmount() != null) {
|
|
|
+ record.setPrice(goods.getAmount());
|
|
|
+ } else if (goods.getPrice() != null && !goods.getPrice().isEmpty()) {
|
|
|
+ try {
|
|
|
+ record.setPrice(new BigDecimal(goods.getPrice()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("转换商品价格时出错: {}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ record.setPosition(goods.getPosition());
|
|
|
+ record.setLikeCount(goods.getLikeCount());
|
|
|
+ record.setCollectCount(goods.getCollectCount());
|
|
|
+ record.setCategoryOneId(goods.getCategoryOneId());
|
|
|
+ record.setCategoryTwoId(goods.getCategoryTwoId());
|
|
|
+ record.setLabel(goods.getLabel());
|
|
|
+ record.setTopic(goods.getTopic());
|
|
|
+ record.setTradeId(goods.getTradeId());
|
|
|
+ record.setReleaseTime(goods.getReleaseTime());
|
|
|
+ record.setGoodsStatus(goods.getGoodsStatus());
|
|
|
+ record.setFailedReason(goods.getFailedReason());
|
|
|
+ record.setHomeImage(goods.getHomeImage());
|
|
|
+ record.setVideoTaskId(goods.getVideoTaskId());
|
|
|
+ record.setVideoFirstFrame(goods.getVideoFirstFrame());
|
|
|
+ record.setDeleteFlag(goods.getDeleteFlag());
|
|
|
+ record.setCreatedTime(goods.getCreatedTime());
|
|
|
+ record.setCreatedUserId(goods.getCreatedUserId());
|
|
|
+ record.setUpdatedTime(goods.getUpdatedTime());
|
|
|
+ record.setUpdatedUserId(goods.getUpdatedUserId());
|
|
|
+ record.setAddressText(goods.getAddressText());
|
|
|
+
|
|
|
+ secondGoodsRecordMapper.insert(record);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("记录商品操作历史时发生异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 保存商品为草稿状态
|
|
|
* @param goods 商品实体
|
|
|
* @return 是否成功保存
|
|
|
@@ -158,18 +214,19 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
SecondGoods goods = new SecondGoods();
|
|
|
BeanUtils.copyProperties(goodsDTO, goods);
|
|
|
|
|
|
+ boolean saveResult;
|
|
|
if (editFlag == 1) {
|
|
|
goods.setId(goodsDTO.getId());
|
|
|
// goods = secondGoodsMapper.selectById(goodsDTO.getId());
|
|
|
// 保存商品基本信息
|
|
|
- if (!updateById(goods)) {
|
|
|
- return false; // 保存失败直接返回
|
|
|
- }
|
|
|
+ saveResult = updateById(goods);
|
|
|
} else {
|
|
|
// 保存商品基本信息
|
|
|
- if (!save(goods)) {
|
|
|
- return false; // 保存失败直接返回
|
|
|
- }
|
|
|
+ saveResult = save(goods);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!saveResult) {
|
|
|
+ return false; // 保存失败直接返回
|
|
|
}
|
|
|
|
|
|
// 获取保存后的商品ID,用于后续业务处理
|
|
|
@@ -185,12 +242,11 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
goods = secondGoodsMapper.selectById(savedGoodsId);
|
|
|
// 执行内容审核(图片和文本)
|
|
|
if (!performContentReviews(goods, goodsDTO)) {
|
|
|
+ // 审核不通过,记录操作历史
|
|
|
+ recordGoodsOperation(goods);
|
|
|
return true; // 审核不通过时已设置状态,返回成功但标记为审核失败
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return true;
|
|
|
} catch (Exception e) {
|
|
|
// 记录异常日志
|
|
|
@@ -209,7 +265,8 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
servicesList.add(TextReviewServiceEnum.AD_COMPLIANCE_DETECTION_PRO.getService());
|
|
|
servicesList.add(TextReviewServiceEnum.LLM_QUERY_MODERATION.getService());
|
|
|
// 使用商品发布场景的审核服务
|
|
|
- TextModerationResultVO textCheckResult = textModerationUtil.invokeFunction(goodsDTO.getDescription(), servicesList);
|
|
|
+ String test = goodsDTO.getDescription() + goodsDTO.getTitle() + goods.getLabel() + goods.getTopic();
|
|
|
+ TextModerationResultVO textCheckResult = textModerationUtil.invokeFunction(test, servicesList);
|
|
|
|
|
|
if ("high".equals(textCheckResult.getRiskLevel())) {
|
|
|
// 文本审核不通过或存在高风险
|
|
|
@@ -279,6 +336,8 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
goods.setFailedReason("");
|
|
|
updateById(goods);
|
|
|
createGoodsAudit(goods, "", SecondGoodsStatusEnum.UNDER_REVIEW.getCode());
|
|
|
+ // 审核中,记录操作历史
|
|
|
+ recordGoodsOperation(goods);
|
|
|
return true; // 异步处理,直接返回
|
|
|
}
|
|
|
}
|
|
|
@@ -293,6 +352,8 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
|
|
|
createGoodsAudit(goods, "", Constants.AuditStatus.PASSED);
|
|
|
// 发送审核成功消息
|
|
|
sendMessage(goods);
|
|
|
+ // 审核成功,记录操作历史
|
|
|
+ recordGoodsOperation(goods);
|
|
|
return true;
|
|
|
}
|
|
|
|