|
@@ -47,19 +47,29 @@ class Index extends Controller
|
|
|
foreach ($newArrival as &$item) {
|
|
|
$item['comment_cnt'] = $rowsByGoodsId[$item['goods_id']] ?? 0;
|
|
|
$temp = bcmul($item['comment_cnt'], 10, 0);
|
|
|
- $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
|
|
|
+ if ($temp){
|
|
|
+ $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
|
|
|
+ }else{
|
|
|
+ $item['avg_score'] = 5;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
foreach ($bestseller as &$item) {
|
|
|
$item['comment_cnt'] = $rowsByGoodsId[$item['goods_id']] ?? 0;
|
|
|
- $temp = bcmul($item['comment_cnt'], 10, 0);
|
|
|
- $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']], $temp, 0);
|
|
|
+ if ($temp){
|
|
|
+ $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
|
|
|
+ }else{
|
|
|
+ $item['avg_score'] = 5;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
foreach ($superDeals as &$item) {
|
|
|
$item['comment_cnt'] = $rowsByGoodsId[$item['goods_id']] ?? 0;
|
|
|
- $temp = bcmul($item['comment_cnt'], 10, 0);
|
|
|
- $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']], $temp, 0);
|
|
|
+ if ($temp){
|
|
|
+ $item['avg_score'] = bcdiv($scoresByGoodsId[$item['goods_id']] ?? '0', $temp, 0);
|
|
|
+ }else{
|
|
|
+ $item['avg_score'] = 5;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$model = new ArticleModel;
|