jyc 3 months ago
parent
commit
c1c6a790ae

+ 12 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreComment.java

@@ -110,4 +110,16 @@ public class StoreComment extends Model<StoreComment> {
     @TableField("phone_id")
     private String phoneId;
 
+    @ApiModelProperty(value = "口味评分")
+    @TableField("taste_score")
+    private Double tasteScore;
+
+    @ApiModelProperty(value = "环境评分")
+    @TableField("en_score")
+    private Double enScore;
+
+    @ApiModelProperty(value = "服务评分")
+    @TableField("service_score")
+    private Double serviceScore;
+
 }

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreCommentAppealLog.java

@@ -60,5 +60,8 @@ public class StoreCommentAppealLog extends Model<StoreCommentAppealLog> {
     @TableField("updated_user_id")
     private Integer updatedUserId;
 
+    @ApiModelProperty(value = "备注")
+    @TableField("log_remark")
+    private String logRemark;
 
 }

+ 16 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreInfo.java

@@ -195,4 +195,20 @@ public class StoreInfo {
 
     @TableField(exist = false)
     private String dist;
+
+    @ApiModelProperty(value = "口味评分")
+    @TableField("taste_score")
+    private Double tasteScore;
+
+    @ApiModelProperty(value = "环境评分")
+    @TableField("en_score")
+    private Double enScore;
+
+    @ApiModelProperty(value = "服务评分")
+    @TableField("service_score")
+    private Double serviceScore;
+
+    @ApiModelProperty(value = "评分")
+    @TableField("score_avg")
+    private Double scoreAvg;
 }

+ 15 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreCommentAppealVo.java

