lyx 3 месяцев назад
Родитель
Сommit
fa11375498

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

@@ -131,4 +131,16 @@ public class StoreComment extends Model<StoreComment> {
     @TableField("lawyer_id")
     private Integer lawyerId;
 
+    @ApiModelProperty(value = "口味评分")
+    @TableField("score_one")
+    private Double scoreOne;
+
+    @ApiModelProperty(value = "环境评分")
+    @TableField("score_two")
+    private Double scoreTwo;
+
+    @ApiModelProperty(value = "服务评分")
+    @TableField("score_three")
+    private Double scoreThree;
+
 }

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

@@ -341,4 +341,14 @@ public class StoreInfo {
     @TableField("business_category_name")
     private String businessCategoryName;
 
+    @ApiModelProperty(value = "评价1")
+    @TableField("score_one")
+    private Double scoreOne;
+     @ApiModelProperty(value = "评价2")
+    @TableField("score_two")
+    private Double scoreTwo;
+     @ApiModelProperty(value = "评价3")
+    @TableField("score_three")
+    private Double scoreThree;
+
 }

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

@@ -9,4 +9,7 @@ public class StoreInfoScoreVo {
     private Double tasteScore;
     private Double enScore;
     private Double serviceScore;
+    private Double scoreOne;
+    private Double scoreTwo;
+    private Double scoreThree;
 }

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

@@ -116,14 +116,14 @@ public interface StoreCommentMapper extends BaseMapper<StoreComment> {
 
     @Select("SELECT " +
             "ifnull(SUM( score ),0) score," +
-            "ifnull(SUM( taste_score ),0) tasteScore," +
-            "ifnull(SUM( en_score ),0) enScore," +
-            "ifnull(SUM( service_score ),0) serviceScore," +
+            "ifnull(SUM( score_one ),0) scoreOne," +
+            "ifnull(SUM( score_two ),0) scoreTwo," +
+            "ifnull(SUM( score_three ),0) scoreThree," +
             "COUNT(0) total " +
             "FROM" +
             "`store_comment` " +
             "WHERE " +
-            "business_type = 5 " +
+            "business_type = 6 " +
             "AND delete_flag = 0 " +
             "AND reply_id IS NULL " +
             "AND store_id = #{storeId}")
@@ -194,7 +194,7 @@ WHERE
             "\tstore_comment s\n" +
             "\tLEFT JOIN life_user lu ON s.user_id = lu.id \n" +
             "WHERE\n" +
-            "\ts.business_type = 5 \n" +
+            "\ts.business_type = 6 \n" +
             "\tAND s.store_id = #{storeId}\n" +
             "\tLIMIT 1")
     StoreCommentVo getCommentOneInfo(@Param("storeId") int storeId);

+ 31 - 20
alien-store/src/main/java/shop/alien/store/controller/StoreCommentController.java

@@ -7,11 +7,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartRequest;
 import shop.alien.entity.result.R;
-import shop.alien.entity.store.vo.LifeUserOrderCommentVo;
-import shop.alien.entity.store.vo.StoreCommentCountVo;
-import shop.alien.entity.store.vo.StoreCommentVo;
-import shop.alien.entity.store.vo.StoreCommitPercentVo;
-import shop.alien.entity.store.vo.UserOrderVo;
+import shop.alien.entity.store.vo.*;
 import shop.alien.store.service.StoreCommentService;
 
 import java.util.Map;
@@ -120,6 +116,7 @@ public class StoreCommentController {
             @ApiImplicitParam(name = "phoneId", value = "用户id", dataType = "String", paramType = "query")
     })
     @PostMapping("/saveComment")
