新增订单长尾流程,并迁移排队、消息、结算与审核模块

将定金订单、历史拍摄与多行程上传接入 Orders,并以真实页面替换首页排队管理、消息中心、景区结算与提现审核占位入口。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-25 13:39:02 +08:00
parent 311a70d610
commit c39c3d3c75
63 changed files with 9823 additions and 58 deletions

View File

@ -0,0 +1,139 @@
//
// WithdrawalAuditViewModel.swift
// suixinkan
//
// Created by Codex on 2026/6/25.
//
import Foundation
import Observation
///
enum WithdrawalAuditFilter: String, CaseIterable, Identifiable {
case all
case processing
case completed
var id: String { rawValue }
///
var title: String {
switch self {
case .all: "全部"
case .processing: "处理中"
case .completed: "已完成"
}
}
}
@MainActor
@Observable
/// ViewModel
final class WithdrawalAuditViewModel {
var records: [WalletWithdrawRecord] = []
var selectedFilter: WithdrawalAuditFilter = .all
var isLoading = false
var isLoadingMore = false
var loadFailed = false
var loadFailureReason: String?
var errorMessage: String?
private let pageSize = 10
private var page = 1
private var total = 0
///
var filteredRecords: [WalletWithdrawRecord] {
filteredRecords(for: selectedFilter)
}
///
var hasMore: Bool {
records.count < total
}
/// 使 total
var totalCount: Int {
max(total, records.count)
}
///
var processingCount: Int {
filteredRecords(for: .processing).count
}
///
var completedCount: Int {
filteredRecords(for: .completed).count
}
///
func filteredRecords(for filter: WithdrawalAuditFilter) -> [WalletWithdrawRecord] {
switch filter {
case .all:
return records
case .processing:
return records.filter { record in
let status = record.statusLabel
return status.contains("") || status.contains("")
}
case .completed:
return records.filter { record in
let status = record.statusLabel
return status.contains("完成") || status.contains("到账") || status.contains("通过")
}
}
}
///
func selectFilter(_ filter: WithdrawalAuditFilter) {
selectedFilter = filter
}
///
func reload(api: WalletServing) async {
isLoading = true
loadFailed = false
loadFailureReason = nil
errorMessage = nil
defer { isLoading = false }
do {
let response = try await api.walletWithdrawList(page: 1, pageSize: pageSize)
records = response.item
total = response.total
page = 1
} catch {
clearRecords()
loadFailed = true
loadFailureReason = error.localizedDescription
errorMessage = error.localizedDescription
}
}
///
func loadMore(api: WalletServing) async {
guard hasMore, !isLoadingMore, !isLoading else { return }
isLoadingMore = true
errorMessage = nil
defer { isLoadingMore = false }
let nextPage = page + 1
do {
let response = try await api.walletWithdrawList(page: nextPage, pageSize: pageSize)
records += response.item
total = response.total
page = nextPage
} catch {
errorMessage = error.localizedDescription
}
}
///
private func clearRecords() {
records = []
page = 1
total = 0
isLoadingMore = false
}
}