|
@@ -1157,8 +1157,16 @@ 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')
|
|
|
- ->orderby('product_attribute', 'desc');
|
|
|
+ ->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');
|
|
|
+ }else{
|
|
|
+ $model = $model->orderByDesc('product_attribute');
|
|
|
+ }
|
|
|
|
|
|
if(! empty($data['title_t'])) {
|
|
|
// 清理用户输入,去除前后空白并替换多个连续空格为单个空格
|