BuyNowPurchase::class, // 立即下单 ]; /** * @desc:执行订单初始化 * @Author: ltm * @Date: 2021/12/30 * @Time: 14:14 * @Copyright: copyright (c) 2021 广东七件事集团 * @param OrderFormLogic $form * @param $type * @return false|mixed */ public function execute(OrderFormLogic $form, $type){ try{ if (!isset($this->handlers[$type])) throw new Exception('下单类型错误'); $class = new $this->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; } } }