| xqd
@@ -8,6 +8,7 @@
|
|
|
|
|
|
namespace App\Http\Controllers\Web;
|
|
|
|
|
|
+use App\Models\AlbumAgentModel;
|
|
|
use App\Models\AlbumManufacturerModel;
|
|
|
use App\Models\AlbumUserModel;
|
|
|
use Illuminate\Http\Request;
|
| xqd
@@ -23,13 +24,14 @@ class AuthController extends Controller
|
|
|
$name = $request->input('name');
|
|
|
if (!$phone) {
|
|
|
$message = '请输入电话号码';
|
|
|
- return view('web.auth.bind', compact('message'));
|
|
|
+ return view('web.auth.error', compact('message'));
|
|
|
} else {
|
|
|
- $check = AlbumUserModel::where([['phone', $phone],['g_open_id', null]])->first();
|
|
|
+ $check = AlbumUserModel::where([['phone', $phone],['g_open_id', null],['is_dealer', 1]])->first();
|
|
|
if (!$check) {
|
|
|
$message = '该号码不存在或是已绑定';
|
|
|
+ return view('web.auth.error', compact('message'));
|
|
|
}
|
|
|
- return view('web.auth.bind', compact('message'));
|
|
|
+
|
|
|
}
|
|
|
$weChatApp = AlbumManufacturerModel::where('store_id', $store_id)->first();
|
|
|
$config = [
|
| xqd
@@ -38,7 +40,7 @@ class AuthController extends Controller
|
|
|
'response_type' => 'array',
|
|
|
'oauth' => [
|
|
|
'scopes' => ['snsapi_userinfo'],
|
|
|
- 'callback' => '/web/notify?store_id=' . $store_id,
|
|
|
+ 'callback' => '/web/notify?store_id=' . $store_id . "&name=$name&phone=$phone",
|
|
|
]
|
|
|
|
|
|
];
|
| xqd
@@ -53,6 +55,8 @@ class AuthController extends Controller
|
|
|
public function notify(Request $request)
|
|
|
{
|
|
|
$store_id = $request->input('store_id');
|
|
|
+ $phone = $request->input('phone');
|
|
|
+ $name = $request->input('name');
|
|
|
$weChatApp = AlbumManufacturerModel::where('store_id', $store_id)->first();
|
|
|
$config = [
|
|
|
'app_id' => $weChatApp->G_app_id,
|
| xqd
@@ -67,21 +71,13 @@ class AuthController extends Controller
|
|
|
$oauth = $app->oauth;
|
|
|
$user = $oauth->user()->toArray();
|
|
|
$check_user = AlbumUserModel::where([['store_id',$store_id],['wechat_union_id',$user['original']['unionid']]])->first();
|
|
|
- if ($check_user) {
|
|
|
- $check_user->g_open_id = $user['id'];
|
|
|
- $check_user->save();
|
|
|
- } else {
|
|
|
- $data['username'] = $user['name'];
|
|
|
- $data['wechat_union_id'] = $user['original']['unionid'];
|
|
|
- $data['avatar'] = $user['avatar'];
|
|
|
- $data['g_open_id'] = $user['id'];
|
|
|
- $data['store_id'] = $store_id;
|
|
|
- $data['is_dealer'] = 0;
|
|
|
- $data['role'] = 0;
|
|
|
- $data['model'] = 0;
|
|
|
- $data['up_agent_id'] = 0;
|
|
|
- AlbumUserModel::create($data);
|
|
|
- }
|
|
|
+ $agent = AlbumAgentModel::where([['store_id', $store_id],['user_id', $check_user->id]])->first();
|
|
|
+ $agent->name = $name;
|
|
|
+ $agent->save();
|
|
|
+ $check_user->g_open_id = $user['id'];
|
|
|
+ $check_user->phone = $phone;
|
|
|
+ $check_user->save();
|
|
|
+
|
|
|
return view('web.auth.success');
|
|
|
}
|
|
|
|