| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\jobs\orderEvent;
- use yii\base\BaseObject;
- use yii\queue\JobInterface;
- use app\events\OrderEvent;
- use app\models\Store;
- use app\constants\OptionSetting;
- use app\models\Option;
- use app\modules\admin\models\jushuitan\JuShuiTanForm;
- class BonusPoolJob extends BaseObject implements JobInterface
- {
- public $store_id;
- public $action;
- public $in_action;
- public $version;
- public $time;
- public function execute($queue) {
- $time = time();
- $newVer = cache()->get('executeBonusPool');
- if($newVer != $this->version){
- debug_log(['executeBonusPool $newVer', time(), $this->version, $newVer], 'debug_task_execute.log');
- return;
- }
- $store_list = Store::find()->where(['is_delete' => 0])->select('id, name')->all();
- foreach($store_list as $store) {
- try {
- // 定时任务
- $event = new OrderEvent();
- $event->store_id = $store->id;
- $event->bonusPool();
- } catch(\Exception $e) {
- \Yii::error('--------auto-execute-error---- '.$store->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
-
- debug_log(['executeBonusPool--end', time() - $time], 'debug_task_execute.log');
- if(time() - $this->version > 55){
- debug_log(['executeBonusPool 55', time(), $this->version], 'debug_task_execute.log');
- return;
- }
- // $queue = queue_push(new \app\jobs\OrderEventJob([
- // 'in_action' => 'executeBonusPool',
- // 'version' => $this->version,
- // ]), 5);
- }
- }
|