Browse Source

feat: 更新订单列表获取逻辑,添加用户ID和标签页参数

在OrderService中,修改getOrderList方法的注释,明确参数含义,并在buildOrderListQuery方法中添加条件以排除已删除的订单。此更改提升了代码可读性和用户体验,确保用户获取的订单列表更加准确。
刘学玺 2 months ago
parent
commit
ee7ff1a375
1 changed files with 6 additions and 1 deletions
  1. 6 1
      app/Services/Client/OrderService.php

+ 6 - 1
app/Services/Client/OrderService.php

@@ -1202,7 +1202,11 @@ readonly class OrderService
     }
 
     /**
-     * 获取订单列表
+     * 获取用户订单列表
+     *
+     * @param int $userId 用户ID
+     * @param int $tab 标签页 0:全部 1:待支付 2:进行中 3:已完成 4:已取消
+     * @return array
      */
     public function getOrderList(int $userId, int $tab = 0)
     {
@@ -1303,6 +1307,7 @@ readonly class OrderService
     private function buildOrderListQuery(MemberUser $user)
     {
         return $user->orders()
+            ->whereNull('user_deleted_at')  // 不显示用户已删除的订单
             ->with([
                 'coach' => function ($query) {
                     $query->with(['info' => function ($q) {