Răsfoiți Sursa

我得足迹修改返回结构

moonsflyer 5 luni în urmă
părinte
comite
453ecf77e4
1 a modificat fișierele cu 17 adăugiri și 2 ștergeri
  1. 17 2
      app/shopapi/lists/GoodsVisitLists.php

+ 17 - 2
app/shopapi/lists/GoodsVisitLists.php

@@ -52,12 +52,27 @@ class GoodsVisitLists extends BaseShopDataLists implements ListsSearchInterface
             ->where($this->searchWhere)
             ->where($this->searchWhere)
             ->append(['goods'])
             ->append(['goods'])
             ->order([
             ->order([
-                'id' => 'desc'
+                'create_time' => 'desc'
             ])
             ])
             ->limit($this->limitOffset, $this->limitLength)
             ->limit($this->limitOffset, $this->limitLength)
             ->select()
             ->select()
             ->toArray();
             ->toArray();
-        return $lists;
+        // 按日期分组
+        $groupedData = [];
+        foreach ($lists as $item) {
+            $date = date('Y-m-d', $item['create_time']);
+            if (!isset($groupedData[$date])) {
+                $groupedData[$date] = [
+                    'date' => $date,
+                    'date_text' => date('Y年m月d日', $item['create_time']),
+                    'goods_list' => []
+                ];
+            }
+            $groupedData[$date]['goods_list'][] = $item;
+        }
+
+        // 转换为数组格式并按日期倒序排列
+        return array_values($groupedData);
     }
     }
 
 
     /**
     /**