|
@@ -6,6 +6,7 @@ namespace App\Http\Controllers\admin;
|
|
|
|
|
|
|
|
use App\Constants\HttpStatus;
|
|
use App\Constants\HttpStatus;
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
+use App\Models\BalanceLog;
|
|
|
use App\Services\BalanceLogService;
|
|
use App\Services\BalanceLogService;
|
|
|
use Illuminate\Validation\ValidationException;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
use Exception;
|
|
use Exception;
|
|
@@ -46,14 +47,33 @@ class Balance extends Controller
|
|
|
request()->validate([
|
|
request()->validate([
|
|
|
'member_id' => ['nullable', 'string', 'min:1']
|
|
'member_id' => ['nullable', 'string', 'min:1']
|
|
|
]);
|
|
]);
|
|
|
- $search = request()->all();
|
|
|
|
|
- $search['change_types'] = BalanceLogService::$RW;
|
|
|
|
|
- $result = BalanceLogService::paginate($search);
|
|
|
|
|
|
|
+ $page = request()->input('page', 1);
|
|
|
|
|
+ $limit = request()->input('limit', 10);
|
|
|
|
|
+ $memberId = request()->input('member_id');
|
|
|
|
|
+ $query = BalanceLog::query();
|
|
|
|
|
+ if ($memberId) {
|
|
|
|
|
+ $query->where('member_id', $memberId);
|
|
|
|
|
+ }
|
|
|
|
|
+ $data['total'] = $query->count();
|
|
|
|
|
+ $data['data'] = $query->orderByDesc('id')
|
|
|
|
|
+ ->forPage($page,$limit)->with(['member'])
|
|
|
|
|
+ ->get()->toArray();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// $search = request()->all();
|
|
|
|
|
+// $search['change_types'] = BalanceLogService::$RW;
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// $result = BalanceLogService::paginate($search);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
} catch (ValidationException $e) {
|
|
} catch (ValidationException $e) {
|
|
|
return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
|
|
return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
return $this->error(intval($e->getCode()));
|
|
return $this->error(intval($e->getCode()));
|
|
|
}
|
|
}
|
|
|
- return $this->success($result);
|
|
|
|
|
|
|
+ return $this->success($data);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|