| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- declare(strict_types=1);
- /**
- * This file is part of Hyperf.
- *
- * @link https://www.hyperf.io
- * @document https://doc.hyperf.io
- * @contact group@hyperf.io
- * @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
- */
- namespace App\Jobs;
- use App\Model\UserModel;
- use Carbon\Carbon;
- use Hyperf\AsyncQueue\Job;
- class RefreshLoginTimeJob extends Job
- {
- public $params;
- public function __construct($params)
- {
- // 这里最好是普通数据,不要使用携带 IO 的对象,比如 PDO 对象
- $this->params = $params;
- }
- public function handle()
- {
- try {
- UserModel::query()->where('code', $this->params['user_id'])
- ->update(
- [
- 'version' => $this->params['version'],
- 'last_login_at' => Carbon::now()->toDateTimeString()
- ]
- );
- } catch (\Exception $exception) {
- logger('RefreshLoginTimeJob', [$exception->getMessage()]);
- }
- // 异步处理该用户的系统消息分配给用户消息.
- dispatch_job(new InitSysMessageJob(['receive_uid' => $this->params['user_id']]));
- }
- }
|