瀏覽代碼

fix: 优化代码

super-yimizi 3 月之前
父節點
當前提交
ac9643bd8d
共有 2 個文件被更改,包括 3 次插入2 次删除
  1. 2 1
      application/api/controller/Goods.php
  2. 1 1
      application/common/Service/Goods/GoodService.php

+ 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();