@@ -1668,4 +1668,19 @@ export class StoreService {
|
||||
await this.partnerGetStore(partnerAccountId, storeId);
|
||||
return this.replaceStoreCategories(storeId, categoryIds, priorities);
|
||||
}
|
||||
|
||||
/** 评价提交后回写门店综合评分(服务+环境均值) */
|
||||
async refreshStoreRatingFromReviews(storeId: bigint) {
|
||||
const agg = await this.prisma.storeRating.aggregate({
|
||||
where: { storeId },
|
||||
_avg: { serviceScore: true, envScore: true },
|
||||
});
|
||||
const avgService = Number(agg._avg.serviceScore ?? 0);
|
||||
const avgEnv = Number(agg._avg.envScore ?? 0);
|
||||
const rating = Math.round(((avgService + avgEnv) / 2) * 100) / 100;
|
||||
await this.prisma.store.update({
|
||||
where: { id: storeId },
|
||||
data: { rating },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user