初始版本
This commit is contained in:
29
server/app/common/logic/ShopLogic.php
Executable file
29
server/app/common/logic/ShopLogic.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?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;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user