初始化仓库
This commit is contained in:
34
common/handlers/PrescriptionAutoExpireHandlerClass.php
Normal file
34
common/handlers/PrescriptionAutoExpireHandlerClass.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace common\handlers;
|
||||
|
||||
|
||||
use common\jobs\PrescriptionAutoExpireJob;
|
||||
|
||||
class PrescriptionAutoExpireHandlerClass extends BasePrescriptionHandler
|
||||
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
self::execute();
|
||||
}
|
||||
|
||||
protected function execute()
|
||||
{
|
||||
$config = \Yii::$app->params;
|
||||
$autoExpireTime = isset($config['prescription']['over_time']) ? $config['prescription']['over_time'] : 900;
|
||||
if (is_numeric($autoExpireTime) && $autoExpireTime >= 0) {
|
||||
// 处方自动失效任务
|
||||
\Yii::$app->queue->delay($autoExpireTime)->push(new PrescriptionAutoExpireJob([
|
||||
'orderId' => $this->event->prescription->id,
|
||||
]));
|
||||
if($this->event->prescription->auto_expire_time){
|
||||
$autoExpire = $this->event->prescription->auto_expire_time + $autoExpireTime;
|
||||
} else {
|
||||
$autoExpire = $this->event->prescription->created_at + $autoExpireTime;
|
||||
}
|
||||
$this->event->prescription->auto_expire_time = $autoExpire;
|
||||
$this->event->prescription->save();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user