牟新芬 4 years ago
parent
commit
2f8a0b59b2
3 changed files with 24 additions and 3 deletions
  1. 20 1
      app/api/controller/v1/Index.php
  2. 1 1
      app/model/api/Product.php
  3. 3 1
      app/model/system/ProductAttr.php

+ 20 - 1
app/api/controller/v1/Index.php

@@ -100,14 +100,33 @@ class Index extends BaseController
         if($storeInfo['price'] == 0){
         if($storeInfo['price'] == 0){
             $storeInfo['price'] = round($storeInfo['ot_price'] * 1.15, 2);
             $storeInfo['price'] = round($storeInfo['ot_price'] * 1.15, 2);
         }
         }
+        $storeInfo['market_price'] = round($storeInfo['price'] * 1.3, 2);
+        $score = Db::name("product_score")->where('product_id', $id)->find();
+        if($score) {
+            $attr = json_decode($score['attribute'], true);
+            $max = $attr[2]['taobao'];
+            if($attr[2]['t1688'] > $max)
+                $max = $attr[2]['t1688'];
+            if($attr[2]['pdd'] > $max)
+                $max = $attr[2]['pdd'];
+            if($attr[2]['dy'] > $max)
+                $max = $attr[2]['dy'];
+            if($attr[2]['ks'] > $max)
+                $max = $attr[2]['ks'];
+            if($attr[2]['other'] > $max)
+                $max = $attr[2]['other'];
+            if($max)
+                $storeInfo['market_price'] = $max;
+        }
         $data['storeInfo'] = $storeInfo;
         $data['storeInfo'] = $storeInfo;
-        list($productAttr, $productValue) = ProductAttr::getProductAttrDetail($id, 0, 0);
+        list($productAttr, $productValue, $sku) = ProductAttr::getProductAttrDetail($id, 0, 0);
         $data['productAttr'] = $productAttr;
         $data['productAttr'] = $productAttr;
         $prices = array_column($productValue, 'price');
         $prices = array_column($productValue, 'price');
         array_multisort($prices, SORT_ASC, SORT_NUMERIC, $productValue);
         array_multisort($prices, SORT_ASC, SORT_NUMERIC, $productValue);
         $keys = array_keys($productValue);
         $keys = array_keys($productValue);
         $productValue = array_combine($keys, $productValue);
         $productValue = array_combine($keys, $productValue);
         $data['productValue'] = $productValue;
         $data['productValue'] = $productValue;
+        $data['sku'] = $sku;
         $data['priceName'] = 0;
         $data['priceName'] = 0;
         $data['good_list'] = Product::getGoodList(18, 'image,store_name,price,id,ot_price,stock,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,unit_name');
         $data['good_list'] = Product::getGoodList(18, 'image,store_name,price,id,ot_price,stock,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,unit_name');
         return app('json')->successful($data);
         return app('json')->successful($data);

+ 1 - 1
app/model/api/Product.php

@@ -52,7 +52,7 @@ class Product extends Model
         return $list;
         return $list;
     }
     }
 
 
-    public static function getValidProduct($productId, $field = 'add_time,browse,cate_id,code_path,cost,ficti,id,image,is_sub,is_best,is_del,is_hot,is_show,keyword,ot_price,postage,price,(price-ot_price) as commission,sales,slider_image,detail_image,sort,stock,store_info,store_name,unit_name,vip_price,spec_type,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,video_link,description')
+    public static function getValidProduct($productId, $field = 'add_time,browse,cate_id,code_path,cost,ficti,id,image,is_sub,is_best,is_del,is_hot,is_show,keyword,ot_price,postage,price,(price-ot_price) as commission,sales,slider_image,detail_image,sort,stock,store_info,store_name,unit_name,vip_price,spec_type,IFNULL(sales,0) + IFNULL(ficti,0) as fsales,video_link,description,code')
     {
     {
         $Product = self::where('is_del', 0)->where('is_show', 1)->where('id', $productId)->field($field)->find();
         $Product = self::where('is_del', 0)->where('is_show', 1)->where('id', $productId)->field($field)->find();
         if ($Product) return $Product->toArray();
         if ($Product) return $Product->toArray();

+ 3 - 1
app/model/system/ProductAttr.php

@@ -57,6 +57,7 @@ class ProductAttr extends BaseModel
         $attrDetail = self::where('product_id', $productId)->where('type', $type_id)->order('attr_values asc')->select()->toArray() ?: [];
         $attrDetail = self::where('product_id', $productId)->where('type', $type_id)->order('attr_values asc')->select()->toArray() ?: [];
         $_values = self::storeProductAttrValueDb()->where('product_id', $productId)->where('type', $type_id)->select();
         $_values = self::storeProductAttrValueDb()->where('product_id', $productId)->where('type', $type_id)->select();
         $values = [];
         $values = [];
+        $sku = [];
         foreach ($_values as $value) {
         foreach ($_values as $value) {
             if ($type) {
             if ($type) {
                 if ($uid)
                 if ($uid)
@@ -66,6 +67,7 @@ class ProductAttr extends BaseModel
                 if (is_null($value['cart_num'])) $value['cart_num'] = 0;
                 if (is_null($value['cart_num'])) $value['cart_num'] = 0;
             }
             }
             $values[$value['suk']] = $value;
             $values[$value['suk']] = $value;
+            $sku[] = $value;
         }
         }
         foreach ($attrDetail as $k => $v) {
         foreach ($attrDetail as $k => $v) {
             $attr = $v['attr_values'];
             $attr = $v['attr_values'];
@@ -75,7 +77,7 @@ class ProductAttr extends BaseModel
                 $attrDetail[$k]['attr_value'][$kk]['check'] = false;
                 $attrDetail[$k]['attr_value'][$kk]['check'] = false;
             }
             }
         }
         }
-        return [$attrDetail, $values];
+        return [$attrDetail, $values, $sku];
     }
     }
 
 
     public static function uniqueByStock($unique)
     public static function uniqueByStock($unique)