// // PaymentAPI.swift // suixinkan // // Created by Codex on 2026/6/22. // import Foundation /// 收款模块服务协议,定义收款码和收款记录接口能力。 @MainActor protocol PaymentServing { /// 获取当前景区的静态收款码和动态收款码基础 URL。 func payCode(scenicId: Int) async throws -> PayCodeResponse /// 获取当前景区的扫码收款记录。 func paymentCollectionRecords(scenicId: Int) async throws -> PaymentCollectionRecordResponse } @MainActor /// 收款 API,封装首页“收款”模块需要的网络请求。 final class PaymentAPI { private let client: APIClient /// 初始化收款 API,并注入共享网络客户端。 init(client: APIClient) { self.client = client } /// 获取当前景区的静态收款码和动态收款码基础 URL。 func payCode(scenicId: Int) async throws -> PayCodeResponse { try await client.send( APIRequest( method: .get, path: "/api/yf-handset-app/photog/pay-code", queryItems: [URLQueryItem(name: "scenic_id", value: String(scenicId))] ) ) } /// 获取当前景区的扫码收款记录。 func paymentCollectionRecords(scenicId: Int) async throws -> PaymentCollectionRecordResponse { try await client.send( APIRequest( method: .get, path: "/api/yf-handset-app/photog/order/photo-scan-order-list", queryItems: [URLQueryItem(name: "scenic_id", value: String(scenicId))] ) ) } } extension PaymentAPI: PaymentServing {}