| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\jobs;
- 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 OrderEventJob extends BaseObject implements JobInterface
- {
- public $store_id;
- public $action;
- public $in_action;
- public $version;
- public $time;
- public function execute($queue)
- {
- debug_log(__METHOD__ . '~~~~~~~~已弃用~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
- throw new \Exception(__METHOD__ . '~~~~~~~~已弃用~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
- return;
- set_time_limit(0);
- // echo '----OrderEventJob----' . $this->store_id . $this->action;
- if($this->action){
- $event = new OrderEvent();
- $event->store_id = $this->store_id;
- $action = $this->action;
- $event->$action();
- }
- if($this->in_action){
- $action = $this->in_action;
- $this->$action();
- }
- }
- public function executeLevel() {
- $time = time();
- $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->level();
- } catch(\Throwable $e) {
- // \Yii::error($e);
- \Yii::error('--------auto-execute-error---- '.$store->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
- debug_log(['executeLevel--end', time() - $time], 'debug_task_execute.log');
- }
- public function executeUserLevelExpiresHandle() {
- try {
- // 定时任务
- $event = new OrderEvent();
- $event->userLevelExpiresHandle();
- } catch(\Throwable $e) {
- // \Yii::error($e);
- \Yii::error('--------auto-execute-error---- ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
- public function executeOrder() {
- $time = time();
- $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->onLoad();
- } catch(\Throwable $e) {
- // \Yii::error($e);
- \Yii::error('--------auto-execute-error---- '.$store->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
- debug_log(['executeOrder--end', time() - $time], 'debug_task_execute.log');
- }
- public function executeStoreWxOrderShipping() {
- $time = time();
- $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->storeWxOrderShipping();
- } catch(\Throwable $e) {
- // \Yii::error($e);
- \Yii::error('--------auto-executeStoreWxOrderShipping-error---- '.$store->id.' ----auto-executeStoreWxOrderShipping-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
- debug_log(['executeStoreWxOrderShipping--end', time() - $time], 'debug_task_execute.log');
- }
- public function executeOtherThird() {
- $time = time();
- $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->otherThird();
- } catch(\Exception $e) {
- \Yii::error('--------auto-execute-error---- '.$store->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
- debug_log(['executeOtherThird--end', time() - $time], 'debug_task_execute.log');
- }
- /**
- * 奖金池自动发放
- * @return void
- */
- public function executeReportPool() {
- $time = time();
- $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->reportPool();
- } catch(\Exception $e) {
- \Yii::error('--------auto-execute-report-pool-error---- '.$store->id.' ----auto-execute-report-pool-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
- debug_log(['executeReportPool--end', time() - $time], 'debug_task_execute.log');
- }
- public function executeAdapayShareToSelf() {
- $time = time();
- $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->adapayShareToSelf();
- } catch(\Exception $e) {
- \Yii::error($e);
- \Yii::error('--------auto-execute-error---- '.$store->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
- debug_log(['executeAdapayShareToSelf--end', time() - $time], 'debug_task_execute.log');
- }
- public function executeBonusPool() {
- $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);
- }
- public function executeJuShuiTanToken() {
- $time = time();
- $store_list = Store::find()->where(['is_delete' => 0])->select('id, name')->all();
- foreach($store_list as $store) {
- try {
- // 定时任务
- JuShuiTanForm::refreshToken($store->id);
- } catch(\Exception $e) {
- \Yii::error('--------auto-execute-error---- '.$store->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- sleep(1);
- }
- debug_log(['executeJuShuiTanToken--end', time() - $time], 'debug_task_execute.log');
- }
- public function executeJuShuiTanTokenSupplier() {
- $time = time();
- $supplier_list = \app\models\Supplier::find()->where(['is_delete' => 0])->select('id, name')->all();
- foreach($supplier_list as $upplier) {
- try {
- // 定时任务
- JuShuiTanForm::initStoreType(JuShuiTanForm::STORE_TYPE_SUPPLIER);
- JuShuiTanForm::refreshToken($upplier->id);
- } catch(\Exception $e) {
- \Yii::error('--------auto-execute-error---- '.$upplier->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- sleep(1);
- }
- debug_log(['executeJuShuiTanTokenSupplier--end', time() - $time], 'debug_task_execute.log');
- }
- public function executeOrder2JstSupplier() {
- $time = time();
- $supplier_list = \app\models\Supplier::find()->where(['is_delete' => 0])->select('id, name')->all();
- foreach($supplier_list as $upplier) {
- try {
- // 定时任务
- JuShuiTanForm::initStoreType(JuShuiTanForm::STORE_TYPE_SUPPLIER);
- JuShuiTanForm::supplierOrder2Jst($upplier->id);
- } catch(\Exception $e) {
- \Yii::error('--------auto-execute-error---- '.$upplier->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- }
- debug_log(['executeOrder2JstSupplier--end', time() - $time], 'debug_task_execute.log');
- }
- public function executeMaiyatianToken() {
- $time = time();
- $store_list = Store::find()->where(['is_delete' => 0])->select('id, name')->all();
- foreach($store_list as $store) {
- try {
- // 定时任务
- \app\modules\admin\models\maiyatian\MaiyatianForm::refreshToken($store->id);
- } catch(\Exception $e) {
- \Yii::error('--------auto-execute-error---- '.$store->id.' ----auto-execute-error--------' . $e->getMessage() . $e->getFile() . $e->getLine());
- }
- sleep(1);
- }
- debug_log(['executeMaiyatianToken--end', time() - $time], 'debug_task_execute.log');
- }
- public function executeActivityOrderRebateSelfRebate() {
- $time = time();
- $res = \app\modules\admin\models\ActivityOrderRebateSelfForm::rebate($this->time);
- if($res['code'] != 0) {
- \Yii::error('--------auto-execute-error---- ' . $res['msg']);
- }
- debug_log(['executeActivityOrderRebateSelfRebate--end', time() - $time], 'debug_task_execute.log');
- }
- }
|