+    @Deprecated
     public R<Integer> saveComment(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) {
         log.info("StoreCommentController.saveComment?id={}&businessId={}&businessType={}&storeId={}&userId={}&replyId={}&commentContent={}&score={}&otherScore={}&isAnonymous={}&evaluationTags={}&phoneId={}", id, businessId, businessType, storeId, userId, replyId, commentContent, score, otherScore, isAnonymous, evaluationTags, phoneId);
         Set<String> fileNameSet = multipartRequest.getMultiFileMap().keySet();
@@ -127,30 +124,44 @@ public class StoreCommentController {
         return R.data(storeCommentService.addComment(multipartRequest, id, businessId, businessType, storeId, userId, replyId, commentContent, score, otherScore, isAnonymous, evaluationTags, phoneId));
     }
 
-    @ApiOperation(value = "新增或修改评论/评价(new)", notes = "0:成功, 1:失败, 2:文本内容异常, 3:图片内容异常")
+    @ApiOperation(value = "新增或修改评论/评价(单独对商家)", notes = "0:成功, 1:失败, 2:文本内容异常, 3:图片内容异常")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "multipartRequest", value = "文件", dataType = "File", paramType = "query"),
+//            @ApiImplicitParam(name = "multipartRequest", value = "文件", dataType = "File", paramType = "query"),
+            @ApiImplicitParam(name = "imageUrls", value = "图片url", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "id", value = "主键", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "businessId", value = "业务id", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "businessType", value = "业务类型(1:订单评论, 2:动态社区评论, 3:活动评论, 4:店铺打卡评论, 5:订单评价)", dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "businessType", value = "业务类型(1:订单评论, 2:动态社区评论, 3:活动评论, 4:店铺打卡评论, 5:订单评价,6:评论店铺)", dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "lawyerId", value = "律师id", dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", paramType = "query", required = true),
             @ApiImplicitParam(name = "replyId", value = "回复id", dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "commentContent", value = "评论内容", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "score", value = "评分", dataType = "Double", paramType = "query"),
             @ApiImplicitParam(name = "otherScore", value = "其他评分", dataType = "String", paramType = "query"),
-            @ApiImplicitParam(name = "isAnonymous", value = "是否匿名(0:否(默认), 1:是)", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "evaluationTags", value = "评价标签", dataType = "String", paramType = "query"),
-            @ApiImplicitParam(name = "phoneId", value = "用户id", dataType = "String", paramType = "query")
+            @ApiImplicitParam(name = "isAnonymous", value = "是否匿名(0:否(默认), 1:是)", dataType = "Integer", paramType = "query")
     })
