dyjh 6 éve
szülő
commit
9e6cd07042
1 módosított fájl, 23 hozzáadás és 4 törlés
  1. 23 4
      app/Http/Controllers/Api/V1/AlbumController.php

+ 23 - 4
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd xqd xqd xqd xqd
@@ -389,17 +389,22 @@ class AlbumController extends Controller
         }
 
         if ($userAuth->up_agent_id != 0) {
+
+
             $agent_in = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
             $set_show_price = $agent_in->is_show_ma_price;
+
         } else {
             $set_show_price = 0;
         }
 
+
         if ($userAuth->is_dealer == 1) {
             $agent_me = AlbumAgentModel::where('user_id',$userAuth->id)->first();
             $set_show_price = $agent_me->is_show_ma_price;
         }
 
+
         $goods = $goods->select('id','cover_pic','thumb','name','style','hot_cake','news','price_default','ma_price','ma_price_comment')->orderByDesc('sort')->paginate(9);
 
         foreach($goods as $key =>$val){
@@ -975,12 +980,12 @@ class AlbumController extends Controller
         $validator = Validator::make($request->all(), [
             'store_id' => 'required',
             'open_id' => 'required',
-           // 'end' => 'required',
+            // 'end' => 'required',
             //'start' => 'required',
         ],[
             'store_id.required'=>'缺少商户参数',
             'open_id.required'=>'缺少风格参数',
-           // 'end.required'=>'缺少结束时间参数',
+            // 'end.required'=>'缺少结束时间参数',
             //'start.required'=>'缺少开始时间参数',
         ]);
         if ($validator->fails()) {
@@ -2342,6 +2347,7 @@ class AlbumController extends Controller
         if (!$end) {
             $end = time();
         }
+
         if (!$start) {
             $start = 0;
         }
@@ -2359,7 +2365,7 @@ class AlbumController extends Controller
             if($goods){
                 $style = AlbumProductStyleModel::where([['store_id',$store_id],['id',$goods->style]])->first();
                 $cat = AlbumCatModel::where([['store_id',$store_id],['id',$goods->cat_id]])->first();
-                $arr[] = ['name'=>$goods->name,'time'=>date('Y-m-d H:i',strtotime($val['created_at'])), 'style'=>$style->name, 'cat'=>$cat->name, 'thumb'=>$goods->thumb];
+                //$arr[] = ['name'=>$goods->name,'time'=>date('Y-m-d H:i',strtotime($val['created_at'])), 'style'=>$style->name, 'cat'=>$cat->name, 'thumb'=>$goods->thumb];
                 if (isset($arr[date('Y-m-d H:i', strtotime($val['created_at']))])) {
                     if (isset($arr[date('Y-m-d H:i', strtotime($val['created_at']))][$goods->id])) {
                         $arr[date('Y-m-d H:i', strtotime($val['created_at']))][$goods->id]['times']++;
@@ -2367,13 +2373,24 @@ class AlbumController extends Controller
                         $arr[date('Y-m-d H:i', strtotime($val['created_at']))][$goods->id] = [
                             'name' => $goods->name,
                             'style' => $style->name,
-                            'cat' => $style->name,
+                            'cat' => $cat->name,
                             'thumb' => $goods->thumb,
+                            'time' => date('Y-m-d H:i', strtotime($val['created_at'])),
                             'times' => 1
                         ];
                     }
+                } else {
+                    $arr[date('Y-m-d H:i', strtotime($val['created_at']))][$goods->id] = [
+                        'name' => $goods->name,
+                        'style' => $style->name,
+                        'cat' => $cat->name,
+                        'thumb' => $goods->thumb,
+                        'time' => date('Y-m-d H:i', strtotime($val['created_at'])),
+                        'times' => 1
+                    ];
                 }
             }
+            krsort($arr);
         }
         return $this->api($arr,0,'success');
     }
@@ -2722,6 +2739,7 @@ class AlbumController extends Controller
         $user_agent->is_show_ma_price = $data['is_show_ma_price'];
         $user_agent->save();
 
+
         $product = AlbumProductModel::where('store_id',$data['store_id'])->get(['id','ma_price']);
         foreach ($product as $key=>$val) {
             $save['price'] = $val['ma_price'] * (1 + $data['point'] / 100);
@@ -2737,6 +2755,7 @@ class AlbumController extends Controller
         }
         $user_agent->set_price_point = $data['point'];
         $user_agent->save();
+
         return $this->api([],0,'success');
     }
 }