| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?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\PaymentResultModel;
- use App\Model\Mongo\VipCodeExchangeHistoryModel;
- use Carbon\Carbon;
- use Hyperf\AsyncQueue\Job;
- class AddExchangeCodeJob extends Job
- {
- public $params;
- public function __construct($params)
- {
- // 这里最好是普通数据,不要使用携带 IO 的对象,比如 PDO 对象
- $this->params = $params;
- }
- public function handle()
- {
- try {
- make(VipCodeExchangeHistoryModel::class)->db()
- ->insertOne(
- [
- 'nick' => $this->params['nick'],
- 'user_id' => $this->params['user_id'],
- 'user_code' => $this->params['user_code'],
- 'code' => $this->params['code'],
- 'title' => $this->params['title'],
- 'day' => $this->params['day'],
- 'created_at' => Carbon::now()->toDateTimeString(),
- ]
- );
- } catch (\Exception $exception) {
- logger('AddExchangeCodeJob', [$exception->getMessage()]);
- }
- }
- }
|