-    @PostMapping("/saveCommentNew")
-    public R<Integer> saveCommentNew(MultipartRequest multipartRequest, Integer id, Integer businessId, Integer businessType, Integer storeId, Integer orderId, Integer lawyerId, Integer userId, Integer replyId, String commentContent, Double score, String otherScore, Integer isAnonymous, String evaluationTags, String phoneId) {
-        log.info("StoreCommentController.saveComment?id={}&businessId={}&businessType={}&storeId={}&userId={}&replyId={}&commentContent={}&score={}&otherScore={}&isAnonymous={}&evaluationTags={}&phoneId={}", id, businessId, businessType, storeId, userId, replyId, commentContent, score, otherScore, isAnonymous, evaluationTags, phoneId);
-        Set<String> fileNameSet = multipartRequest.getMultiFileMap().keySet();
-        log.info(String.valueOf(fileNameSet.size()));
-        return R.data(storeCommentService.addCommentNew(multipartRequest, id, businessId, businessType, storeId,storeId,storeId, orderId, lawyerId, commentContent, score, otherScore, isAnonymous, evaluationTags, phoneId));
+    @PostMapping("/saveCommentOnlyStore")
+    public R<Integer> saveCommentOnlyStore(@RequestBody Map<String,String> map) {
+//        log.info("StoreCommentController.saveComment?id={}&businessType={}&storeId={}&userId={}&replyId={}&commentContent={}&score={}&otherScore={}&isAnonymous={}", id, businessType, storeId, userId, replyId, commentContent, score, otherScore, isAnonymous);
+//        log.info(String.valueOf(imageUrls));
+        String imageUrls = map.get("imageUrls");
+        String s = map.get("id");
+        Integer id = null;
+        if(null != s) {
+            id =  Integer.parseInt(s);
+        }
+        Integer businessType = Integer.parseInt(map.get("businessType"));
+        Integer storeId = Integer.parseInt(map.get("storeId"));
+        Integer userId = Integer.parseInt(map.get("userId"));
+        String b = map.get("replyId");
+        Integer replyId = null;
+        if(null != b) {
+            replyId =  Integer.parseInt(b);
+        }
+
+        String commentContent = map.get("commentContent");
+        Double score = Double.parseDouble(map.get("score"));
+        String otherScore = map.get("otherScore");
+        Integer isAnonymous = Integer.parseInt(map.get("isAnonymous"));
+        return R.data(storeCommentService.saveCommentOnlyStore(imageUrls, id, businessType, storeId, userId, replyId, commentContent, score, otherScore, isAnonymous));
     }
 
     @ApiOperation(value = "回复率, 评价比例")

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

@@ -872,7 +872,7 @@ public class StoreInfoController {
         log.info("StoreInfoController.getStoreEvaluateTags?storeId={}, tagType={}", storeId);
         Map<String,Object> map = new HashMap<>();
         List<TagsMainVo> voList = tagsMainMapper.getStoreEvaluateTags(storeId);
-        if(voList !=null && voList.size()>0){
+//        if(voList !=null && voList.size()>0){
             StoreCommentVo storeComment = storeCommentMapper.getCommentOneInfo(storeId);
             if(storeComment!=null){
                 if(storeComment.getImgId()!=null){
@@ -882,14 +882,14 @@ public class StoreInfoController {
                 }
                 LambdaQueryWrapper<StoreComment> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
                 lambdaQueryWrapper1.eq(StoreComment :: getStoreId, storeId);
-                lambdaQueryWrapper1.eq(StoreComment :: getBusinessType, 5);
+                lambdaQueryWrapper1.eq(StoreComment :: getBusinessType, 6);
                 lambdaQueryWrapper1.eq(StoreComment :: getDeleteFlag, 0);
                 Integer commitCount = storeCommentMapper.selectCount(lambdaQueryWrapper1);
                 map.put("commitCount",commitCount);
             }
             map.put("tag",voList);
             map.put("evaluate",storeComment);
-        }
+//        }
         return R.data(map);
     }
 

+ 15 - 19
alien-store/src/main/java/shop/alien/store/service/StoreCommentService.java

@@ -93,25 +93,6 @@ public interface StoreCommentService extends IService<StoreComment> {
      */
     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);
 
-    /**
-     * 新增或修改评论/评价
-     *
-     * @param multipartRequest 文件
-     * @param id               主键
-     * @param businessId       业务id
-     * @param businessType     业务类型(1:订单评论, 2:动态社区评论, 3:活动评论,4:店铺打卡评论)
-     * @param storeId          门店id
-     * @param userId           用户id
-     * @param replyId          回复id
-     * @param commentContent   评价内容
-     * @param score            评分
-     * @param otherScore       其他评分
-     * @param isAnonymous      是否匿名(0:否(默认), 1:是)
-     * @param evaluationTags   评价标签
-     * @param phoneId          用户id
-     * @return 0:成功, 1:失败, 2:文本内容异常, 3:图片内容异常
-     */
-    Integer addCommentNew(MultipartRequest multipartRequest, Integer id, Integer businessId, Integer businessType, Integer storeId, Integer orderId, Integer lawyerId, Integer userId, Integer replyId, String commentContent, Double score, String otherScore, Integer isAnonymous, String evaluationTags, String phoneId);
 
     /**
      * 回复率, 评价比例
@@ -145,4 +126,19 @@ public interface StoreCommentService extends IService<StoreComment> {
      */
     IPage<UserOrderVo> getUserAllOrders(Integer pageNum, Integer pageSize, Integer userId, Integer type);
 
+    /**
+     * 新增或修改评论/评价(仅店铺)
+     * @param imageUrls 图片url
+     * @param id               主键
+     * @param businessType     业务类型(1:订单评论, 2:动态社区评论, 3:活动评论,4:店铺打卡评论)
+     * @param storeId          门店id
+     * @param userId           用户id
+     * @param replyId          回复id
+     * @param commentContent   评价内容
+     * @param score            评分
+     * @param otherScore       其他评分
+     * @param isAnonymous      是否匿名(0:否(默认), 1:是)
+     * @return 0:成功, 1:失败, 2:文本内容异常, 3:图片内容异常
+     */
+    Integer saveCommentOnlyStore(String imageUrls, Integer id, Integer businessType, Integer storeId, Integer userId, Integer replyId, String commentContent, Double score, String otherScore, Integer isAnonymous);
 }

+ 138 - 154
alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentServiceImpl.java

@@ -1,10 +1,8 @@
 package shop.alien.store.service.impl;
 
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson2.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;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
@@ -22,11 +20,8 @@ import org.springframework.web.multipart.MultipartRequest;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.vo.*;
 import shop.alien.mapper.*;
-import shop.alien.entity.store.vo.LawyerConsultationOrderVO;
-import shop.alien.entity.store.vo.UserOrderVo;
 import shop.alien.store.config.WebSocketProcess;
 import shop.alien.store.service.StoreCommentService;
-import shop.alien.store.service.StoreImgService;
 import shop.alien.store.util.FileUploadUtil;
 import shop.alien.util.common.DateUtils;
 import shop.alien.util.common.netease.ImageCheckUtil;
@@ -582,7 +577,7 @@ 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 {
+      /*  try {
             List<String> servicesList = Lists.newArrayList();
             servicesList.add(TextReviewServiceEnum.COMMENT_DETECTION_PRO.getService());
             servicesList.add(TextReviewServiceEnum.LLM_QUERY_MODERATION.getService());
@@ -591,10 +586,10 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
                 return 2;
             }
 
-            /*Map<String, String> checkText = TextCheckUtil.check(commentContent);
+            *//*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);
@@ -704,153 +699,10 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
             log.error("StoreCommentService.userComment ERROR Msg={}", e.getMessage());
             return 1;
         }
-
+*/
+        return 0;
     }
 
-    /**
-     * 新增或修改评论/评价
-     *
-     * @param multipartRequest 文件
-     * @param id               主键
-     * @param businessId       业务id
-     * @param businessType     业务类型(1:订单评论, 2:动态社区评论, 3:活动评论,4:店铺打卡评论)
-     * @param storeId          门店id
-     * @param userId           用户id
-     * @param replyId          回复id
-     * @param commentContent   评价内容
-     * @param score            评分
-     * @param otherScore       其他评分
-     * @param isAnonymous      是否匿名(0:否(默认), 1:是)
-     * @param evaluationTags   评价标签
-     * @param phoneId          用户id
-     * @return 0:成功, 1:失败, 2:文本内容异常, 3:图片内容异常
-     */
-    @Override
-    public Integer addCommentNew(MultipartRequest multipartRequest, Integer id, Integer businessId, Integer businessType, Integer storeId, Integer orderId, Integer lawyerId, Integer userId, Integer replyId, String commentContent, Double score, String otherScore, Integer isAnonymous, String evaluationTags, String phoneId) {
-        try {
-            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);
-            storeComment.setUserId(userId);
-            storeComment.setCommentContent(commentContent);
-            storeComment.setReplyId(replyId);
-            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);
-            storeComment.setPhoneId(phoneId);
-            List<String> fileNameSet = new ArrayList<>(multipartRequest.getMultiFileMap().keySet());
-            if (!fileNameSet.isEmpty() && storeId != null) {
-                StringBuilder imgId = new StringBuilder();
-                for (int i = 0; i < fileNameSet.size(); i++) {
-                    MultipartFile multipartFile = multipartRequest.getFileMap().get(fileNameSet.get(i));
-                    //b
-                    System.out.println(multipartFile.getSize());
-                    //kb
-                    System.out.println(multipartFile.getSize() / 1024);
-                    if (null != multipartFile && multipartFile.getSize() / 1024 > 0) {
-                        byte[] fileByte;
-                        try {
-                            fileByte = multipartFile.getBytes();
-                        } catch (IOException e) {
-                            return 1;
-                        }
-                        String base64 = Base64.getEncoder().encodeToString(fileByte);
-                        Map<String, String> checkImage = ImageCheckUtil.check(base64, 2);
-                        if (checkImage != null && checkImage.get("result").equals("1")) {
-                            return 3;
-                        }
-                        StoreImg storeImg = new StoreImg();
-                        storeImg.setStoreId(storeComment.getStoreId());
-                        storeImg.setImgType(8);
-                        storeImg.setImgSort(i + 1);
-                        storeImg.setImgUrl(fileUploadUtil.uploadOneFile(multipartFile));
-                        storeImgMapper.insert(storeImg);
-                        imgId.append(storeImg.getId()).append(",");
-                    }
-                }
-                if (!imgId.toString().isEmpty()) {
-                    storeComment.setImgId(imgId.substring(0, imgId.length() - 1));
-                }
-            }
-            storeComment.setCreatedUserId(storeComment.getUserId());
-            int i = this.save(storeComment) ? 0 : 1;
-
-            //判断类型如果为5是评价 更新订单表orderAppraise为1 订单已评价
-            if(businessType == 5){
-                LambdaUpdateWrapper<LifeUserOrder> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
-                lambdaUpdateWrapper.eq(LifeUserOrder :: getId, businessId );
-                lambdaUpdateWrapper.set(LifeUserOrder :: getOrderAppraise, 1);
-                lifeUserOrderMapper.update(null,lambdaUpdateWrapper);
-            }
-            StoreInfoScoreVo storeInfoScoreVo = storeCommentMapper.getCommentCountAndScoreInfo(storeId);
-            double total = storeInfoScoreVo.getTotal();
-            double scoreAvg = (total == 0 ? 0 : storeInfoScoreVo.getScore() / total);
-            double tasteScore = (total == 0 ? 0 : storeInfoScoreVo.getTasteScore() / total);
-            double enScore = (total == 0 ? 0 : storeInfoScoreVo.getEnScore() / total);
-            double serviceScore = (total == 0 ? 0 : storeInfoScoreVo.getServiceScore() / total);
-            StoreInfo storeInfo = new StoreInfo();
-            storeInfo.setId(storeId);
-            storeInfo.setScoreAvg(new BigDecimal(scoreAvg).setScale(2, RoundingMode.HALF_UP).doubleValue());
-            storeInfo.setTasteScore(new BigDecimal(tasteScore).setScale(2, RoundingMode.HALF_UP).doubleValue());
-            storeInfo.setEnScore(new BigDecimal(enScore).setScale(2, RoundingMode.HALF_UP).doubleValue());
-            storeInfo.setServiceScore(new BigDecimal(serviceScore).setScale(2, RoundingMode.HALF_UP).doubleValue());
-            storeInfoMapper.updateById(storeInfo);
-            StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfo.getId()).eq(StoreUser::getDeleteFlag, 0));
-
-            // 如果差评,则发送差评提醒
-            if(score != null && score >= 0.5 && score <= 2.5){
-                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                String commonDate = simpleDateFormat.format(new Date());
-                LifeNotice lifeMessage = new LifeNotice();
-                lifeMessage.setReceiverId("store_" + storeUser.getPhone());
-                String text = "在"+commonDate+",您的店铺有一条差评记录,您可查看评价内容是否属实,如不属实,可向平台进行申诉。";
-                JSONObject jsonObject = new JSONObject();
-                jsonObject.put("message", text);
-                lifeMessage.setContext(jsonObject.toJSONString());
-                lifeMessage.setTitle("差评通知");
-                lifeMessage.setSenderId("system");
-                lifeMessage.setIsRead(0);
-                lifeMessage.setNoticeType(1);
-                lifeNoticeMapper.insert(lifeMessage);
-
-                WebSocketVo websocketVo = new WebSocketVo();
-                websocketVo.setSenderId("system");
-                websocketVo.setReceiverId("store_" + storeUser.getPhone());
-                websocketVo.setCategory("notice");
-                websocketVo.setNoticeType("1");
-                websocketVo.setIsRead(0);
-                websocketVo.setText(JSONObject.from(lifeMessage).toJSONString());
-                webSocketProcess.sendMessage("store_" + storeUser.getPhone(), JSONObject.from(websocketVo).toJSONString());
-            }
-            return i;
-        } catch (Exception e) {
-            log.error("StoreCommentService.userComment ERROR Msg={}", e.getMessage());
-            return 1;
-        }
-
-    }
 
     /**
      * 回复率, 评价比例
@@ -1054,7 +906,7 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
         return new LambdaQueryWrapper<StoreComment>()
                 .eq(StoreComment::getStoreId, storeId)
                 .gt(StoreComment::getScore,0 )
-                .eq(StoreComment::getBusinessType, 5)
+                .eq(StoreComment::getBusinessType, 6)
                 .eq(StoreComment::getDeleteFlag, 0);
     }
 
@@ -1189,6 +1041,138 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
         return resultPage;
     }
 
+     @Override
+    public Integer saveCommentOnlyStore(String imageUrls, Integer id, Integer businessType, Integer storeId, Integer userId, Integer replyId, String commentContent, Double score, String otherScore, Integer isAnonymous) {
+        try {
+            // 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;
+            }
+            // 2.构造评价实体类
+            StoreComment storeComment = new StoreComment();
+            storeComment.setId(id);
+            storeComment.setStoreId(storeId);
+            storeComment.setUserId(userId);
+            storeComment.setCommentContent(commentContent);
+            storeComment.setReplyId(replyId);
+            storeComment.setBusinessType(businessType);
+            storeComment.setScore(score);
+
+            if (StringUtils.isNotEmpty(otherScore)) {
+                JSONObject parse = JSONObject.parse(otherScore);
+                storeComment.setScoreOne(parse.getDouble("scoreOne"));
+                storeComment.setScoreTwo(parse.getDouble("scoreTwo"));
+                storeComment.setScoreThree(parse.getDouble("scoreThree"));
+            }
+            storeComment.setOtherScore(otherScore);
+            storeComment.setIsAnonymous(isAnonymous);
+//            List<String> fileNameSet = new ArrayList<>(multipartRequest.getMultiFileMap().keySet());
+            StringBuilder imgId = new StringBuilder();
+            String[] split = imageUrls.split(",");
+
+            for (int i = 0; i < split.length; i++) {
+                StoreImg storeImg = new StoreImg();
+                storeImg.setStoreId(storeComment.getStoreId());
+                storeImg.setImgType(8);
+                storeImg.setImgSort(i + 1);
+                storeImg.setImgUrl(split[i]);
+                storeImgMapper.insert(storeImg);
+                imgId.append(storeImg.getId()).append(",");
+            }
+            if (!imgId.toString().isEmpty()) {
+                storeComment.setImgId(imgId.substring(0, imgId.length() - 1));
+            }
+            storeComment.setCreatedUserId(storeComment.getUserId());
+
+/*            List<MultipartFile> fileNameSet = multipartRequest.getMultiFileMap().get("file");
+            if (!fileNameSet.isEmpty() && storeId != null) {
+                StringBuilder imgId = new StringBuilder();
+                for (int i = 0; i < fileNameSet.size(); i++) {
+                    MultipartFile multipartFile = fileNameSet.get(i);
+                    //b
+                    System.out.println(multipartFile.getSize());
+                    //kb
+                    System.out.println(multipartFile.getSize() / 1024);
+                    if (null != multipartFile && !multipartFile.isEmpty()) {
+                        byte[] fileByte;
+                        try {
+                            fileByte = multipartFile.getBytes();
+                        } catch (IOException e) {
+                            return 1;
+                        }
+                        String base64 = Base64.getEncoder().encodeToString(fileByte);
+                        Map<String, String> checkImage = ImageCheckUtil.check(base64, 2);
+                        if (checkImage != null && checkImage.get("result").equals("1")) {
+                            return 3;
+                        }
+                        StoreImg storeImg = new StoreImg();
+                        storeImg.setStoreId(storeComment.getStoreId());
+                        storeImg.setImgType(8);
+                        storeImg.setImgSort(i + 1);
+                        storeImg.setImgUrl(fileUploadUtil.uploadOneFile(multipartFile));
+                        storeImgMapper.insert(storeImg);
+                        imgId.append(storeImg.getId()).append(",");
+                    }
+                }
+                if (!imgId.toString().isEmpty()) {
+                    storeComment.setImgId(imgId.substring(0, imgId.length() - 1));
+                }
+            }*/
+            storeComment.setCreatedUserId(storeComment.getUserId());
+            int i = this.save(storeComment) ? 0 : 1;
+
+            // 更新门店评价信息
+            StoreInfoScoreVo storeInfoScoreVo = storeCommentMapper.getCommentCountAndScoreInfo(storeId);
+            double total = storeInfoScoreVo.getTotal();
+            double scoreAvg = (total == 0 ? 0 : storeInfoScoreVo.getScore() / total);
+            double scoreOne = (total == 0 ? 0 : storeInfoScoreVo.getScoreOne() / total);
+            double scoreTwo = (total == 0 ? 0 : storeInfoScoreVo.getScoreTwo() / total);
+            double scoreThree = (total == 0 ? 0 : storeInfoScoreVo.getScoreThree() / total);
+            StoreInfo storeInfo = new StoreInfo();
+            storeInfo.setId(storeId);
+            storeInfo.setScoreAvg(new BigDecimal(scoreAvg).setScale(2, RoundingMode.HALF_UP).doubleValue());
+            storeInfo.setScoreOne(new BigDecimal(scoreOne).setScale(2, RoundingMode.HALF_UP).doubleValue());
+            storeInfo.setScoreTwo(new BigDecimal(scoreTwo).setScale(2, RoundingMode.HALF_UP).doubleValue());
+            storeInfo.setScoreThree(new BigDecimal(scoreThree).setScale(2, RoundingMode.HALF_UP).doubleValue());
+            storeInfoMapper.updateById(storeInfo);
+            StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfo.getId()).eq(StoreUser::getDeleteFlag, 0));
+
+            // 如果差评,则发送差评提醒
+            if(score != null && score >= 0.5 && score <= 2.5){
+                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                String commonDate = simpleDateFormat.format(new Date());
+                LifeNotice lifeMessage = new LifeNotice();
+                lifeMessage.setReceiverId("store_" + storeUser.getPhone());
+                String text = "在"+commonDate+",您的店铺有一条差评记录,您可查看评价内容是否属实,如不属实,可向平台进行申诉。";
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("message", text);
+                lifeMessage.setContext(jsonObject.toJSONString());
+                lifeMessage.setTitle("差评通知");
+                lifeMessage.setSenderId("system");
+                lifeMessage.setIsRead(0);
+                lifeMessage.setNoticeType(1);
+                lifeNoticeMapper.insert(lifeMessage);
+
+                WebSocketVo websocketVo = new WebSocketVo();
+                websocketVo.setSenderId("system");
+                websocketVo.setReceiverId("store_" + storeUser.getPhone());
+                websocketVo.setCategory("notice");
+                websocketVo.setNoticeType("1");
+                websocketVo.setIsRead(0);
+                websocketVo.setText(JSONObject.from(lifeMessage).toJSONString());
+                webSocketProcess.sendMessage("store_" + storeUser.getPhone(), JSONObject.from(websocketVo).toJSONString());
+            }
+            return i;
+        } catch (Exception e) {
+            log.error("StoreCommentService.saveCommentOnlyStore ERROR Msg={}", e.getMessage());
+            return 1;
+        }
+    }
+
     /**
      * 转换商户订单为统一VO
      */

