public function __construct($id, $config = []) { if (empty($id) || !is_numeric($id)) { throw new InvalidParamException('参数错误!'); } $this->_goods = Goods::findOne($id); if (!$this->_goods) { throw new InvalidParamException('未找到该商品!'); } parent::__construct($config); }