Browse Source

评论接口回滚,将逻辑挪到新写入的接口,返回值为查询信息vo

zhangchen 3 months ago
parent
commit
de9644bc03

+ 2 - 0
alien-entity/src/main/java/shop/alien/entity/store/WebAudit.java

@@ -31,6 +31,8 @@ public class WebAudit {
 
     private String lifeActivityId;
 
+    private String couponId;
+
     private String content;
 
     private String type;

+ 3 - 1
alien-entity/src/main/java/shop/alien/mapper/WebAuditMapper.java

@@ -22,7 +22,9 @@ public interface WebAuditMapper  extends BaseMapper<WebAudit> {
             "    WHEN 4 THEN\n" +
             "    '套餐' \n" +
             "    WHEN 5 THEN\n" +
-            "    '活动' ELSE '未知类型' \n" +
+            "    '活动' \n" +
+            "    WHEN 6 THEN\n" +
+            "    '代金券' ELSE '未知类型' \n" +
             "  END AS type,\n" +
             "  COUNT(*) AS typeSum \n" +
             "FROM\n" +

+ 2 - 5
alien-store/src/main/java/shop/alien/store/controller/LifeCouponController.java

@@ -28,12 +28,9 @@ public class LifeCouponController {
 
     @ApiOperation("新建代金券")
     @PostMapping("/addOrUpdateCoupon")
-    public R<Boolean> addOrUpdateCoupon(@RequestBody LifeCoupon lifeCoupon) {
+    public R<LifeCoupon> addOrUpdateCoupon(@RequestBody LifeCoupon lifeCoupon) {
         log.info("LifeCouponController.addOrUpdateCoupon?lifeCoupon={}", lifeCoupon.toString());
-        if (lifeCouponService.addOrUpdateCoupon(lifeCoupon)) {
-            return R.success("成功");
-        }
-        return R.fail("失败");
+        return  R.data(lifeCouponService.addOrUpdateCoupon(lifeCoupon));
     }
 
     /**

+ 18 - 2
alien-store/src/main/java/shop/alien/store/controller/StoreCommentAppealController.java

@@ -50,12 +50,28 @@ public class StoreCommentAppealController {
             @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true),
             @ApiImplicitParam(name = "commentId", value = "评论id", dataType = "Integer", paramType = "query", required = true),
             @ApiImplicitParam(name = "appealReason", value = "申诉原因", dataType = "String", paramType = "query", required = true)})
-    @PostMapping("/addAppeal")
-    public R<StoreCommentAppealInfoVo> addAppeal(MultipartRequest multipartRequest,
+    @PostMapping("/addAppealNew")
+    public R<StoreCommentAppealInfoVo> addAppealNew(MultipartRequest multipartRequest,
                                                  @RequestParam("storeId") Integer storeId,
                                                  @RequestParam("commentId") Integer commentId,
                                                  @RequestParam("appealReason") String appealReason) {
         Set<String> fileNameSet = multipartRequest.getMultiFileMap().keySet();
+        log.info("StoreCommentAppealController.addAppealNew?multipartRequest={}&storeId={}&commentId={}&appealReason={}", fileNameSet, storeId, commentId, appealReason);
+        return R.data(storeCommentAppealService.addAppealNew(multipartRequest, storeId, commentId, appealReason));
+    }
+
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "商家端-新增申诉(0:申诉成功, 1:申诉失败, 2:申诉已存在)")
+    @ApiImplicitParams({@ApiImplicitParam(name = "multipartRequest", value = "文件", dataType = "File", paramType = "query", required = true),
+            @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "commentId", value = "评论id", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "appealReason", value = "申诉原因", dataType = "String", paramType = "query", required = true)})
+    @PostMapping("/addAppeal")
+    public R<Integer> addAppeal(MultipartRequest multipartRequest,
+                                @RequestParam("storeId") Integer storeId,
+                                @RequestParam("commentId") Integer commentId,
+                                @RequestParam("appealReason") String appealReason) {
+        Set<String> fileNameSet = multipartRequest.getMultiFileMap().keySet();
         log.info("StoreCommentAppealController.addAppeal?multipartRequest={}&storeId={}&commentId={}&appealReason={}", fileNameSet, storeId, commentId, appealReason);
         return R.data(storeCommentAppealService.addAppeal(multipartRequest, storeId, commentId, appealReason));
     }

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/LifeCouponService.java

@@ -16,7 +16,7 @@ import java.util.Map;
  */
 public interface LifeCouponService extends IService<LifeCoupon> {
 
-    boolean addOrUpdateCoupon(LifeCoupon lifeCoupon);
+    LifeCoupon addOrUpdateCoupon(LifeCoupon lifeCoupon);
 
     /**
      * 修改库存数量

+ 14 - 1
alien-store/src/main/java/shop/alien/store/service/StoreCommentAppealService.java

@@ -44,7 +44,20 @@ public interface StoreCommentAppealService extends IService<StoreCommentAppeal>
      * @param appealReason     申诉原因
      * @return Integer(0 : 申诉成功, 1 : 申诉失败, 2 : 申诉已存在, 3 : 文本内容异常)
      */
-    StoreCommentAppealInfoVo addAppeal(MultipartRequest multipartRequest, Integer storeId, Integer commentId, String appealReason);
+    Integer addAppeal(MultipartRequest multipartRequest, Integer storeId, Integer commentId, String appealReason);
+
+    /**
+     * 新增申诉
+     *
+     * @param multipartRequest 文件
+     * @param storeId          门店id
+     * @param commentId        评论id
+     * @param appealReason     申诉原因
+     * @return Integer(0 : 申诉成功, 1 : 申诉失败, 2 : 申诉已存在, 3 : 文本内容异常)
+     */
+    StoreCommentAppealInfoVo addAppealNew(MultipartRequest multipartRequest, Integer storeId, Integer commentId, String appealReason);
+
+
 
     /**
      * 申诉详情

+ 4 - 3
alien-store/src/main/java/shop/alien/store/service/impl/LifeCouponServiceImpl.java

@@ -62,7 +62,7 @@ public class LifeCouponServiceImpl extends ServiceImpl<LifeCouponMapper, LifeCou
 
 
     @Override
-    public boolean addOrUpdateCoupon(LifeCoupon lifeCoupon) {
+    public LifeCoupon addOrUpdateCoupon(LifeCoupon lifeCoupon) {
 
         // 添加优惠tag
         //获取经营板块id
@@ -101,10 +101,11 @@ public class LifeCouponServiceImpl extends ServiceImpl<LifeCouponMapper, LifeCou
         if (StringUtils.isEmpty(lifeCoupon.getId())) {
             lifeCoupon.setType(1);
             lifeCoupon.setCouponCode(UniqueRandomNumGenerator.generateUniqueCode(12));
-            return this.save(lifeCoupon);
+            this.save(lifeCoupon);
         } else {
-            return this.updateById(lifeCoupon);
+            this.updateById(lifeCoupon);
         }
+        return lifeCoupon;
     }
 
     /**

+ 73 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentAppealServiceImpl.java

@@ -114,7 +114,79 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
      * @return Integer(0 : 申诉成功, 1 : 申诉失败, 2 : 申诉已存在, 3 : 文本内容异常)
      */
     @Override
-    public StoreCommentAppealInfoVo addAppeal(MultipartRequest multipartRequest, Integer storeId, Integer commentId, String appealReason) {
+    public Integer addAppeal(MultipartRequest multipartRequest, Integer storeId, Integer commentId, String appealReason) {
+        try {
+            Map<String, String> checkText = TextCheckUtil.check(appealReason);
+            if (null == checkText || checkText.get("result").equals("1")) {
+                return 3;
+            }
+            List<String> fileNameSet = new ArrayList<>(multipartRequest.getMultiFileMap().keySet());
+            LambdaQueryWrapper<StoreCommentAppeal> wrapper = new LambdaQueryWrapper<>();
+            //待审批, 已通过
+            List<Integer> list = new ArrayList<>();
+            list.add(0);
+            list.add(2);
+            wrapper.eq(StoreCommentAppeal::getStoreId, storeId)
+                    .eq(StoreCommentAppeal::getCommentId, commentId)
+                    .in(StoreCommentAppeal::getAppealStatus, list)
+                    .orderByDesc(StoreCommentAppeal::getCreatedTime)
+                    .last("limit 1");
+            if (this.getOne(wrapper) != null) {
+                return 2;
+            }
+            StoreCommentAppeal storeCommentAppeal = new StoreCommentAppeal();
+            StringBuilder imgId = new StringBuilder();
+            for (int i = 0; i < fileNameSet.size(); i++) {
+                MultipartFile multipartFile = multipartRequest.getFileMap().get(fileNameSet.get(i));
+                if (null != multipartFile) {
+                    StoreImg storeImg = new StoreImg();
+                    storeImg.setStoreId(storeId);
+                    storeImg.setImgType(9);
+                    storeImg.setImgSort(i + 1);
+                    storeImg.setImgUrl(fileUploadUtil.uploadOneFile(multipartFile));
+                    storeImgMapper.insert(storeImg);
+                    imgId.append(storeImg.getId()).append(",");
+                }
+            }
+            if (!imgId.toString().isEmpty()) {
+                storeCommentAppeal.setImgId(imgId.substring(0, imgId.length() - 1));
+            }
+            storeCommentAppeal.setStoreId(storeId);
+            storeCommentAppeal.setCommentId(commentId);
+            storeCommentAppeal.setAppealReason(appealReason);
+            storeCommentAppeal.setAppealStatus(0);
+            boolean storeCommentAppealSave = this.save(storeCommentAppeal);
+            //商家申诉
+            StoreCommentAppealLog storeCommentAppealLog = new StoreCommentAppealLog();
+            storeCommentAppealLog.setAppealId(storeCommentAppeal.getId());
+            storeCommentAppealLog.setProcessType(0);
+            storeCommentAppealLog.setDeleteFlag(0);
+            storeCommentAppealLog.setCreatedTime(storeCommentAppeal.getCreatedTime());
+            boolean result = storeCommentAppealSave && storeCommentAppealLogMapper.insert(storeCommentAppealLog) > 0;
+            //系统审核
+            StoreCommentAppealLog storeCommentAppealLogSystem = new StoreCommentAppealLog();
+            storeCommentAppealLogSystem.setAppealId(storeCommentAppeal.getId());
+            storeCommentAppealLogSystem.setProcessType(1);
+            storeCommentAppealLogSystem.setDeleteFlag(0);
+            storeCommentAppealLogSystem.setCreatedTime(storeCommentAppeal.getCreatedTime());
+            boolean resultSystem = storeCommentAppealSave && storeCommentAppealLogMapper.insert(storeCommentAppealLogSystem) > 0;
+            return result && resultSystem ? 0 : 1;
+        } catch (Exception e) {
+            return 1;
+        }
+    }
+
+    /**
+     * 新增申诉
+     *
+     * @param multipartRequest 文件
+     * @param storeId          门店id
+     * @param commentId        评论id
+     * @param appealReason     申诉原因
+     * @return Integer(0 : 申诉成功, 1 : 申诉失败, 2 : 申诉已存在, 3 : 文本内容异常)
+     */
+    @Override
+    public StoreCommentAppealInfoVo addAppealNew(MultipartRequest multipartRequest, Integer storeId, Integer commentId, String appealReason) {
         StoreCommentAppealInfoVo storeCommentAppealInfoVo = new StoreCommentAppealInfoVo();
         try {
             Map<String, String> checkText = TextCheckUtil.check(appealReason);

+ 15 - 2
alien-store/src/main/java/shop/alien/store/service/impl/WebAuditServiceImpl.java

@@ -34,10 +34,13 @@ public class WebAuditServiceImpl extends ServiceImpl<WebAuditMapper, WebAudit> i
 
     private final StoreCommentAppealMapper storeCommentAppealMapper;
 
+    private final LifeCouponMapper lifeCouponMapper;
+
     private final LifeGroupPackageMapper lifeGroupPackageMapper;
 
     private final LifeActivityMapper lifeActivityMapper;
 
+
     @Override
     public IPage<WebAudit> getOrderList(int page, int size, String status, String type) {
         IPage<WebAudit> storePage = new Page<>(page, size);
@@ -64,7 +67,9 @@ public class WebAuditServiceImpl extends ServiceImpl<WebAuditMapper, WebAudit> i
                 item.setType("套餐");
             } else if ("5".equals(item.getType())) {
                 item.setType("活动");
-            } else {
+            }else if ("6".equals(item.getType())) {
+                item.setType("代金券");
+            }  else {
                 item.setType("未知类型");
             }
         });
@@ -124,9 +129,14 @@ public class WebAuditServiceImpl extends ServiceImpl<WebAuditMapper, WebAudit> i
             newWebAudit.setLifeActivityId(countColumn.getLifeActivityId());
             LifeActivity lifeActivity = lifeActivityMapper.selectById(countColumn.getLifeActivityId());
             newWebAudit.setContent(lifeActivity.getName());
+        }
 
-
+        if (countColumn.getCouponId() != null) {
+            newWebAudit.setCouponId(countColumn.getCouponId());
+            LifeCoupon lifeCoupon = lifeCouponMapper.selectById(countColumn.getCouponId());
+            newWebAudit.setContent(lifeCoupon.getName());
         }
+
         newWebAudit.setCreatedTime(new Date());
         newWebAudit.setDeleteFlag(0);
         newWebAudit.setStatus("0");
@@ -161,6 +171,9 @@ public class WebAuditServiceImpl extends ServiceImpl<WebAuditMapper, WebAudit> i
         } else if ("5".equals(webAudit.getType())) {
             webAudit.setLifeActivityId(webAudit.getId());
             return webAudit;
+        } else if("6".equals(webAudit.getType())){
+            webAudit.setCouponId(webAudit.getId());
+            return webAudit;
         }
         return null;
     }