+ 32 - 8
alien-util/src/main/java/shop/alien/util/file/FileUtil.java

@@ -489,10 +489,22 @@ public class FileUtil {
     public static Map<String, String> getFileNameAndType(MultipartFile multipartFile) {
         String originalFilename = multipartFile.getOriginalFilename();
         Map<String, String> map = new HashMap<>();
-        String fileName = originalFilename.substring(0, originalFilename.lastIndexOf('.'));
-        String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1);
-        map.put("name", fileName);
-        map.put("type", fileType);
+        if (originalFilename == null || originalFilename.isEmpty()) {
+            map.put("name", "");
+            map.put("type", "");
+            return map;
+        }
+        int lastDotIndex = originalFilename.lastIndexOf('.');
+        if (lastDotIndex == -1 || lastDotIndex == originalFilename.length() - 1) {
+            // 没有扩展名或点号在最后
+            map.put("name", originalFilename);
+            map.put("type", "");
+        } else {
+            String fileName = originalFilename.substring(0, lastDotIndex);
+            String fileType = originalFilename.substring(lastDotIndex + 1);
+            map.put("name", fileName);
+            map.put("type", fileType);
+        }
         return map;
     }
 
@@ -505,10 +517,22 @@ public class FileUtil {
     public static Map<String, String> getFileNameAndType(File file) {
         String originalFilename = file.getName();
         Map<String, String> map = new HashMap<>();
-        String fileName = originalFilename.substring(0, originalFilename.lastIndexOf('.'));
-        String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1);
-        map.put("name", fileName);
-        map.put("type", fileType);
+        if (originalFilename == null || originalFilename.isEmpty()) {
+            map.put("name", "");
+            map.put("type", "");
+            return map;
+        }
+        int lastDotIndex = originalFilename.lastIndexOf('.');
+        if (lastDotIndex == -1 || lastDotIndex == originalFilename.length() - 1) {
+            // 没有扩展名或点号在最后
+            map.put("name", originalFilename);
+            map.put("type", "");
+        } else {
+            String fileName = originalFilename.substring(0, lastDotIndex);
+            String fileType = originalFilename.substring(lastDotIndex + 1);
+            map.put("name", fileName);
+            map.put("type", fileType);
+        }
         return map;
     }
 }