dyjh 6 jaren geleden
bovenliggende
commit
da6a835a49

+ 9 - 8
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd xqd xqd xqd
@@ -558,8 +558,8 @@ class AlbumController extends Controller
             if(!empty($price)){
                 $goods->price = $price->price;
                 $goods->mobile = $price->mobile;
-                $address = AlbumAgentModel::where('id',$userAuth->up_agent_id)->first();
-                $goods->address = $address;
+                $address = AlbumAgentModel::where('id',$agent_id)->first();
+                $goods->address = $address->address;
             }else{
                 $goods->price = '';
                 $goods->mobile = '';
@@ -1046,7 +1046,6 @@ class AlbumController extends Controller
      * @apiPermission none
      * @apiVersion 0.1.0
      * @apiParam {int}    [goods_id]  商品id
-     * @apiParam {int}    [agent_id]  经销商id 模拟值为10
      * @apiParam {int}    [store_id]  商户id 模拟值为0
      * @apiParam {int}    [type]  修改类型 0 电话 1 价格
      * @apiParam {string}    [mobile]  电话号码
@@ -1077,6 +1076,8 @@ class AlbumController extends Controller
     public function albumSetPrice(Request $request)
     {
         $userAuth = Auth('api')->user();
+        $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
+        $agent_id = $user_agent['id'];
         $data = $request->all();
         //print_r($data);
         $save = array();
@@ -1085,14 +1086,14 @@ class AlbumController extends Controller
             $save['mobile'] = $data['mobile'];
             $product = AlbumProductModel::where('store_id',$data['store_id'])->get();
             foreach($product as $key=>$val){
-                $check = AlbumProductPriceModel::where([['agent_id',$data['agent_id']],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
+                $check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->first();
                 if(empty($check)){
                     $save['agent_id'] = $data['agent_id'];
                     $save['store_id'] = $data['store_id'];
                     $save['product_id'] = $val['id'];
                     $res = AlbumProductPriceModel::create($save);
                 }else{
-                    $res = AlbumProductPriceModel::where([['agent_id',$data['agent_id']],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
+                    $res = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$val['id']]])->update($save);
                 }
                 if(!$res){
                     $return['msg'] = 'error';
@@ -1102,7 +1103,7 @@ class AlbumController extends Controller
             $update_agent['phone'] = $data['mobile'];
             $update_agent['address'] = $data['address'];
 
-            $update_res = AlbumAgentModel::where('id',$data['agent_id'])->update($update_agent);
+            $update_res = AlbumAgentModel::where('id',$agent_id)->update($update_agent);
             if(!$update_res){
                 $return['msg'] = 'error';
                 return $this->api($return);
@@ -1112,14 +1113,14 @@ class AlbumController extends Controller
             $return['msg'] = 'success';
         } elseif ($data['type'] == 1){
             $save['price'] = $data['price'];
-            $check = AlbumProductPriceModel::where([['agent_id',$data['agent_id']],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
+            $check = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->first();
             if(empty($check)){
                 $save['agent_id'] = $data['agent_id'];
                 $save['store_id'] = $data['store_id'];
                 $save['product_id'] = $data['goods_id'];
                 $res = AlbumProductPriceModel::create($save);
             }else{
-                $res = AlbumProductPriceModel::where([['agent_id',$data['agent_id']],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->update($save);
+                $res = AlbumProductPriceModel::where([['agent_id',$agent_id],['store_id',$data['store_id']],['product_id',$data['goods_id']]])->update($save);
             }
             if($res){
                 $return['msg'] = 'success';

+ 0 - 7
public/apidoc/api_data.js

xqd
@@ -433,13 +433,6 @@ define({ "api": [
             "field": "goods_id",
             "description": "<p>商品id</p>"
           },
-          {
-            "group": "Parameter",
-            "type": "int",
-            "optional": true,
-            "field": "agent_id",
-            "description": "<p>经销商id 模拟值为10</p>"
-          },
           {
             "group": "Parameter",
             "type": "int",

+ 0 - 7
public/apidoc/api_data.json

xqd
@@ -433,13 +433,6 @@
             "field": "goods_id",
             "description": "<p>商品id</p>"
           },
-          {
-            "group": "Parameter",
-            "type": "int",
-            "optional": true,
-            "field": "agent_id",
-            "description": "<p>经销商id 模拟值为10</p>"
-          },
           {
             "group": "Parameter",
             "type": "int",

+ 1 - 1
public/apidoc/api_project.js

xqd
@@ -9,7 +9,7 @@ define({
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2018-11-13T07:04:21.367Z",
+    "time": "2018-11-14T02:49:23.700Z",
     "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-13T07:04:21.367Z",
+    "time": "2018-11-14T02:49:23.700Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }