Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

林海涛 2 lat temu
rodzic
commit
bfe98e7d6c

+ 21 - 0
app/api/controller/LoginController.php

@@ -16,6 +16,7 @@ namespace app\api\controller;
 
 use app\common\enum\LoginEnum;
 use app\common\enum\user\UserTerminalEnum;
+use app\common\model\user\User;
 use app\api\validate\{LoginAccountValidate, RegisterValidate, WebScanLoginValidate, WechatLoginValidate};
 use app\api\logic\LoginLogic;
 
@@ -40,6 +41,15 @@ class LoginController extends BaseApiController
     {
         $params = (new RegisterValidate())->post()->goCheck('register');
         $result = LoginLogic::register($params);
+        //验证是否传微信小程序的CODE,如果传入进行绑定
+        if(!empty($params['wx_code']) and $params['channel']==1){
+            $params['code'] = $params['wx_code'];
+            $params['user_id'] = User::where('sn',$result['sn'])->value('id');
+            $wx_result = LoginLogic::mnpAuthLogin($params);
+            if ($wx_result === false) {
+                return $this->fail(LoginLogic::getError());
+            }
+        }
         if (true === $result) {
             return $this->success('注册成功', [], 1, 1);
         }
@@ -57,6 +67,17 @@ class LoginController extends BaseApiController
     {
         $params = (new LoginAccountValidate())->post()->goCheck();
         $result = LoginLogic::login($params);
+
+        //验证是否传微信小程序的CODE,如果传入进行绑定
+        if(!empty($params['wx_code']) and $params['terminal']==1){
+            $params['code'] = $params['wx_code'];
+            $params['user_id'] = User::where('sn',$result['sn'])->value('id');
+            $wx_result = LoginLogic::mnpAuthLogin($params);
+            if ($wx_result === false) {
+                return $this->fail(LoginLogic::getError());
+            }
+        }
+
         if (false === $result) {
             return $this->fail(LoginLogic::getError());
         }

+ 5 - 0
app/api/lists/GoodsLists.php

@@ -73,6 +73,11 @@ class GoodsLists  extends BaseApiDataLists implements ListsSearchInterface
         $lists = Goods::order(['id' => 'desc'])
             ->where($this->searchWhere)
             ->where($this->queryWhere())
+            ->visible([
+                'id','goods_image','goods_video','goods_category_ids',
+                'goods_number','good_unit','base_service_fee',
+                'service_total','service_fee','service_image','fee_schedule','warranty_period'
+            ])
             ->limit($this->limitOffset, $this->limitLength)
             ->select()
             ->toArray();

+ 13 - 1
app/api/logic/LoginLogic.php

@@ -323,8 +323,20 @@ class LoginLogic extends BaseLogic
     {
         //先检查openid是否有记录
         $isAuth = UserAuth::where('openid', '=', $response['openid'])->findOrEmpty();
+
         if (!$isAuth->isEmpty()) {
-            throw new \Exception('该微信已被绑定');
+            if($isAuth->user_id != $response['user_id']) {
+                throw new \Exception('该微信已被绑定');
+            }
+            if($isAuth->user_id == 0) {
+                //更新操作
+                $isAuth->user_id = $response['user_id'];
+                $isAuth->save();
+                return true;
+            }
+            if($isAuth->user_id == $response['user_id']) {
+                return true;
+            }
         }
 
         if (isset($response['unionid']) && !empty($response['unionid'])) {