dyjh 6 lat temu
rodzic
commit
4cd4c2d808

+ 75 - 0
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd
@@ -507,6 +507,7 @@ class AlbumController extends Controller
      *          "price": "",
      *          "mobile": "",
      *          "address": "",
+     *          "realname": "",
      *          "is_favorite": 1,
      *          "favorite_id": 4
      *      }
@@ -586,6 +587,7 @@ class AlbumController extends Controller
                 $goods->mobile = $price->mobile;
                 $address = AlbumAgentModel::where('id',$agent_id)->first();
                 $goods->address = $address->address;
+                $goods->realname = $address->realname;
             }else{
                 $goods->price = '';
                 $goods->mobile = '';
@@ -1561,4 +1563,77 @@ class AlbumController extends Controller
         }
 
     }
+
+    /**
+     * @api {get} /api/album/add_agent 申请经销商(add_agent)
+     * @apiDescription 申请经销商(add_agent)
+     * @apiGroup Album
+     * @apiPermission none
+     * @apiVersion 0.1.0
+     * @apiParam {int}    [store_id]  商户id
+     * @apiParam {int}    [realname]  姓名
+     * @apiParam {int}    [address]  地址
+     * @apiParam {int}    [phone]  电话
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "status": true,
+     *     "status_code": 0,
+     *     "message": "",
+     *     "data": []//返回信息
+     * }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     * 可能出现的错误代码:
+     *    1000    CLIENT_WRONG_PARAMS             传入参数不正确
+     */
+
+    public function albumAddAgent(Request $request)
+    {
+        $userAuth = Auth('api')->user();
+        if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
+        $validator = Validator::make($request->all(), [
+            'realname' => 'required',
+            'address' => 'required',
+            'phone' => 'required',
+            'store_id' => 'required',
+        ],[
+            'address.required'=>'缺少地址参数',
+            'real_name.required'=>'缺少信息参数',
+            'phone.required'=>'缺少电话参数',
+            'store_id.required'=>'缺少商户参数',
+        ]);
+
+        if ($validator->fails()) {
+            return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
+        }
+        $data = $request->input();
+        $agent_check = AlbumAgentModel::where([['store_id',$data['store_id']],['user_id',$userAuth->id]])->first();
+        if($agent_check){
+            if($agent_check->status==0) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户已提交申请!');
+            return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户已是经销商!');
+        }
+        $data['status'] = 0;
+        $data['user_id'] = $userAuth->id;
+        $data['name'] = $userAuth->username;
+        $res = AlbumAgentModel::create($data);
+        if($res){
+            $d = [
+                'code' =>0,
+                'msg' =>'success',
+            ];
+        }else{
+            $d = [
+                'code' =>1,
+                'msg' =>'error',
+            ];
+        }
+        return $this->api($d);
+    }
 }

+ 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',
-                'albumGetWatchRecord','albumSetWatch','albumGetCartOfWatch','albumSaveFormId'
+                'albumGetWatchRecord','albumSetWatch','albumGetCartOfWatch','albumSaveFormId','albumAddAgent'
             ]
         ]);
 

+ 2 - 0
app/Models/AlbumAgentModel.php

xqd
@@ -48,6 +48,8 @@ class AlbumAgentModel extends BaseModel
                            'lat',
                            'lon',
                            'name',
+                           'status',
+                           'realname',
                           ];
 
 }

+ 34 - 0
database/migrations/2018_11_23_150146_add_column_to_album_agent.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddColumnToAlbumAgent extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('album_agent', function (Blueprint $table) {
+            //
+            $table->unsignedInteger('status')->define(0)->comment('是否通过审核  0 否 1 是');
+            $table->string('realname',100)->nullable()->comment('真实姓名');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('album_agent', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 8 - 3
routes/api.php

xqd
@@ -245,9 +245,14 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'uses' => 'AlbumController@albumSavePhone',
     ]);
 
-    $api->post('album/get-watch-recored', [
-        'as' => 'album.GetWatchRecord',
-        'uses' => 'AlbumController@albumGetWatchRecord',
+    $api->post('album/set-phone', [
+        'as' => 'album.savePhone',
+        'uses' => 'AlbumController@albumSavePhone',
+    ]);
+
+    $api->post('album/add_agent', [
+        'as' => 'album.AddAgent',
+        'uses' => 'AlbumController@albumAddAgent',
     ]);
 
     $api->post('album/get-cart-of-watch', [