12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Wechat\Official\Event;
- use App\Models\Company;
- use App\Models\Member;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Str;
- /**
- * 用户关注公众号事件
- * Class SubscribeEvent
- * @package App\Wechat\Official\Event
- * Auth Zhong
- * Date 2019-05-08
- */
- class SubscribeEvent implements EventInterface
- {
- /**
- * @param array $wechatUser 从微信里获取的用户基本信息
- * @param bool|Company|Member $user 有没有绑定系统用户,false为未绑定,否则为对应的用户模型
- * @param array $payload 该事件的参数
- * @return mixed
- */
- public function handle(array $wechatUser, $user, array $payload)
- {
- file_put_contents('/data/wwwroot/jucai/public/test.log',json_encode($payload));
- if (isset($payload['EventKey']) && Str::contains($payload['EventKey'], 'qrscene_')) {
- $key=str_replace("qrscene_", "", $payload['EventKey']);
- if ($key == 'LoginEvent') {
- if ($user) {
- Cache::put($payload['Ticket'], $user, 60);
- $url = route('mobile.auth.thirdlogin.official.login_to_web', ['ticket'=>$payload['Ticket']]);
- return <<<EOT
- <a href='{$url}'>点此立即登录</a>
- EOT;
- } else {
- $url = route('mobile.auth.thirdlogin.official');
- $siteName=config('aix.system.site.site.site_name');
- return <<<EOT
- 欢迎关注{$siteName}!\n\n
- 绑定您的{$siteName}帐号,求职招聘更加方便,并实时接收提醒通知。<a href='{$url}'>点此立即绑定</a>
- EOT;
- }
- }
- }
- if ($user) {
- return "欢迎关注".config('aix.system.site.site.site_name')."! ";
- } else {
- $url = route('mobile.auth.thirdlogin.official');
- $siteName=config('aix.system.site.site.site_name');
- return <<<EOT
- 欢迎关注{$siteName}!\n\n
- 绑定您的{$siteName}帐号,求职招聘更加方便,并实时接收提醒通知。<a href='{$url}'>点此立即绑定</a>
- EOT;
- }
- }
- }
|