dyjh 6 yıl önce
ebeveyn
işleme
f15d80c700

+ 68 - 27
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -50,19 +50,27 @@ class AlbumController extends Controller
         $store_id = $request->store_id;
         //小程序設置
 
-        $setting = AlbumManufacturerModel::where('store_id',$store_id)->first();
+        $setting = AlbumManufacturerModel::where('store_id', $store_id)->first();
         //轮播图
-        $banner = AlbumBannerModel::where('store_id',$store_id)->orderByDesc('sort')->get();
+        $banner = AlbumBannerModel::where('store_id', $store_id)->orderByDesc('sort')->get();
 
         //底部导航栏
-        $navbar = AlbumNavModel::where([['store_id',$store_id],['state',0]])->orderByDesc('sort')->get();
+        $navbar = AlbumNavModel::where([['store_id', $store_id],['state',0]])->orderByDesc('sort')->get();
 
         //顶部菜单栏
-        $menus = AlbumNavModel::where([['store_id',$store_id],['state',1]])->orderByDesc('sort')->get();
+        $menus = AlbumNavModel::where([['store_id', $store_id],['state',1]])->orderByDesc('sort')->get();
 
-        $news = AlbumNewsModel::where([['store_id',$store_id]])->orderByDesc('sort')->paginate(5);
+        $news = AlbumNewsModel::where([['store_id', $store_id]])->orderByDesc('sort')->paginate(5);
 
-        return $this->api(compact('setting','banner','news','navbar','menus'));
+        $userAuth = Auth('api')->user();
+        $agent_set = array();
+        if ($userAuth && $userAuth->is_dealer == 1) {
+            $user_agent = AlbumAgentModel::where('user_id', $userAuth->id)->first();
+            $agent_set['set_price_point'] = $user_agent->set_price_point;
+            $agent_set['is_show_ma_price'] = $user_agent->is_show_ma_price;
+        }
+
+        return $this->api(compact('setting', 'banner', 'news', 'navbar', 'menus', 'agent_set'));
     }
 
 
@@ -970,23 +978,31 @@ class AlbumController extends Controller
         if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
         $validator = Validator::make($request->all(), [
             'store_id' => 'required',
-            'open_id' => 'required'
+            'open_id' => 'required',
+            'end' => 'required',
+            'start' => 'required',
         ],[
             'store_id.required'=>'缺少商户参数',
             'open_id.required'=>'缺少风格参数',
+            'end.required'=>'缺少结束时间参数',
+            'start.required'=>'缺少开始时间参数',
         ]);
         if ($validator->fails()) {
             return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
         }
         $store_id = $request->input('store_id');
         $open_id = $request->input('open_id');
+        $end = $request->input('end');
+        $start = $request->input('start');
+        $end= date('Y-m-d H:i:s',$end);
+        $start= date('Y-m-d H:i:s',$start);
         if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
 
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
         $cat = AlbumCatModel::where('store_id',$store_id)->get(['name','id'])->toArray();
         $total = 0;
         foreach ($cat as $key=>$val){
-            $count = CustomerCatRecordModel::where([['agent_id',$user_agent->id],['store_id',$store_id],['open_id',$open_id],['cat_id',$val['id']]])->count();
+            $count = CustomerCatRecordModel::where([['agent_id',$user_agent->id],['store_id',$store_id],['open_id',$open_id],['cat_id',$val['id']],['updated_at','>=',$start],['updated_at','<=',$end]])->count();
             $total += $count;
             $cat[$key]['num'] = $count;
         }
@@ -2222,18 +2238,26 @@ class AlbumController extends Controller
         $validator = Validator::make($request->all(), [
             'store_id' => 'required',
             'open_id' => 'required',
+            'end' => 'required',
+            'start' => 'required',
         ],[
             'store_id.required'=>'缺少商户参数',
             'open_id.required'=>'缺少用户参数',
+            'end.required'=>'缺少结束时间参数',
+            'start.required'=>'缺少开始时间参数',
         ]);
         if ($validator->fails()) {
             return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
         }
         $store_id = $request->input('store_id');
         $open_id = $request->input('open_id');
+        $end = $request->input('end');
+        $start = $request->input('start');
+        $end= date('Y-m-d H:i:s',$end);
+        $start= date('Y-m-d H:i:s',$start);
         if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
