dyjh hace 6 años
padre
commit
9e2677cc44

+ 11 - 39
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd xqd xqd xqd xqd
@@ -288,7 +288,9 @@ class AlbumController extends Controller
         if (Auth::loginUsingId($check->id)) {
             $userAuth = Auth::user();
             if($check->is_dealer ==0 && $request->input('agent_id')!=0){
-                $userAuth->up_agent_id = $request->input('agent_id');
+            //    if($request->input('agent_id')!=0){
+                    $userAuth->up_agent_id = $request->input('agent_id');
+               // }
                 $add_record['agent_id'] = $request->input('agent_id');
                 $add_record['open_id'] = $check->wechat_open_id;
                 $add_record['action'] = 4;
@@ -570,11 +572,14 @@ class AlbumController extends Controller
                 $address = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
                 $goods->address = $address->address;
                 $goods->realname = $address->realname;
+                $goods->avatar = $address->avatar;
             }else{
+                $ma = AlbumManufacturerModel::where('store_id',$store_id)->first();
                 $goods->price = '';
-                $goods->mobile = '';
-                $goods->address = '';
-                $goods->realname = '';
+                $goods->mobile = $ma->phone;
+                $goods->address = $ma->address;
+                $goods->realname = $ma->name;
+                $goods->avatar = $ma->avatar;
             }
             $check_favorite = AlbumFavoriteModel::where([['user_id',$userAuth->id],['store_id',$store_id],['product_id',$goods['id']]])->first();
             //dd($check_favorite);
@@ -595,8 +600,6 @@ class AlbumController extends Controller
             }else{
                 $goods->price = '';
                 $goods->mobile = '';
-                $goods->address = '';
-                $goods->realname = '';
             }
             $address = AlbumAgentModel::where('id',$agent_id)->first();
             $goods->address = $address->address;
@@ -872,6 +875,7 @@ class AlbumController extends Controller
         }
         $store_id = $request->input('store_id');
         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());
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
         $count_user = AlbumWatchRecord::where([['agent_id',$user_agent->id],['store_id',$store_id]])->groupBy('open_id')->get();
 
@@ -1262,9 +1266,6 @@ class AlbumController extends Controller
      * @apiVersion 0.1.0
      * @apiParam {int}    [goods_id]  商品id
      * @apiParam {int}    [store_id]  商户id 模拟值为0
-     * @apiParam {int}    [type]  修改类型 0 电话 1 价格
-     * @apiParam {string}    [mobile]  电话号码
-     * @apiParam {string}    [address]  地址
      * @apiParam {double}    [price]  价格
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
@@ -1297,36 +1298,7 @@ class AlbumController extends Controller
         //print_r($data);
         $save = array();
         $return_data = array();
-        if($data['type'] == 0) {
-            $save['mobile'] = $data['mobile'];
-            $product = AlbumProductModel::where('store_id',$data['store_id'])->get();
-            foreach($product as $key=>$val){
-                $check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
-                if(empty($check)){
-                    $save['agent_id'] = $agent_id;
-                    $save['store_id'] = $data['store_id'];
-                    $save['product_id'] = $val['id'];
-                    $res = AlbumProductPriceModel::create($save);
-                }else{
-                    $res = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
-                }
-                if(!$res){
-                    $return['msg'] = 'error';
-                    return $this->api($return);
-                }
-            }
-            $update_agent['phone'] = $data['mobile'];
-            $update_agent['address'] = $data['address'];
 
-            $update_res = AlbumAgentModel::where('id',$agent_id)->update($update_agent);
-            if(!$update_res){
-                $return['msg'] = 'error';
-                return $this->api($return);
-            }
-            $return_data['mobile'] = $data['mobile'];
-            $return_data['address'] = $data['address'];
-            $return['msg'] = 'success';
-        } elseif ($data['type'] == 1){
             $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)){
@@ -1343,7 +1315,7 @@ class AlbumController extends Controller
             } else {
                 $return['msg'] = 'error';
             }
-        }
+
         $return['data'] = $return_data;
         return $this->api($return);
     }

+ 0 - 21
public/apidoc/api_data.js

xqd
@@ -610,27 +610,6 @@ define({ "api": [
             "field": "store_id",
             "description": "<p>商户id 模拟值为0</p>"
           },
-          {
-            "group": "Parameter",
-            "type": "int",
-            "optional": true,
-            "field": "type",
-            "description": "<p>修改类型 0 电话 1 价格</p>"
-          },
-          {
-            "group": "Parameter",
-            "type": "string",
-            "optional": true,
-            "field": "mobile",
-            "description": "<p>电话号码</p>"
-          },
-          {
-            "group": "Parameter",
-            "type": "string",
-            "optional": true,
-            "field": "address",
-            "description": "<p>地址</p>"
-          },
           {
             "group": "Parameter",
             "type": "double",

+ 0 - 21
public/apidoc/api_data.json

xqd
@@ -610,27 +610,6 @@
             "field": "store_id",
             "description": "<p>商户id 模拟值为0</p>"
           },
-          {
-            "group": "Parameter",
-            "type": "int",
-            "optional": true,
-            "field": "type",
-            "description": "<p>修改类型 0 电话 1 价格</p>"
-          },
-          {
-            "group": "Parameter",
-            "type": "string",
-            "optional": true,
-            "field": "mobile",
-            "description": "<p>电话号码</p>"
-          },
-          {
-            "group": "Parameter",
-            "type": "string",
-            "optional": true,
-            "field": "address",
-            "description": "<p>地址</p>"
-          },
           {
             "group": "Parameter",
             "type": "double",

+ 1 - 1
public/apidoc/api_project.js

xqd
@@ -9,7 +9,7 @@ define({
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2018-11-28T08:21:13.418Z",
+    "time": "2018-12-13T09:47:11.785Z",
     "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": "2018-11-28T08:21:13.418Z",
+    "time": "2018-12-13T09:47:11.785Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }