LNHttpManager+Purchase.swift 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // LNHttpManager+Purchase.swift
  3. // Lanu
  4. //
  5. // Created by OneeChan on 2025/12/22.
  6. //
  7. import Foundation
  8. import UIKit
  9. import SnapKit
  10. private let kNetPath_Purchase_Wallet = "/user/my/wallet"
  11. private let kNetPath_Purchase_Goods = "/wallet/recharge/goods"
  12. private let kNetPath_Purchase_Create = "/wallet/recharge/submit"
  13. private let kNetPath_Purchase_Verify = "/wallet/recharge/goods/payBak"
  14. private let kNetPath_Purchase_Exchange = "/wallet/exchange"
  15. private let kNetPath_Purchase_Pre = "/wallet/exchange/pre"
  16. extension LNHttpManager {
  17. func getWalletInfo(completion: @escaping (LNUserWalletInfoResponse?, LNHttpError?) -> Void) {
  18. post(path: kNetPath_Purchase_Wallet, completion: completion)
  19. }
  20. func getGoodsList(currencyType: LNCurrencyType, completion: @escaping (LNPurchaseGoodsListResponse?, LNHttpError?) -> Void) {
  21. post(path: kNetPath_Purchase_Goods, params: [
  22. "walletType": currencyType.rawValue,
  23. "rechargePlatform": LNPurchasePlatform.iOS.rawValue
  24. ], completion: completion)
  25. }
  26. func createPurchase(id: String, completion: @escaping (LNPurchaseCreateOrderResponse?, LNHttpError?) -> Void) {
  27. post(path: kNetPath_Purchase_Create, params: [
  28. "id": id
  29. ], completion: completion)
  30. }
  31. func exchangeCurrency(from: LNCurrencyType, to: LNCurrencyType,
  32. amount: Double, completion: @escaping (LNHttpError?) -> Void) {
  33. post(path: kNetPath_Purchase_Exchange, params: [
  34. "fromWalletType": from.rawValue,
  35. "toWalletType": to.rawValue,
  36. "amount": amount
  37. ], completion: completion)
  38. }
  39. func verifyPurchase(orderId: String, receipt: String, completion: @escaping (LNHttpError?) -> Void) {
  40. post(path: kNetPath_Purchase_Verify, params: [
  41. "userId": myUid,
  42. "orderId": orderId,
  43. "payType": LNPurchasePayType.apple.rawValue,
  44. "receipt": receipt
  45. ], completion: completion)
  46. }
  47. func getExchangeExpectResult(from: LNCurrencyType, to: LNCurrencyType, count: Double,
  48. completion: @escaping (LNExchangeExpectResponse?, LNHttpError?) -> Void) {
  49. post(path: kNetPath_Purchase_Pre, params: [
  50. "fromWalletType": from.rawValue,
  51. "toWalletType": to.rawValue,
  52. "amount": count
  53. ], completion: completion)
  54. }
  55. }