getHandlers(); if (!isset($handlers[$type])) throw new Exception('下单类型错误'); /** @var BasePurchase $class */ $class = new $handlers[$type](); $class->isNewRecord = $this->isNewRecord; $form = $class->execute($form); if($form === false) throw new Exception($class->getError()); if (!$form->order_goods) throw new Exception('该下单的产品不存在或者已经删除'); $form = $class->afterExecute($form, $class::getType()); if($form === false) throw new Exception($class->getError()); return $form; } catch (Exception $e) { $this->setError($e->getMessage()); return false; } } }