29 lines
768 B
PHP
Executable File
29 lines
768 B
PHP
Executable File
<?php
|
|
namespace app\common\logic;
|
|
use app\common\model\goods\GoodsComment;
|
|
use app\common\model\shop\Shop;
|
|
|
|
class ShopLogic extends BaseLogic
|
|
{
|
|
|
|
/**
|
|
* @notes 更新商家评分
|
|
* @param int $shopId
|
|
* @return true
|
|
* @author cjhao
|
|
* @date 2024/12/6 12:32
|
|
*/
|
|
public static function updateShopComment(int $shopId)
|
|
{
|
|
|
|
$shopAllComment = GoodsComment::where(['shop_id'=>$shopId])->sum('service_comment');
|
|
$commentCount = GoodsComment::where(['shop_id'=>$shopId])->count();
|
|
$shopGoodsComment = 0;
|
|
if($commentCount){
|
|
$shopGoodsComment = round($shopAllComment/$commentCount,2);
|
|
}
|
|
Shop::update(['good_comment'=>$shopGoodsComment],['id'=>$shopId]);
|
|
return true;
|
|
|
|
}
|
|
} |