浏览代码

新增获取商户信息接口

zhangchangchun 6 年之前
父节点
当前提交
d2b4bb4480
共有 3 个文件被更改,包括 108 次插入54 次删除
  1. 63 0
      app/Http/Controllers/V1/ShopController.php
  2. 40 0
      app/Shop.php
  3. 5 54
      routes/api.php

+ 63 - 0
app/Http/Controllers/V1/ShopController.php

@@ -0,0 +1,63 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019-05-06
+ * Time: 16:01
+ */
+
+namespace App\Http\Controllers\V1;
+
+
+use App\Shop;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
+
+class ShopController extends Controller {
+    /**
+     * @param Request $request
+     * @return array
+     * 获取商户详情
+     */
+    public function getShop(Request $request){
+        $data = $request->only('id');
+        $validator = Validator::make($data, [
+            'id' => 'required|integer',
+        ]);
+        if ($validator->fails()) {
+            return $this->jsonError($validator->errors()->first());
+        }
+        $res['data']  = Shop::where('shop_id',$data['id'])->first();
+        if($res){
+            return $this->jsonSuccess(['data'=>$res]);
+        }else{
+            return $this->jsonError('获取失败');
+        }
+    }
+    /**
+     * @param Request $request
+     * @return array
+     * 根据ids 获取商户
+     */
+    public function getShopList(Request $request){
+        $data = $request->only('ids');
+        $validator = Validator::make($data, [
+            'ids' => 'required|string',
+        ]);
+        if ($validator->fails()) {
+            return $this->jsonError($validator->errors()->first());
+        }
+        $ids = explode(",", $request['ids']);
+        $data = [];
+        foreach ($ids as $v){
+            $shop = Shop::where('shop_id',$v)->first();
+            if($shop){
+                $data[][$shop->shop_id] =$shop->shop_name;
+            }else{
+                return $this->jsonError('失败 shop_id '.$v.'未找到');
+            }
+
+        }
+        return $this->jsonSuccess($data);
+    }
+}

+ 40 - 0
app/Shop.php

@@ -0,0 +1,40 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Administrator
+ * Date: 2019-04-28
+ * Time: 15:30
+ */
+
+namespace App;
+
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class Shop extends Model
+{
+    use SoftDeletes;
+
+    protected $primaryKey = 'shop_id';
+
+    public $table = 'shop';
+    /**
+     * The attributes that are mass assignable.
+     *
+     * @var array
+     */
+    protected $fillable = ['shop_name','shop_short_name','mobile','address','province_id','province_name','city_id','city_name','contact_mobile','contact_name','shop_desc','status','logo_img','license_img','food_trans_license','other_license','proportion','verify_type','star'];
+
+    /**
+     * The attributes excluded from the model's JSON form.
+     *
+     * @var array
+     */
+    protected $hidden = [];
+    //关联账户
+    public function account()
+    {
+        return $this->hasOne('App\ShopAccount', 'shop_id', 'shop_id');
+    }
+}

+ 5 - 54
routes/api.php

@@ -16,34 +16,7 @@ $api = app('Dingo\Api\Routing\Router');
 $api->version('v1', [
 $api->version('v1', [
     'namespace' => 'App\Http\Controllers\V1',
     'namespace' => 'App\Http\Controllers\V1',
 ], function ($api) {
 ], function ($api) {
-    //登录
-    $api->post('login', 'AuthController@authenticate');
-    //测试签名
-    $api->post('sign', 'IndexController@index4');
-    //测试支付宝 支付
-    $api->post('alipay', 'AlipayController@index');
-    //回调
-    $api->post('return', 'AlipayController@return');
-    //异步回调
-    $api->post('notify', 'AlipayController@notify');
-    //测试微信支付
-    $api->post('weixin', 'WeixinPayController@index');
-    //微信回调
-    $api->post('wxin_notify', 'WeixinPayController@notify');
-    //测试短信验证码
-    $api->post('send_sms', 'SendSmsController@index');
-    //手机号码注册
-    $api->post('mobileRegister', 'AuthController@mobileRegister');
-    //微信注册
-    $api->post('weixinRegister', 'AuthController@weixinRegister');
-    //手机号码,密码登录
-    $api->post('mobileLogin', 'AuthController@mobileLogin');
-    //手机号码短信登陆
-    $api->post('mobileSmsLogin', 'AuthController@mobileSmsLogin');
-    //微信登录
-    $api->post('weixinLogin', 'AuthController@weixinLogin');
-    //测试reids
-    $api->post('loginCount', 'AuthController@loginCount');
+
 
 
 
 
     $api->group(['middleware' => 'auth:api'], function ($api) {
     $api->group(['middleware' => 'auth:api'], function ($api) {
@@ -52,32 +25,10 @@ $api->version('v1', [
 
 
     //登录+验签
     //登录+验签
     $api->group(['middleware' => ['chxq_jwt_auth','chxq_sign']], function ($api) {
     $api->group(['middleware' => ['chxq_jwt_auth','chxq_sign']], function ($api) {
-        //登出
-        $api->post('logout', 'AuthController@logout');
-        //刷新身份令牌
-        $api->post('refresh', 'AuthController@refresh');
-        //绑定微信
-        $api->post('bindWeixin', 'AuthController@bindWeixin');
-        //绑定手机
-        $api->post('bindMobile', 'AuthController@bindMobile');
-        //设置密码
-        $api->post('setPassword', 'AuthController@setPassword');
-        //修改密码
-        $api->post('updatePassword', 'AuthController@updatePassword');
-        //解绑温馨
-        $api->post('unbindWeixin', 'AuthController@unbindWeixin');
-        //检查微信号是否绑定
-        $api->post('isBindWeixin', 'AuthController@isBindWeixin');
-        //新增快递地址
-        $api->post('addExpressAddress', 'MemberExpressAddressController@addExpressAddress');
-        //新增自提地址
-        $api->post('addSelfAddress', 'MemberExpressAddressController@addSelfAddress');
-        //用户自提地址
-        $api->post('selfAddressList', 'MemberExpressAddressController@selfAddressList');
-        //删除地址
-        $api->post('addressDelete', 'MemberExpressAddressController@delete');
-        //设置默认地址
-        $api->post('addressIsDefault', 'MemberExpressAddressController@isDefault');
+        //获取商户列表
+        $api->post('getShopList', 'ShopController@getShopList');
+        //获取商户详情
+        $api->post('view', 'ShopController@getShop');
     });
     });
     //仅验签
     //仅验签
     $api->group(['middleware' => 'chxq_sign'], function ($api) {
     $api->group(['middleware' => 'chxq_sign'], function ($api) {