From f7839d10a0f47e4c6f06427b5f7aced7e53725cb Mon Sep 17 00:00:00 2001 From: Terry <2358269014@qq.com> Date: Wed, 26 Jul 2017 11:12:26 +0800 Subject: [PATCH] =?UTF-8?q?php5=E5=92=8Cphp7=E7=9A=84=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/Catalog/block/product/Index.php | 5 +- .../modules/Catalog/block/product/Review.php | 4 +- .../Catalog/block/reviewproduct/Add.php | 4 +- .../Catalog/block/reviewproduct/Lists.php | 7 +- .../modules/Catalog/block/product/Index.php | 5 +- .../modules/Catalog/block/product/Review.php | 3 +- .../Catalog/block/reviewproduct/Add.php | 3 +- .../Catalog/block/reviewproduct/Lists.php | 6 +- services/Customer.php | 26 +++---- services/Order.php | 22 +++--- services/Request.php | 2 +- services/cart/Coupon.php | 34 ++++----- services/cart/Quote.php | 10 +-- services/cart/QuoteItem.php | 18 ++--- services/category/CategoryMongodb.php | 37 +++++----- services/category/Menu.php | 10 +-- services/cms/article/ArticleMongodb.php | 10 +-- services/cms/article/ArticleMysqldb.php | 10 +-- .../cms/staticblock/StaticBlockMongodb.php | 14 ++-- .../cms/staticblock/StaticBlockMysqldb.php | 14 ++-- services/customer/Address.php | 22 +++--- services/customer/Newsletter.php | 7 +- services/helper/Log.php | 2 +- services/order/Item.php | 4 +- services/page/Newsletter.php | 2 +- services/product/Favorite.php | 14 ++-- services/product/ProductMongodb.php | 51 +++++++------- services/product/Review.php | 70 +++++++++++-------- services/product/Stock.php | 46 ++++++------ services/product/viewLog/Db.php | 4 +- services/product/viewLog/Mongodb.php | 6 +- services/search/MongoSearch.php | 43 +++++++----- services/search/XunSearch.php | 14 ++-- services/session/MysqlDbSession.php | 8 +-- services/url/rewrite/RewriteMongodb.php | 18 ++--- services/url/rewrite/RewriteMysqldb.php | 18 ++--- 36 files changed, 301 insertions(+), 272 deletions(-) diff --git a/app/appfront/modules/Catalog/block/product/Index.php b/app/appfront/modules/Catalog/block/product/Index.php index 1d986371f..0d5e7b6b6 100644 --- a/app/appfront/modules/Catalog/block/product/Index.php +++ b/app/appfront/modules/Catalog/block/product/Index.php @@ -50,14 +50,15 @@ public function __construct() public function getLastData() { + $reviewHelper = $this->_reviewHelper; $productImgSize = Yii::$app->controller->module->params['productImgSize']; $productImgMagnifier = Yii::$app->controller->module->params['productImgMagnifier']; if(!$this->initProduct()){ Yii::$service->url->redirect404(); return; } - $this->_reviewHelper::initReviewConfig(); - $ReviewAndStarCount = $this->_reviewHelper::getReviewAndStarCount($this->_product); + $reviewHelper::initReviewConfig(); + $ReviewAndStarCount = $reviewHelper::getReviewAndStarCount($this->_product); list($review_count, $reviw_rate_star_average) = $ReviewAndStarCount; $this->filterProductImg($this->_product['image']); $groupAttr = Yii::$service->product->getGroupAttr($this->_product['attr_group']); diff --git a/app/appfront/modules/Catalog/block/product/Review.php b/app/appfront/modules/Catalog/block/product/Review.php index 27a76e15b..9f1590029 100644 --- a/app/appfront/modules/Catalog/block/product/Review.php +++ b/app/appfront/modules/Catalog/block/product/Review.php @@ -35,9 +35,9 @@ public function __construct() * 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中 */ list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName); - + $reviewHelper = $this->_reviewHelper; // 初始化当前appfront的设置,覆盖service的初始设置。 - $this->_reviewHelper::initReviewConfig(); + $reviewHelper::initReviewConfig(); } /** * 得到当前spu下面的所有评论信息。 diff --git a/app/appfront/modules/Catalog/block/reviewproduct/Add.php b/app/appfront/modules/Catalog/block/reviewproduct/Add.php index 58f18507c..8885a9b57 100644 --- a/app/appfront/modules/Catalog/block/reviewproduct/Add.php +++ b/app/appfront/modules/Catalog/block/reviewproduct/Add.php @@ -31,8 +31,8 @@ public function __construct() * 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中 */ list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName); - - $this->_reviewHelper::initReviewConfig(); + $reviewHelper = $this->_reviewHelper; + $reviewHelper::initReviewConfig(); } /** * @return boolean , review页面是否开启验证码验证。 diff --git a/app/appfront/modules/Catalog/block/reviewproduct/Lists.php b/app/appfront/modules/Catalog/block/reviewproduct/Lists.php index b999f47b3..9cf0f3e39 100644 --- a/app/appfront/modules/Catalog/block/reviewproduct/Lists.php +++ b/app/appfront/modules/Catalog/block/reviewproduct/Lists.php @@ -37,8 +37,8 @@ public function __construct() * 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中 */ list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName); - - $this->_reviewHelper::initReviewConfig(); + $reviewHelper = $this->_reviewHelper; + $reviewHelper::initReviewConfig(); } /** * @property $countTotal | Int @@ -97,7 +97,8 @@ public function getLastData() $pageToolBar = $this->getProductPage($count); $coll = $data['coll']; - $ReviewAndStarCount = $this->_reviewHelper::getReviewAndStarCount($product); + $reviewHelper = $this->_reviewHelper; + $ReviewAndStarCount = $reviewHelper::getReviewAndStarCount($product); list($review_count, $reviw_rate_star_average) = $ReviewAndStarCount; return [ diff --git a/app/apphtml5/modules/Catalog/block/product/Index.php b/app/apphtml5/modules/Catalog/block/product/Index.php index d6c96db41..3664b5157 100644 --- a/app/apphtml5/modules/Catalog/block/product/Index.php +++ b/app/apphtml5/modules/Catalog/block/product/Index.php @@ -54,8 +54,9 @@ public function getLastData() Yii::$service->url->redirect404(); return; } - $this->_reviewHelper::initReviewConfig(); - $ReviewAndStarCount = $this->_reviewHelper::getReviewAndStarCount($this->_product); + $reviewHelper = $this->_reviewHelper; + $reviewHelper::initReviewConfig(); + $ReviewAndStarCount = $reviewHelper::getReviewAndStarCount($this->_product); list($review_count, $reviw_rate_star_average) = $ReviewAndStarCount; $this->filterProductImg($this->_product['image']); $groupAttr = Yii::$service->product->getGroupAttr($this->_product['attr_group']); diff --git a/app/apphtml5/modules/Catalog/block/product/Review.php b/app/apphtml5/modules/Catalog/block/product/Review.php index 65b6c4f32..8cf92a0b4 100644 --- a/app/apphtml5/modules/Catalog/block/product/Review.php +++ b/app/apphtml5/modules/Catalog/block/product/Review.php @@ -35,7 +35,8 @@ public function __construct() */ list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName); // 初始化当前apphtml5的设置,覆盖service的初始设置。 - $this->_reviewHelper::initReviewConfig(); + $reviewHelper = $this->_reviewHelper; + $reviewHelper::initReviewConfig(); } /** diff --git a/app/apphtml5/modules/Catalog/block/reviewproduct/Add.php b/app/apphtml5/modules/Catalog/block/reviewproduct/Add.php index 7b13a624a..9926ceb2a 100644 --- a/app/apphtml5/modules/Catalog/block/reviewproduct/Add.php +++ b/app/apphtml5/modules/Catalog/block/reviewproduct/Add.php @@ -31,7 +31,8 @@ public function __construct() * 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中 */ list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName); - $this->_reviewHelper::initReviewConfig(); + $reviewHelper = $this->_reviewHelper; + $reviewHelper::initReviewConfig(); } /** diff --git a/app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php b/app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php index 5690177d7..ed8d7ff20 100644 --- a/app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php +++ b/app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php @@ -38,7 +38,8 @@ public function __construct() */ list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName); // 初始化服务 - $this->_reviewHelper::initReviewConfig(); + $reviewHelper = $this->_reviewHelper; + $reviewHelper::initReviewConfig(); } /** * @property $countTotal | Int @@ -97,7 +98,8 @@ public function getLastData() $pageToolBar = $this->getProductPage($count); $coll = $data['coll']; - $ReviewAndStarCount = $this->_reviewHelper::getReviewAndStarCount($product); + $reviewHelper = $this->_reviewHelper; + $ReviewAndStarCount = $reviewHelper::getReviewAndStarCount($product); list($review_count, $reviw_rate_star_average) = $ReviewAndStarCount; return [ diff --git a/services/Customer.php b/services/Customer.php index 7f6f27174..dd802d415 100644 --- a/services/Customer.php +++ b/services/Customer.php @@ -132,7 +132,7 @@ protected function actionRegister($param) */ protected function actionIsRegistered($email) { - $customer = $this->_customerModel::findOne(['email' => $email]); + $customer = $this->_customerModel->findOne(['email' => $email]); if ($customer['email']) { return true; } else { @@ -190,10 +190,10 @@ protected function actionChangePassword($password, $identity) { if (is_int($identity)) { $customer_id = $identity; - $customerModel = $this->_customerModel::findIdentity($customer_id); + $customerModel = $this->_customerModel->findIdentity($customer_id); } elseif (is_string($identity)) { $email = $identity; - $customerModel = $this->_customerModel::findByEmail($email); + $customerModel = $this->_customerModel->findByEmail($email); } elseif (is_object($identity)) { $customerModel = $identity; } @@ -222,7 +222,7 @@ protected function actionGetModelName() protected function actionGetByPrimaryKey($val) { if ($val) { - $one = $this->_customerModel::findOne($val); + $one = $this->_customerModel->findOne($val); $primaryKey = $this->getPrimaryKey(); if ($one[$primaryKey]) { return $one; @@ -242,10 +242,10 @@ protected function actionChangePasswordAndClearToken($password, $identity) { if (is_int($identity)) { $customer_id = $identity; - $customerModel = $this->_customerModel::findIdentity($customer_id); + $customerModel = $this->_customerModel->findIdentity($customer_id); } elseif (is_string($identity)) { $email = $identity; - $customerModel = $this->_customerModel::findByEmail($email); + $customerModel = $this->_customerModel->findByEmail($email); } elseif (is_object($identity)) { $customerModel = $identity; } else { @@ -286,7 +286,7 @@ protected function actionGetCurrentAccount() */ protected function actionGetUserIdentityByEmail($email) { - $one = $this->_customerModel::findByEmail($email); + $one = $this->_customerModel->findByEmail($email); if ($one['email']) { return $one; } else { @@ -324,7 +324,7 @@ protected function actionGeneratePasswordResetToken($identify) */ protected function actionFindByPasswordResetToken($token) { - return $this->_customerModel::findByPasswordResetToken($token); + return $this->_customerModel->findByPasswordResetToken($token); } /** @@ -379,7 +379,8 @@ protected function actionLoginSuccessRedirect($urlKey = '') */ protected function actionGetStatusDeleted() { - return $this->_customerModel::STATUS_DELETED; + $model = $this->_customerModel; + return $model::STATUS_DELETED; } /** @@ -387,7 +388,8 @@ protected function actionGetStatusDeleted() */ protected function actionGetStatusActive() { - return $this->_customerModel::STATUS_ACTIVE; + $model = $this->_customerModel; + return $model::STATUS_ACTIVE; } /** * 得到customer 表的主键(mysql表) @@ -415,7 +417,7 @@ protected function actionGetPrimaryKey() */ protected function actionColl($filter = '') { - $query = $this->_customerModel::find(); + $query = $this->_customerModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); //var_dump($query->all());exit; return [ @@ -433,7 +435,7 @@ protected function actionGetEmailByIds($user_ids) { $arr = []; if (is_array($user_ids) && !empty($user_ids)) { - $data = $this->_customerModel::find()->where([ + $data = $this->_customerModel->find()->where([ 'in', 'id', $user_ids, ])->all(); if (is_array($data) && !empty($data)) { diff --git a/services/Order.php b/services/Order.php index 1f369bf37..a2e7244ed 100644 --- a/services/Order.php +++ b/services/Order.php @@ -138,7 +138,7 @@ protected function actionGetPrimaryKey() */ protected function actionGetByPrimaryKey($primaryKey) { - $one = $this->_orderModel::findOne($primaryKey); + $one = $this->_orderModel->findOne($primaryKey); $primaryKey = $this->getPrimaryKey(); if ($one[$primaryKey]) { return $one; @@ -154,7 +154,7 @@ protected function actionGetByPrimaryKey($primaryKey) */ protected function actionGetByIncrementId($increment_id) { - $one = $this->_orderModel::findOne(['increment_id' => $increment_id]); + $one = $this->_orderModel->findOne(['increment_id' => $increment_id]); $primaryKey = $this->getPrimaryKey(); if ($one[$primaryKey]) { return $one; @@ -219,7 +219,7 @@ protected function actionGetOrderInfoById($order_id) if (!$order_id) { return; } - $one = $this->_orderModel::findOne($order_id); + $one = $this->_orderModel->findOne($order_id); $primaryKey = $this->getPrimaryKey(); if (!isset($one[$primaryKey]) || empty($one[$primaryKey])) { return; @@ -256,7 +256,7 @@ protected function actionGetOrderInfoById($order_id) */ protected function actionColl($filter = '') { - $query = $this->_orderModel::find(); + $query = $this->_orderModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); $coll = $query->all(); @@ -276,7 +276,7 @@ protected function actionSave($one) $primaryKey = $this->getPrimaryKey(); $primaryVal = isset($one[$primaryKey]) ? $one[$primaryKey] : ''; if ($primaryVal) { - $model = $this->_orderModel::findOne($primaryVal); + $model = $this->_orderModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('order '.$this->getPrimaryKey().' is not exist'); @@ -308,7 +308,7 @@ protected function actionRemove($ids) } if (is_array($ids) && !empty($ids)) { foreach ($ids as $id) { - $model = $this->_orderModel::findOne($id); + $model = $this->_orderModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $model->delete(); } else { @@ -319,7 +319,7 @@ protected function actionRemove($ids) } } else { $id = $ids; - $model = $this->_orderModel::findOne($id); + $model = $this->_orderModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $model->delete(); } else { @@ -380,7 +380,7 @@ protected function actionGeneratePPExpressOrder($token){ * 通过token 得到订单 Object */ protected function actionGetByPaymentToken($token){ - $one = $this->_orderModel::find()->where(['payment_token' => $token]) + $one = $this->_orderModel->find()->where(['payment_token' => $token]) ->one(); if(isset($one['order_id']) && $one['order_id']){ return $one; @@ -547,12 +547,12 @@ protected function actionGenerateOrderByCart($address, $shipping_method, $paymen */ protected function checkOrderVersion($increment_id){ # 更新订单版本号,防止被多次执行。 - $sql = 'update '.$this->_orderModel::tableName().' set version = version + 1 where increment_id = :increment_id'; + $sql = 'update '.$this->_orderModel->tableName().' set version = version + 1 where increment_id = :increment_id'; $data = [ 'increment_id' => $increment_id, ]; - $result = $this->_orderModel::getDb()->createCommand($sql,$data)->execute(); - $myOrder = $this->_orderModel::find()->where([ + $result = $this->_orderModel->getDb()->createCommand($sql,$data)->execute(); + $myOrder = $this->_orderModel->find()->where([ 'increment_id' => $increment_id, ])->one(); # 如果版本号不等于1,则回滚 diff --git a/services/Request.php b/services/Request.php index e468c8d08..042cb6c9d 100644 --- a/services/Request.php +++ b/services/Request.php @@ -131,7 +131,7 @@ public function setRequestParam($originUrlPath) */ protected function getOriginUrl($urlKey) { - $UrlData = $this->_urlRewriteModel::find()->where([ + $UrlData = $this->_urlRewriteModel->find()->where([ 'custom_url_key' => $urlKey, ])->asArray()->one(); if ($UrlData['custom_url_key']) { diff --git a/services/cart/Coupon.php b/services/cart/Coupon.php index 6022aeba1..5def0fedb 100644 --- a/services/cart/Coupon.php +++ b/services/cart/Coupon.php @@ -49,7 +49,7 @@ protected function actionGetPrimaryKey() */ protected function actionGetByPrimaryKey($primaryKey) { - $one = $this->_couponModel::findOne($primaryKey); + $one = $this->_couponModel->findOne($primaryKey); $primaryKey = $this->getPrimaryKey(); if ($one[$primaryKey]) { return $one; @@ -73,7 +73,7 @@ protected function actionGetCouponUsageModel($customer_id = '', $coupon_id = '') $coupon_id = isset($couponModel['coupon_id']) ? $couponModel['coupon_id'] : ''; } if ($customer_id && $coupon_id) { - $one = $this->_couponUsageModel::findOne([ + $one = $this->_couponUsageModel->findOne([ 'customer_id' => $customer_id, 'coupon_id' => $coupon_id, ]); @@ -97,7 +97,7 @@ protected function actionGetCouponModel($coupon_code = '') $coupon_code = $this->_coupon_code; } if ($coupon_code) { - $one = $this->_couponModel::findOne(['coupon_code' => $coupon_code]); + $one = $this->_couponModel->findOne(['coupon_code' => $coupon_code]); if ($one['coupon_code']) { $this->_coupon_model = $one; } @@ -127,7 +127,7 @@ protected function actionGetCouponModel($coupon_code = '') */ protected function actionColl($filter = '') { - $query = $this->_couponModel::find(); + $query = $this->_couponModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); $coll = $query->all(); return [ @@ -145,13 +145,13 @@ protected function actionSave($one) $primaryKey = $this->getPrimaryKey(); $primaryVal = isset($one[$primaryKey]) ? $one[$primaryKey] : ''; if ($primaryVal) { - $model = $this->_couponModel::findOne($primaryVal); + $model = $this->_couponModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('coupon '.$this->getPrimaryKey().' is not exist'); return; } else { - $o_one = $this->_couponModel::find() + $o_one = $this->_couponModel->find() ->where(['coupon_code' =>$one['coupon_code']]) ->andWhere(['!=', $primaryKey, $primaryVal]) ->one(); @@ -162,7 +162,7 @@ protected function actionSave($one) } } } else { - $o_one = $this->_couponModel::find() + $o_one = $this->_couponModel->find() ->where(['coupon_code' =>$one['coupon_code']]) ->one(); if ($o_one[$primaryKey]) { @@ -203,7 +203,7 @@ protected function actionRemove($ids) } if (is_array($ids) && !empty($ids)) { foreach ($ids as $id) { - $model = $this->_couponModel::findOne($id); + $model = $this->_couponModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $model->delete(); } else { @@ -214,7 +214,7 @@ protected function actionRemove($ids) } } else { $id = $ids; - $model = $this->_couponModel::findOne($id); + $model = $this->_couponModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $model->delete(); } else { @@ -341,35 +341,35 @@ protected function updateCouponUse($type) $cu_model->save(); } else { // 通过update函数 将times_used +1 - $sql = 'update '.$this->_couponUsageModel::tableName().' set times_used = times_used + 1 where id = :id'; + $sql = 'update '.$this->_couponUsageModel->tableName().' set times_used = times_used + 1 where id = :id'; $data = [ 'id' => $cu_model['id'], ]; - $result = $this->_couponUsageModel::getDb()->createCommand($sql,$data)->execute(); + $result = $this->_couponUsageModel->getDb()->createCommand($sql,$data)->execute(); } // coupon的总使用次数+1 - $sql = 'update '.$this->_couponModel::tableName().' set times_used = times_used + 1 where coupon_id = :coupon_id '; + $sql = 'update '.$this->_couponModel->tableName().' set times_used = times_used + 1 where coupon_id = :coupon_id '; $data = [ 'coupon_id' => $c_model['coupon_id'], ]; - $result = $this->_couponModel::getDb()->createCommand($sql,$data)->execute(); + $result = $this->_couponModel->getDb()->createCommand($sql,$data)->execute(); return true; } elseif ($type == 'cancel') { $couponModel = $this->getCouponModel(); $cu_model = $this->getCouponUsageModel(); if ($cu_model) { // $this->_couponUsageModel 使用次数-1 - $sql = 'update '.$this->_couponUsageModel::tableName().' set times_used = times_used - 1 where id = :id'; + $sql = 'update '.$this->_couponUsageModel->tableName().' set times_used = times_used - 1 where id = :id'; $data = [ 'id' => $cu_model['id'], ]; - $result = $this->_couponUsageModel::getDb()->createCommand($sql,$data)->execute(); + $result = $this->_couponUsageModel->getDb()->createCommand($sql,$data)->execute(); // $this->_couponModel 使用次数-1 - $sql = 'update '.$this->_couponModel::tableName().' set times_used = times_used - 1 where coupon_id = :coupon_id '; + $sql = 'update '.$this->_couponModel->tableName().' set times_used = times_used - 1 where coupon_id = :coupon_id '; $data = [ 'coupon_id' => $c_model['coupon_id'], ]; - $result = $this->_couponModel::getDb()->createCommand($sql,$data)->execute(); + $result = $this->_couponModel->getDb()->createCommand($sql,$data)->execute(); return true; } diff --git a/services/cart/Quote.php b/services/cart/Quote.php index a58cf1109..f79659b90 100644 --- a/services/cart/Quote.php +++ b/services/cart/Quote.php @@ -113,7 +113,7 @@ public function getCurrentCart() if (!$this->_cart) { $cart_id = $this->getCartId(); if ($cart_id) { - $one = $this->_cartModel::findOne(['cart_id' => $cart_id]); + $one = $this->_cartModel->findOne(['cart_id' => $cart_id]); if ($one['cart_id']) { $this->_cart = $one; } @@ -135,7 +135,7 @@ public function getCart() if (!$cart_id) { $this->createCart(); } else { - $one = $this->_cartModel::findOne(['cart_id' => $cart_id]); + $one = $this->_cartModel->findOne(['cart_id' => $cart_id]); if ($one['cart_id']) { $this->_cart = $one; } else { @@ -167,7 +167,7 @@ public function getCartItemCount() if ($cart_id = $this->getCartId()) { if($cart_id ){ $cart = $this->getCart(); - //$one = $this->_cartModel::findOne(['cart_id' => $cart_id]); + //$one = $this->_cartModel->findOne(['cart_id' => $cart_id]); if (isset($cart['items_count']) && $cart['items_count']) { $items_count = $cart['items_count']; } @@ -248,7 +248,7 @@ protected function actionCreateCart() $myCart->save(); $cart_id = $myCart['cart_id']; $this->setCartId($cart_id); - $this->setCart($this->_cartModel::findOne($cart_id)); + $this->setCart($this->_cartModel->findOne($cart_id)); } /** 该函数已经废弃 @@ -533,7 +533,7 @@ public function mergeCartAfterUserLogin() public function getCartByCustomerId($customer_id) { if ($customer_id) { - $one = $this->_cartModel::findOne(['customer_id' => $customer_id]); + $one = $this->_cartModel->findOne(['customer_id' => $customer_id]); if ($one['cart_id']) { return $one; } diff --git a/services/cart/QuoteItem.php b/services/cart/QuoteItem.php index 40b691979..358c8ffbd 100644 --- a/services/cart/QuoteItem.php +++ b/services/cart/QuoteItem.php @@ -60,7 +60,7 @@ public function addItem($item) if (isset($item['custom_option_sku']) && !empty($item['custom_option_sku'])) { $where['custom_option_sku'] = $item['custom_option_sku']; } - $item_one = $this->_itemModel::find()->where($where)->one(); + $item_one = $this->_itemModel->find()->where($where)->one(); if ($item_one['cart_id']) { $item_one->qty = $item['qty'] + $item_one['qty']; $item_one->save(); @@ -96,7 +96,7 @@ public function changeItemQty($item) { $cart_id = Yii::$service->cart->quote->getCartId(); // 查看是否存在此产品,如果存在,则更改 - $item_one = $this->_itemModel::find()->where([ + $item_one = $this->_itemModel->find()->where([ 'cart_id' => $cart_id, 'product_id' => $item['product_id'], 'custom_option_sku' => $item['custom_option_sku'], @@ -127,7 +127,7 @@ public function getItemQty() $cart_id = Yii::$service->cart->quote->getCartId(); $item_qty = 0; if ($cart_id) { - $data = $this->_itemModel::find()->asArray()->where([ + $data = $this->_itemModel->find()->asArray()->where([ 'cart_id' => $cart_id, ])->all(); if (is_array($data) && !empty($data)) { @@ -158,7 +158,7 @@ public function getCartProductInfo() $product_weight = 0; if ($cart_id) { if (!isset($this->_cart_product_info[$cart_id])) { - $data = $this->_itemModel::find()->where([ + $data = $this->_itemModel->find()->where([ 'cart_id' => $cart_id, ])->all(); if (is_array($data) && !empty($data)) { @@ -254,7 +254,7 @@ public function addOneItem($item_id) { $cart_id = Yii::$service->cart->quote->getCartId(); if ($cart_id) { - $one = $this->_itemModel::find()->where([ + $one = $this->_itemModel->find()->where([ 'cart_id' => $cart_id, 'item_id' => $item_id, ])->one(); @@ -280,7 +280,7 @@ public function lessOneItem($item_id) { $cart_id = Yii::$service->cart->quote->getCartId(); if ($cart_id) { - $one = $this->_itemModel::find()->where([ + $one = $this->_itemModel->find()->where([ 'cart_id' => $cart_id, 'item_id' => $item_id, ])->one(); @@ -308,7 +308,7 @@ public function removeItem($item_id) { $cart_id = Yii::$service->cart->quote->getCartId(); if ($cart_id) { - $one = $this->_itemModel::find()->where([ + $one = $this->_itemModel->find()->where([ 'cart_id' => $cart_id, 'item_id' => $item_id, ])->one(); @@ -336,7 +336,7 @@ public function removeItemByCartId($cart_id = '') $cart_id = Yii::$service->cart->quote->getCartId(); } if ($cart_id) { - $items = $this->_itemModel::deleteAll([ + $items = $this->_itemModel->deleteAll([ 'cart_id' => $cart_id, //'item_id' => $item_id, ]); @@ -356,7 +356,7 @@ public function removeItemByCartId($cart_id = '') public function updateCartId($new_cart_id, $cart_id) { if ($cart_id && $new_cart_id) { - $this->_itemModel::updateAll( + $this->_itemModel->updateAll( ['cart_id'=>$new_cart_id], // $attributes 'cart_id = '.$cart_id // $condition ); diff --git a/services/category/CategoryMongodb.php b/services/category/CategoryMongodb.php index b23beb040..d26ee026b 100644 --- a/services/category/CategoryMongodb.php +++ b/services/category/CategoryMongodb.php @@ -33,7 +33,7 @@ public function __construct(){ public function getByPrimaryKey($primaryKey) { if ($primaryKey) { - return $this->_categoryModel::findOne($primaryKey); + return $this->_categoryModel->findOne($primaryKey); } else { return new $this->_categoryModelName; } @@ -50,14 +50,15 @@ public function getPrimaryKey() * 得到分类激活状态的值 */ public function getCategoryEnableStatus(){ - - return $this->_categoryModel::STATUS_ENABLE; + $model = $this->_categoryModel; + return $model::STATUS_ENABLE; } /** * 得到分类在menu中显示的状态值 */ public function getCategoryMenuShowStatus(){ - return $this->_categoryModel::MENU_SHOW; + $model = $this->_categoryModel; + return $model::MENU_SHOW; } @@ -77,7 +78,7 @@ public function getCategoryMenuShowStatus(){ */ public function coll($filter = '') { - $query = $this->_categoryModel::find(); + $query = $this->_categoryModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return [ @@ -91,7 +92,7 @@ public function coll($filter = '') */ public function collCount($filter = '') { - $query = $this->_categoryModel::find(); + $query = $this->_categoryModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return $query->count(); @@ -107,7 +108,7 @@ public function save($one, $originUrlKey = 'catalog/category/index') $currentDateTime = \fec\helpers\CDate::getCurrentDateTime(); $primaryVal = isset($one[$this->getPrimaryKey()]) ? $one[$this->getPrimaryKey()] : ''; if ($primaryVal) { - $model = $this->_categoryModel::findOne($primaryVal); + $model = $this->_categoryModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('Category '.$this->getPrimaryKey().' is not exist'); @@ -126,7 +127,7 @@ public function save($one, $originUrlKey = 'catalog/category/index') if ($parent_id === '0') { $model['level'] = 1; } else { - $parent_model = $this->_categoryModel::findOne($parent_id); + $parent_model = $this->_categoryModel->findOne($parent_id); if ($parent_level = $parent_model['level']) { $model['level'] = $parent_level + 1; } @@ -159,7 +160,7 @@ public function remove($id) return false; } - $model = $this->_categoryModel::findOne($id); + $model = $this->_categoryModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $url_key = $model['url_key']; Yii::$service->url->removeRewriteUrlKey($url_key); @@ -176,7 +177,7 @@ public function remove($id) protected function removeChildCate($id) { - $data = $this->_categoryModel::find()->where(['parent_id'=>$id])->all(); + $data = $this->_categoryModel->find()->where(['parent_id'=>$id])->all(); if (!empty($data)) { foreach ($data as $one) { $idVal = (string) $one['_id']; @@ -206,7 +207,7 @@ public function getTreeArr($rootCategoryId = '', $lang = '') } else { $where = ['parent_id' => $rootCategoryId]; } - $categorys = $this->_categoryModel::find()->asArray()->where($where)->all(); + $categorys = $this->_categoryModel->find()->asArray()->where($where)->all(); //var_dump($categorys);exit; $idKey = $this->getPrimaryKey(); if (!empty($categorys)) { @@ -229,7 +230,7 @@ public function getTreeArr($rootCategoryId = '', $lang = '') protected function hasChildCategory($idVal) { - $one = $this->_categoryModel::find()->asArray()->where(['parent_id'=>$idVal])->one(); + $one = $this->_categoryModel->find()->asArray()->where(['parent_id'=>$idVal])->one(); if (!empty($one)) { return true; } @@ -247,7 +248,7 @@ protected function hasChildCategory($idVal) public function getAllParentInfo($parent_id) { if ($parent_id) { - $parentModel = $this->_categoryModel::findOne($parent_id); + $parentModel = $this->_categoryModel->findOne($parent_id); $parent_parent_id = $parentModel['parent_id']; $parent_category = []; if ($parent_parent_id !== '0') { @@ -272,7 +273,7 @@ protected function getParentCategory($parent_id) if ($parent_id === '0') { return []; } - $category = $this->_categoryModel::find()->asArray()->where(['_id' => new \MongoDB\BSON\ObjectId($parent_id)])->one(); + $category = $this->_categoryModel->find()->asArray()->where(['_id' => new \MongoDB\BSON\ObjectId($parent_id)])->one(); if (isset($category['_id']) && !empty($category['_id'])) { $currentUrlKey = $category['url_key']; $currentName = $category['name']; @@ -306,7 +307,7 @@ public function getFilterCategory($category_id, $parent_id) { $returnData = []; $primaryKey = $this->getPrimaryKey(); - $currentCategory = $this->_categoryModel::findOne($category_id); + $currentCategory = $this->_categoryModel->findOne($category_id); $currentUrlKey = $currentCategory['url_key']; $currentName = $currentCategory['name']; $currentId = (string) $currentCategory['_id']; @@ -337,7 +338,7 @@ protected function getOneLevelCateChild($category) $_id = $category['_id']; $name = $category['name']; $url_key = $category['url_key']; - $cate = $this->_categoryModel::find()->asArray()->where([ + $cate = $this->_categoryModel->find()->asArray()->where([ 'parent_id' => $_id, ])->all(); if (is_array($cate) && !empty($cate)) { @@ -365,7 +366,7 @@ protected function getAllParentCate($allParent) $category_id = $category['_id']; $parent_id = $category['parent_id']; if ($parent_id) { - $cate = $this->_categoryModel::find()->asArray()->where([ + $cate = $this->_categoryModel->find()->asArray()->where([ 'parent_id' => $parent_id, ])->all(); //var_dump($cate); @@ -404,7 +405,7 @@ protected function getAllParentCate($allParent) protected function getChildCate($category_id) { //echo $category_id; - $data = $this->_categoryModel::find()->asArray()->where([ + $data = $this->_categoryModel->find()->asArray()->where([ 'parent_id' => $category_id, ])->all(); $arr = []; diff --git a/services/category/Menu.php b/services/category/Menu.php index a84ed1711..f5156e411 100644 --- a/services/category/Menu.php +++ b/services/category/Menu.php @@ -32,17 +32,17 @@ public function __construct(){ */ protected function actionGetCategoryMenuArr($parentId = '') { - + $model = $this->_categoryModel; $arr = []; if (!$parentId) { $parentId = $this->rootCategoryId; } - $data = $this->_categoryModel::find()->asArray()->select([ + $data = $this->_categoryModel->find()->asArray()->select([ '_id', 'parent_id', 'name', 'url_key', 'menu_custom', ])->where([ 'parent_id' => $parentId, - 'status' => $this->_categoryModel::STATUS_ENABLE, - 'menu_show' => $this->_categoryModel::MENU_SHOW, + 'status' => $model::STATUS_ENABLE, + 'menu_show' => $model::MENU_SHOW, ])->all(); if (is_array($data) && !empty($data)) { foreach ($data as $category) { @@ -71,7 +71,7 @@ protected function actionGetCategoryMenuArr($parentId = '') */ protected function hasChild($categoryId) { - $one = $this->_categoryModel::find()->asArray()->where([ + $one = $this->_categoryModel->find()->asArray()->where([ 'parent_id' => $categoryId, ])->one(); if ($one['_id']) { diff --git a/services/cms/article/ArticleMongodb.php b/services/cms/article/ArticleMongodb.php index 4ceda59be..45d58e4bd 100644 --- a/services/cms/article/ArticleMongodb.php +++ b/services/cms/article/ArticleMongodb.php @@ -35,7 +35,7 @@ public function getPrimaryKey() public function getByPrimaryKey($primaryKey) { if ($primaryKey) { - return $this->_articleModel::findOne($primaryKey); + return $this->_articleModel->findOne($primaryKey); } else { return new $this->_articleModelName; } @@ -57,7 +57,7 @@ public function getByPrimaryKey($primaryKey) */ public function coll($filter = '') { - $query = $this->_articleModel::find(); + $query = $this->_articleModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return [ @@ -75,7 +75,7 @@ public function save($one, $originUrlKey) $currentDateTime = \fec\helpers\CDate::getCurrentDateTime(); $primaryVal = isset($one[$this->getPrimaryKey()]) ? $one[$this->getPrimaryKey()] : ''; if ($primaryVal) { - $model = $this->_articleModel::findOne($primaryVal); + $model = $this->_articleModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('article '.$this->getPrimaryKey().' is not exist'); @@ -113,7 +113,7 @@ public function remove($ids) } if (is_array($ids) && !empty($ids)) { foreach ($ids as $id) { - $model = $this->_articleModel::findOne($id); + $model = $this->_articleModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $url_key = $model['url_key']; Yii::$service->url->removeRewriteUrlKey($url_key); @@ -127,7 +127,7 @@ public function remove($ids) } } else { $id = $ids; - $model = $this->_articleModel::findOne($id); + $model = $this->_articleModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $url_key = $model['url_key']; Yii::$service->url->removeRewriteUrlKey($url_key); diff --git a/services/cms/article/ArticleMysqldb.php b/services/cms/article/ArticleMysqldb.php index 5420ad7a2..958a65c55 100644 --- a/services/cms/article/ArticleMysqldb.php +++ b/services/cms/article/ArticleMysqldb.php @@ -44,7 +44,7 @@ public function getPrimaryKey() public function getByPrimaryKey($primaryKey) { if ($primaryKey) { - $one = $this->_articleModel::findOne($primaryKey); + $one = $this->_articleModel->findOne($primaryKey); foreach ($this->_lang_attr as $attrName) { if (isset($one[$attrName])) { $one[$attrName] = unserialize($one[$attrName]); @@ -73,7 +73,7 @@ public function getByPrimaryKey($primaryKey) */ public function coll($filter = '') { - $query = $this->_articleModel::find(); + $query = $this->_articleModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); $coll = $query->all(); if (!empty($coll)) { @@ -100,7 +100,7 @@ public function save($one, $originUrlKey) $currentDateTime = \fec\helpers\CDate::getCurrentDateTime(); $primaryVal = isset($one[$this->getPrimaryKey()]) ? $one[$this->getPrimaryKey()] : ''; if ($primaryVal) { - $model = $this->_articleModel::findOne($primaryVal); + $model = $this->_articleModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('article '.$this->getPrimaryKey().' is not exist'); @@ -142,7 +142,7 @@ public function remove($ids) $innerTransaction = Yii::$app->db->beginTransaction(); try { foreach ($ids as $id) { - $model = $this->_articleModel::findOne($id); + $model = $this->_articleModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $url_key = $model['url_key']; Yii::$service->url->removeRewriteUrlKey($url_key); @@ -165,7 +165,7 @@ public function remove($ids) } } else { $id = $ids; - $model = $this->_articleModel::findOne($id); + $model = $this->_articleModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $innerTransaction = Yii::$app->db->beginTransaction(); try { diff --git a/services/cms/staticblock/StaticBlockMongodb.php b/services/cms/staticblock/StaticBlockMongodb.php index a611fe680..da78072a3 100644 --- a/services/cms/staticblock/StaticBlockMongodb.php +++ b/services/cms/staticblock/StaticBlockMongodb.php @@ -34,7 +34,7 @@ public function getPrimaryKey() public function getByPrimaryKey($primaryKey) { if ($primaryKey) { - return $this->_staticBlockModel::findOne($primaryKey); + return $this->_staticBlockModel->findOne($primaryKey); } else { return new $this->_staticBlockModelName(); } @@ -42,7 +42,7 @@ public function getByPrimaryKey($primaryKey) public function getByIdentify($identify) { - return $this->_staticBlockModel::find()->asArray()->where([ + return $this->_staticBlockModel->find()->asArray()->where([ 'identify' => $identify, ])->one(); } @@ -63,7 +63,7 @@ public function getByIdentify($identify) */ public function coll($filter = '') { - $query = $this->_staticBlockModel::find(); + $query = $this->_staticBlockModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return [ @@ -86,7 +86,7 @@ public function save($one) return; } if ($primaryVal) { - $model = $this->_staticBlockModel::findOne($primaryVal); + $model = $this->_staticBlockModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('StaticBlock '.$this->getPrimaryKey().' is not exist'); @@ -113,7 +113,7 @@ protected function validateIdentify($one) $id = $this->getPrimaryKey(); $primaryVal = isset($one[$id]) ? $one[$id] : ''; $where = ['identify' => $identify]; - $query = $this->_staticBlockModel::find()->asArray(); + $query = $this->_staticBlockModel->find()->asArray(); $query->where(['identify' => $identify]); if ($primaryVal) { $query->andWhere([$id => ['$ne'=> new \MongoDB\BSON\ObjectId($primaryVal)]]); @@ -139,12 +139,12 @@ public function remove($ids) } if (is_array($ids) && !empty($ids)) { foreach ($ids as $id) { - $model = $this->_staticBlockModel::findOne($id); + $model = $this->_staticBlockModel->findOne($id); $model->delete(); } } else { $id = $ids; - $model = $this->_staticBlockModel::findOne($id); + $model = $this->_staticBlockModel->findOne($id); $model->delete(); } diff --git a/services/cms/staticblock/StaticBlockMysqldb.php b/services/cms/staticblock/StaticBlockMysqldb.php index a4e17162b..279b014bb 100644 --- a/services/cms/staticblock/StaticBlockMysqldb.php +++ b/services/cms/staticblock/StaticBlockMysqldb.php @@ -41,7 +41,7 @@ public function getPrimaryKey() public function getByPrimaryKey($primaryKey) { if ($primaryKey) { - $one = $this->_staticBlockModel::findOne($primaryKey); + $one = $this->_staticBlockModel->findOne($primaryKey); foreach ($this->_lang_attr as $attrName) { if (isset($one[$attrName])) { $one[$attrName] = unserialize($one[$attrName]); @@ -56,7 +56,7 @@ public function getByPrimaryKey($primaryKey) public function getByIdentify($identify) { - $one = $this->_staticBlockModel::find()->asArray()->where([ + $one = $this->_staticBlockModel->find()->asArray()->where([ 'identify' => $identify, ])->one(); foreach ($this->_lang_attr as $attrName) { @@ -84,7 +84,7 @@ public function getByIdentify($identify) */ public function coll($filter = '') { - $query = $this->_staticBlockModel::find(); + $query = $this->_staticBlockModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); $coll = $query->all(); if (!empty($coll)) { @@ -116,7 +116,7 @@ public function save($one) return; } if ($primaryVal) { - $model = $this->_staticBlockModel::findOne($primaryVal); + $model = $this->_staticBlockModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('static block '.$this->getPrimaryKey().' is not exist'); @@ -146,7 +146,7 @@ protected function validateIdentify($one) $id = $this->getPrimaryKey(); $primaryVal = isset($one[$id]) ? $one[$id] : ''; $where = ['identify' => $identify]; - $query = $this->_staticBlockModel::find()->asArray(); + $query = $this->_staticBlockModel->find()->asArray(); $query->where(['identify' => $identify]); if ($primaryVal) { $query->andWhere(['<>', $id, $primaryVal]); @@ -168,13 +168,13 @@ public function remove($ids) } if (is_array($ids) && !empty($ids)) { foreach ($ids as $id) { - $model = $this->_staticBlockModel::findOne($id); + $model = $this->_staticBlockModel->findOne($id); $model->delete(); } } else { $id = $ids; foreach ($ids as $id) { - $model = $this->_staticBlockModel::findOne($id); + $model = $this->_staticBlockModel->findOne($id); $model->delete(); } } diff --git a/services/customer/Address.php b/services/customer/Address.php index bf78c2758..d0008574c 100644 --- a/services/customer/Address.php +++ b/services/customer/Address.php @@ -41,7 +41,7 @@ protected function actionGetPrimaryKey() */ protected function actionGetByPrimaryKey($primaryKey) { - $one = $this->_addressModel::findOne($primaryKey); + $one = $this->_addressModel->findOne($primaryKey); $primaryKey = $this->getPrimaryKey(); if ($one[$primaryKey]) { return $one; @@ -58,7 +58,7 @@ protected function actionGetByPrimaryKey($primaryKey) protected function actionGetAddressByIdAndCustomerId($address_id, $customer_id) { $primaryKey = $this->getPrimaryKey(); - $one = $this->_addressModel::findOne([ + $one = $this->_addressModel->findOne([ $primaryKey => $address_id, 'customer_id' => $customer_id, ]); @@ -88,7 +88,7 @@ protected function actionGetAddressByIdAndCustomerId($address_id, $customer_id) */ protected function actionColl($filter = '') { - $query = $this->_addressModel::find(); + $query = $this->_addressModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); $coll = $query->all(); @@ -171,7 +171,7 @@ protected function actionSave($one) $primaryKey = $this->getPrimaryKey(); $primaryVal = isset($one[$primaryKey]) ? $one[$primaryKey] : ''; if ($primaryVal) { - $model = $this->_addressModel::findOne($primaryVal); + $model = $this->_addressModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('address '.$this->getPrimaryKey().' is not exist'); @@ -186,7 +186,7 @@ protected function actionSave($one) $primaryVal = $model[$primaryKey]; if ($one['is_default'] == 1) { $customer_id = $one['customer_id']; - $this->_addressModel::updateAll( + $this->_addressModel->updateAll( ['is_default'=>2], // $attributes 'customer_id = '.$customer_id.' and '.$primaryKey.' != ' .$primaryVal // $condition //[':customer_id' => $customer_id] @@ -212,7 +212,7 @@ protected function actionRemove($ids, $customer_id) } if (is_array($ids) && !empty($ids)) { foreach ($ids as $id) { - $model = $this->_addressModel::findOne($id); + $model = $this->_addressModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { if ($customer_id) { if ($model['customer_id'] == $customer_id) { @@ -234,7 +234,7 @@ protected function actionRemove($ids, $customer_id) } } else { $id = $ids; - $model = $this->_addressModel::findOne($id); + $model = $this->_addressModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { if ($customer_id) { if ($model['customer_id'] == $customer_id) { @@ -256,11 +256,11 @@ protected function actionRemove($ids, $customer_id) } // 查看是否有默认地址?如果该用户存在记录,但是没有默认地址, // 则查找用户是否存在非默认地址,如果存在,则取一个设置为默认地址 - $addressOne = $this->_addressModel::find()->asArray() + $addressOne = $this->_addressModel->find()->asArray() ->where(['customer_id' => $customer_id, 'is_default' => 1]) ->one(); if (!$addressOne['address_id']) { - $assOne = $this->_addressModel::find() + $assOne = $this->_addressModel->find() ->where(['customer_id' => $customer_id]) ->one(); if ($assOne['address_id']) { @@ -300,13 +300,13 @@ protected function actionGetDefaultAddress($customer_id = ''){ $customer_id = $identity['id']; } if($customer_id ){ - $addressOne = $this->_addressModel::find()->asArray() + $addressOne = $this->_addressModel->find()->asArray() ->where(['customer_id' => $customer_id,'is_default' => 1]) ->one(); if($addressOne['address_id']){ return $addressOne; }else{ - $assOne = $this->_addressModel::find()->asArray() + $assOne = $this->_addressModel->find()->asArray() ->where(['customer_id' => $customer_id]) ->one(); if($assOne['address_id']){ diff --git a/services/customer/Newsletter.php b/services/customer/Newsletter.php index 20c9561cf..e8bcae548 100644 --- a/services/customer/Newsletter.php +++ b/services/customer/Newsletter.php @@ -33,8 +33,8 @@ public function __construct(){ */ protected function emailIsExist($emailAddress) { - $primaryKey = $this->_newsletterModel::primaryKey(); - $one = $this->_newsletterModel::findOne(['email' => $emailAddress]); + $primaryKey = $this->_newsletterModel->primaryKey(); + $one = $this->_newsletterModel->findOne(['email' => $emailAddress]); if ($one[$primaryKey]) { return true; } @@ -62,10 +62,11 @@ protected function actionSubscribe($emailAddress) return; } + $model = $this->_newsletterModel; $newsletterModel = new $this->_newsletterModelName(); $newsletterModel->email = $emailAddress; $newsletterModel->created_at = time(); - $newsletterModel->status = $this->_newsletterModel::ENABLE_STATUS; + $newsletterModel->status = $model::ENABLE_STATUS; $newsletterModel->save(); return true; diff --git a/services/helper/Log.php b/services/helper/Log.php index e944e1860..726a20091 100644 --- a/services/helper/Log.php +++ b/services/helper/Log.php @@ -72,7 +72,7 @@ public function isServiceLogEnable() public function printServiceLog($log_info) { if ($this->isServiceLogDbPrint()) { - $this->_logModel::getCollection()->save($log_info); + $this->_logModel->getCollection()->save($log_info); } if ($this->isServiceLogHtmlPrint() || $this->isServiceLogDbPrintByParam()) { $str = '
#################################
'; diff --git a/services/order/Item.php b/services/order/Item.php index 752112c87..02d642e84 100644 --- a/services/order/Item.php +++ b/services/order/Item.php @@ -34,7 +34,7 @@ public function __construct(){ */ protected function actionGetByOrderId($order_id, $onlyFromTable = false) { - $items = $this->_itemModel::find()->asArray()->where([ + $items = $this->_itemModel->find()->asArray()->where([ 'order_id' => $order_id, ])->all(); if ($onlyFromTable) { @@ -177,7 +177,7 @@ protected function actionSaveOrderItems($items, $order_id, $store) * 由于是通过session查订单的方式,而不是新建,paypal报错可能多次下单(更新方式), * 因此在添加订单产品的时候先进行一次删除产品操作。 */ - $this->_itemModel::deleteAll(['order_id' => $order_id]); + $this->_itemModel->deleteAll(['order_id' => $order_id]); if (is_array($items) && !empty($items) && $order_id && $store) { foreach ($items as $item) { $myOrderItem = new $this->_itemModelName(); diff --git a/services/page/Newsletter.php b/services/page/Newsletter.php index 8e6bcc79a..64a674141 100644 --- a/services/page/Newsletter.php +++ b/services/page/Newsletter.php @@ -36,7 +36,7 @@ protected function actionSubscription($email) 'email' => $email, ]; if ($mongoNewsletter->validate()) { - $one = $this->_newsletterModel::find()->where(['email' => $email])->one(); + $one = $this->_newsletterModel->find()->where(['email' => $email])->one(); if ($one['id']) { return [ 'code' => 300, diff --git a/services/product/Favorite.php b/services/product/Favorite.php index 693ee48e7..31f855acc 100644 --- a/services/product/Favorite.php +++ b/services/product/Favorite.php @@ -34,7 +34,7 @@ protected function actionGetPrimaryKey() protected function actionGetByPrimaryKey($val) { - $one = $this->_favoriteModel::findOne($val); + $one = $this->_favoriteModel->findOne($val); if ($one[$this->getPrimaryKey()]) { return $one; } else { @@ -53,7 +53,7 @@ protected function actionGetByProductIdAndUserId($product_id, $user_id = '') $user_id = $identity['id']; } if ($user_id) { - $one = $this->_favoriteModel::findOne([ + $one = $this->_favoriteModel->findOne([ 'product_id' => $product_id, 'user_id' => $user_id, ]); @@ -80,7 +80,7 @@ protected function actionAdd($product_id, $user_id) } //echo $product_id;exit; $favoritePrimaryKey = Yii::$service->product->favorite->getPrimaryKey(); - $one = $this->_favoriteModel::findOne([ + $one = $this->_favoriteModel->findOne([ 'product_id' => $product_id, 'user_id' => $user_id, ]); @@ -112,7 +112,7 @@ protected function actionAdd($product_id, $user_id) protected function updateProductFavoriteCount($product_id) { if ($product_id) { - $count = $this->_favoriteModel::find()->where(['product_id'=>$product_id])->count(); + $count = $this->_favoriteModel->find()->where(['product_id'=>$product_id])->count(); $product = Yii::$service->product->getByPrimaryKey($product_id); if ($product['_id']) { $product->favorite_count = $count; @@ -132,7 +132,7 @@ protected function updateUserFavoriteCount($user_id = '') $user_id = $identity['id']; } if ($user_id) { - $count = $this->_favoriteModel::find()->where(['user_id'=>$user_id])->count(); + $count = $this->_favoriteModel->find()->where(['user_id'=>$user_id])->count(); $identity->favorite_product_count = $count; $identity->save(); } @@ -154,7 +154,7 @@ protected function updateUserFavoriteCount($user_id = '') */ protected function actionList($filter) { - $query = $this->_favoriteModel::find(); + $query = $this->_favoriteModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return [ @@ -177,7 +177,7 @@ protected function actionCurrentUserRemove($favorite_id) $identity = Yii::$app->user->identity; $user_id = $identity['id']; - $one = $this->_favoriteModel::findOne([ + $one = $this->_favoriteModel->findOne([ '_id' => new \MongoDB\BSON\ObjectId($favorite_id), 'user_id' => $user_id, ]); diff --git a/services/product/ProductMongodb.php b/services/product/ProductMongodb.php index 1c902bbfb..8388bb823 100644 --- a/services/product/ProductMongodb.php +++ b/services/product/ProductMongodb.php @@ -36,13 +36,14 @@ public function getPrimaryKey() * 得到分类激活状态的值 */ public function getEnableStatus(){ - return $this->_productModel::STATUS_ENABLE; + $model = $this->_productModel; + return $model::STATUS_ENABLE; } public function getByPrimaryKey($primaryKey) { if ($primaryKey) { - return $this->_productModel::findOne($primaryKey); + return $this->_productModel->findOne($primaryKey); } else { return new $this->_productModelName(); } @@ -59,11 +60,11 @@ public function getBySku($sku, $returnArr = true) { if ($sku) { if ($returnArr) { - $product = $this->_productModel::find()->asArray() + $product = $this->_productModel->find()->asArray() ->where(['sku' => $sku]) ->one(); } else { - $product = $this->_productModel::findOne(['sku' => $sku]); + $product = $this->_productModel->findOne(['sku' => $sku]); } $primaryKey = $this->getPrimaryKey(); if (isset($product[$primaryKey]) && !empty($product[$primaryKey])) { @@ -83,11 +84,11 @@ public function getBySpu($spu, $returnArr = true) { if ($spu) { if ($returnArr) { - return $this->_productModel::find()->asArray() + return $this->_productModel->find()->asArray() ->where(['spu' => $spu]) ->all(); } else { - return $this->_productModel::find() + return $this->_productModel->find() ->where(['spu' => $spu]) ->all(); } @@ -112,7 +113,7 @@ public function getBySpu($spu, $returnArr = true) */ public function coll($filter = '') { - $query = $this->_productModel::find(); + $query = $this->_productModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return [ @@ -128,7 +129,7 @@ public function coll($filter = '') */ public function apicoll() { - $collection = $this->_productModel::find()->getCollection(); + $collection = $this->_productModel->find()->getCollection(); $cursor = $collection->find(); $count = $collection->count(); $arr = []; @@ -149,7 +150,7 @@ public function apicoll() */ public function apiGetByPrimaryKey($primaryKey) { - $collection = $this->_productModel::find()->getCollection(); + $collection = $this->_productModel->find()->getCollection(); $cursor = $collection->findOne(['_id' => $primaryKey]); $arr = []; foreach ($cursor as $k => $v) { @@ -165,7 +166,7 @@ public function apiGetByPrimaryKey($primaryKey) */ public function apiSave($product_one) { - $collection = $this->_productModel::find()->getCollection(); + $collection = $this->_productModel->find()->getCollection(); $collection->save($product_one); return true; @@ -177,7 +178,7 @@ public function apiSave($product_one) */ public function apiDelete($primaryKey) { - $collection = $this->_productModel::find()->getCollection(); + $collection = $this->_productModel->find()->getCollection(); $collection->remove(['_id' => $primaryKey]); return true; @@ -200,7 +201,7 @@ public function apiDelete($primaryKey) */ public function collCount($filter = '') { - $query = $this->_productModel::find(); + $query = $this->_productModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return $query->count(); @@ -217,7 +218,7 @@ public function getCategoryProductIds($product_id_arr, $category_id) { $id_arr = []; if (is_array($product_id_arr) && !empty($product_id_arr)) { - $query = $this->_productModel::find()->asArray(); + $query = $this->_productModel->find()->asArray(); $mongoIds = []; foreach ($product_id_arr as $id) { $mongoIds[] = new \MongoDB\BSON\ObjectId($id); @@ -245,7 +246,7 @@ public function addGroupAttrs($attr_group) $attrInfo = Yii::$service->product->getGroupAttrInfo($attr_group); if (is_array($attrInfo) && !empty($attrInfo)) { $attrs = array_keys($attrInfo); - $this->_productModel::addCustomProductAttrs($attrs); + $this->_productModel->addCustomProductAttrs($attrs); } } @@ -264,7 +265,7 @@ public function save($one, $originUrlKey = 'catalog/product/index') $currentDateTime = \fec\helpers\CDate::getCurrentDateTime(); $primaryVal = isset($one[$this->getPrimaryKey()]) ? $one[$this->getPrimaryKey()] : ''; if ($primaryVal) { - $model = $this->_productModel::findOne($primaryVal); + $model = $this->_productModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('Product '.$this->getPrimaryKey().' is not exist'); @@ -272,7 +273,7 @@ public function save($one, $originUrlKey = 'catalog/product/index') } //验证sku 是否重复 - $product_one = $this->_productModel::find()->asArray()->where([ + $product_one = $this->_productModel->find()->asArray()->where([ '<>', $this->getPrimaryKey(), (new \MongoDB\BSON\ObjectId($primaryVal)), ])->andWhere([ 'sku' => $one['sku'], @@ -289,7 +290,7 @@ public function save($one, $originUrlKey = 'catalog/product/index') $primaryVal = new \MongoDB\BSON\ObjectId(); $model->{$this->getPrimaryKey()} = $primaryVal; //验证sku 是否重复 - $product_one = $this->_productModel::find()->asArray()->where([ + $product_one = $this->_productModel->find()->asArray()->where([ 'sku' => $one['sku'], ])->one(); if ($product_one['sku']) { @@ -382,7 +383,7 @@ public function remove($ids) } if (is_array($ids)) { foreach ($ids as $id) { - $model = $this->_productModel::findOne($id); + $model = $this->_productModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $url_key = $model['url_key']; // 删除在重写url里面的数据。 @@ -401,7 +402,7 @@ public function remove($ids) } } else { $id = $ids; - $model = $this->_productModel::findOne($id); + $model = $this->_productModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $url_key = $model['url_key']; // 删除在重写url里面的数据。 @@ -438,7 +439,7 @@ public function addAndDeleteProductCategory($category_id, $addCateProductIdArr, if (!$product_id) { continue; } - $product = $this->_productModel::findOne($product_id); + $product = $this->_productModel->findOne($product_id); if (!$product[$idKey]) { continue; } @@ -460,7 +461,7 @@ public function addAndDeleteProductCategory($category_id, $addCateProductIdArr, if (!$product_id) { continue; } - $product = $this->_productModel::findOne($product_id); + $product = $this->_productModel->findOne($product_id); if (!$product[$idKey]) { continue; } @@ -491,7 +492,7 @@ public function getProducts($filter) return []; } $select = $filter['select']; - $query = $this->_productModel::find()->asArray(); + $query = $this->_productModel->find()->asArray(); $query->where($where); $query->andWhere(['status' => $this->getEnableStatus()]); if (is_array($select) && !empty($select)) { @@ -559,7 +560,7 @@ public function getFrontCategoryProducts($filter) '$sort' => $orderBy, ], ]; - $product_data = $this->_productModel::getCollection()->aggregate($pipelines); + $product_data = $this->_productModel->getCollection()->aggregate($pipelines); $product_total_count = count($product_data); $pageOffset = ($pageNum - 1) * $numPerPage; $products = array_slice($product_data, $pageOffset, $numPerPage); @@ -595,7 +596,7 @@ public function getFrontCategoryFilter($filter_attr, $where) '$group' => $group, ], ]; - $filter_data = $this->_productModel::getCollection()->aggregate($pipelines); + $filter_data = $this->_productModel->getCollection()->aggregate($pipelines); return $filter_data; } @@ -610,7 +611,7 @@ public function getFrontCategoryFilter($filter_attr, $where) */ public function updateProductReviewInfo($spu, $avag_rate, $count, $lang_code, $avag_lang_rate, $lang_count) { - $data = $this->_productModel::find()->where([ + $data = $this->_productModel->find()->where([ 'spu' => $spu, ])->all(); if (!empty($data) && is_array($data)) { diff --git a/services/product/Review.php b/services/product/Review.php index 695c3341e..c77b001e9 100644 --- a/services/product/Review.php +++ b/services/product/Review.php @@ -9,7 +9,7 @@ namespace fecshop\services\product; -use fecshop\models\mongodb\product\Review as ReviewModel; +//use fecshop\models\mongodb\product\Review as ReviewModel; use fecshop\services\Service; use Yii; use yii\base\InvalidValueException; @@ -22,13 +22,19 @@ class Review extends Service { public $filterByLang; - + protected $_reviewModelName = '\fecshop\models\mongodb\product\Review'; + protected $_reviewModel; + + public function __construct(){ + list($this->_reviewModelName,$this->_reviewModel) = \Yii::mapGet($this->_reviewModelName); + } /** * 得到review noactive status,默认状态 */ protected function actionNoActiveStatus() { - return ReviewModel::NOACTIVE_STATUS; + $model = $this->_reviewModel; + return $model::NOACTIVE_STATUS; } /** @@ -36,7 +42,8 @@ protected function actionNoActiveStatus() */ protected function actionActiveStatus() { - return ReviewModel::ACTIVE_STATUS; + $model = $this->_reviewModel; + return $model::ACTIVE_STATUS; } /** @@ -44,7 +51,8 @@ protected function actionActiveStatus() */ protected function actionRefuseStatus() { - return ReviewModel::REFUSE_STATUS; + $model = $this->_reviewModel; + return $model::REFUSE_STATUS; } /** @@ -54,11 +62,10 @@ protected function actionRefuseStatus() protected function actionInitReviewAttr($arr) { if (!empty($arr) && is_array($arr)) { - $ReviewModel = new ReviewModel(); - $attr_arr = $ReviewModel->attributes(true); + $attr_arr = $this->_reviewModel->attributes(true); $arr_keys = array_keys($arr); $attrs = array_diff($arr_keys, $attr_arr); - ReviewModel::addCustomAttrs($attrs); + $this->_reviewModel->addCustomAttrs($attrs); } } @@ -80,7 +87,7 @@ protected function actionGetCountBySpu($spu) if ($this->filterByLang && ($currentLangCode = Yii::$service->store->currentLangCode)) { $where['lang_code'] = $currentLangCode; } - $count = ReviewModel::find()->asArray()->where($where)->count(); + $count = $this->_reviewModel->find()->asArray()->where($where)->count(); return $count ? $count : 0; } @@ -103,7 +110,7 @@ protected function actionGetListBySpu($filter) if ($this->filterByLang && ($currentLangCode = Yii::$service->store->currentLangCode)) { $filter['where'][] = ['lang_code' => $currentLangCode]; } - $query = ReviewModel::find(); + $query = $this->_reviewModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return [ @@ -120,12 +127,12 @@ protected function actionGetListBySpu($filter) protected function actionAddReview($review_data) { //$this->initReviewAttr($review_data); - $model = new ReviewModel(); + $model = new $this->_reviewModelName(); if (isset($review_data[$this->getPrimaryKey()])) { unset($review_data[$this->getPrimaryKey()]); } - - $review_data['status'] = ReviewModel::NOACTIVE_STATUS; + $model = $this->_reviewModel; + $review_data['status'] = $model::NOACTIVE_STATUS; $review_data['store'] = Yii::$service->store->currentStore; $review_data['lang_code'] = Yii::$service->store->currentLangCode; @@ -149,7 +156,7 @@ protected function actionAddReview($review_data) protected function actionUpdateReview($review_data) { //$this->initReviewAttr($review_data); - $model = ReviewModel::findOne([$this->getPrimaryKey()=> $review_data[$this->getPrimaryKey()]]); + $model = $this->_reviewModel->findOne([$this->getPrimaryKey()=> $review_data[$this->getPrimaryKey()]]); unset($review_data[$this->getPrimaryKey()]); $saveStatus = Yii::$service->helper->ar->save($model, $review_data); @@ -173,7 +180,7 @@ protected function actionUpdateReview($review_data) */ protected function actionList($filter) { - $query = ReviewModel::find(); + $query = $this->_reviewModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return [ @@ -190,7 +197,7 @@ protected function actionList($filter) */ protected function actionGetByReviewId($_id) { - return ReviewModel::getCollection()->findOne([$this->getPrimaryKey() => $_id]); + return $this->_reviewModel->getCollection()->findOne([$this->getPrimaryKey() => $_id]); } /** @@ -200,9 +207,9 @@ protected function actionGetByReviewId($_id) protected function actionGetByPrimaryKey($primaryKey) { if ($primaryKey) { - return ReviewModel::findOne($primaryKey); + return $this->_reviewModel->findOne($primaryKey); } else { - return new ReviewModel(); + return new $this->_reviewModelName(); } } @@ -241,19 +248,19 @@ protected function actionSave($one) $one['rate_star'] = (int) $one['rate_star']; if ($primaryVal) { - $model = ReviewModel::findOne($primaryVal); + $model = $this->_reviewModel->findOne($primaryVal); if (!$model) { - Yii::$service->helper->errors->add('ReviewModel '.$this->getPrimaryKey().' is not exist'); + Yii::$service->helper->errors->add('reviewModel '.$this->getPrimaryKey().' is not exist'); return; } } else { - $model = new ReviewModel(); + $model = new $this->_reviewModelName(); $model->created_admin_user_id = \fec\helpers\CUser::getCurrentUserId(); $primaryVal = new \MongoDB\BSON\ObjectId(); $model->{$this->getPrimaryKey()} = $primaryVal; } - //$review_data['status'] = ReviewModel::ACTIVE_STATUS; + //$review_data['status'] = $this->_reviewModel->ACTIVE_STATUS; $model->review_date = time(); unset($one[$this->getPrimaryKey()]); $saveStatus = Yii::$service->helper->ar->save($model, $one); @@ -277,7 +284,7 @@ protected function actionRemove($ids) } if (is_array($ids) && !empty($ids)) { foreach ($ids as $id) { - $model = ReviewModel::findOne($id); + $model = $this->_reviewModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $product_spu = $model['product_spu']; $model->delete(); @@ -292,7 +299,7 @@ protected function actionRemove($ids) } } else { $id = $ids; - $model = ReviewModel::findOne($id); + $model = $this->_reviewModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $model->delete(); } else { @@ -311,15 +318,16 @@ protected function actionRemove($ids) */ protected function actionAuditReviewByIds($ids) { + $reviewModel = $this->_reviewModel; if (is_array($ids) && !empty($ids)) { $identity = Yii::$app->user->identity; $user_id = $identity['id']; foreach ($ids as $id) { - $model = ReviewModel::findOne($id); + $model = $this->_reviewModel->findOne($id); if ($model[$this->getPrimaryKey()]) { $model->audit_user = $user_id; $model->audit_date = time(); - $model->status = ReviewModel::ACTIVE_STATUS; + $model->status = $reviewModel->ACTIVE_STATUS; $model->save(); // 更新评论信息到产品表中。 $this->updateProductSpuReview($model['product_spu'], $model['lang_code']); @@ -334,15 +342,16 @@ protected function actionAuditReviewByIds($ids) */ protected function actionAuditRejectedReviewByIds($ids) { + $reviewModel = $this->_reviewModel; if (is_array($ids) && !empty($ids)) { $identity = Yii::$app->user->identity; $user_id = $identity['id']; foreach ($ids as $id) { - $model = ReviewModel::findOne($id); + $model = $this->_reviewModel->findOne($id); if ($model[$this->getPrimaryKey()]) { $model->audit_user = $user_id; $model->audit_date = time(); - $model->status = ReviewModel::REFUSE_STATUS; + $model->status = $reviewModel->REFUSE_STATUS; $model->save(); // 更新评论的信息到产品表 $this->updateProductSpuReview($model['product_spu'], $model['lang_code']); @@ -357,10 +366,11 @@ protected function actionAuditRejectedReviewByIds($ids) */ protected function actionUpdateProductSpuReview($spu, $lang_code) { + $reviewModel = $this->_reviewModel; $filter = [ 'where' => [ ['product_spu' => $spu], - ['status' => ReviewModel::ACTIVE_STATUS], + ['status' => $reviewModel->ACTIVE_STATUS], ], ]; $coll = $this->coll($filter); @@ -412,7 +422,7 @@ protected function actionUpdateProductSpuReview($spu, $lang_code) */ protected function actionGetReviewsByUserId($filter) { - $query = ReviewModel::find(); + $query = $this->_reviewModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return [ diff --git a/services/product/Stock.php b/services/product/Stock.php index 375ab3738..2e9eee05b 100644 --- a/services/product/Stock.php +++ b/services/product/Stock.php @@ -54,7 +54,7 @@ public function getQtyByProductIds($productIds){ Yii::$service->helper->errors->add('ProductIds must be Array'); return false; } - $data = $this->_flatQtyModel::find()->asArray()->where([ + $data = $this->_flatQtyModel->find()->asArray()->where([ 'in','product_id',$productIds ])->all(); $arr = []; @@ -86,7 +86,7 @@ public function saveProductStock($product_id,$one){ Yii::$service->helper->errors->add('save product qty error: product qty is empty'); } // 保存产品flat qty - $productFlatQty = $this->_flatQtyModel::find() + $productFlatQty = $this->_flatQtyModel->find() ->where(['product_id' => $product_id]) ->one(); if(!$productFlatQty['product_id']){ @@ -101,7 +101,7 @@ public function saveProductStock($product_id,$one){ $co_sku_arr = $this->getProductCustomOptionSkuArr($product_id); $product_sku_arr = []; foreach($one['custom_option'] as $custom_option_sku => $c_one){ - $productCustomOptionQty = $this->_COQtyModel::find() + $productCustomOptionQty = $this->_COQtyModel->find() ->where([ 'product_id' => $product_id, 'custom_option_sku' => $custom_option_sku, @@ -120,7 +120,7 @@ public function saveProductStock($product_id,$one){ //var_dump($delete_sku_arr); // 删除掉产品中不存在customOptionSku对应的库存、 if(!empty($delete_sku_arr) && is_array($delete_sku_arr)){ - $this->_COQtyModel::deleteAll([ + $this->_COQtyModel->deleteAll([ 'and', ['product_id' => $product_id], ['in','custom_option_sku',$delete_sku_arr] @@ -138,7 +138,7 @@ public function removeProductStock($product_id){ Yii::$service->helper->errors->add('remove product qty error: product is empty'); } // 保存产品flat qty - $this->_flatQtyModel::deleteAll(['product_id' => $product_id]); + $this->_flatQtyModel->deleteAll(['product_id' => $product_id]); productCustomOptionQty::deleteAll(['product_id' => $product_id]); return true; } @@ -191,13 +191,13 @@ protected function actionDeduct($items = '') if ($product_id && $sale_qty) { if(!$custom_option_sku){ // 应对高并发库存超卖的控制,更新后在查询产品的库存,如果库存小于则回滚。 - $sql = 'update '.$this->_flatQtyModel::tableName().' set qty = qty - :sale_qty where product_id = :product_id'; + $sql = 'update '.$this->_flatQtyModel->tableName().' set qty = qty - :sale_qty where product_id = :product_id'; $data = [ 'sale_qty' => $sale_qty, 'product_id'=> $product_id, ]; - $result = $this->_flatQtyModel::getDb()->createCommand($sql,$data)->execute(); - $productFlatQty = $this->_flatQtyModel::find()->where([ + $result = $this->_flatQtyModel->getDb()->createCommand($sql,$data)->execute(); + $productFlatQty = $this->_flatQtyModel->find()->where([ 'product_id' => $product_id ])->one(); if($productFlatQty['qty'] < 0){ @@ -206,14 +206,14 @@ protected function actionDeduct($items = '') } }else{ // 对于custom option(淘宝模式)的库存扣除 - $sql = 'update '.$this->_COQtyModel::tableName().' set qty = qty - :sale_qty where product_id = :product_id and custom_option_sku = :custom_option_sku'; + $sql = 'update '.$this->_COQtyModel->tableName().' set qty = qty - :sale_qty where product_id = :product_id and custom_option_sku = :custom_option_sku'; $data = [ 'sale_qty' => $sale_qty, 'product_id'=> $product_id, 'custom_option_sku' => $custom_option_sku ]; - $result = $this->_COQtyModel::getDb()->createCommand($sql,$data)->execute(); - $productCustomOptionQty = $this->_COQtyModel::find()->where([ + $result = $this->_COQtyModel->getDb()->createCommand($sql,$data)->execute(); + $productCustomOptionQty = $this->_COQtyModel->find()->where([ 'product_id' => $product_id, 'custom_option_sku' => $custom_option_sku, ])->one(); @@ -299,7 +299,7 @@ protected function actionCheckItemsQty() $custom_option_sku = $item['custom_option_sku']; if ($product_id && $sale_qty) { if(!$custom_option_sku){ - $productM = $this->_flatQtyModel::find()->where([ + $productM = $this->_flatQtyModel->find()->where([ 'product_id' => $product_id ])->one(); @@ -323,7 +323,7 @@ protected function actionCheckItemsQty() ]; } }else{ - $productCustomOptionM = $this->_COQtyModel::find()->where([ + $productCustomOptionM = $this->_COQtyModel->find()->where([ 'product_id' => $product_id, 'custom_option_sku' => $custom_option_sku, ])->one(); @@ -396,22 +396,22 @@ protected function actionReturnQty($product_items) $custom_option_sku = $item['custom_option_sku']; if ($product_id && $sale_qty) { if(!$custom_option_sku){ - $sql = 'update '.$this->_flatQtyModel::tableName().' set qty = qty + :sale_qty where product_id = :product_id'; + $sql = 'update '.$this->_flatQtyModel->tableName().' set qty = qty + :sale_qty where product_id = :product_id'; $data = [ 'sale_qty' => $sale_qty, 'product_id'=> $product_id, ]; - $result = $this->_flatQtyModel::getDb()->createCommand($sql,$data)->execute(); + $result = $this->_flatQtyModel->getDb()->createCommand($sql,$data)->execute(); }else{ // 对于custom option(淘宝模式)的库存扣除 - $sql = 'update '.$this->_COQtyModel::tableName().' set qty = qty + :sale_qty where product_id = :product_id and custom_option_sku = :custom_option_sku'; + $sql = 'update '.$this->_COQtyModel->tableName().' set qty = qty + :sale_qty where product_id = :product_id and custom_option_sku = :custom_option_sku'; $data = [ 'sale_qty' => $sale_qty, 'product_id'=> $product_id, 'custom_option_sku' => $custom_option_sku ]; - $result = $this->_COQtyModel::getDb()->createCommand($sql,$data)->execute(); + $result = $this->_COQtyModel->getDb()->createCommand($sql,$data)->execute(); } } @@ -442,7 +442,7 @@ protected function actionProductIsInStock($product, $sale_qty, $custom_option_sk if ($this->checkOnShelfStatus($is_in_stock)) { if ($custom_option_sku) { - $productCustomOptionQty = $this->_COQtyModel::find()->where([ + $productCustomOptionQty = $this->_COQtyModel->find()->where([ 'product_id' => $product_id, 'custom_option_sku' => $custom_option_sku ])->one(); @@ -459,7 +459,7 @@ protected function actionProductIsInStock($product, $sale_qty, $custom_option_sk //Yii::$service->helper->errors->add('Product Id:'.$product['_id'].' && customOptionSku:'.$custom_option_sku.' , The product has no qty'); } } elseif (($product_qty > 0) && ($product_qty > $sale_qty)) { - $productFlatQty = $this->_flatQtyModel::find()->where([ + $productFlatQty = $this->_flatQtyModel->find()->where([ 'product_id' => $product_id ])->one(); if($productFlatQty['qty']){ @@ -498,7 +498,7 @@ protected function actionCheckOnShelfStatus($is_in_stock) * 得到产品的库存个数(Flat Qty) */ public function getProductFlatQty($product_id){ - $productFlatQty = $this->_flatQtyModel::find()->asArray() + $productFlatQty = $this->_flatQtyModel->find()->asArray() ->where([ 'product_id' => $product_id ])->one(); @@ -516,7 +516,7 @@ public function getProductFlatQty($product_id){ * 得到产品的custom option 部分的库存 */ public function getProductCustomOptionQty($product_id,$onlySku=false){ - $arr = $this->_COQtyModel::find()->asArray() + $arr = $this->_COQtyModel->find()->asArray() ->where([ 'product_id' => $product_id ])->all(); @@ -536,7 +536,7 @@ public function getProductCustomOptionQty($product_id,$onlySku=false){ * 得到产品的所有custom_option_sku 数组 */ public function getProductCustomOptionSkuArr($product_id){ - $arr = $this->_COQtyModel::find()->asArray() + $arr = $this->_COQtyModel->find()->asArray() ->where([ 'product_id' => $product_id ])->all(); @@ -555,7 +555,7 @@ public function getProductCustomOptionSkuArr($product_id){ * 得到产品的custom option 部分,相应的$custom_option_sku的库存 */ public function getProductCustomOptionSkuQty($product_id,$custom_option_sku){ - $productCustomOptionQty = $this->_COQtyModel::find()->asArray() + $productCustomOptionQty = $this->_COQtyModel->find()->asArray() ->where([ 'product_id' => $product_id, 'custom_option_sku' => $custom_option_sku diff --git a/services/product/viewLog/Db.php b/services/product/viewLog/Db.php index 151808952..927ed04d0 100644 --- a/services/product/viewLog/Db.php +++ b/services/product/viewLog/Db.php @@ -34,7 +34,7 @@ public function init() if (!$this->table) { $this->table = $this->_defaultTable; } - $this->_logModel::setCurrentTableName($this->table); + $this->_logModel->setCurrentTableName($this->table); } /** @@ -51,7 +51,7 @@ public function getHistory($user_id = '', $count = '') if (!$user_id) { return; } - $coll = $this->_logModel::find()->where([ + $coll = $this->_logModel->find()->where([ 'user_id' => $user_id, ]) ->asArray() diff --git a/services/product/viewLog/Mongodb.php b/services/product/viewLog/Mongodb.php index 6f5f883b8..5f0ea2342 100644 --- a/services/product/viewLog/Mongodb.php +++ b/services/product/viewLog/Mongodb.php @@ -34,7 +34,7 @@ public function init() if (!$this->collection) { $this->collection = $this->_defaultCollection; } - $this->_logModel::setCurrentCollectionName($this->collection); + $this->_logModel->setCurrentCollectionName($this->collection); } /** @@ -51,7 +51,7 @@ public function getHistory($user_id = '', $count = '') if (!$user_id) { return; } - $coll = $this->_logModel::find()->where([ + $coll = $this->_logModel->find()->where([ 'user_id' => $user_id, ]) ->asArray() @@ -84,7 +84,7 @@ public function setHistory($productOb) return; } - $mongodbViewLog = $this->_logModel::getCollection(); + $mongodbViewLog = $this->_logModel->getCollection(); $mongodbViewLog->save($arr); } } diff --git a/services/search/MongoSearch.php b/services/search/MongoSearch.php index 534c5c9fe..0f0236308 100644 --- a/services/search/MongoSearch.php +++ b/services/search/MongoSearch.php @@ -31,8 +31,10 @@ class MongoSearch extends Service implements SearchInterface public function init() { + list($this->_productModelName,$this->_productModel) = \Yii::mapGet($this->_productModelName); list($this->_searchModelName,$this->_searchModel) = \Yii::mapGet($this->_searchModelName); + $sModel = $this->_searchModel; /** * 初始化search model 的属性,将需要过滤的属性添加到search model的类属性中。 * $searchModel = new $this->_searchModelName; @@ -42,7 +44,7 @@ public function init() */ $filterAttr = Yii::$service->search->filterAttr; if (is_array($filterAttr) && !empty($filterAttr)) { - $this->_searchModel::$_filterColumns = $filterAttr; + $sModel::$_filterColumns = $filterAttr; } } @@ -51,6 +53,7 @@ public function init() */ protected function actionInitFullSearchIndex() { + $sModel = $this->_searchModel; $config1 = []; $config2 = []; //var_dump($this->searchIndexConfig);exit; @@ -70,16 +73,16 @@ protected function actionInitFullSearchIndex() * 能够进行搜索的语言列表:https://docs.mongodb.com/manual/reference/text-search-languages/#text-search-languages */ if ($mongoSearchLangName) { - $this->_searchModel::$_lang = $langCode; + $sModel::$_lang = $langCode; $searchModel = new $this->_searchModelName(); - $colltionM = $searchModel::getCollection(); + $colltionM = $searchModel->getCollection(); $config2['default_language'] = $mongoSearchLangName; $colltionM->createIndex($config1, $config2); } } } /* - $searchModel::getCollection()->ensureIndex( + $searchModel->getCollection()->ensureIndex( [ 'name' => 'text', 'description' => 'text', @@ -102,6 +105,7 @@ protected function actionInitFullSearchIndex() */ protected function actionSyncProductInfo($product_ids, $numPerPage) { + $sModel = $this->_searchModel; if (is_array($product_ids) && !empty($product_ids)) { $productPrimaryKey = Yii::$service->product->getPrimaryKey(); $searchModel = new $this->_searchModelName(); @@ -121,8 +125,8 @@ protected function actionSyncProductInfo($product_ids, $numPerPage) $one_short_description = $one['short_description']; if (!empty($this->searchLang) && is_array($this->searchLang)) { foreach ($this->searchLang as $langCode => $mongoSearchLangName) { - $this->_searchModel::$_lang = $langCode; - $searchModel = $this->_searchModel::findOne(['_id' => $one['_id']]); + $sModel::$_lang = $langCode; + $searchModel = $this->_searchModel->findOne(['_id' => $one['_id']]); if (!$searchModel['_id']) { $searchModel = new $this->_searchModelName(); } @@ -152,19 +156,20 @@ protected function actionSyncProductInfo($product_ids, $numPerPage) */ protected function actionDeleteNotActiveProduct($nowTimeStamp) { + $sModel = $this->_searchModel; echo "begin delete Mongodb Search Date \n"; //$langCodes = Yii::$service->fecshoplang->allLangCode; //if(!empty($langCodes) && is_array($langCodes)){ // foreach($langCodes as $langCodeInfo){ if (!empty($this->searchLang) && is_array($this->searchLang)) { foreach ($this->searchLang as $langCode => $mongoSearchLangName) { - $this->_searchModel::$_lang = $langCode; + $sModel::$_lang = $langCode; // 更新时间方式删除。 - $this->_searchModel::deleteAll([ + $this->_searchModel->deleteAll([ '<', 'sync_updated_at', (int) $nowTimeStamp, ]); // 不存在更新时间的直接删除掉。 - $this->_searchModel::deleteAll([ + $this->_searchModel->deleteAll([ 'sync_updated_at' => [ '?exists' => false, ], @@ -175,11 +180,11 @@ protected function actionDeleteNotActiveProduct($nowTimeStamp) protected function actionRemoveByProductId($product_id) { - //echo 1;exit; + $sModel = $this->_searchModel; if (!empty($this->searchLang) && is_array($this->searchLang)) { foreach ($this->searchLang as $langCode => $mongoSearchLangName) { - $this->_searchModel::$_lang = $langCode; - $this->_searchModel::deleteAll([ + $sModel::$_lang = $langCode; + $this->_searchModel->deleteAll([ '_id' => $product_id, ]); } @@ -242,6 +247,7 @@ protected function actionGetSearchProductColl($select, $where, $pageNum, $numPer */ protected function fullTearchText($filter) { + $sModel = $this->_searchModel; $where = $filter['where']; $product_search_max_count = $filter['product_search_max_count'] ? $filter['product_search_max_count'] : 1000; @@ -255,13 +261,13 @@ protected function fullTearchText($filter) * 详细参看:https://docs.mongodb.com/manual/core/text-search-operators/ * 2. sort排序:search_score是全文搜索匹配后的得分,score是product表的一个字段,这个字段可以通过销售量或者其他作为参考设置。 */ - $this->_searchModel::$_lang = Yii::$service->store->currentLangCode; - //$search_data = $this->_searchModel::getCollection(); + $sModel::$_lang = Yii::$service->store->currentLangCode; + //$search_data = $this->_searchModel->getCollection(); //$mongodb = Yii::$app->mongodb; //$search_data = $mongodb->getCollection('full_search_product_en') - $search_data = $this->_searchModel::getCollection()->find( + $search_data = $this->_searchModel->getCollection()->find( $where, ['search_score'=>['$meta'=>'textScore'], 'id' => 1, 'spu'=> 1, 'score' => 1], [ @@ -288,7 +294,7 @@ protected function fullTearchText($filter) } $productIds = array_slice($productIds, $offset, $limit); if (!empty($productIds)) { - $query = $this->_productModel::find()->asArray() + $query = $this->_productModel->find()->asArray() ->select($select) ->where(['_id'=> ['$in'=>$productIds]]); $data = $query->all(); @@ -337,8 +343,9 @@ protected function actionGetFrontSearchFilter($filter_attr, $where) '$group' => $group, ], ]; - $this->_searchModel::$_lang = Yii::$service->store->currentLangCode; - $filter_data = $this->_searchModel::getCollection()->aggregate($pipelines); + $sModel = $this->_searchModel; + $sModel::$_lang = Yii::$service->store->currentLangCode; + $filter_data = $this->_searchModel->getCollection()->aggregate($pipelines); return $filter_data; } diff --git a/services/search/XunSearch.php b/services/search/XunSearch.php index 0f9e50d6a..ca57e6c09 100644 --- a/services/search/XunSearch.php +++ b/services/search/XunSearch.php @@ -101,15 +101,15 @@ protected function actionDeleteNotActiveProduct($nowTimeStamp) protected function actionXunDeleteAllProduct($numPerPage, $i) { //var_dump($index); - $dbName = $this->_searchMode::projectName(); + $dbName = $this->_searchModel->projectName(); // 删除索引 Yii::$app->xunsearch->getDatabase($dbName)->getIndex()->clean(); //$index = Yii::$app->xunsearch->getDatabase($dbName)->index; echo "begin delete Xun Search Date \n"; $nowTimeStamp = (int) $nowTimeStamp; - $XunSearchData = $this->_searchMode::find() - ->limit($numPerPage) + $XunSearchData = $this->_searchModel->find() + ->limit($numPerPage) ->offset(($i - 1) * $numPerPage) ->all(); foreach ($XunSearchData as $one) { @@ -132,7 +132,7 @@ protected function actionGetSearchProductColl($select, $where, $pageNum, $numPer protected function fullTearchText($select, $where, $pageNum, $numPerPage, $product_search_max_count) { - $XunSearchQuery = $this->_searchMode::find()->asArray(); + $XunSearchQuery = $this->_searchModel->find()->asArray(); $XunSearchQuery->fuzzy($this->fuzzy); $XunSearchQuery->synonyms($this->synonyms); @@ -171,7 +171,7 @@ protected function fullTearchText($select, $where, $pageNum, $numPerPage, $produ $productIds = array_slice($productIds, $offset, $limit); if (!empty($productIds)) { - $query = $this->_productModel::find()->asArray() + $query = $this->_productModel->find()->asArray() ->select($select) ->where(['_id'=> ['$in'=>$productIds]]); $data = $query->all(); @@ -201,7 +201,7 @@ protected function fullTearchText($select, $where, $pageNum, $numPerPage, $produ protected function actionGetFrontSearchFilter($filter_attr, $where) { //var_dump($where); - $dbName = $this->_searchMode::projectName(); + $dbName = $this->_searchModel->projectName(); $_search = Yii::$app->xunsearch->getDatabase($dbName)->getSearch(); $text = isset($where['$text']['$search']) ? $where['$text']['$search'] : ''; if (!$text) { @@ -245,7 +245,7 @@ protected function actionRemoveByProductId($product_id) { if (is_object($product_id)) { $product_id = (string) $product_id; - $model = $this->_searchMode::findOne($product_id); + $model = $this->_searchModel->findOne($product_id); if($model){ $model->delete(); } diff --git a/services/session/MysqlDbSession.php b/services/session/MysqlDbSession.php index 053ea1be7..0df819f4d 100644 --- a/services/session/MysqlDbSession.php +++ b/services/session/MysqlDbSession.php @@ -28,7 +28,7 @@ public function __construct(){ public function set($key,$val,$timeout){ $uuid = Yii::$service->session->getUUID(); - $one = $this->_sessionModel::find()->where([ + $one = $this->_sessionModel->find()->where([ 'uuid' => $uuid, 'key' => $key, ])->one(); @@ -46,7 +46,7 @@ public function set($key,$val,$timeout){ public function get($key,$reflush){ $uuid = Yii::$service->session->getUUID(); - $one = $this->_sessionModel::find()->where([ + $one = $this->_sessionModel->find()->where([ 'uuid' => $uuid, 'key' => $key, ])->one(); @@ -65,7 +65,7 @@ public function get($key,$reflush){ public function remove($key){ $uuid = Yii::$service->session->getUUID(); - $one = $this->_sessionModel::find()->where([ + $one = $this->_sessionModel->find()->where([ 'uuid' => $uuid, 'key' => $key, ])->one(); @@ -82,7 +82,7 @@ public function setFlash($key,$val,$timeout){ public function getFlash($key){ $uuid = Yii::$service->session->getUUID(); - $one = $this->_sessionModel::find()->where([ + $one = $this->_sessionModel->find()->where([ 'uuid' => $uuid, 'key' => $key, ])->one(); diff --git a/services/url/rewrite/RewriteMongodb.php b/services/url/rewrite/RewriteMongodb.php index 5941bf240..9f163e6e7 100644 --- a/services/url/rewrite/RewriteMongodb.php +++ b/services/url/rewrite/RewriteMongodb.php @@ -34,7 +34,7 @@ public function __construct(){ */ public function getOriginUrl($urlKey) { - $UrlData = $this->_urlRewriteModel::find()->where([ + $UrlData = $this->_urlRewriteModel->find()->where([ 'custom_url_key' => $urlKey, ])->asArray()->one(); if ($UrlData['custom_url_key']) { @@ -50,7 +50,7 @@ public function getPrimaryKey() public function getByPrimaryKey($primaryKey) { if ($primaryKey) { - return $this->_urlRewriteModel::findOne($primaryKey); + return $this->_urlRewriteModel->findOne($primaryKey); } else { return new $this->_urlRewriteModelName(); } @@ -72,7 +72,7 @@ public function getByPrimaryKey($primaryKey) */ public function coll($filter = '') { - $query = $this->_urlRewriteModel::find(); + $query = $this->_urlRewriteModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); return [ @@ -89,7 +89,7 @@ public function save($one) { $primaryVal = isset($one[$this->getPrimaryKey()]) ? $one[$this->getPrimaryKey()] : ''; if ($primaryVal) { - $model = $this->_urlRewriteModel::findOne($primaryVal); + $model = $this->_urlRewriteModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('UrlRewrite '.$this->getPrimaryKey().' is not exist'); @@ -116,7 +116,7 @@ public function remove($ids) } if (is_array($ids) && !empty($ids)) { foreach ($ids as $id) { - $model = $this->_urlRewriteModel::findOne($id); + $model = $this->_urlRewriteModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $url_key = $model['url_key']; $model->delete(); @@ -129,7 +129,7 @@ public function remove($ids) } } else { $id = $ids; - $model = $this->_urlRewriteModel::findOne($id); + $model = $this->_urlRewriteModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $url_key = $model['url_key']; $model->delete(); @@ -149,7 +149,7 @@ public function remove($ids) public function removeByUpdatedAt($time) { if ($time) { - $this->_urlRewriteModel::deleteAll([ + $this->_urlRewriteModel->deleteAll([ '$or' => [ [ 'updated_at' => [ @@ -172,14 +172,14 @@ public function removeByUpdatedAt($time) */ public function find() { - return $this->_urlRewriteModel::find(); + return $this->_urlRewriteModel->find(); } /** * 返回url rewrite 查询结果 */ public function findOne($where) { - return $this->_urlRewriteModel::findOne($where); + return $this->_urlRewriteModel->findOne($where); } /** * 返回url rewrite model diff --git a/services/url/rewrite/RewriteMysqldb.php b/services/url/rewrite/RewriteMysqldb.php index 1b34727cf..52f35f533 100644 --- a/services/url/rewrite/RewriteMysqldb.php +++ b/services/url/rewrite/RewriteMysqldb.php @@ -39,7 +39,7 @@ public function __construct(){ */ public function getOriginUrl($urlKey) { - $UrlData = $this->_urlRewriteModel::find()->where([ + $UrlData = $this->_urlRewriteModel->find()->where([ 'custom_url_key' => $urlKey, ])->asArray()->one(); if ($UrlData['custom_url_key']) { @@ -55,7 +55,7 @@ public function getPrimaryKey() public function getByPrimaryKey($primaryKey) { if ($primaryKey) { - $one = $this->_urlRewriteModel::findOne($primaryKey); + $one = $this->_urlRewriteModel->findOne($primaryKey); if (!empty($this->_lang_attr)) { foreach ($this->_lang_attr as $attrName) { if (isset($one[$attrName])) { @@ -86,7 +86,7 @@ public function getByPrimaryKey($primaryKey) */ public function coll($filter = '') { - $query = $this->_urlRewriteModel::find(); + $query = $this->_urlRewriteModel->find(); $query = Yii::$service->helper->ar->getCollByFilter($query, $filter); $coll = $query->all(); if (!empty($coll)) { @@ -114,7 +114,7 @@ public function save($one) { $primaryVal = isset($one[$this->getPrimaryKey()]) ? $one[$this->getPrimaryKey()] : ''; if ($primaryVal) { - $model = $this->_urlRewriteModel::findOne($primaryVal); + $model = $this->_urlRewriteModel->findOne($primaryVal); if (!$model) { Yii::$service->helper->errors->add('UrlRewrite '.$this->getPrimaryKey().' is not exist'); @@ -143,7 +143,7 @@ public function remove($ids) $innerTransaction = Yii::$service->db->beginTransaction(); try { foreach ($ids as $id) { - $model = $this->_urlRewriteModel::findOne($id); + $model = $this->_urlRewriteModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $url_key = $model['url_key']; $model->delete(); @@ -165,7 +165,7 @@ public function remove($ids) } } else { $id = $ids; - $model = $this->_urlRewriteModel::findOne($id); + $model = $this->_urlRewriteModel->findOne($id); if (isset($model[$this->getPrimaryKey()]) && !empty($model[$this->getPrimaryKey()])) { $innerTransaction = Yii::$service->db->beginTransaction(); try { @@ -192,7 +192,7 @@ public function remove($ids) public function removeByUpdatedAt($time) { if ($time) { - $this->_urlRewriteModel::deleteAll([ + $this->_urlRewriteModel->deleteAll([ '<', 'updated_at', $time, ]); } @@ -202,14 +202,14 @@ public function removeByUpdatedAt($time) */ public function find() { - return $this->_urlRewriteModel::find(); + return $this->_urlRewriteModel->find(); } /** * 返回url rewrite 查询结果 */ public function findOne($where) { - return $this->_urlRewriteModel::findOne($where); + return $this->_urlRewriteModel->findOne($where); } /** * 返回url rewrite model