@@ -22,6 +22,12 @@ public class StoreCommentAppealVo extends StoreCommentAppeal {
     @ApiModelProperty(value = "商家申诉图片链接")
     private List<String> imgList;
 
+    @ApiModelProperty(value = "评论图片链接")
+    private List<String> commentImgList;
+
+    @ApiModelProperty(value = "商家申诉图片id")
+    private String commentImgId;
+
     @ApiModelProperty(value = "申诉状态字符串")
     private String appealStatusStr;
 
@@ -31,6 +37,12 @@ public class StoreCommentAppealVo extends StoreCommentAppeal {
     @ApiModelProperty(value = "顾客评论星级")
     private Integer commentStar;
 
+    @ApiModelProperty(value = "评分")
+    private String score;
+
+    @ApiModelProperty(value = "其他评分")
+    private String otherScore;
+
     @ApiModelProperty(value = "顾客用户名")
     private String userName;
 
@@ -56,6 +68,9 @@ public class StoreCommentAppealVo extends StoreCommentAppeal {
     @ApiModelProperty(value = "门店状态字符串")
     private String storeTypeStr;
 
+    @ApiModelProperty(value = "申诉备注")
+    private String logRemark;
+
     @ApiModelProperty(value = "申诉流程记录")
     private List<StoreCommentAppealLogVo> storeCommentAppealLogList;
 }

+ 9 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreCommentVo.java

@@ -45,6 +45,15 @@ public class StoreCommentVo extends StoreComment {
     @ApiModelProperty(value = "评论数")
     public Integer commitCount;
 
+    @ApiModelProperty(value = "是否申诉(0否/1是)")
+    public Integer appealFlag;
+
+    @ApiModelProperty(value = "申诉状态字符串")
+    private String appealStatusStr;
+
+    @ApiModelProperty(value = "申诉状态")
+    private Integer appealStatus;
+
     @ApiModelProperty(value = "标签")
     private List<String> labels;
 

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

@@ -26,10 +26,10 @@ public interface StoreCommentAppealMapper extends BaseMapper<StoreCommentAppeal>
      * @param queryWrapper 查询条件
      * @return IPage<StoreCommentAppealVo>
      */
-    @Select("select a.*, b.dict_detail appeal_status_str, c.comment_content, c.comment_star, d.user_name, d.user_image, e.store_name, f.phone store_phone, f.name store_contact, e.store_type " +
+    @Select("select a.*, b.dict_detail appeal_status_str, c.comment_content, c.comment_star, c.score, c.other_score, d.user_name, d.user_image, e.store_name, f.phone store_phone, f.name store_contact, e.store_type " +
             "from store_comment_appeal a " +
             "left join store_dictionary b on a.appeal_status = b.dict_id and b.type_name = 'appealStatus' and b.delete_flag = 0 " +
-            "left join store_comment c on a.comment_id = c.id and c.delete_flag = 0 " +
+            "left join store_comment c on a.comment_id = c.id " +
             "left join life_user d on c.user_id = d.id and d.delete_flag = 0 " +
             "left join store_info e on a.store_id = e.id and e.delete_flag = 0 " +
             "Left join store_user f on e.id = f.store_id and f.delete_flag = 0 ${ew.customSqlSegment}")
@@ -55,7 +55,7 @@ public interface StoreCommentAppealMapper extends BaseMapper<StoreCommentAppeal>
      * @param queryWrapper 查询条件
      * @return StoreCommentAppealVo
      */
-    @Select("select a.*, b.dict_detail appeal_status_str, c.comment_content, a.created_time comment_time, c.comment_star, d.user_name, e.phone store_phone, d.user_name userName, d.user_image userImage " +
+    @Select("select a.*, b.dict_detail appeal_status_str, c.comment_content, c.score, c.other_score, a.created_time comment_time, c.comment_star,c.img_id commentImgId, d.user_name, e.phone store_phone, d.user_name userName, d.user_image userImage " +
             "from store_comment_appeal a " +
             "left join store_dictionary b on a.appeal_status = b.dict_id and b.type_name = 'appealStatus' " +
             "left join store_comment c on a.comment_id = c.id  and c.delete_flag = 0 " +

+ 20 - 5
alien-entity/src/main/java/shop/alien/mapper/StoreCommentMapper.java

@@ -109,11 +109,26 @@ public interface StoreCommentMapper extends BaseMapper<StoreComment> {
      * @param storeId 门店id
      * @return StoreCommitPercentVo
      */
-    @Select("select (select COUNT(1) from store_comment where business_type = 5 and delete_flag = 0 and reply_id is null and score >= 4 and store_id = #{storeId}) highCommentCount, " +
-            "(select COUNT(1) from store_comment where business_type = 5 and delete_flag = 0 and reply_id is null and score >= 3 and score < 4 and store_id = #{storeId}) midCommentCount, " +
-            "(select COUNT(1) from store_comment where business_type = 5 and delete_flag = 0 and reply_id is null and score < 3 and store_id = #{storeId}) lowCommentCount, " +
+    @Select("select (select COUNT(1) from store_comment where business_type = 5 and delete_flag = 0 and reply_id is null and score >= 4.5 and store_id = #{storeId}) highCommentCount, " +
+            "(select COUNT(1) from store_comment where business_type = 5 and delete_flag = 0 and reply_id is null and score >= 3 and score <= 4 and store_id = #{storeId}) midCommentCount, " +
+            "(select COUNT(1) from store_comment where business_type = 5 and delete_flag = 0 and reply_id is null and score >= 0.5 and score <= 2.5 and store_id = #{storeId}) lowCommentCount, " +
             "(select COUNT(1) from store_comment where business_type = 5 and delete_flag = 0 and score is not null and store_id = #{storeId}) allCommentCount, " +
-            "(select count(1) from store_comment where business_type = 5 and reply_id is null and store_id = #{storeId}) rootCommentCount, " +
-            "(select count(DISTINCT reply_id) from store_comment where business_type = 5 and reply_id is NOT null and store_id = #{storeId}) commentCount ")
+            "(select count(1) from store_comment where business_type = 5 and reply_id is null and delete_flag = 0 and store_id = #{storeId}) rootCommentCount, " +
+            "(select count(DISTINCT reply_id) from store_comment where reply_id is NOT null and store_id = #{storeId} and phone_id like '%store%' and delete_flag = 0) commentCount ")
     StoreCommitPercentVo getCommentByStoreId(Integer storeId);
+
+    @Select("SELECT" +
+            "SUM( score ) score," +
+            "SUM( taste_score ) tasteScore," +
+            "SUM( en_score ) enScore," +
+            "SUM( service_score ) serviceScore," +
+            "COUNT(0) total" +
+            "FROM" +
+            "`store_comment` " +
+            "WHERE" +
+            "business_type = 5 " +
+            "AND delete_flag = 0 " +
+            "AND reply_id IS NULL" +
+            "AND store_id = #{storeId}")
+    Map<String, String> getCommentCountAndScore(@Param("storeId") Integer storeId);
 }

+ 13 - 3
alien-store/src/main/java/shop/alien/store/controller/StoreCommentAppealController.java

@@ -98,9 +98,9 @@ public class StoreCommentAppealController {
             @ApiImplicitParam(name = "appealStatus", value = "申诉状态: 0:待处理, 1:已驳回, 2:已同意", dataType = "String", paramType = "query")
     })
     @GetMapping("/setAppealStatus")
-    public R<Boolean> setAppealStatus(Integer id, Integer appealStatus) {
-        log.info("StoreCommentAppealController.setAppealStatus?id={}&appealStatus={}", id, appealStatus);
-        if (storeCommentAppealService.setAppealStatus(id, appealStatus)) {
+    public R<Boolean> setAppealStatus(Integer id, Integer appealStatus, @RequestParam(required = false, defaultValue = "") String logRemark) {
+        log.info("StoreCommentAppealController.setAppealStatus?id={}&appealStatus={}&logRemark={}", id, appealStatus, logRemark);
+        if (storeCommentAppealService.setAppealStatus(id, appealStatus, logRemark)) {
             return R.success("修改申诉状态成功");
         }
         return R.fail("修改申诉状态失败");
@@ -113,4 +113,14 @@ public class StoreCommentAppealController {
         log.info("StoreCommentAppealController.exportToExcel");
         return storeCommentAppealService.exportToExcel();
     }
+
+    @ApiOperationSupport(order = 7)
+    @ApiOperation("申诉历史各状态数量")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true)})
+    @GetMapping("/getAppealHistoryCountStatus")
+    public R getAppealHistoryCountStatus(Integer storeId) {
+        log.info("StoreCommentAppealController.getAppealHistoryCountStatus?storeId={}", storeId);
+        return R.data(storeCommentAppealService.getAppealHistoryCountStatus(storeId));
+    }
 }

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

@@ -8,6 +8,8 @@ import shop.alien.entity.store.StoreCommentAppeal;
 import shop.alien.entity.store.vo.StoreCommentAppealInfoVo;
 import shop.alien.entity.store.vo.StoreCommentAppealVo;
 
+import java.util.Map;
+
 /**
  * 评论申诉表 服务类
  *
@@ -28,6 +30,12 @@ public interface StoreCommentAppealService extends IService<StoreCommentAppeal>
     IPage<StoreCommentAppealVo> getAppealHistory(Integer pageNum, Integer pageSize, Integer storeId, String appealStatus);
 
     /**
+     * 申诉历史各状态数量
+     * @param storeId      门店id
+     */
+    Map<String, Integer> getAppealHistoryCountStatus(Integer storeId);
+
+    /**
      * 新增申诉
      *
      * @param multipartRequest 文件
@@ -66,7 +74,7 @@ public interface StoreCommentAppealService extends IService<StoreCommentAppeal>
      * @param appealStatus 申诉状态: 0:待处理, 1:已驳回, 2:已同意
      * @return boolean
      */
-    boolean setAppealStatus(Integer id, Integer appealStatus);
+    boolean setAppealStatus(Integer id, Integer appealStatus,String logRemark);
 
     /**
      * 导出Excel

+ 59 - 8
alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentAppealServiceImpl.java

@@ -2,7 +2,10 @@ package shop.alien.store.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
@@ -14,11 +17,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartRequest;
-import shop.alien.entity.store.StoreCommentAppeal;
-import shop.alien.entity.store.StoreCommentAppealLog;
-import shop.alien.entity.store.StoreDictionary;
-import shop.alien.entity.store.StoreImg;
+import shop.alien.entity.store.*;
 import shop.alien.entity.store.excelVo.util.ExcelExporter;
+import shop.alien.entity.store.vo.StoreCommentAppealLogVo;
 import shop.alien.entity.store.vo.StoreCommentAppealInfoVo;
 import shop.alien.entity.store.vo.StoreCommentAppealVo;
 import shop.alien.mapper.*;
@@ -89,6 +90,20 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
         return storeCommentAppealPage;
     }
 
+    @Override
+    public Map<String, Integer> getAppealHistoryCountStatus(Integer storeId) {
+        Map<String, Integer> map = new HashMap<>();
+        //全部
+        map.put("-1", storeCommentAppealMapper.selectCount(new LambdaQueryWrapper<StoreCommentAppeal>().eq(StoreCommentAppeal::getStoreId, storeId).eq(StoreCommentAppeal::getDeleteFlag, 0)));
+        //审核中
+        map.put("0", storeCommentAppealMapper.selectCount(new LambdaQueryWrapper<StoreCommentAppeal>().eq(StoreCommentAppeal::getStoreId, storeId).eq(StoreCommentAppeal::getDeleteFlag, 0).eq(StoreCommentAppeal::getAppealStatus, 0)));
+        //驳回
+        map.put("1", storeCommentAppealMapper.selectCount(new LambdaQueryWrapper<StoreCommentAppeal>().eq(StoreCommentAppeal::getStoreId, storeId).eq(StoreCommentAppeal::getDeleteFlag, 0).eq(StoreCommentAppeal::getAppealStatus, 1)));
+        // 通过
+        map.put("2", storeCommentAppealMapper.selectCount(new LambdaQueryWrapper<StoreCommentAppeal>().eq(StoreCommentAppeal::getStoreId, storeId).eq(StoreCommentAppeal::getDeleteFlag, 0).eq(StoreCommentAppeal::getAppealStatus, 2)));
+        return map;
+    }
+
     /**
      * 新增申诉
      *
@@ -123,6 +138,10 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
                 storeCommentAppealInfoVo.setResult(2);
                 return storeCommentAppealInfoVo;
             }
+            /*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));
@@ -136,7 +155,6 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
                     imgId.append(storeImg.getId()).append(",");
                 }
             }
-            StoreCommentAppeal storeCommentAppeal = new StoreCommentAppeal();
             if (!imgId.toString().isEmpty()) {
                 storeCommentAppeal.setImgId(imgId.substring(0, imgId.length() - 1));
             }
@@ -182,7 +200,36 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
         QueryWrapper<StoreCommentAppealVo> storeCommentAppealVoQueryWrapper = new QueryWrapper<>();
         storeCommentAppealVoQueryWrapper.eq("a.id", id).eq("a.delete_flag", 0);
         StoreCommentAppealVo commentDetail = storeCommentAppealMapper.getCommentDetail(storeCommentAppealVoQueryWrapper);
-        commentDetail.setStoreCommentAppealLogList(storeCommentAppealLogMapper.getStoreCommentAppealLogVo(commentDetail.getId()));
+
+        String[] split = commentDetail.getImgId().split(",");
+        List<String> imgList = new ArrayList<>();
+        for (String s : split) {
+            StoreImg storeImg = storeImgMapper.selectById(s);
+            if (null != storeImg) {
+                imgList.add(storeImg.getImgUrl());
+            }
+        }
+        commentDetail.setImgList(imgList);
+
+        if (StringUtils.isNotEmpty(commentDetail.getCommentImgId())) {
+            String[] split2 = commentDetail.getCommentImgId().split(",");
+            List<String> imgList2 = new ArrayList<>();
+            for (String s : split2) {
+                StoreImg storeImg = storeImgMapper.selectById(s);
+                if (null != storeImg) {
+                    imgList2.add(storeImg.getImgUrl());
+                }
+            }
+            commentDetail.setCommentImgList(imgList2);
+        } else {
+            commentDetail.setCommentImgList(new ArrayList<>());
+        }
+
+        List<StoreCommentAppealLogVo> storeCommentAppealLogVo = storeCommentAppealLogMapper.getStoreCommentAppealLogVo(commentDetail.getId());
+        commentDetail.setStoreCommentAppealLogList(storeCommentAppealLogVo);
+        if (ObjectUtils.isNotEmpty(storeCommentAppealLogVo)) {
+            commentDetail.setLogRemark(storeCommentAppealLogVo.get(storeCommentAppealLogVo.size() - 1).getLogRemark());
+        }
         return commentDetail;
     }
 
@@ -254,7 +301,7 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
      * @return boolean
      */
     @Override
-    public boolean setAppealStatus(Integer id, Integer appealStatus) {
+    public boolean setAppealStatus(Integer id, Integer appealStatus, String logRemark) {
         StoreCommentAppeal storeCommentAppeal = new StoreCommentAppeal();
         storeCommentAppeal.setId(id);
         storeCommentAppeal.setAppealStatus(appealStatus);
@@ -268,7 +315,10 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
             case 2:
                 storeCommentAppeal.setFinalResult("已同意");
                 //删除原评论
-                storeCommentMapper.deleteById(this.getById(id).getCommentId());
+                StoreCommentAppeal byId = this.getById(id);
+                storeCommentMapper.deleteById(byId.getCommentId());
+                //删除原评论下的评论
+                storeCommentMapper.update(null, new LambdaUpdateWrapper<StoreComment>().eq(StoreComment::getReplyId, byId.getCommentId()).set(StoreComment::getDeleteFlag, 1));
                 break;
         }
         //商家申诉
@@ -281,6 +331,7 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
         }
         storeCommentAppealLog.setDeleteFlag(0);
         storeCommentAppealLog.setCreatedTime(new Date());
+        storeCommentAppealLog.setLogRemark(logRemark);
         storeCommentAppealLogMapper.insert(storeCommentAppealLog);
         return this.updateById(storeCommentAppeal);
     }

+ 64 - 7
alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentServiceImpl.java

@@ -1,19 +1,25 @@
 package shop.alien.store.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartRequest;
 import shop.alien.entity.store.*;
+import shop.alien.entity.store.vo.LifeCouponVo;
+import shop.alien.entity.store.vo.StoreCommentAppealVo;
 import shop.alien.entity.store.vo.StoreCommentVo;
 import shop.alien.entity.store.vo.StoreCommitPercentVo;
 import shop.alien.mapper.*;
@@ -22,6 +28,9 @@ import shop.alien.store.util.FileUploadUtil;
 import shop.alien.util.common.DateUtils;
 import shop.alien.util.common.netease.ImageCheckUtil;
 import shop.alien.util.common.netease.TextCheckUtil;
+import shop.alien.util.common.safe.TextModerationResultVO;
+import shop.alien.util.common.safe.TextModerationUtil;
+import shop.alien.util.common.safe.TextReviewServiceEnum;
 
 import java.io.IOException;
 import java.math.BigDecimal;
@@ -55,6 +64,13 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
 
     private final LifeUserMapper lifeUserMapper;
 
+    private final StoreCommentAppealMapper storeCommentAppealMapper;
+
+    private final StoreInfoMapper storeInfoMapper;
+
+    @Autowired
+    private TextModerationUtil textModerationUtil;
+
     /**
      * 评论列表
      *
@@ -78,11 +94,11 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
         queryWrapper.eq(null != businessType, "a.business_type", businessType);
         queryWrapper.eq(null != storeId, "a.store_id", storeId);
         //好评 a>=4
-        queryWrapper.ge(null != commentLevel && 1 == commentLevel, "a.score", 4);
+        queryWrapper.ge(null != commentLevel && 1 == commentLevel, "a.score", 4.5);
         //中评 a>=2&& a<4
-        queryWrapper.ge(null != commentLevel && 2 == commentLevel, "a.score", 3).lt(null != commentLevel && 2 == commentLevel, "a.score", 4);
+        queryWrapper.ge(null != commentLevel && 2 == commentLevel, "a.score", 3).le(null != commentLevel && 2 == commentLevel, "a.score", 4);
         //差评 a<2
-        queryWrapper.lt(null != commentLevel && 3 == commentLevel, "a.score", 2);
+        queryWrapper.ge(null != commentLevel && 3 == commentLevel, "a.score", 0.5).le(null != commentLevel && 3 == commentLevel, "a.score", 2.5);
         if (null != days) {
             Date date = DateUtils.calcDays(new Date(), -days);
             queryWrapper.ge("a.created_time", DateUtils.formatDate(date, "yyyy-MM-dd"));
@@ -148,6 +164,17 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
             //低分
             storeCommentVo.setLowScore(records.get(i).getScore() <= 1);
             storeCommentVoList.add(storeCommentVo);
+
+            QueryWrapper<StoreCommentAppealVo> storeCommentAppealVoQueryWrapper = new QueryWrapper<>();
+            storeCommentAppealVoQueryWrapper.eq("a.comment_id", storeCommentVo.getId()).eq("a.delete_flag", 0).orderByDesc("a.created_time").last("limit 1");
+            StoreCommentAppealVo commentDetail = storeCommentAppealMapper.getCommentDetail(storeCommentAppealVoQueryWrapper);
+            if (ObjectUtils.isNotEmpty(commentDetail)) {
+                storeCommentVo.setAppealFlag(1);
+                storeCommentVo.setAppealStatusStr(commentDetail.getAppealStatusStr());
+                storeCommentVo.setAppealStatus(commentDetail.getAppealStatus());
+            }else {
+                storeCommentVo.setAppealFlag(0);
+            }
         }
 
         //塞图片
@@ -233,10 +260,10 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
         if (replyStatus != null) {
             if (1 == replyStatus) {
                 //只查询有回复的评论
-                collect = storeCommentVoList.stream().filter(storeCommentVo -> !storeCommentVo.getStoreComment().isEmpty()).collect(Collectors.toList());
+                collect = storeCommentVoList.stream().filter(storeCommentVo -> ObjectUtils.isNotEmpty(storeCommentVo.getStoreComment())).collect(Collectors.toList());
             } else if (2 == replyStatus) {
                 //只查询无回复的评论
-                collect = storeCommentVoList.stream().filter(storeCommentVo -> storeCommentVo.getStoreComment().isEmpty()).collect(Collectors.toList());
+                collect = storeCommentVoList.stream().filter(storeCommentVo -> ObjectUtils.isEmpty(storeCommentVo.getStoreComment())).collect(Collectors.toList());
             } else {
                 collect = storeCommentVoList;
             }
@@ -482,10 +509,18 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
     @Override
     public Integer addComment(MultipartRequest multipartRequest, Integer id, Integer businessId, Integer businessType, Integer storeId, Integer userId, Integer replyId, String commentContent, Double score, String otherScore, Integer isAnonymous, String evaluationTags, String phoneId) {
         try {
-            Map<String, String> checkText = TextCheckUtil.check(commentContent);
-            if (null == checkText || checkText.get("result").equals("1")) {
+            List<String> servicesList = Lists.newArrayList();
+            servicesList.add(TextReviewServiceEnum.COMMENT_DETECTION_PRO.getService());
+            servicesList.add(TextReviewServiceEnum.LLM_QUERY_MODERATION.getService());
+            TextModerationResultVO textCheckResult = textModerationUtil.invokeFunction(commentContent, servicesList);
+            if ("high".equals(textCheckResult.getRiskLevel())) {
                 return 2;
             }
+
+            /*Map<String, String> checkText = TextCheckUtil.check(commentContent);
+            if (null == checkText || checkText.get("result").equals("1")) {
+                return 2;
+            }*/
             StoreComment storeComment = new StoreComment();
             storeComment.setId(id);
             storeComment.setStoreId(storeId);
@@ -495,6 +530,13 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
             storeComment.setBusinessId(businessId);
             storeComment.setBusinessType(businessType);
             storeComment.setScore(score);
+
+            if (StringUtils.isNotEmpty(otherScore)) {
+                List<LifeCouponVo> lifeCouponVos = JSONArray.parseArray(otherScore, LifeCouponVo.class);
+                lifeCouponVos.stream().filter(i -> "口味".equals(i.getName())).findFirst().ifPresent(item -> storeComment.setTasteScore(Double.valueOf(item.getRateScore())));
+                lifeCouponVos.stream().filter(i -> "环境".equals(i.getName())).findFirst().ifPresent(item -> storeComment.setEnScore(Double.valueOf(item.getRateScore())));
+                lifeCouponVos.stream().filter(i -> "服务".equals(i.getName())).findFirst().ifPresent(item -> storeComment.setServiceScore(Double.valueOf(item.getRateScore())));
+            }
             storeComment.setOtherScore(otherScore);
             storeComment.setIsAnonymous(isAnonymous);
             storeComment.setEvaluationTags(evaluationTags);
@@ -534,6 +576,21 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
                 }
             }
             storeComment.setCreatedUserId(storeComment.getUserId());
+
+            Map<String, String> commentCountAndScore = storeCommentMapper.getCommentCountAndScore(storeId);
+            double total = StringUtils.isNotEmpty(commentCountAndScore.get("total")) ? Double.parseDouble(commentCountAndScore.get("total")) : 0;
+            double scoreAvg = StringUtils.isNotEmpty(commentCountAndScore.get("score")) ? Double.parseDouble(commentCountAndScore.get("score")) / total : 0;
+            double tasteScore = StringUtils.isNotEmpty(commentCountAndScore.get("tasteScore")) ? Double.parseDouble(commentCountAndScore.get("tasteScore")) / total : 0;
+            double enScore = StringUtils.isNotEmpty(commentCountAndScore.get("enScore")) ? Double.parseDouble(commentCountAndScore.get("enScore")) / total : 0;
+            double serviceScore = StringUtils.isNotEmpty(commentCountAndScore.get("serviceScore")) ? Double.parseDouble(commentCountAndScore.get("serviceScore")) / total : 0;
+            StoreInfo storeInfo = new StoreInfo();
+            storeInfo.setId(storeId);
+            storeInfo.setScoreAvg(scoreAvg);
+            storeInfo.setTasteScore(tasteScore);
+            storeInfo.setEnScore(enScore);
+            storeInfo.setServiceScore(serviceScore);
+            storeInfoMapper.updateById(storeInfo);
+
             return this.save(storeComment) ? 0 : 1;
         } catch (Exception e) {
             log.error("StoreCommentService.userComment ERROR Msg={}", e.getMessage());

+ 24 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -1357,6 +1357,30 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 queryWrapper.orderByDesc("collect_num");
             }
         }
+
+        if (ObjectUtils.isNotEmpty(vo.getKwyx())) {
+            if (vo.getKwyx() == 1) {
+                queryWrapper.orderByDesc("taste_score");
+            }
+        }
+
+        if (ObjectUtils.isNotEmpty(vo.getHjyx())) {
+            if (vo.getHjyx() == 1) {
+                queryWrapper.orderByDesc("en_score");
+            }
+        }
+
+        if (ObjectUtils.isNotEmpty(vo.getFwyx())) {
+            if (vo.getFwyx() == 1) {
+                queryWrapper.orderByDesc("service_score");
+            }
+        }
+
+        if (ObjectUtils.isNotEmpty(vo.getHpyx())) {
+            if (vo.getHpyx() == 1) {
+                queryWrapper.orderByDesc("score_avg");
+            }
+        }
         queryWrapper.orderByAsc("dist");
         storeInfoIPage = storeInfoMapper.getPageForDistance(page, lon + "," + lat, queryWrapper);
         List<StoreInfoVo> storeInfoVoList = storeInfoIPage.getRecords();