Explorar el Código

feat:新增接口判断是否可以评价

刘云鑫 hace 9 horas
padre
commit
d6f9b6cbc8

+ 6 - 0
alien-entity/src/main/java/shop/alien/mapper/StoreCommentAppealMapper.java

@@ -132,4 +132,10 @@ public interface StoreCommentAppealMapper extends BaseMapper<StoreCommentAppeal>
     void updateByRecordIdNew(@Param("id") Integer id,
                           @Param("appealStatus") Integer appealStatus,
                           @Param("finalResult") String finalResult);
+
+    @Select("select count(1)\n" +
+            "from store_comment_appeal sca\n" +
+            "where sca.comment_id in (select id from common_rating cr where cr.user_id=#{userId} and cr.business_type = 1)\n" +
+            "and sca.created_time >= DATE_SUB(NOW(), INTERVAL 30 DAY)")
+    int canRate(@Param("userId") Integer userId);
 }

+ 8 - 1
alien-store/src/main/java/shop/alien/store/controller/StoreCommentAppealController.java

@@ -8,7 +8,6 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartRequest;
 import shop.alien.entity.result.R;
-import shop.alien.entity.store.StoreCommentAppeal;
 import shop.alien.entity.store.vo.StoreCommentAppealInfoVo;
 import shop.alien.entity.store.vo.StoreCommentAppealVo;
 import shop.alien.store.annotation.TrackEvent;
@@ -157,4 +156,12 @@ public class StoreCommentAppealController {
         log.info("StoreCommentAppealController.getAppealHistoryCountStatus?storeId={}", storeId);
         return R.data(storeCommentAppealService.getAppealHistoryCountStatus(storeId));
     }
+
+    // TODO 查询当前用户前30天所有评价被申诉通过的次数,如果> 3 次返回true
+    @ApiOperation("是否可以评价")
+    @GetMapping("/canRate")
+    public R<Boolean> canRate(Integer userId) {
+        log.info("StoreCommentAppealController.canRate");
+        return R.data(storeCommentAppealService.canRate(userId));
+    }
 }

+ 2 - 0
alien-store/src/main/java/shop/alien/store/service/StoreCommentAppealService.java

@@ -103,4 +103,6 @@ public interface StoreCommentAppealService extends IService<StoreCommentAppeal>
      * @return ResponseEntity
      */
     ResponseEntity<byte[]> exportToExcel();
+
+    Boolean canRate(Integer userId);
 }

+ 5 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentAppealServiceImpl.java

@@ -722,6 +722,11 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
         }
     }
 
+    @Override
+    public Boolean canRate(Integer userId) {
+        return storeCommentAppealMapper.canRate(userId) > 3;
+    }
+
     /**
      * 更新店铺评分(删除评价后重新计算门店评分)
      *