diff --git a/backend/app/api/controller/v1/order/CenterOrderController.php b/backend/app/api/controller/v1/order/CenterOrderController.php index 9e42fff98..2d0a26292 100644 --- a/backend/app/api/controller/v1/order/CenterOrderController.php +++ b/backend/app/api/controller/v1/order/CenterOrderController.php @@ -2763,7 +2763,10 @@ class CenterOrderController // ==================== 3. 获取用户信息 ==================== $uid = (int)request()->uid(); $user_info = request()->user(); - // 用户信息在 Service 中处理 + // StoreProductReplyServices::comment() 要求数组(取 nickname/avatar) + if (is_object($user_info)) { + $user_info = $user_info->toArray(); + } // ==================== 4. 从中台订单快照定位商品(unique 为 SKU 唯一码,限定本人订单防越权) ==================== $item = $this->findOrderItemBySkuUnique((string)$unique, $uid); diff --git a/backend/app/services/product/product/StoreProductReplyServices.php b/backend/app/services/product/product/StoreProductReplyServices.php index fe4bf5354..bab33a03c 100644 --- a/backend/app/services/product/product/StoreProductReplyServices.php +++ b/backend/app/services/product/product/StoreProductReplyServices.php @@ -158,6 +158,7 @@ class StoreProductReplyServices extends BaseService if (!$res) { throw new AdminException('评价失败'); } + $replyId = (int)($res->id ?? 0); // ==================== 触发评价事件 ==================== // 订单评价事件(通知管理员、缓存抽奖次数等) @@ -168,7 +169,7 @@ class StoreProductReplyServices extends BaseService 'uid' => $uid, 'product_id'=> $productId, 'order_id' => $cartInfo['oid'], - 'reply_id' => $res, + 'reply_id' => $replyId, 'star' => $data['star'] ?? 5, 'content' => $data['comment'] ?? '', ]]); @@ -176,7 +177,8 @@ class StoreProductReplyServices extends BaseService // 检查订单是否全部评价完成,若是则更新订单状态为已完成 $this->checkOrderOverAfterComment($cartInfo['oid']); - return $res; + // save() 返回模型实例,签名声明返回 int(评价ID) + return $replyId; } /**