diff --git a/backend/app/dao/product/product/StoreProductReplyDao.php b/backend/app/dao/product/product/StoreProductReplyDao.php index 6d48fd421..180bf1d8d 100644 --- a/backend/app/dao/product/product/StoreProductReplyDao.php +++ b/backend/app/dao/product/product/StoreProductReplyDao.php @@ -54,8 +54,9 @@ class StoreProductReplyDao extends BaseDao */ public function getProductReply(int $productId) { + // cartInfo 关联已随 eb_store_order_cart_info 删除,SKU 由本表 suk 承载,仅预加载 userInfo return $this->search(['product_id' => $productId, 'is_del' => 0, 'status' => 1]) - ->with(['cartInfo', 'userInfo']) + ->with(['userInfo']) ->order('add_time DESC,product_score DESC,service_score DESC,add_time DESC') ->find(); } diff --git a/backend/app/services/product/CenterProductServices.php b/backend/app/services/product/CenterProductServices.php index 13e46a8b0..fd0581152 100644 --- a/backend/app/services/product/CenterProductServices.php +++ b/backend/app/services/product/CenterProductServices.php @@ -840,11 +840,14 @@ class CenterProductServices extends BaseService $reply = null; $replyCount = 0; $replyChance = 0; + $replyService = app()->make(\app\services\product\product\StoreProductReplyServices::class); + // 统计与推荐评价拆开:推荐评价失败不应拖垮数量/好评率 try { - $replyService = app()->make(\app\services\product\product\StoreProductReplyServices::class); - $reply = get_thumb_water($replyService->getRecProductReply($id), 'big', ['pics']); [$replyCount, $goodReply, $replyChance] = $replyService->getProductReplyData($id); } catch (\Throwable $e) {} + try { + $reply = get_thumb_water($replyService->getRecProductReply($id), 'big', ['pics']); + } catch (\Throwable $e) {} // ========== 9. 优惠券 ========== $coupons = []; diff --git a/backend/app/services/product/product/StoreProductReplyServices.php b/backend/app/services/product/product/StoreProductReplyServices.php index 88d256de3..6eae248cb 100644 --- a/backend/app/services/product/product/StoreProductReplyServices.php +++ b/backend/app/services/product/product/StoreProductReplyServices.php @@ -246,17 +246,16 @@ class StoreProductReplyServices extends BaseService if ($res) { $res = $res->toArray(); - if ($res['suk'] === '') { - $res['suk'] = isset($res['cart_info']['productInfo']['attrInfo']) ? $res['cart_info']['productInfo']['attrInfo']['suk'] : ''; - } + // SKU 以评价表 suk 为准(旧 cartInfo 关联已删除) + $res['suk'] = (string)($res['suk'] ?? ''); $res['nickname'] = anonymity($res['nickname']); - $res['merchant_reply_time'] = date('Y-m-d H:i', $res['merchant_reply_time']); + $replyTime = (int)($res['merchant_reply_time'] ?? 0); + $res['merchant_reply_time'] = $replyTime > 0 ? date('Y-m-d H:i', $replyTime) : ''; $res['add_time'] = time_tran($res['add_time']); - $res['star'] = bcadd($res['product_score'], $res['service_score'], 2); + $res['star'] = bcadd((string)$res['product_score'], (string)$res['service_score'], 2); $res['star'] = bcdiv($res['star'], '2', 0); $res['comment'] = $res['comment'] ?: '此用户没有填写评价'; $res['pics'] = is_string($res['pics']) ? json_decode($res['pics'], true) : $res['pics']; - unset($res['cartInfo']); } return $res; }