提交 7fa5d0bf 编写于 作者: T Terry

后台计算产品评论总数的bug处理

上级 8201ca85
......@@ -48,16 +48,16 @@ class Lists
protected function getProductPage($countTotal)
{
if ($countTotal <= $this->numPerPage) {
echo "$countTotal <= $this->numPerPage";
//echo "$countTotal <= $this->numPerPage";
return '';
}
$config = [
'class' => 'fecshop\app\apphtml5\widgets\Page',
'view' => 'widgets/page.php',
'pageNum' => $this->pageNum,
'numPerPage' => $this->numPerPage,
'countTotal' => $countTotal,
'page' => $this->_page,
'class' => 'fecshop\app\apphtml5\widgets\Page',
'view' => 'widgets/page.php',
'pageNum' => $this->pageNum,
'numPerPage' => $this->numPerPage,
'countTotal' => $countTotal,
'page' => $this->_page,
];
return Yii::$service->page->widget->renderContent('category_product_page', $config);
......@@ -106,17 +106,17 @@ class Lists
return [
'_id' => $this->product_id,
'spu' => $this->spu,
'review_count' => $review_count,
'reviw_rate_star_average' => $reviw_rate_star_average,
'pageToolBar' => $pageToolBar,
'coll' => $coll,
'noActiveStatus'=> Yii::$service->product->review->noActiveStatus(),
'addReviewUrl' => $addReviewUrl,
'name' => $name,
'price_info' => $price_info,
'main_img' => $main_img,
'editForm' => $editForm,
'url' => Yii::$service->url->getUrl($url_key),
'review_count' => $review_count,
'reviw_rate_star_average' => $reviw_rate_star_average,
'pageToolBar' => $pageToolBar,
'coll' => $coll,
'noActiveStatus' => Yii::$service->product->review->noActiveStatus(),
'addReviewUrl' => $addReviewUrl,
'name' => $name,
'price_info' => $price_info,
'main_img' => $main_img,
'editForm' => $editForm,
'url' => Yii::$service->url->getUrl($url_key),
];
}
}
......@@ -127,21 +127,24 @@ class Lists
public function getReviewsBySpu($spu)
{
$currentIp = \fec\helpers\CFunc::get_real_ip();
$lang_code = Yii::$service->store->currentLangCode;
$filter = [
'numPerPage' => $this->numPerPage,
'pageNum' => $this->pageNum,
'numPerPage' => $this->numPerPage,
'pageNum' => $this->pageNum,
'orderBy' => [$this->filterOrderBy => SORT_DESC],
'where' => [
'where' => [
[
'$or' => [
[
'status' => Yii::$service->product->review->activeStatus(),
'product_spu' => $spu,
'lang_code' => $lang_code
],
[
'status' => Yii::$service->product->review->noActiveStatus(),
'product_spu' => $spu,
'ip' => $currentIp,
'lang_code' => $lang_code
],
],
],
......
......@@ -51,7 +51,7 @@
<span class="average_rating"><?= Yii::$service->page->translate->__('Average rating :');?></span>
<span class="review_star review_star_<?= $reviw_rate_star_average ?>" style="font-weight:bold;" itemprop="average"></span>
<a rel="nofollow" href="<?= Yii::$service->url->getUrl('catalog/reviewproduct/lists',['spu'=>$spu,'_id'=>$_id]); ?>">
<a external rel="nofollow" href="<?= Yii::$service->url->getUrl('catalog/reviewproduct/lists',['spu'=>$spu,'_id'=>$_id]); ?>">
(<span itemprop="count"><?= $review_count ?> <?= Yii::$service->page->translate->__('reviews');?></span>)
</a>
</span>
......
......@@ -26,7 +26,7 @@ class Lists
public $numPerPage = 20;
public $pageNum;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected $_reviewHelperName = '\fecshop\app\apphtml5\modules\Catalog\helpers\Review';
protected $_reviewHelper;
......@@ -34,16 +34,16 @@ class Lists
public function __construct()
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list($this->_reviewHelperName,$this->_reviewHelper) = Yii::mapGet($this->_reviewHelperName);
// 初始化服务
// 初始化服务
$reviewHelper = $this->_reviewHelper;
$reviewHelper::initReviewConfig();
}
/**
* @property $countTotal | Int
* 得到toolbar的分页部分
* 得到toolbar的分页部分
*/
protected function getProductPage($countTotal)
{
......@@ -61,7 +61,7 @@ class Lists
return Yii::$service->page->widget->renderContent('category_product_page', $config);
}
// 初始化参数
// 初始化参数
public function initParam()
{
$this->pageNum = Yii::$app->request->get($this->_page);
......@@ -130,7 +130,7 @@ class Lists
}
/**
* @property $spu | String
* 通过spu得到产品评论
* 通过spu得到产品评论
*/
public function getReviewsBySpu($spu)
{
......@@ -158,7 +158,7 @@ class Lists
return Yii::$service->product->review->getListBySpu($filter);
}
// 产品价格信息
// 产品价格信息
protected function getProductPriceInfo($product)
{
$price = $product['price'];
......
......@@ -360,7 +360,7 @@ class Review extends Service
}
}
}
/**
* @property $spu | String
* 当评论保存,更新评论的总数,平均评分信息到产品表的所有spu
......@@ -369,6 +369,8 @@ class Review extends Service
{
$reviewModel = $this->_reviewModel;
$filter = [
'numPerPage' => 10000, // mongodb 查询,numPerPage必须设置,如果不设置,默认为20
'pageNum' => 1,
'where' => [
['product_spu' => $spu],
['status' => $reviewModel->getActiveStatus()],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册