* @version : HUOSDK 8.0 */ namespace huo\controller\queue; use huo\controller\common\Base; use huolib\queue\constant\ClassConst; use huolib\queue\constant\JobConst; use huolib\status\CommonStatus; use think\Queue; class AccountOrderQueue extends Base { protected $delay = 3600; protected $param = []; protected $job_class = ''; protected $job_name = ''; public function __construct($order_info, $delay = 3600) { $this->job_class = ClassConst::CLASS_ACCOUNT_ORDER_FIRE; $this->job_name = JobConst::JOB_ACCOUNT_ORDER; $this->param['ts'] = time(); $this->setOrderInfo($order_info); $this->setDelay($delay); } public function setOrderInfo($order_info) { $this->param['order_info'] = $order_info; } public function getOrderInfo() { return $this->param['order_info']; } /** * 返回数据 * * @param int $code * @param array $data * * @return array */ protected function retSucMsg($code = CommonStatus::NO_ERROR, $data = []) { /* 数据录入LOG */ $this->param['queue'] = '1'; return $this->huoSuccess($code, '', $data); } /** * 返回数据 * * @param $code * * @return array|mixed */ protected function retErrMsg($code = CommonStatus::PUSH_QUEUE_ERROR) { /* 数据录入LOG */ $this->param['queue'] = '0'; return $this->huoError($code); } /** * 入队列 * * @return array */ public function pushQueue() { if (class_exists('think\\Queue')) { $_is_pushed = Queue::later($this->delay, $this->job_class, $this->param, $this->job_name); if ($_is_pushed !== false) { return $this->retErrMsg(); } } return $this->retSucMsg(); } /** * @return string */ public function getJobClass() { return $this->job_class; } /** * @param string $job_class */ public function setJobClass($job_class) { $this->job_class = $job_class; } /** * @return string */ public function getJobName() { return $this->job_name; } /** * @param string $job_name */ public function setJobName($job_name) { $this->job_name = $job_name; } /** * @return int */ public function getDelay() { return $this->delay; } /** * @param int $delay */ public function setDelay($delay) { $this->delay = $delay; } }