You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
896 B
PHTML
31 lines
896 B
PHTML
5 years ago
|
<?php
|
||
|
namespace Base\Task;
|
||
|
|
||
|
use Base\Service\MarketService;
|
||
|
|
||
|
/**
|
||
|
* 任务处理
|
||
|
* @author elf<360197197@qq.com>
|
||
|
*/
|
||
|
class MarketShiftTask extends BaseTask
|
||
|
{
|
||
|
public function run()
|
||
|
{
|
||
|
$id = $this->params['market_shift_id'];
|
||
|
$record = M('market_shift', 'tab_')->where(['id' => $id])->find();
|
||
|
if (!$record) {
|
||
|
throw new \Exception('换绑记录不存在');
|
||
|
}
|
||
|
if ($record['status'] != 0) {
|
||
|
throw new \Exception('换绑记录状态错误');
|
||
|
}
|
||
|
try {
|
||
|
$marketService = new MarketService();
|
||
|
$marketService->shift($record);
|
||
|
M('market_shift', 'tab_')->where(['id' => $id])->save(['status' => 1]);
|
||
|
} catch (\Exception $e) {
|
||
|
M('market_shift', 'tab_')->where(['id' => $id])->save(['status' => 2]);
|
||
|
throw new \Exception($e->getMessage());
|
||
|
}
|
||
|
}
|
||
|
}
|