diff --git a/services/order/Item.php b/services/order/Item.php index b3435c811ef33973b22d3f1644142b4e8fef3a7a..aef06665d575e357e71f838f07c953bcf82ce1d2 100644 --- a/services/order/Item.php +++ b/services/order/Item.php @@ -30,7 +30,31 @@ class Item extends Service parent::init(); list($this->_itemModelName, $this->_itemModel) = \Yii::mapGet($this->_itemModelName); } + + /** + * 得到order 表的id字段。 + */ + protected function actionGetPrimaryKey() + { + return 'item_id'; + } + /** + * @param $primaryKey | Int + * @return Object($this->_itemModel) + * 通过主键值,返回Order Model对象 + */ + protected function actionGetByPrimaryKey($primaryKey) + { + $one = $this->_itemModel->findOne($primaryKey); + $primaryKey = $this->getPrimaryKey(); + if ($one[$primaryKey]) { + return $one; + } else { + return new $this->_orderModelName(); + } + } + /** * @param $product_id | string , 产品的id * @param $customer_id | int, 用户的id