-        if($user_agent) $res=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['agent_id',$user_agent->id],['open_id',$open_id]])->groupBy('detail')->get(['detail']);
+        if($user_agent) $res=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['agent_id',$user_agent->id],['open_id',$open_id],['updated_at','>=',$start],['updated_at','<=',$end]])->groupBy('detail')->get(['detail']);
         $arr = array();
         foreach ($res as $key=>$val){
             $detail = json_decode($val['detail'],true);
@@ -2289,19 +2313,27 @@ class AlbumController extends Controller
         if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
         $validator = Validator::make($request->all(), [
             'store_id' => 'required',
-            'open_id'=>'required'
+            'open_id'=>'required',
+            'end' => 'required',
+            'start' => 'required',
         ],[
             'store_id.required'=>'缺少商户参数',
             'open_id.required'=>'缺少用户参数',
+            'end.required'=>'缺少结束时间参数',
+            'start.required'=>'缺少开始时间参数',
         ]);
         if ($validator->fails()) {
             return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
         }
         $store_id = $request->input('store_id');
         $open_id = $request->input('open_id');
+        $end = $request->input('end');
+        $start = $request->input('start');
+        $end= date('Y-m-d H:i:s',$end);
+        $start= date('Y-m-d H:i:s',$start);
         if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
-        if($user_agent) $res=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->orderByDesc('id')->get(['detail','created_at'])->toArray();
+        if($user_agent) $res=  AlbumWatchRecord::where([['action',3],['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id],['updated_at','>=',$start],['updated_at','<=',$end]])->orderByDesc('id')->get(['detail','created_at'])->toArray();
         $arr = array();
         foreach ($res as $key=>$val){
             $detail = json_decode($val['detail'],true);
@@ -2547,21 +2579,29 @@ class AlbumController extends Controller
             'store_id' => 'required',
             'open_id' => 'required',
             'type' => 'required',
+            'end' => 'required',
+            'start' => 'required',
         ],[
             'store_id.required'=>'缺少商户参数',
             'open_id.required'=>'缺少用户参数',
             'type.required'=>'缺少类型参数',
+            'end.required'=>'缺少结束时间参数',
+            'start.required'=>'缺少开始时间参数',
         ]);
         if ($validator->fails()) {
             return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
         }
         $data = $request->input();
         $res = array();
+        $end = $request->input('end');
+        $start = $request->input('start');
+        $end= date('Y-m-d H:i:s',$end);
+        $start= date('Y-m-d H:i:s',$start);
         if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
         $user = AlbumUserModel::where([['open_id',$data['open_id']],['store_id',$data['store_id']]])->first();
         if ($data['type'] == 1) {    //尺寸统计
-            $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['detail','like','%'.'u5c3a'.'%'],['action',5],['store_id',$data['store_id']]])->get();
+            $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['detail','like','%'.'u5c3a'.'%'],['action',5],['store_id',$data['store_id']],['updated_at','>=',$start],['updated_at','<=',$end]])->get();
             foreach ($record as $key=>$val){
                 $detail = json_decode($val['detail'],true);
                 $goods = AlbumProductModel::where([['store_id',$data['store_id']],['id',$detail['goods_id']]])->first();
@@ -2574,7 +2614,7 @@ class AlbumController extends Controller
                 ];
             }
         } elseif ($data['type'] == 2) {   //拨打电话
-            $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['action',7],['store_id',$data['store_id']]])->get();
+            $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['action',7],['store_id',$data['store_id']],['updated_at','>=',$start],['updated_at','<=',$end]])->get();
             foreach ($record as $key=>$val){
                 $res[] = [
                     'content' => $user->username . '拨打了经销商电话',
@@ -2582,7 +2622,7 @@ class AlbumController extends Controller
                 ];
             }
         } else {
-            $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['action',8],['store_id',$data['store_id']]])->get();
+            $record = AlbumWatchRecord::where([['open_id',$data['open_id']],['agent_id',$user_agent->id],['action',8],['store_id',$data['store_id']],['updated_at','>=',$start],['updated_at','<=',$end]])->get();
             foreach ($record as $key=>$val){
                 $goods = AlbumProductModel::where([['store_id',$data['store_id']],['id',$val['detail']]])->first();
                 $style = AlbumProductStyleModel::where([['store_id',$data['store_id']],['id',$goods->style]])->first();
@@ -2647,20 +2687,21 @@ 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);
-                $check = AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
-                if(empty($check)){
-                    $save['agent_id'] = $user_agent->id;
-                    $save['store_id'] = $data['store_id'];
-                    $save['product_id'] = $val['id'];
-                    AlbumProductPriceModel::create($save);
-                }else{
-                    AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($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);
+            $check = AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
+            if(empty($check)){
+                $save['agent_id'] = $user_agent->id;
+                $save['store_id'] = $data['store_id'];
+                $save['product_id'] = $val['id'];
+                AlbumProductPriceModel::create($save);
+            }else{
+                AlbumProductPriceModel::where([['agent_id',$user_agent->id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
             }
-
+        }
+        $user_agent->set_price_point = $data['point'];
+        $user_agent->save();
         return $this->api([],0,'success');
     }
 }

+ 1 - 1
app/Http/Controllers/Api/V1/AlbumPosterController.php

xqd
@@ -145,7 +145,7 @@ class AlbumPosterController extends Controller
             'response_type' => 'array',
         ];
         $app = Factory::miniProgram($config);
-        $response = $app->app_code->get('pages/index/loading?agentid=' . $agent_id, [
+        $response = $app->app_code->get('pages/index/index?agentid=' . $agent_id, [
             'width' => 140,
         ]);
 

+ 1 - 0
app/Models/AlbumAgentModel.php

xqd
@@ -44,6 +44,7 @@ class AlbumAgentModel extends BaseModel
         'store_id',
         'is_show_ma_price',
         'user_id',
+        'ste_price_point',
         'phone',
         'address',
         'lat',

+ 33 - 0
database/migrations/2019_04_03_101526_add_column_set_price_point_to_album_agent.php

xqd
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddColumnSetPricePointToAlbumAgent extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('album_agent', function (Blueprint $table) {
+            //
+            $table->unsignedInteger('set_price_point')->nullable()->default(0);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('album_agent', function (Blueprint $table) {
+            //
+        });
+    }
+}