-
-
-
-
= $name; ?>
-
-
-
-
- Average rating :
- 0
-
-
- (0 reviews)
-
-
-
- Item Code: = $sku; ?>
-
- 'catalog/product/index/price.php'
- ];
- $priceParam = [
- 'price_info' => $price_info,
- ];
- ?>
- = Yii::$service->page->widget->render($priceView,$priceParam); ?>
+
+
-
-
-
- 'catalog/product/index/options.php'
- ];
- $optionsParam = [
- 'options' => $options,
- ];
- ?>
- = Yii::$service->page->widget->render($optionsView,$optionsParam); ?>
-
+
+
= $name; ?>
+
+
-
+
+ Average rating :
+ 0
+
+
+ (0 reviews)
+
+
+
- 'catalog/product/index/custom_option.php'
+
Item Code: = $sku; ?>
+
+ 'catalog/product/index/price.php'
];
- $optionsParam = [
- 'custom_option' => $custom_option,
+ $priceParam = [
+ 'price_info' => $price_info,
];
?>
- = Yii::$service->page->widget->render($optionsView,$optionsParam); ?>
+ = Yii::$service->page->widget->render($priceView,$priceParam); ?>
-
-
-
\ No newline at end of file
diff --git a/config/services/Product.php b/config/services/Product.php
index 2cc09a08ca4cb0c5e7e4fa07c816086e9dd467da..af8a5c86dbeb08df7ffcc43211eb452c54b3da82 100644
--- a/config/services/Product.php
+++ b/config/services/Product.php
@@ -83,9 +83,12 @@ return [
],
'review' => [
'class' => 'fecshop\services\product\Review',
+ 'filterByStore' => false, # 是否通过store的值进行评论过滤?
+ 'filterByLang' => false, # 是否通过语言进行评论过滤?
],
'info' => [
'class' => 'fecshop\services\product\Info',
+
],
'coll' => [
'class' => 'fecshop\services\product\Coll',
diff --git a/models/mongodb/product/Review.php b/models/mongodb/product/Review.php
new file mode 100644
index 0000000000000000000000000000000000000000..c44e39ae107fc49c7fcf00ef020b77cac566577d
--- /dev/null
+++ b/models/mongodb/product/Review.php
@@ -0,0 +1,65 @@
+
+ * @since 1.0
+ */
+class Review extends ActiveRecord
+{
+ public static $_customAttrs;
+
+
+
+ public static function collectionName()
+ {
+ return 'review';
+ }
+ # ֶ̬Ρ
+ public static function addCustomAttrs($attrs){
+ self::$_customAttrs = $attrs;
+ }
+
+ public function attributes($origin=false)
+ {
+ $origin = [
+ '_id',
+ 'product_spu',
+ 'product_id',
+ 'rate_star',
+ 'name',
+ 'summary',
+ 'review_content',
+ 'review_date', #
+ 'store', # store
+ 'lang_code', #
+ 'status', # ״̬
+ 'audit_user', # ˺
+ 'audit_date', # ʱ
+ ];
+ if($origin){ # ȡԭʼ
+ return $origin;
+ }
+ if(is_array(self::$_customAttrs) && !empty(self::$_customAttrs)){
+ $origin = array_merge($origin,self::$_customAttrs);
+ }
+ return $origin;
+ }
+
+
+
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/services/product/Review.php b/services/product/Review.php
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..39f0bbdd943c730bf23bf7b63b370848cc503557 100644
--- a/services/product/Review.php
+++ b/services/product/Review.php
@@ -0,0 +1,153 @@
+
+ * @since 1.0
+ */
+class Review extends Service
+{
+ public $filterByStore;
+ public $filterByLang;
+ /**
+ * @property $arr | Array
+ * ʼreview modelԣΪÿһƷĿӵֶβͬ
+ */
+ protected function actionInitReviewAttr($arr){
+ if(!empty($arr) && is_array($arr)){
+ $ReviewModel = new ReviewModel;
+ $attr_arr = $ReviewModel->attributes(true);
+ $arr_keys = array_keys($arr);
+ $attrs = array_diff($arr_keys,$attr_arr);
+ ReviewModel::addCustomAttrs($attrs);
+ }
+ }
+ /**
+ * @property $spu | String.
+ * ͨspuҵ
+ */
+ protected function actionGetCountBySpu($spu){
+ $where = [
+ 'product_spu' => $spu
+ ];
+ if($this->filterByStore && ($currentStore = Yii::$service->store->currentStore)){
+ $where['store'] = $currentStore;
+ }
+ if($this->filterByLang && ($currentLangCode = Yii::$service->store->currentLangCode)){
+ $where['lang_code'] = $currentLangCode;
+ }
+ $count = ReviewModel::find()->asArray()->where($where)->count();
+ return $count ? $count : 0;
+ }
+ /**
+ * example filter:
+ * [
+ * 'numPerPage' => 20,
+ * 'pageNum' => 1,
+ * 'orderBy' => ['review_date' => SORT_DESC],
+ * where' => [
+ * ['spu' => 'uk10001'],
+ * ],
+ * 'asArray' => true,
+ * ]
+ * ͨspuҵlisting
+ */
+ protected function actionGetListBySpu($filter){
+
+ if($this->filterByStore && ($currentStore = Yii::$service->store->currentStore)){
+ $filter['where'][] = ['store' => $currentStore ];
+ }
+ if($this->filterByLang && ($currentLangCode = Yii::$service->store->currentLangCode)){
+ $filter['where'][] = ['lang_code' => $currentLangCode ];
+ }
+ $query = ReviewModel::find();
+ $query = Yii::$service->helper->ar->getCollByFilter($query,$filter);
+ return [
+ 'coll' => $query->all(),
+ 'count'=> $query->count(),
+ ];
+
+ }
+
+ /**
+ * @property $review_data | Array
+ *
+ *
+ */
+ protected function actionAddReview($review_data){
+ $this->initReviewAttr($review_data);
+ $model = new ReviewModel;
+ if(isset($review_data['_id'])){
+ unset($review_data['_id']);
+ }
+ $saveStatus = Yii::$service->helper->ar->save($model,$review_data);
+ return true;
+ }
+
+ /**
+ * @property $review_data | Array
+ *
+ */
+ protected function actionUpdateReview($review_data){
+ $this->initReviewAttr($review_data);
+ $model = ReviewModel::findOne(['_id'=> $review_data[$primaryKey]]);
+ unset($review_data[$primaryKey]);
+ $saveStatus = Yii::$service->helper->ar->save($model,$review_data);
+ return true;
+ }
+
+ /*
+ * example filter:
+ * [
+ * 'numPerPage' => 20,
+ * 'pageNum' => 1,
+ * 'orderBy' => ['_id' => SORT_DESC, 'sku' => SORT_ASC ],
+ * 'where' => [
+ ['>','price',1],
+ ['<=','price',10]
+ * ['sku' => 'uk10001'],
+ * ],
+ * 'asArray' => true,
+ * ]
+ * 鿴review б
+ */
+ protected function actionList($filter){
+ $query = ReviewModel::find();
+ $query = Yii::$service->helper->ar->getCollByFilter($query,$filter);
+ return [
+ 'coll' => $query->all(),
+ 'count'=> $query->count(),
+ ];
+ }
+ /**
+ * @property $_id | String
+ * ̨༭ ͨidҵ
+ * ע⣺ΪÿƷۿܼµֶΣ˲ʹActiveRecordķʽȡ
+ * ʹķʽֶζȡ
+ */
+ protected function actionGetByReviewId($_id){
+
+ return ReviewModel::getCollection()->findOne(['_id' => $_id]);
+
+ }
+
+
+
+
+
+
+
+}
\ No newline at end of file
Qty:
-
-
+
+
-
-
+ 'catalog/product/index/options.php'
+ ];
+ $optionsParam = [
+ 'options' => $options,
+ ];
+ ?>
+ = Yii::$service->page->widget->render($optionsView,$optionsParam); ?>
+
+
+
+ 'catalog/product/index/custom_option.php'
+ ];
+ $optionsParam = [
+ 'custom_option' => $custom_option,
+ ];
+ ?>
+ = Yii::$service->page->widget->render($optionsView,$optionsParam); ?>
+
-
-
-
-
+
-
+ 'catalog/product/index/tier_price.php'
+ ];
+ $priceParam = [
+ 'tier_price' => $tier_price,
+ ];
+ ?>
+ = Yii::$service->page->widget->render($priceView,$priceParam); ?>
+
- 'catalog/product/index/tier_price.php'
- ];
- $priceParam = [
- 'tier_price' => $tier_price,
- ];
- ?>
- = Yii::$service->page->widget->render($priceView,$priceParam); ?>
-
+
-
+
+
+ 'catalog/product/index/image.php'
+ ];
+ $imageParam = [
+ 'media_size' => $media_size,
+ 'image' => $image,
+ 'productImgMagnifier' => $productImgMagnifier,
+ ];
+ ?>
+ = Yii::$service->page->widget->render($imageView,$imageParam); ?>
+
-
-
-
- 'catalog/product/index/image.php'
- ];
- $imageParam = [
- 'media_size' => $media_size,
- 'image' => $image,
- 'productImgMagnifier' => $productImgMagnifier,
- ];
- ?>
- = Yii::$service->page->widget->render($imageView,$imageParam); ?>
-
+
+
+
-
-
+
+ -
+
- DESCRIPTION +
- REVIEWS +
- SHIPPING & PAYMENT +
- WHOLESALE +
+
+ = $description; ?>
+
+
+ 'catalog/product/index/review.php'
+ ];
+ $reviewParam = [
+ '_id' => $_id,
+ 'review_count' => $review_count,
+ 'spu' => $spu,
+ ];
+ ?>
+ = Yii::$service->page->widget->render($reviewView,$reviewParam); ?>
+
+ text3
+ text2
+
+
-
-
-
- -
-
- DESCRIPTION -
- REVIEWS -
- QUESTIONS -
- WHOLESALE -
-
text1
- text2
- text3
- text2
-
-