Przeglądaj źródła

修复:退换/售后页的tab状态筛选

萤火科技 5 lat temu
rodzic
commit
badf57115e
2 zmienionych plików z 7 dodań i 6 usunięć
  1. 3 3
      app/api/controller/Refund.php
  2. 4 3
      app/api/model/OrderRefund.php

+ 3 - 3
app/api/controller/Refund.php

@@ -8,7 +8,7 @@
 // +----------------------------------------------------------------------
 // | Author: 萤火科技 <admin@yiovo.com>
 // +----------------------------------------------------------------------
-declare (strict_types = 1);
+declare (strict_types=1);
 
 namespace app\api\controller;
 
@@ -24,12 +24,12 @@ class Refund extends Controller
 {
     /**
      * 售后单列表
-     * @param int|null $state
+     * @param int $state
      * @return array|\think\response\Json
      * @throws BaseException
      * @throws \think\db\exception\DbException
      */
-    public function list(int $state = null)
+    public function list(int $state = -1)
     {
         $model = new OrderRefundModel;
         $list = $model->getList($state);

+ 4 - 3
app/api/model/OrderRefund.php

@@ -80,21 +80,22 @@ class OrderRefund extends OrderRefundModel
 
     /**
      * 获取用户售后单列表
-     * @param int|null $state 售后单状态
+     * @param int $state 售后单状态 -1为全部
      * @return \think\Paginator
      * @throws \app\common\exception\BaseException
      * @throws \think\db\exception\DbException
      */
-    public function getList(int $state = null)
+    public function getList(int $state = -1)
     {
         // 检索查询条件
         $filter = [];
         // 售后单状态
-        !is_null($state) && $filter[] = ['status', '=', $state];
+        $state > -1 && $filter[] = ['status', '=', $state];
         // 当前用户ID
         $userId = UserService::getCurrentLoginUserId();
         // 查询列表记录
         return $this->with(['orderGoods.image'])
+            ->where($filter)
             ->where('user_id', '=', $userId)
             ->order(['create_time' => 'desc'])
             ->paginate(15);