From 17c0c047646ed67a78ae53038c50726706490a17 Mon Sep 17 00:00:00 2001 From: Terry <2358269014@qq.com> Date: Sat, 17 Jun 2017 17:02:32 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D=EF=BC=9Ablock=20cache=20k?= =?UTF-8?q?ey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/appfront/widgets/Footer.php | 2 +- app/appfront/widgets/Head.php | 2 +- app/appfront/widgets/Headers.php | 2 +- app/appfront/widgets/Menu.php | 2 +- app/apphtml5/widgets/Footer.php | 2 +- app/apphtml5/widgets/Head.php | 2 +- app/apphtml5/widgets/Headers.php | 2 +- app/apphtml5/widgets/Menu.php | 2 +- services/AdminUser.php | 5 ++++- services/Cart.php | 36 ++++++++++++++------------------ services/Category.php | 9 +------- 11 files changed, 29 insertions(+), 37 deletions(-) diff --git a/app/appfront/widgets/Footer.php b/app/appfront/widgets/Footer.php index dad1b533..17712bbd 100644 --- a/app/appfront/widgets/Footer.php +++ b/app/appfront/widgets/Footer.php @@ -16,7 +16,7 @@ class Footer implements BlockCache public function getCacheKey() { - $lang = Yii::$service->store->currentLanguage; + $lang = Yii::$service->store->currentLangCode; return self::BLOCK_CACHE_PREFIX.'_'.$lang; } diff --git a/app/appfront/widgets/Head.php b/app/appfront/widgets/Head.php index 48cf4c15..09d65a62 100644 --- a/app/appfront/widgets/Head.php +++ b/app/appfront/widgets/Head.php @@ -16,7 +16,7 @@ class Head implements BlockCache public function getCacheKey() { - $store = Yii::$service->store->currentStore; + $store = Yii::$service->store->currentLangCode; $moduleId = Yii::$app->controller->module->id; $controllerId = Yii::$app->controller->id; $actionId = Yii::$app->controller->action->id; diff --git a/app/appfront/widgets/Headers.php b/app/appfront/widgets/Headers.php index 4a17f9b0..49d21aad 100644 --- a/app/appfront/widgets/Headers.php +++ b/app/appfront/widgets/Headers.php @@ -28,7 +28,7 @@ class Headers implements BlockCache public function getCacheKey() { - $lang = Yii::$service->store->currentStore; + $lang = Yii::$service->store->currentLangCode; $currency = Yii::$service->page->currency->getCurrentCurrency(); return self::BLOCK_CACHE_PREFIX.'_'.$lang.'_'.$currency; diff --git a/app/appfront/widgets/Menu.php b/app/appfront/widgets/Menu.php index d74dcd74..26a32904 100644 --- a/app/appfront/widgets/Menu.php +++ b/app/appfront/widgets/Menu.php @@ -18,7 +18,7 @@ class Menu implements BlockCache public function getCacheKey() { - $lang = Yii::$service->store->currentLanguage; + $lang = Yii::$service->store->currentLangCode; return self::BLOCK_CACHE_PREFIX.'_'.$lang; } diff --git a/app/apphtml5/widgets/Footer.php b/app/apphtml5/widgets/Footer.php index c5e77a3e..ff0ca0a8 100644 --- a/app/apphtml5/widgets/Footer.php +++ b/app/apphtml5/widgets/Footer.php @@ -16,7 +16,7 @@ class Footer implements BlockCache public function getCacheKey() { - $lang = Yii::$service->store->currentLanguage; + $lang = Yii::$service->store->currentLangCode; return self::BLOCK_CACHE_PREFIX.'_'.$lang; } diff --git a/app/apphtml5/widgets/Head.php b/app/apphtml5/widgets/Head.php index 68e1a4ed..dc06b297 100644 --- a/app/apphtml5/widgets/Head.php +++ b/app/apphtml5/widgets/Head.php @@ -16,7 +16,7 @@ class Head implements BlockCache public function getCacheKey() { - $store = Yii::$service->store->currentStore; + $store = Yii::$service->store->currentLangCode; $moduleId = Yii::$app->controller->module->id; $controllerId = Yii::$app->controller->id; $actionId = Yii::$app->controller->action->id; diff --git a/app/apphtml5/widgets/Headers.php b/app/apphtml5/widgets/Headers.php index 239ec448..86edc381 100644 --- a/app/apphtml5/widgets/Headers.php +++ b/app/apphtml5/widgets/Headers.php @@ -28,7 +28,7 @@ class Headers implements BlockCache public function getCacheKey() { - $lang = Yii::$service->store->currentStore; + $lang = Yii::$service->store->currentLangCode; $currency = Yii::$service->page->currency->getCurrentCurrency(); return self::BLOCK_CACHE_PREFIX.'_'.$lang.'_'.$currency; diff --git a/app/apphtml5/widgets/Menu.php b/app/apphtml5/widgets/Menu.php index 34dee031..9ade42f2 100644 --- a/app/apphtml5/widgets/Menu.php +++ b/app/apphtml5/widgets/Menu.php @@ -18,7 +18,7 @@ class Menu implements BlockCache public function getCacheKey() { - $lang = Yii::$service->store->currentLanguage; + $lang = Yii::$service->store->currentLangCode; return self::BLOCK_CACHE_PREFIX.'_'.$lang; } diff --git a/services/AdminUser.php b/services/AdminUser.php index e7c29090..40171086 100644 --- a/services/AdminUser.php +++ b/services/AdminUser.php @@ -18,7 +18,10 @@ use Yii; */ class AdminUser extends Service { - //Yii::$service->adminUser->getIdAndNameArrByIds($ids) + /** + * @property $ids | Int Array + * @return 得到相应用户的数组。 + */ protected function actionGetIdAndNameArrByIds($ids) { $user_coll = \fecadmin\models\AdminUser::find()->asArray()->select(['id', 'username'])->where([ diff --git a/services/Cart.php b/services/Cart.php index 33dd07c9..490bf4e5 100644 --- a/services/Cart.php +++ b/services/Cart.php @@ -36,7 +36,6 @@ class Cart extends Service if (isset($item['custom_option_sku']) && !empty($item['custom_option_sku'])) { if (is_array($item['custom_option_sku'])) { $custom_option_sku = Yii::$service->cart->info->getCustomOptionSku($item, $product); - if (!$custom_option_sku) { Yii::$service->helper->errors->add('product custom_option_sku is not exist'); @@ -52,18 +51,11 @@ class Cart extends Service } // 开始加入购物车 // service 里面不允许有事务,请在调用层使用事务。 - //$innerTransaction = Yii::$app->db->beginTransaction(); - //try { - - $beforeEventName = 'event_add_to_cart_before'; - $afterEventName = 'event_add_to_cart_after'; + $beforeEventName = 'event_add_to_cart_before'; + $afterEventName = 'event_add_to_cart_after'; Yii::$service->event->trigger($beforeEventName, $item); // 触发事件 - 加购物车前事件 Yii::$service->cart->quoteItem->addItem($item); Yii::$service->event->trigger($afterEventName, $item); // 触发事件 - 加购物车前事件 - //$innerTransaction->commit(); - //} catch (Exception $e) { - // $innerTransaction->rollBack(); - //} return true; } @@ -74,6 +66,9 @@ class Cart extends Service } /** + * @property $shipping_method | String 货运方式code + * @property $country | String 国家code + * @property $region | String 省市code * 得到购物车中的信息。 */ protected function actionGetCartInfo($shipping_method = '', $country = '', $region = '*') @@ -126,15 +121,9 @@ class Cart extends Service } /** - * @property $coupon_code 优惠卷码 - * @return bool 优惠券使用成功则返回true,失败则返回false - */ - //protected function actionAddCoupon($coupon_code){ - - //} - - /** - * merge cart , if current cart currency is not equals to user cart currency when user login account. + * 购物车合并:用户未登录账号,把一部分产品加入购物车,当用户 + * 登录账号的时候,账号对应的购物车信息和用户未登录前的购物车产品信息进行合并的操作 + * 在用户登录账户的时候,会执行该方法。 */ protected function actionMergeCartAfterUserLogin() { @@ -143,13 +132,20 @@ class Cart extends Service /** * @property $address|array + * @property $shipping_method | String 发货方式 + * @property $payment_method | String 支付方式 * save cart address.like,, customer name,tel,email,address ,,etc,,. */ protected function actionUpdateGuestCart($address, $shipping_method, $payment_method) { return Yii::$service->cart->quote->updateGuestCart($address, $shipping_method, $payment_method); } - + /** + * @property $address_id | Int + * @property $shipping_method | String 货运方式 + * @property $payment_method | String 支付方式 + * 更新登录用户的购物车。 + */ protected function actionUpdateLoginCart($address_id, $shipping_method, $payment_method) { return Yii::$service->cart->quote->updateLoginCart($address_id, $shipping_method, $payment_method); diff --git a/services/Category.php b/services/Category.php index 6885766d..d71acd4d 100644 --- a/services/Category.php +++ b/services/Category.php @@ -25,6 +25,7 @@ class Category extends Service /** * init function , 初始化category,使用哪一个category service. + * 目前只支持mongodb,不支持mysql */ public function init() { @@ -35,14 +36,6 @@ class Category extends Service } } - /** - * Get Url by article's url key. - */ - //public function getUrlByPath($urlPath){ - //return Yii::$service->url->getHttpBaseUrl().'/'.$urlKey; - //return Yii::$service->url->getUrlByPath($urlPath); - //} - /** * 得到当前的category service 对应的主键名称,譬如如果是mongo,返回的是 _id. */ -- GitLab