From 19df67e19f23cd2a04d1c7f355e1e656f4140af4 Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期四, 17 四月 2025 20:04:14 +0800
Subject: [PATCH] 后台:首页统计、系统管理、广告管理、用户管理、商品分类管理

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java |   40 +++++++++++++++++++++++-----------------
 1 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java
index 57fb9fe..54f4cea 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/GoodsEvaluateServiceImpl.java
@@ -1,6 +1,7 @@
 package com.ruoyi.other.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.utils.StringUtils;
@@ -41,32 +42,37 @@
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void addGoodsEvaluate(GoodsEvaluateVO goodsEvaluateVO) {
-        List<GoodsEvaluate> evaluates = goodsEvaluateVO.getEvaluates();
-        for (GoodsEvaluate goodsEvaluate : evaluates) {
-            goodsEvaluate.setStatus(2);
-            if (StringUtils.isNotEmpty(goodsEvaluate.getIdStr())){
-                goodsEvaluate.setId(Long.valueOf(goodsEvaluate.getIdStr()));
-                updateById(goodsEvaluate);
-            }else {
-                LoginUser loginUserApplet = tokenService.getLoginUserApplet();
-                goodsEvaluate.setAppUserId(loginUserApplet.getUserid());
-                goodsEvaluate.setCreateTime(LocalDateTime.now());
-                save(goodsEvaluate);
+    public R addGoodsEvaluate(GoodsEvaluate goodsEvaluate) {
+
+        if (goodsEvaluate.getId() == null) {
+            //新增
+            GoodsEvaluate evaluate = this.getOne(new LambdaQueryWrapper<GoodsEvaluate>()
+                    .eq(GoodsEvaluate::getStatus, 2)
+                    .eq(GoodsEvaluate::getDelFlag, 0)
+                    .eq(GoodsEvaluate::getOrderId, goodsEvaluate.getId()));
+            if (evaluate != null) {
+                return R.fail("已评价过");
             }
-        }
-        if (CollectionUtil.isNotEmpty(evaluates)){
-            Long orderId = goodsEvaluateVO.getEvaluates().get(0).getOrderId();
+            goodsEvaluate.setStatus(2);
+            LoginUser loginUserApplet = tokenService.getLoginUserApplet();
+            goodsEvaluate.setAppUserId(loginUserApplet.getUserid());
+            goodsEvaluate.setCreateTime(LocalDateTime.now());
+            save(goodsEvaluate);
+            Long orderId = goodsEvaluate.getOrderId();
             Order data = orderClient.getOrderById(orderId).getData();
             Order order = new Order();
             order.setId(data.getId());
             order.setOldOrderStatus(data.getOrderStatus());
             order.setOrderStatus(8);
             R<Void> r = remoteOrderGoodsClient.updateOrderStatus(order);
-            if (R.isError(r)){
+            if (R.isError(r)) {
                 throw new RuntimeException("修改订单状态失败");
             }
+        } else {
+            //修改
+            goodsEvaluate.setUpdateTime(LocalDateTime.now());
+            updateById(goodsEvaluate);
         }
-
+        return R.ok();
     }
 }

--
Gitblit v1.7.1