|
@@ -14,6 +14,7 @@ use App\Events\WebSocketMessage; |
|
@@ -14,6 +14,7 @@ use App\Events\WebSocketMessage; |
|
14
|
use App\Events\WebSocketMessageSent;
|
14
|
use App\Events\WebSocketMessageSent;
|
|
15
|
use App\Helper\Arr;
|
15
|
use App\Helper\Arr;
|
|
16
|
use App\Helper\Common;
|
16
|
use App\Helper\Common;
|
|
|
|
17
|
+use App\Helper\Socket;
|
|
17
|
use App\Helper\Translate;
|
18
|
use App\Helper\Translate;
|
|
18
|
use App\Helper\Wechat;
|
19
|
use App\Helper\Wechat;
|
|
19
|
use App\Http\Logic\Bside\User\UserLoginLogic;
|
20
|
use App\Http\Logic\Bside\User\UserLoginLogic;
|
|
@@ -167,21 +168,9 @@ class LoginController extends BaseController |
|
@@ -167,21 +168,9 @@ class LoginController extends BaseController |
|
167
|
public function eventMessage(){
|
168
|
public function eventMessage(){
|
|
168
|
$message = file_get_contents("php://input");
|
169
|
$message = file_get_contents("php://input");
|
|
169
|
$message = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
|
170
|
$message = simplexml_load_string($message, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NOERROR);
|
|
170
|
- $arr = [
|
|
|
|
171
|
- 'ToUserName' => 'gh_27174ac5c9d8',
|
|
|
|
172
|
- 'FromUserName' => 'oMbcI6gRzvfrU8ssGsEyvzXOO94w',
|
|
|
|
173
|
- 'CreateTime' => '1693385898',
|
|
|
|
174
|
- 'MsgType' => 'event',
|
|
|
|
175
|
- 'Event' => 'subscribe',
|
|
|
|
176
|
- 'EventKey' => 'qrscene_global-v6_v6',
|
|
|
|
177
|
- 'Ticket' => 'gQF27zwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyWnppdHhWTlRjOEcxTlBpTE5BY2IAAgRjBO9kAwQQDgAA',
|
|
|
|
178
|
- ];
|
|
|
|
179
|
- //查看当前账户是否绑定
|
|
|
|
180
|
- $userModel = new UserModel();
|
|
|
|
181
|
- $info = $userModel->read(['wechat'=>$message->FromUserName]);
|
|
|
|
182
|
- if($info === false){
|
|
|
|
183
|
-
|
|
|
|
184
|
- }
|
171
|
+ $data = $this->wechatLogin($message->FromUserName);
|
|
|
|
172
|
+ $socket = new Socket();
|
|
|
|
173
|
+ $socket->socket(json_encode($data));
|
|
185
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($message, true) . PHP_EOL, FILE_APPEND);
|
174
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($message, true) . PHP_EOL, FILE_APPEND);
|
|
186
|
return "<xml>
|
175
|
return "<xml>
|
|
187
|
<ToUserName><![CDATA[$message->FromUserName]]></ToUserName>
|
176
|
<ToUserName><![CDATA[$message->FromUserName]]></ToUserName>
|
|
@@ -219,4 +208,52 @@ class LoginController extends BaseController |
|
@@ -219,4 +208,52 @@ class LoginController extends BaseController |
|
219
|
$this->response('success',Code::SUCCESS,['info'=>$info]);
|
208
|
$this->response('success',Code::SUCCESS,['info'=>$info]);
|
|
220
|
}
|
209
|
}
|
|
221
|
|
210
|
|
|
|
|
211
|
+ /**
|
|
|
|
212
|
+ * @remark :微信登录处理数据
|
|
|
|
213
|
+ * @name :wechatLogin
|
|
|
|
214
|
+ * @author :lyh
|
|
|
|
215
|
+ * @method :post
|
|
|
|
216
|
+ * @time :2023/8/31 9:13
|
|
|
|
217
|
+ */
|
|
|
|
218
|
+ public function wechatLogin($wechat){
|
|
|
|
219
|
+ //查看当前账户是否绑定
|
|
|
|
220
|
+ $userModel = new UserModel();
|
|
|
|
221
|
+ $info = $userModel->read(['wechat'=>$wechat]);
|
|
|
|
222
|
+ if($info === false){
|
|
|
|
223
|
+ $data = [
|
|
|
|
224
|
+ 'code'=>Code::USER_LOGIN_ERROE,
|
|
|
|
225
|
+ 'message'=>'当前用户未绑定账户,请绑定后',
|
|
|
|
226
|
+ ];
|
|
|
|
227
|
+ }else {
|
|
|
|
228
|
+ //获取项目详情
|
|
|
|
229
|
+ $info = $this->assembleParam($info['mobile'],$info['project_id']);
|
|
|
|
230
|
+ if(isset($info['token']) && !empty($info['token'])){
|
|
|
|
231
|
+ //清除上一次用户缓存
|
|
|
|
232
|
+ Cache::pull($info['token']);
|
|
|
|
233
|
+ }
|
|
|
|
234
|
+ //生成新token
|
|
|
|
235
|
+ $token = md5(uniqid().$info['id']);
|
|
|
|
236
|
+ //存储缓存
|
|
|
|
237
|
+ $info['token'] = $token;
|
|
|
|
238
|
+ Cache::add($token,$info,3600);
|
|
|
|
239
|
+ //更新用户信息
|
|
|
|
240
|
+ $this->model->edit(['token'=>$token],['id'=>$info['id']]);
|
|
|
|
241
|
+ $data = [
|
|
|
|
242
|
+ 'code'=>Code::SUCCESS,
|
|
|
|
243
|
+ 'message'=>'当前用户未绑定账户,请绑定后',
|
|
|
|
244
|
+ 'data'=>$info
|
|
|
|
245
|
+ ];
|
|
|
|
246
|
+ }
|
|
|
|
247
|
+ return $data;
|
|
|
|
248
|
+ }
|
|
|
|
249
|
+
|
|
|
|
250
|
+
|
|
|
|
251
|
+ public function ceshi(){
|
|
|
|
252
|
+ $data = [
|
|
|
|
253
|
+ 'code'=>Code::USER_LOGIN_ERROE,
|
|
|
|
254
|
+ 'message'=>'当前用户未绑定账户,请绑定后',
|
|
|
|
255
|
+ ];
|
|
|
|
256
|
+ $socket = new Socket();
|
|
|
|
257
|
+ return $socket->socket(json_encode($data));
|
|
|
|
258
|
+ }
|
|
222
|
} |
259
|
} |