dyjh 6 سال پیش
والد
کامیت
3cd4d01a8d

+ 184 - 92
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd 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'));
     }
 
 
@@ -154,56 +162,56 @@ class AlbumController extends Controller
             $check = AlbumUserModel::where('wechat_union_id', $decryptedData['unionId'])->first();
         }
 
-            if(!$check){
-                $add['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
-                $add['open_id'] = $res['openid'];
-                $add['wechat_union_id'] = isset($decryptedData['unionId'])?$decryptedData['unionId']:'';
-                $add['avatar'] = $datas['avatar'];
-                $add['is_agent'] = 0;
-                $add['model'] = 1;
-                $add['store_id'] = $datas['store_id'];
-                $res = AlbumUserModel::create($add);
-              //  dd($res);
-                if($res){
-                    $check = AlbumUserModel::where([['wechat_union_id',$res->wechat_union_id],['store_id',$datas['store_id']]])->first();
-                    $user = [
-                        'user_id'=>$check['id'],
-                        //'avatar'=>$check['avatar'],
-                       // 'username'=>$check['username'],
-                        'phone'=>$check->phone,
-                        'is_agent'=>0,
-                        'agent_id'=>'',
-                    ];
-                }else{
-                    $user=[
-                        'error'=>1
-                    ];
-                }
-            } else {
-                //print_r($check);die;
-                $save['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
-                $save['avatar'] = $datas['avatar'];
-               // $save['open_id'] = $res['openid'];
-                $save['model'] = 1;
-                AlbumUserModel::where('open_id',$res['openid'])->update($save);
-                //echo 111;
-                    //print_r($check);die;
-                if($check->is_dealer == 1){
-                    $user_agent = AlbumAgentModel::where([['user_id',$check->id],['status',1]])->first();
-                    $agent_id = $user_agent['id'];
-                } else {
-                    $agent_id = '';
-                }
+        if(!$check){
+            $add['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
+            $add['open_id'] = $res['openid'];
+            $add['wechat_union_id'] = isset($decryptedData['unionId'])?$decryptedData['unionId']:'';
+            $add['avatar'] = $datas['avatar'];
+            $add['is_agent'] = 0;
+            $add['model'] = 1;
+            $add['store_id'] = $datas['store_id'];
+            $res = AlbumUserModel::create($add);
+            //  dd($res);
+            if($res){
+                $check = AlbumUserModel::where([['wechat_union_id',$res->wechat_union_id],['store_id',$datas['store_id']]])->first();
                 $user = [
-
-                    'user_id'=>$check->id,
+                    'user_id'=>$check['id'],
+                    //'avatar'=>$check['avatar'],
+                    // 'username'=>$check['username'],
                     'phone'=>$check->phone,
-                    'is_agent'=>$check->is_dealer,
-                    'agent_id'=>$agent_id,
-
+                    'is_agent'=>0,
+                    'agent_id'=>'',
+                ];
+            }else{
+                $user=[
+                    'error'=>1
                 ];
             }
-       // echo 111;die;
+        } else {
+            //print_r($check);die;
+            $save['username'] = preg_replace('/[\xf0-\xf7].{3}/', '', $datas['nickName']);
+            $save['avatar'] = $datas['avatar'];
+            // $save['open_id'] = $res['openid'];
+            $save['model'] = 1;
+            AlbumUserModel::where('open_id',$res['openid'])->update($save);
+            //echo 111;
+            //print_r($check);die;
+            if($check->is_dealer == 1){
+                $user_agent = AlbumAgentModel::where([['user_id',$check->id],['status',1]])->first();
+                $agent_id = $user_agent['id'];
+            } else {
+                $agent_id = '';
+            }
+            $user = [
+
+                'user_id'=>$check->id,
+                'phone'=>$check->phone,
+                'is_agent'=>$check->is_dealer,
+                'agent_id'=>$agent_id,
+
+            ];
+        }
+        // echo 111;die;
         if (Auth::loginUsingId($check->id)) {
             $userAuth = Auth::user();
             if($check->is_dealer ==0){
@@ -216,8 +224,8 @@ class AlbumController extends Controller
                 $add_record['store_id'] = $datas['store_id'];
                 $add_record['detail'] = null;
                 AlbumWatchRecord::create($add_record);
-             //   dd($add_record);
-               // print_r($add_record['agent_id']);die;
+                //   dd($add_record);
+                // print_r($add_record['agent_id']);die;
                 $user_agent = AlbumAgentModel::where('id',$add_record['agent_id'])->first();
                 //dd($user_agent);
                 if($user_agent){
@@ -385,14 +393,23 @@ class AlbumController extends Controller
         }
 
         if ($userAuth->up_agent_id != 0) {
-            $agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
-            $set_show_price = $agent->is_show_ma_price;
+
+
+            $agent_in = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
+            $set_show_price = $agent_in->is_show_ma_price;
+
         } else {
             $set_show_price = 0;
         }
 
 
-        $goods = $goods->select('id','cover_pic','thumb','name','style','hot_cake','news','price_default')->orderByDesc('sort')->paginate(9);
+        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){
             if($userAuth->is_dealer != 1){
@@ -478,7 +495,7 @@ class AlbumController extends Controller
      */
     public function albumGoodsDetail(Request $request)
     {
-      //  $userAuth = AlbumXyxUserModel::find(1);
+        //  $userAuth = AlbumXyxUserModel::find(1);
         $userAuth = Auth('api')->user();
         if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
         $validator = Validator::make($request->all(), [
@@ -766,7 +783,7 @@ class AlbumController extends Controller
             }
 
             $user = AlbumUserModel::where([['open_id',$val->open_id],['store_id',$val->store_id]])->select(['username','avatar','phone'])->first();
-           // dd(111);
+            // dd(111);
             $data_res[] = [
                 'time'=>$val->created_at,
                 'action'=>$action,
@@ -966,23 +983,37 @@ 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');
+        if (!$end) {
+            $end = time();
+        }
+        if (!$start) {
+            $start = 0;
+        }
+        $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;
         }
@@ -1064,7 +1095,7 @@ class AlbumController extends Controller
         $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());
-       // if($userAuth->up_agent_id==0) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未选择经销商!', $validator->messages());
+        // if($userAuth->up_agent_id==0) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未选择经销商!', $validator->messages());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
         $count_user = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id],['updated_at','>=',$start],['updated_at','<=',$end]])->orderBy('id','DESC')->groupBy('open_id')->get();
         $checkAllstart = mktime(0,0,0,date('m'),date('d'),date('Y'));
@@ -1518,22 +1549,22 @@ class AlbumController extends Controller
         $save = array();
         $return_data = array();
 
-            $save['price'] = $data['price'];
-            $check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
-            if(empty($check)){
-                $save['agent_id'] = $agent_id;
-                $save['store_id'] = $data['store_id'];
-                $save['product_id'] = $data['goods_id'];
-                $res = AlbumProductPriceModel::create($save);
-            }else{
-                $res = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->update($save);
-            }
-            if($res){
-                $return['msg'] = 'success';
-                $return_data['price'] = $data['price'];
-            } else {
-                $return['msg'] = 'error';
-            }
+        $save['price'] = $data['price'];
+        $check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
+        if(empty($check)){
+            $save['agent_id'] = $agent_id;
+            $save['store_id'] = $data['store_id'];
+            $save['product_id'] = $data['goods_id'];
+            $res = AlbumProductPriceModel::create($save);
+        }else{
+            $res = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->update($save);
+        }
+        if($res){
+            $return['msg'] = 'success';
+            $return_data['price'] = $data['price'];
+        } else {
+            $return['msg'] = 'error';
+        }
 
         $return['data'] = $return_data;
         return $this->api($return);
@@ -1686,7 +1717,7 @@ class AlbumController extends Controller
             $add_record['action'] = $data['type'];
             $add_record['store_id'] = $data['store_id'];
             $add_record['detail'] = json_encode($select_info);
-           // dd($add_record);
+            // dd($add_record);
             $res = AlbumWatchRecord::create($add_record);
             $user_agent = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
             $agent = AlbumUserModel::where('id',$user_agent->user_id)->first();
@@ -1762,7 +1793,7 @@ class AlbumController extends Controller
         $weChatApp = AlbumManufacturerModel::where('store_id', $storeid)->first();//\Log::info('2221');
 
         $res_account = $this->accountMesage($g_open_id,$weChatApp,$name,$content);
-     //   \Log::info($res_account);
+        //   \Log::info($res_account);
         if($user && $formId && (!$weChatApp->G_app_id || !$weChatApp->G_app_secret)){
             $config_app = [
                 'app_id' => $weChatApp->app_id,
@@ -1781,7 +1812,7 @@ class AlbumController extends Controller
                     'keyword3' => date('Y-m-d H:i'),
                 ],
             ]);
-          //  dd($res);
+            //  dd($res);
             if($res){
                 $formId->delete();
             }
@@ -1802,7 +1833,7 @@ class AlbumController extends Controller
      */
     private function accountMesage($g_open_id,$weChatApp,$name,$content)
     {
-       // Cache::flush();
+        // Cache::flush();
         $value = Cache::get($g_open_id);
         \Log::info($value);\Log::info('2225');
         if ($g_open_id && (!$value || ($value + 60) <= time())) {
@@ -2155,7 +2186,7 @@ class AlbumController extends Controller
         $open_id = $request->input('open_id');
         $key = $request->input('key');
         $value = $request->input('value');
-        if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
+        if($userAuth->is_dealer != 1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
         if ($key == 'phone') {
             $user = AlbumUserModel::where([['store_id',$store_id],['open_id',$open_id]])->first();
@@ -2165,10 +2196,10 @@ class AlbumController extends Controller
         }
         $customer = CustomerDetailsModel::where([['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->first(['purpose_level','comment','tips','address']);
         if($customer){
-           /// $customer->$key = $value;
+            /// $customer->$key = $value;
             $update[$key] = $value;
             CustomerDetailsModel::where([['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->update($update);
-          //  $customer->save();
+            //  $customer->save();
         }else{
             $add['agent_id'] = $user_agent->id;
             $add['open_id'] = $open_id;
@@ -2218,18 +2249,32 @@ 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');
+        if (!$end) {
+            $end = time();
+        }
+        if (!$start) {
+            $start = 0;
+        }
+        $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);
@@ -2285,19 +2330,33 @@ 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');
+        if (!$end) {
+            $end = time();
+        }
+        if (!$start) {
+            $start = 0;
+        }
+        $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);
@@ -2377,7 +2436,7 @@ class AlbumController extends Controller
             }
 
             $res[$key]['name'] = $goods->name;
-           // dd($res);
+            // dd($res);
             $res[$key]['count'] = AlbumFavoriteModel::whereIn('user_id',$users)->where([['store_id',$store_id],['product_id',$val['product_id']]])->count();
         }
         return $this->api($res,0,'success');
@@ -2543,21 +2602,35 @@ 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');
+        if (!$end) {
+            $end = time();
+        }
+        if (!$start) {
+            $start = 0;
+        }
+        $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();
@@ -2570,7 +2643,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 . '拨打了经销商电话',
@@ -2578,7 +2651,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();
@@ -2642,6 +2715,7 @@ class AlbumController extends Controller
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
         $user_agent->is_show_ma_price = $data['is_show_ma_price'];
         $user_agent->save();
+<<<<<<< HEAD
         if ($data['point'] != 0) {
             $product = AlbumProductModel::where('store_id',$data['store_id'])->all('id','price_default');
             foreach ($product as $key=>$val) {
@@ -2657,6 +2731,24 @@ class AlbumController extends Controller
                 }
             }
         }
+=======
+
+        $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();
+>>>>>>> master
         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 - 1
app/Http/Controllers/Api/V1/Controller.php

xqd
@@ -22,7 +22,7 @@ class Controller extends BaseController
         $this->middleware('auth:api', [
             'except' => [
                 'upload', 'getCode', 'reset', 'login', 'get', 'register', 'alipayNotify', 'wechatpayNotify', 'get', 'area', 'get_province', 'get_city', 'get_county', 'albumStyle', 'test', 'index', 'companyInfo', 'shop2', 'cardIndex', 'cardUserInfo', 'cardUserProgress', 'cardUserHonor', 'cardUserProject', 'CardUserTrend', 'projectDetail', 'trendDetail', 'albumSetting', 'albumXyxLogin', 'albumCat', 'albumchecklogin', 'albumGoods', 'albumGoodsDetail', 'albumSetPrice', 'albumXcxLogin', 'albumContentList', 'albumSearchGoods','albumContentDetail','albumFavoriteList','albumAddFavorite','albumFavoriteDel','getAttr','getOrder','getProgress','getReviewCount', 'furnitureNewsDetail','furnitureSetting','furnitureXcxLogin','furnitureGoodsList','serviceLogin','getFurnitureAds','getPhoneNumber','getQrcode','orderCount','searchList','printOrder','saveFormId','furnitureNewsList','getMoreComments','addToLike','albumSavePhone','albumGetStatistical','test',
-                'albumGetWatchRecord','albumSetWatch','albumGetCartOfWatch','albumSaveFormId','albumAddAgent','albumGetBanner','albumGetDataGoods','newgoods_list','newgoods_index','albumGetAgentAdress','albumSetCustomer','albumGetCustomer','albumGetDataCat','albumCustomerGoods','albumCustomerGoodsDetail','albumGetDataCatSingle','albumGetCountOfFavorite','albumGetUserInfo','albumStatistical','posterInfo','createPoster','posterDel'
+                'albumGetWatchRecord','albumSetWatch','albumGetCartOfWatch','albumSaveFormId','albumAddAgent','albumGetBanner','albumGetDataGoods','newgoods_list','newgoods_index','albumGetAgentAdress','albumSetCustomer','albumGetCustomer','albumGetDataCat','albumCustomerGoods','albumCustomerGoodsDetail','albumGetDataCatSingle','albumGetCountOfFavorite','albumGetUserInfo','albumStatistical','posterInfo','createPoster','posterDel','albumAgentPriceSet'
             ]
         ]);
 

+ 8 - 1
app/Http/Controllers/Api/V1/FurnitureController.php

xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers\Api\V1;
 
+use App\Models\AlbumAgentModel;
 use App\Models\AlbumBannerModel;
 use App\Models\AlbumCommentsModel;
 use App\Models\AlbumManufacturerModel;
@@ -1115,8 +1116,14 @@ class FurnitureController extends Controller
         $getFocus = $conf->getFocus;
         if (Auth::loginUsingId($userinfo->id)) {
             $user = Auth::user();
+            $agent = AlbumAgentModel::where('user_id', $user->id)->first();
+            if ($agent) {
+                $real_name = $agent->realname;
+            } else {
+                $real_name = '暂无';
+            }
             $token = $user->createToken($user->id . '-' . $user->openid)->accessToken;
-            return $this->api(compact('token', 'user', 'session_key','getFocus'));
+            return $this->api(compact('token', 'user', 'session_key','getFocus' ,'real_name'));
         } else {
 
             return $this->error(ErrorCode::INCORRECT_USER_OR_PASS);

+ 17 - 0
app/Models/AlbumAgentModel.php

xqd xqd
@@ -41,6 +41,7 @@ class AlbumAgentModel extends BaseModel
      * @var string
      */
     protected $fillable = [
+<<<<<<< HEAD
                            'store_id',
                            'is_show_ma_price',
                            'user_id',
@@ -54,5 +55,21 @@ class AlbumAgentModel extends BaseModel
                            'get_count',
                            'share_times'
                           ];
+=======
+        'store_id',
+        'is_show_ma_price',
+        'user_id',
+        'ste_price_point',
+        'phone',
+        'address',
+        'lat',
+        'lon',
+        'name',
+        'status',
+        'realname',
+        'get_count',
+        'share_times'
+    ];
+>>>>>>> master
 
 }

+ 2 - 0
app/Models/AlbumProductModel.php

xqd
@@ -38,6 +38,8 @@ class AlbumProductModel extends BaseModel
                            'store_id',
                            'name',
                            'price_default',
+                           'ma_price',
+                           'ma_price_comment',
                            'detail_pic',
                            'cat_id',
                            'specifications_img',

+ 34 - 0
database/migrations/2019_03_29_174712_add_column_ma_price_to_album_product.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddColumnMaPriceToAlbumProduct extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('album_product', function (Blueprint $table) {
+            //
+            $table->decimal('ma_price', 8, 2)->nullable()->default(0)->comment('出厂价');
+            $table->string('ma_price_comment', 255)->nullable()->default(null)->comment('出厂价备注');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('album_product', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 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) {
+            //
+        });
+    }
+}

+ 61 - 0
public/apidoc/api_data.js

xqd
@@ -858,6 +858,67 @@ define({ "api": [
     "groupTitle": "Album",
     "name": "GetApiAlbumStyle"
   },
+  {
+    "type": "post",
+    "url": "/api/album/agent_price_set",
+    "title": "厂家价格设置(agent_price_set)",
+    "description": "<p>厂家价格设置(agent_price_set)</p>",
+    "group": "Album",
+    "permission": [
+      {
+        "name": "AUTH"
+      }
+    ],
+    "version": "0.1.0",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "store_id",
+            "description": "<p>商户id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "point",
+            "description": "<p>价格设置比例 为0不设置</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "is_show_ma_price",
+            "description": "<p>厂家价格是否可见 0 不可见 1 可见</p>"
+          }
+        ]
+      }
+    },
+    "success": {
+      "examples": [
+        {
+          "title": "Success-Response:",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"success\",\n    \"data\":[]\n}",
+          "type": "json"
+        }
+      ]
+    },
+    "error": {
+      "examples": [
+        {
+          "title": "Error-Response:",
+          "content": "HTTP/1.1 400 Bad Request\n{\n    \"state\": false,\n    \"code\": 1000,\n    \"message\": \"传入参数不正确\",\n    \"data\": null or []\n}\n可能出现的错误代码:\n   1000    CLIENT_WRONG_PARAMS             传入参数不正确",
+          "type": "json"
+        }
+      ]
+    },
+    "filename": "app/Http/Controllers/Api/V1/AlbumController.php",
+    "groupTitle": "Album",
+    "name": "PostApiAlbumAgent_price_set"
+  },
   {
     "type": "post",
     "url": "/api/album/customer-goods-detail",

+ 61 - 0
public/apidoc/api_data.json

xqd
@@ -858,6 +858,67 @@
     "groupTitle": "Album",
     "name": "GetApiAlbumStyle"
   },
+  {
+    "type": "post",
+    "url": "/api/album/agent_price_set",
+    "title": "厂家价格设置(agent_price_set)",
+    "description": "<p>厂家价格设置(agent_price_set)</p>",
+    "group": "Album",
+    "permission": [
+      {
+        "name": "AUTH"
+      }
+    ],
+    "version": "0.1.0",
+    "parameter": {
+      "fields": {
+        "Parameter": [
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "store_id",
+            "description": "<p>商户id</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "point",
+            "description": "<p>价格设置比例 为0不设置</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "int",
+            "optional": true,
+            "field": "is_show_ma_price",
+            "description": "<p>厂家价格是否可见 0 不可见 1 可见</p>"
+          }
+        ]
+      }
+    },
+    "success": {
+      "examples": [
+        {
+          "title": "Success-Response:",
+          "content": "HTTP/1.1 200 OK\n{\n    \"status\": true,\n    \"status_code\": 0,\n    \"message\": \"success\",\n    \"data\":[]\n}",
+          "type": "json"
+        }
+      ]
+    },
+    "error": {
+      "examples": [
+        {
+          "title": "Error-Response:",
+          "content": "HTTP/1.1 400 Bad Request\n{\n    \"state\": false,\n    \"code\": 1000,\n    \"message\": \"传入参数不正确\",\n    \"data\": null or []\n}\n可能出现的错误代码:\n   1000    CLIENT_WRONG_PARAMS             传入参数不正确",
+          "type": "json"
+        }
+      ]
+    },
+    "filename": "app/Http/Controllers/Api/V1/AlbumController.php",
+    "groupTitle": "Album",
+    "name": "PostApiAlbumAgent_price_set"
+  },
   {
     "type": "post",
     "url": "/api/album/customer-goods-detail",

+ 1 - 1
public/apidoc/api_project.js

xqd
@@ -9,7 +9,7 @@ define({
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2019-03-07T02:27:39.345Z",
+    "time": "2019-03-28T09:03:36.904Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }

+ 1 - 1
public/apidoc/api_project.json

xqd
@@ -9,7 +9,7 @@
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2019-03-07T02:27:39.345Z",
+    "time": "2019-03-28T09:03:36.904Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }

+ 16 - 0
resources/views/admin/album/product/edit.blade.php

xqd
@@ -68,6 +68,22 @@
                                     </div>
                                 </div>
                                 <div class="form-group">
+
+                                    <label class="control-label col-sm-3">出厂价</label>
+
+                                    <div class="col-sm-9">
+                                        <input id="data_ma_price" name="data[ma_price]" type="number" class="form-control" value="{{ $data['ma_price'] or ''}}" required="" aria-required="true"  placeholder="">
+                                    </div>
+                                </div>
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">出厂价备注</label>
+
+                                    <div class="col-sm-9">
+                                        <input id="data_ma_price_comment" name="data[ma_price_comment]" class="form-control" value="{{ $data['ma_price_comment'] or ''}}"  placeholder="">
+                                    </div>
+                                </div>
+                                <div class="form-group">
                                     
                  <label class="control-label col-sm-3">尺寸图片(1920*1080)</label>
                     <div class="col-sm-9">

+ 5 - 0
routes/api.php

xqd
@@ -226,6 +226,11 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'album.checklogin',
         'uses' => 'AlbumController@albumchecklogin',
     ]);
+    $api->post('album/agent_price_set', [
+        'as' => 'album.AgentPriceSet',
+        'uses' => 'AlbumController@albumAgentPriceSet',
+    ]);
+
     $api->get('album/get-banner', [
         'as' => 'album.GetBanner',
         'uses' => 'AlbumController@albumGetBanner',