Browse Source

fix: 优化代码

super-yimizi 1 month ago
parent
commit
ac9643bd8d

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

@@ -100,7 +100,8 @@ class Goods extends Base
         $row['discount_info'] = DiscountService::getGoodsDiscountDetail($row['id']);
         $row['comment_total'] = $comment_count;
         // 查询是否有定制规格
-        $row['is_customized_spec'] = GoodService::getGoodsCustomizedSpec($id, 2) ? 1: 0;
+        $goodsCustomizedSpec = GoodService::getGoodsCustomizedSpec($id, 2);
+        $row['is_customized_spec'] = !empty($goodsCustomizedSpec) ? 1: 0;
         $this->success('获取成功', $row);
     }
 

+ 1 - 1
application/common/Service/Goods/GoodService.php

@@ -39,7 +39,7 @@ class GoodService
     //  查询商品关联规格
     public static function getGoodsCustomizedSpec($goods_id = 0, $type = 0)
     {
-        $goodsSkuSpec = GoodsSkuSpec::where('id', $goods_id)
+        $goodsSkuSpec = GoodsSkuSpec::where('goods_id', $goods_id)
              ->where('type', $type)
              ->find();