fix(订单): 修复商品评价提交两处 PHP 类型错误

- CenterOrderController 评价入口把 User 模型实例直接传入要求
  array 的 StoreProductReplyServices::comment(),先 toArray
- comment() 声明返回 int 但 save() 返回模型实例,取 id 返回,
  OrderComment 事件的 reply_id 参数同步统一为 int
This commit is contained in:
吴昊天 2026-10-08 14:24:07 +08:00
parent e81b48ff57
commit 6e1f2e9d39
2 changed files with 8 additions and 3 deletions

View File

@ -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);

View File

@ -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;
}
/**