|
@@ -18,6 +18,7 @@ use think\Db;
|
|
use app\common\Service\SkuSpec as SkuSpecService;
|
|
use app\common\Service\SkuSpec as SkuSpecService;
|
|
use app\common\Service\Goods\CategoryService;
|
|
use app\common\Service\Goods\CategoryService;
|
|
use app\common\Service\DiscountService;
|
|
use app\common\Service\DiscountService;
|
|
|
|
+use app\common\Service\Goods\CommentService;
|
|
/**
|
|
/**
|
|
* 商品接口
|
|
* 商品接口
|
|
*/
|
|
*/
|
|
@@ -77,23 +78,20 @@ class Goods extends Base
|
|
$row->sku_spec = $skuSpecData; // 处理完后重新赋值
|
|
$row->sku_spec = $skuSpecData; // 处理完后重新赋值
|
|
}
|
|
}
|
|
//
|
|
//
|
|
|
|
+ unset($item);
|
|
|
|
|
|
//服务保障
|
|
//服务保障
|
|
- $row->guarantee = $row->guarantee_ids ? Guarantee::field('id,name,intro')->where('id', 'IN', $row->guarantee_ids)->where('status', 'normal')->select() : [];
|
|
|
|
|
|
+ $row->guarantee = $row->guarantee_ids ? Guarantee::field('id,name,intro')->where('id', 'IN', $row->guarantee_ids)
|
|
|
|
+ ->where('status', 'normal')->select() : [];
|
|
//属性
|
|
//属性
|
|
$row->attributes = AttributeValue::getAttributeList($row->attribute_ids);
|
|
$row->attributes = AttributeValue::getAttributeList($row->attribute_ids);
|
|
//好评度
|
|
//好评度
|
|
- // $row->favor_rate = Comment::degree($id);
|
|
|
|
|
|
+ $commentInfo = CommentService::getCommentCountAndFirstComment($id);
|
|
|
|
+ $row->comment_count = $commentInfo['total'] ?? 0;
|
|
|
|
+ $row->comment = $commentInfo['comment'] ?? null;
|
|
|
|
|
|
- //评论
|
|
|
|
- $comment = collection($row->comment)->toArray();
|
|
|
|
- foreach ($comment as &$item) {
|
|
|
|
- if ($item['user']) {
|
|
|
|
- $item['user']['avatar'] = cdnurl($item['user']['avatar'], true);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- $row->setRelation('comment', $comment);
|
|
|
|
- unset($item);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
//优惠券
|
|
//优惠券
|
|
// $conditions = CouponCondition::getGoodsCondition($id, $row->category_id, $row->brand_id);
|
|
// $conditions = CouponCondition::getGoodsCondition($id, $row->category_id, $row->brand_id);
|
|
// $sql = "condition_ids IS NULL OR condition_ids=''";
|
|
// $sql = "condition_ids IS NULL OR condition_ids=''";
|