Browse Source

商品审核发送消息修改

wxd 1 week ago
parent
commit
e8a0f1a3c4

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/second/SecondGoods.java

@@ -52,6 +52,9 @@ public class SecondGoods implements Serializable {
     @ApiModelProperty(value = "商品价格(元,保留小数后两位)")
     private BigDecimal price;
 
+    @TableField(exist = false)
+    private Integer auditRecordId;
+
     @TableField("position")
     @ApiModelProperty(value = "商品位置")
     private String position;

+ 1 - 1
alien-entity/src/main/java/shop/alien/entity/second/vo/SellGoodsVo.java

@@ -101,7 +101,7 @@ public class SellGoodsVo extends SecondGoods {
     @ApiModelProperty(value = "卖家交易状态  1-交易成功  2-交易失败")
     private Integer sellerTransactionStatus;
 
-    @ApiModelProperty(value = "交易状态  0-待交易  1-交易成功  2-交易失败  3-交易取消")
+    @ApiModelProperty(value = "交易状态  1-待确认  2-已拒绝  3-待交易  4-交易成功  5-交易失败  6-交易取消")
     private Integer tradeStatus;
 
     @ApiModelProperty(value = "买家评价")

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

@@ -11,7 +11,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.second.SecondGoods;
+import shop.alien.entity.second.SecondGoodsAudit;
 import shop.alien.entity.second.vo.SecondGoodsVo;
+import shop.alien.mapper.second.SecondGoodsAuditMapper;
 import shop.alien.second.service.SecondGoodsService;
 import shop.alien.util.common.JwtUtil;
 import shop.alien.util.common.safe.*;
@@ -33,6 +35,8 @@ public class SecondGoodsController {
 
     private final SecondGoodsService secondGoodsService;
 
+    private final SecondGoodsAuditMapper secondGoodsAuditMapper;
+
     // 注入文本审核工具
     private final TextModerationUtil textModerationUtil;
 
@@ -119,8 +123,12 @@ public class SecondGoodsController {
      */
     @GetMapping("/getGoodsAuditStatus")
     @ApiOperation("商品审核状态查询-消息跳转用(商品状态 0:草稿 1:审核中 2:审核失败 3:已上架 4:已下架 5:已售出)")
-    public R<Integer> getGoodsAuditStatus(@ApiParam("商品id") @RequestParam Integer goodsId) {
-        log.info("SecondGoodsController.getGoodsAuditStatus?goodsId={}", goodsId);
+    public R<Integer> getGoodsAuditStatus(@ApiParam("商品审核id") @RequestParam Integer auditId) {
+        log.info("SecondGoodsController.getGoodsAuditStatus?auditId={}", auditId);
+        QueryWrapper<SecondGoodsAudit> queryWrapperAudit = new QueryWrapper<>();
+        queryWrapperAudit.lambda()
+                .eq(SecondGoodsAudit::getId, auditId);
+        Integer goodsId = secondGoodsAuditMapper.selectById(queryWrapperAudit).getGoodsId();
         // 获取商品审核状态
         QueryWrapper<SecondGoods> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda()

+ 16 - 4
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsServiceImpl.java

@@ -1,6 +1,7 @@
 package shop.alien.second.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
+import com.google.gson.JsonObject;
 import lombok.RequiredArgsConstructor;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.BeanUtils;
@@ -240,6 +242,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
         auditRecord.setCreatedTime(new Date());
         auditRecord.setUpdatedTime(new Date());
         secondGoodsAuditMapper.insert(auditRecord);
+        goods.setAuditRecordId(auditRecord.getId());
     }
 
     /**
@@ -294,9 +297,13 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
         LifeNotice lifeNotice = new LifeNotice();
         lifeNotice.setSenderId("system");
         lifeNotice.setReceiverId("user_"+ phone);
-        lifeNotice.setBusinessId(goods.getId());
+        lifeNotice.setBusinessId(goods.getAuditRecordId());
         lifeNotice.setTitle("商品发布通知");
-        lifeNotice.setContext("恭喜您的商品已发成功");
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("status", "true");
+        jsonObject.put("text", "恭喜您的商品已发成功");
+        lifeNotice.setContext(jsonObject.toJSONString());
+//        lifeNotice.setContext("恭喜您的商品已发成功");
         lifeNotice.setNoticeType(1); // 系统通知
         lifeNotice.setIsRead(0);
         lifeNoticeMapper.insert(lifeNotice);
@@ -315,11 +322,16 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
         LifeNotice lifeNotice = new LifeNotice();
         lifeNotice.setSenderId("system");
         lifeNotice.setReceiverId("user_"+ phone);
-        lifeNotice.setBusinessId(goods.getId());
+        lifeNotice.setBusinessId(goods.getAuditRecordId());
         lifeNotice.setTitle("商品审核通知");
         // TODO: 失败原因本期为固定文案,实际原因暂不保存
+
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("status", "false");
+        jsonObject.put("text", "抱歉您的商品发布失败,图片或文字存在违规行为。请您修改后从新发布");
+        lifeNotice.setContext(jsonObject.toJSONString());
 //        lifeNotice.setContext("商品审核失败,原因为:" + goods.getFailedReason());
-        lifeNotice.setContext("抱歉您的商品发布失败,图片或文字存在违规行为。请您修改后从新发布");
+//        lifeNotice.setContext("抱歉您的商品发布失败,图片或文字存在违规行为。请您修改后从新发布");
         lifeNotice.setNoticeType(1); // 系统通知
         lifeNotice.setIsRead(0);
         lifeNoticeMapper.insert(lifeNotice);