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

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

@@ -9,6 +9,7 @@ use app\model\system\ProductAttr;
 use app\Request;
 use library\services\UtilService;
 use library\services\QrcodeService;
+use think\facade\Db;
 
 class Index extends BaseController
 {
@@ -51,7 +52,24 @@ 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);
+            $list[$k]['market_price'] = round($list[$k]['price'] * 1.3, 2);
+            $score = Db::name("product_score")->where('product_id', $v['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)
+                    $list[$k]['market_price'] = $max;
+            }
             if($v['label'] != ""){
                 $list[$k]['label'] = explode('、',$v['label']);
             }else{

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

@@ -35,7 +35,7 @@ class Product extends Model
             }
         }else{
             if($data['sort'] == 'sort'){
-                $model->where('stars', '>', 1)->order('stars DESC, add_time DESC');
+                $model->where('stars', '>', 1)->order('stars DESC, sort DESC, add_time DESC');
             }
         }
         if($data['sort'] == 'sales'){