| 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\Mongo\PayNotifyModel;
- use App\Model\Mongo\RegisterModel;
- use App\Model\VipOrderModel;
- use Hyperf\AsyncQueue\Job;
- class AddPayNotifyJob extends Job
- {
- public $params;
- public function __construct($params)
- {
- // 这里最好是普通数据,不要使用携带 IO 的对象,比如 PDO 对象
- $this->params = $params;
- }
- public function handle()
- {
- try {
- make(PayNotifyModel::class)->db()
- ->insertOne($this->params);
- $uid = VipOrderModel::query()->where('id', $this->params['order_id'])
- ->value('user_id');
- make(RegisterModel::class)->db()->updateOne(
- ['uid' => (int)$uid],
- ['$set' => ['is_vip' => 1]]
- );
- } catch (\Exception $exception) {
- logger('AddPayNotifyJob', [$exception->getMessage()]);
- }
- }
- }
|