Commit 0bbbe261 authored by zhz's avatar zhz

evaluation

parent 6c2fe510
...@@ -539,7 +539,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -539,7 +539,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
if(!$goodsCommonId){ if(!$goodsCommonId){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyCommonId); \Error\ErrorModel::throwException(\Error\CodeConfigModel::emptyCommonId);
} }
$grade = $this->getEvaluatesStatistics($goodsCommonId); //$grade = $this->getEvaluatesStatistics($goodsCommonId);
$statistics = \DAO\GoodsScoreStatisticsModel::getInstance()->getGrade($goodsCommonId);
$evaluateInstance = \DAO\EvaluateGoodsModel::getInstance(); $evaluateInstance = \DAO\EvaluateGoodsModel::getInstance();
$evaluation = \Our\RedisHelper::cachedFunction(\Redis\Db4\EvaluateGoodsRedisModel::getInstance(),array(&$evaluateInstance, 'getList'),array(array('geval_goods_commonid'=>$goodsCommonId,'geval_state'=>0),'geval_frommemberid,geval_frommembername AS memberName,geval_content AS gevalContent,geval_addtime AS gevalTime,geval_image,geval_explain AS gevalExplain,geval_isanonymous AS isAnonymous,goods_spec,member_avatar AS memberAvatar',array('geval_addtime','DESC'),1,1),\Our\ApiConst::oneDaySecond,array($goodsCommonId)); $evaluation = \Our\RedisHelper::cachedFunction(\Redis\Db4\EvaluateGoodsRedisModel::getInstance(),array(&$evaluateInstance, 'getList'),array(array('geval_goods_commonid'=>$goodsCommonId,'geval_state'=>0),'geval_frommemberid,geval_frommembername AS memberName,geval_content AS gevalContent,geval_addtime AS gevalTime,geval_image,geval_explain AS gevalExplain,geval_isanonymous AS isAnonymous,goods_spec,member_avatar AS memberAvatar',array('geval_addtime','DESC'),1,1),\Our\ApiConst::oneDaySecond,array($goodsCommonId));
if($evaluation){ if($evaluation){
...@@ -561,7 +562,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -561,7 +562,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
// } // }
// } // }
$spec = \DAO\GoodsModel::getInstance()->getFormatGoodsAttr($evaluation['goods_spec']); $spec = \DAO\GoodsModel::getInstance()->getFormatGoodsAttr($evaluation['goods_spec']);
$evaluation['totalCount'] = $grade['totalCount']; $evaluation['totalCount'] = $statistics['evaluation_number'];
$evaluation['goodsAttr'] = $spec; $evaluation['goodsAttr'] = $spec;
$evaluation['gevalImage'] = $gevalImage; $evaluation['gevalImage'] = $gevalImage;
unset($evaluation['goods_spec']); unset($evaluation['goods_spec']);
...@@ -629,7 +630,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -629,7 +630,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$args[] = true; $args[] = true;
} }
$evaluations = \Our\RedisHelper::cachedFunction(\Redis\Db4\EvaluateGoodsRedisModel::getInstance(),array(&$evaluateInstance, 'getList'),$args,\Our\ApiConst::oneDaySecond,array($goodsCommonId)); $evaluations = \Our\RedisHelper::cachedFunction(\Redis\Db4\EvaluateGoodsRedisModel::getInstance(),array(&$evaluateInstance, 'getList'),$args,\Our\ApiConst::oneDaySecond,array($goodsCommonId));
$statistics = $this->getEvaluatesStatistics($goodsCommonId); $statistics = \DAO\GoodsScoreStatisticsModel::getInstance()->getGrade($goodsCommonId);
//$statistics = $this->getEvaluatesStatistics($goodsCommonId);
$data = []; $data = [];
if(is_array($evaluations) && !empty($evaluations)){ if(is_array($evaluations) && !empty($evaluations)){
foreach ($evaluations as $evaluation){ foreach ($evaluations as $evaluation){
...@@ -656,7 +658,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -656,7 +658,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$data[] = $evaluation; $data[] = $evaluation;
} }
} }
return array('evaluates'=>$data,'totalCount'=>$statistics['totalCount'],'grade'=>$statistics['avgScores'],'haveImgCount'=>$statistics['haveImgCount']); return array('evaluates'=>$data,'totalCount'=>$statistics['evaluation_number'],'grade'=>$statistics['evaluation_score']?number_format(($statistics['evaluation_score']/$statistics['evaluation_number']),1,'.',''):'5.0','haveImgCount'=>$statistics['evaluation_img_number']);
} }
/** /**
* 获取商品评价统计信息 * 获取商品评价统计信息
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment