*/ 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()); } } }