BonusPoolJob.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\jobs\orderEvent;
  8. use yii\base\BaseObject;
  9. use yii\queue\JobInterface;
  10. use app\events\OrderEvent;
  11. use app\models\Store;
  12. use app\constants\OptionSetting;
  13. use app\models\Option;
  14. use app\modules\admin\models\jushuitan\JuShuiTanForm;
  15. class BonusPoolJob extends BaseObject implements JobInterface
  16. {
  17. public $store_id;
  18. public $action;
  19. public $in_action;
  20. public $version;
  21. public $time;
  22. public function execute($queue) {
  23. $time = time();
  24. $newVer = cache()->get('executeBonusPool');
  25. if($newVer != $this->version){
  26. debug_log(['executeBonusPool $newVer', time(), $this->version, $newVer], 'debug_task_execute.log');
  27. return;
  28. }
  29. $store_list = Store::find()->where(['is_delete' => 0])->select('id, name')->all();
  30. foreach($store_list as $store) {
  31. try {
  32. // 定时任务
  33. $event = new OrderEvent();
  34. $event->store_id = $store->id;
  35. $event->bonusPool();
  36. } catch(\Exception $e) {
  37. \Yii::error('--------auto-execute-error---- '.$store->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
  38. }
  39. }
  40. debug_log(['executeBonusPool--end', time() - $time], 'debug_task_execute.log');
  41. if(time() - $this->version > 55){
  42. debug_log(['executeBonusPool 55', time(), $this->version], 'debug_task_execute.log');
  43. return;
  44. }
  45. // $queue = queue_push(new \app\jobs\OrderEventJob([
  46. // 'in_action' => 'executeBonusPool',
  47. // 'version' => $this->version,
  48. // ]), 5);
  49. }
  50. }