Browse Source

fix: 评论

super-yimizi 1 month ago
parent
commit
9c76d5feb6
1 changed files with 2 additions and 25 deletions
  1. 2 25
      application/api/controller/Goods.php

+ 2 - 25
application/api/controller/Goods.php

@@ -87,33 +87,9 @@ class Goods extends Base
         $row->attributes = AttributeValue::getAttributeList($row->attribute_ids);
         //好评度
         $commentInfo = CommentService::getCommentCountAndFirstComment($id);
-        $row->comment_count = $commentInfo['total'] ?? 0;
+        $comment_count = $commentInfo['total'] ?? 0;
         $row->comment    = $commentInfo['comment'] ?? null;
 
-    
-      
-        //优惠券
-        // $conditions = CouponCondition::getGoodsCondition($id, $row->category_id, $row->brand_id);
-        // $sql = "condition_ids IS NULL OR condition_ids=''";
-        // foreach ($conditions as $key => $item) {
-        //     $sql .= " OR FIND_IN_SET('{$item['id']}',condition_ids)";
-        // }
-        // $couponList = Coupon::field('id,name,result,result_data,allow_num,begintime,endtime,use_times,received_num,give_num,mode,createtime')
-        //     ->where($sql)
-        //     ->where('is_open', 1)
-        //     ->where('is_private', 'no')
-        //     ->where('endtime', '>', time())
-        //     ->select();
-        // //已经登录,渲染已领的优惠券
-        // $coupon_ids = [];
-        // if ($this->auth->isLogin()) {
-        //     $coupon_ids = UserCoupon::where('user_id', $this->auth->id)->column('coupon_id');
-        // }
-        // foreach ($couponList as $key => &$item) {
-        //     Coupon::render($item, $coupon_ids);
-        //     $item->hidden(['received_num', 'give_num', 'condition_ids']);
-        // }
-        // $row->coupon = $couponList;
 
         $row->visible(explode(',', 'id,title,type,spec_type,sub_title,category_ids,price,lineation_price,sales,views,is_hot,
         image,content,images,sku_spec,sku,comment,is_collect,guarantee,attributes,favor_rate,coupon'));
@@ -122,6 +98,7 @@ class Goods extends Base
 
         //查询折扣信息   以及倒计时
         $row['discount_info'] = DiscountService::getGoodsDiscountDetail($row['id']);
+        $row['comment_total'] = $comment_count;
         $this->success('获取成功', $row);
     }