2 次代码提交 4371380eb0 ... 305b7392a6

作者 SHA1 备注 提交日期
  wxd 305b7392a6 Merge remote-tracking branch 'origin/master' 1 周之前
  wxd fab87ca95c 商品审核发送消息修改 1 周之前

+ 2 - 2
alien-second/src/main/java/shop/alien/second/controller/SecondGoodsController.java

@@ -123,7 +123,7 @@ public class SecondGoodsController {
      */
     @GetMapping("/getGoodsAuditStatus")
     @ApiOperation("商品审核状态查询-消息跳转用(商品状态 0:草稿 1:审核中 2:审核失败 3:已上架 4:已下架 5:已售出)")
-    public R<Integer> getGoodsAuditStatus(@ApiParam("商品审核id") @RequestParam Integer auditId) {
+    public R<SecondGoods> getGoodsAuditStatus(@ApiParam("商品审核id") @RequestParam Integer auditId) {
         log.info("SecondGoodsController.getGoodsAuditStatus?auditId={}", auditId);
         QueryWrapper<SecondGoodsAudit> queryWrapperAudit = new QueryWrapper<>();
         queryWrapperAudit.lambda()
@@ -133,7 +133,7 @@ public class SecondGoodsController {
         QueryWrapper<SecondGoods> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda()
                 .eq(SecondGoods::getId, goodsId);
-        return R.data(secondGoodsService.getOne(queryWrapper).getGoodsStatus());
+        return R.data(secondGoodsService.getOne(queryWrapper));
     }
 
     /**

+ 13 - 10
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsServiceImpl.java

@@ -160,9 +160,6 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
             goods.setGoodsStatus(3); // 上架
             goods.setReleaseTime(new Date()); // 上架时间
             updateById(goods);
-
-            // 发送消息
-            sendMessage(goods);
             return true;
         } catch (Exception e) {
             // 记录异常日志
@@ -188,7 +185,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
             goods.setGoodsStatus(2); // 审核失败
             goods.setFailedReason("文本审核不通过:" + (textCheckResult.getRiskWords() != null ? textCheckResult.getRiskWords() : "存在高风险内容"));
             // 插入审核记录
-            createGoodsAudit(goods, textCheckResult.getRiskWords());
+            createGoodsAudit(goods, textCheckResult.getRiskWords(),2);
             // 发送审核失败消息
             sendFailedMsg(goods);
             return false;
@@ -209,7 +206,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
                     goods.setGoodsStatus(2); // 审核失败
                     goods.setFailedReason("图片审核不通过:图片中包含" + (response.getDescriptions() != null ? response.getDescriptions() : "高风险内容"));
                     // 插入审核记录
-                    createGoodsAudit(goods, response.getDescriptions());
+                    createGoodsAudit(goods, response.getDescriptions(),2);
                     // 发送审核失败消息
                     sendFailedMsg(goods);
                     return false;
@@ -219,6 +216,10 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
 
         // 所有审核通过
         goods.setGoodsStatus(3); // 上架
+        // 插入审核记录
+        createGoodsAudit(goods, "",1);
+        // 发送审核成功消息
+        sendMessage(goods);
         goods.setFailedReason("");
         return true;
     }
@@ -229,14 +230,16 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
      * @param goods 商品
      * @param riskWords 文本审核结果
      */
-    private void createGoodsAudit(SecondGoods goods, String riskWords) {
+    private void createGoodsAudit(SecondGoods goods, String riskWords,Integer goodsStatus) {
         // 保存审核结果
         secondGoodsMapper.updateById(goods);
         // 插入审核记录
         SecondGoodsAudit auditRecord = new SecondGoodsAudit();
         auditRecord.setGoodsId(goods.getId());
-        auditRecord.setGoodsStatus(2); // 审核失败
-        auditRecord.setFailedReason("文本审核不通过:" + (riskWords != null ? riskWords : "存在高风险内容"));
+        auditRecord.setGoodsStatus(goodsStatus); // 审核失败
+        if (goodsStatus == 2) {
+            auditRecord.setFailedReason("文本审核不通过:" + (riskWords != null ? riskWords : "存在高风险内容"));
+        }
         auditRecord.setCreatedUserId(goods.getUserId());
         auditRecord.setUpdatedUserId(goods.getUserId());
         auditRecord.setCreatedTime(new Date());
@@ -301,7 +304,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
         lifeNotice.setTitle("商品发布通知");
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("status", "true");
-        jsonObject.put("text", "恭喜您的商品已发成功");
+        jsonObject.put("message", "恭喜您的商品已发成功");
         lifeNotice.setContext(jsonObject.toJSONString());
 //        lifeNotice.setContext("恭喜您的商品已发成功");
         lifeNotice.setNoticeType(1); // 系统通知
@@ -328,7 +331,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
 
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("status", "false");
-        jsonObject.put("text", "抱歉您的商品发布失败,图片或文字存在违规行为。请您修改后从新发布");
+        jsonObject.put("message", "抱歉您的商品发布失败,图片或文字存在违规行为。请您修改后从新发布");
         lifeNotice.setContext(jsonObject.toJSONString());
 //        lifeNotice.setContext("商品审核失败,原因为:" + goods.getFailedReason());
 //        lifeNotice.setContext("抱歉您的商品发布失败,图片或文字存在违规行为。请您修改后从新发布");