diff --git a/module/product/model.php b/module/product/model.php index c608c47c7d..8db06d4e6c 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -1517,7 +1517,7 @@ class productModel extends model } } - $casesCount = $this->productTao->getStoriesInCasesCount($storyIdList); + $casesCount = $this->productTao->getStoryCasesCount($storyIdList); $rate = count($stories) == 0 || $rateCount == 0 ? 0 : round($casesCount / $rateCount, 2); $storyCommon = $this->lang->SRCommon; diff --git a/module/product/tao.php b/module/product/tao.php index 9bfeb1a4e7..c1ea41b61a 100644 --- a/module/product/tao.php +++ b/module/product/tao.php @@ -637,13 +637,11 @@ class productTao extends productModel * @access protected * @return int */ - protected function getStoriesInCasesCount(array $storyIdList): int + protected function getStoryCasesCount(array $storyIdList): int { if(empty($storyIdList)) return 0; - $cases = $this->dao->select('story')->from(TABLE_CASE)->where('story')->in($storyIdList)->andWhere('deleted')->eq(0)->fetchAll('story'); - - return count($cases); + return $this->dao->select('COUNT(story) AS count')->from(TABLE_CASE)->where('story')->in($storyIdList)->andWhere('deleted')->eq('0')->fetch('count'); } /**