牟新芬 4 years ago
parent
commit
53f7484ef2
2 changed files with 9 additions and 2 deletions
  1. 7 0
      app/api/controller/v1/Index.php
  2. 2 2
      app/model/api/Product.php

+ 7 - 0
app/api/controller/v1/Index.php

@@ -51,6 +51,13 @@ class Index extends BaseController
             if($v['price'] == 0) {
                 $list[$k]['price'] = round($v['ot_price'] * 1.15, 2);
             }
+            $list[$k]['market_price'] = round($list[$k]['price'] * 1.15, 2);
+            if($v['label'] != ""){
+                $list[$k]['label'] = explode('、',$v['label']);
+            }else{
+                $list[$k]['label'] = [];
+            }
+            $list[$k]['saler'] = random_int(1, 100);
         }
         return app('json')->success($list);
     }

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

@@ -35,7 +35,7 @@ class Product extends Model
             }
         }else{
             if($data['sort'] == 'sort'){
-                $model->where('is_best', 1)->order('sort DESC, add_time DESC');
+                $model->where('is_best', 1)->order('stars DESC, add_time DESC');
             }
         }
         if($data['sort'] == 'sales'){
@@ -47,7 +47,7 @@ class Product extends Model
         if($data['sort'] == 'new'){
             $model->order('add_time DESC');
         }
-        $list = $model->page((int)$page, (int)$limit)->field('id,store_name,image,price,cost,ot_price,(price-ot_price) as commission,IFNULL(sales,0) + IFNULL(ficti,0) as sales')->select();
+        $list = $model->page((int)$page, (int)$limit)->field('id,store_name,image,price,cost,ot_price,(price-ot_price) as commission,IFNULL(sales,0) + IFNULL(ficti,0) as sales,label')->select();
         $list = count($list) ? $list->toArray() : [];
         return $list;
     }