cqp 6 ماه پیش
والد
کامیت
57b870348a
2فایلهای تغییر یافته به همراه18 افزوده شده و 12 حذف شده
  1. 4 0
      app/Model/Product.php
  2. 14 12
      app/Service/ProductService.php

+ 4 - 0
app/Model/Product.php

@@ -23,11 +23,15 @@ class Product extends UseScopeBaseModel
     const Product_attribute_one = 1;
     const Product_attribute_two = 2;
     const Product_attribute_three = 3;
+    const Product_attribute_four = 4;
+    const Product_attribute_five = 5;
     public static $product_attribute = [
         self::Product_attribute_zero => '无',
         self::Product_attribute_one => '其他',
         self::Product_attribute_two => '主推款',
         self::Product_attribute_three => '热卖款',
+        self::Product_attribute_four => '精选',
+        self::Product_attribute_five => 'new',
     ];
     public static $product_attribute_color = [
         self::Product_attribute_zero => [

+ 14 - 12
app/Service/ProductService.php

@@ -1157,18 +1157,20 @@ class ProductService extends Service
             ->where('item_code','<>',"")
             ->select('title','id','product_category_id','product_category','retail_price','product_attribute','item_code','unit','size','code','bar_code')
             ->where('is_use', Product::is_use_one)
-            ->groupBy('item_code');
-
-        if(isset($data['from_wechat_program'])){
-            //先根据大类分类排序 然后再根据子类分类排序 然后再根据产品属性排序
-            $model = $model->orderByRaw("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(product_category, ',', 1), '[', -1) AS UNSIGNED)")
-                ->orderByRaw("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(product_category, ',', 2), ',', -1) AS UNSIGNED)")
-                ->orderByDesc('product_attribute')
-                ->orderByDesc('item_code');
-        }else{
-            $model = $model->orderByDesc('product_attribute')
-                ->orderByDesc('item_code');
-        }
+            ->groupBy('item_code')
+            ->orderByDesc('product_attribute')
+            ->orderByDesc('item_code');
+
+//        if(isset($data['from_wechat_program'])){
+//            //先根据大类分类排序 然后再根据子类分类排序 然后再根据产品属性排序
+//            $model = $model->orderByRaw("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(product_category, ',', 1), '[', -1) AS UNSIGNED)")
+//                ->orderByRaw("CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(product_category, ',', 2), ',', -1) AS UNSIGNED)")
+//                ->orderByDesc('product_attribute')
+//                ->orderByDesc('item_code');
+//        }else{
+//            $model = $model->orderByDesc('product_attribute')
+//                ->orderByDesc('item_code');
+//        }
 
         if(! empty($data['title_t'])) {
             // 清理用户输入,去除前后空白并替换多个连续空格为单个空格