Browse Source

全部评价完才算已评价

lizhen_gitee 3 months ago
parent
commit
f641805ba4
2 changed files with 5 additions and 2 deletions
  1. 4 2
      addons/unishop/controller/Order.php
  2. 1 0
      addons/unishop/controller/Product.php

+ 4 - 2
addons/unishop/controller/Order.php

@@ -699,7 +699,7 @@ class Order extends Base
             $this->error(__('Order not exist'));
         }
         if ($order->have_received == $orderModel::RECEIVED_NO) {
-            $this->error(__('未收货,不可评价'));
+            $this->error(__('未核销,不可评价'));
         }
 
         $result = false;
@@ -716,7 +716,9 @@ class Order extends Base
             $evaluate->spec = $orderProduct->spec;
             $result = $evaluate->save();
 
-            if ($result) {
+            $orderProduct  = Db::name('unishop_order_product')->where(['order_id' => $order_id])->count();
+            $orderevaluate = Db::name('unishop_evaluate')->where(['order_id' => $order_id])->count();
+            if ($result && ($orderProduct == $orderevaluate)) {
                 $order->have_commented = time();
                 $order->save();
             }

+ 1 - 0
addons/unishop/controller/Product.php

@@ -102,6 +102,7 @@ class Product extends Base
             $data->cart_num = (new \addons\unishop\model\Cart)->where(['user_id' => $this->auth->id])->count();
 
             // 评价信息
+            $data->evaluate_list = [];
             $evaluate = (new Evaluate)->alias('e')
                 ->join('user u', 'e.user_id = u.id')
                 ->where(['e.product_id' => $productId, 'toptime' => ['>', Evaluate::TOP_OFF]])