jsdw_ios/QuickLocation/Section/VipRecharge/VipExpenseModel.swift

89 lines
2.0 KiB
Swift

//
// VipExpenseModel.swift
// QuickLocation
//
// Created by 八条 on 2026/6/3.
//
import ObjectMapper
import RxDataSources
struct VipExpenseResponse: BaseModelProtocol {
// 状态码
var code: String?
// 消息
var message: String?
//
var list: [VipExpenseModel] = []
init?(map: Map) {}
mutating func mapping(map: Map) {
code <- map["code"]
message <- map["msg"]
list <- map["data"]
}
}
struct VipExpenseModel: Mappable, Equatable {
///
var goods_id: String = ""
/// 资费名字
var goods_name: String = ""
/// 资费
var price: String = ""
/// 资费原价
var origin_price: String = ""
/// 资费标签
var tips: String = ""
/// 资费说明
var tips2: String = ""
/// 单位 月1m 年 12m 得换算
var value: String = ""
var unit: String {
guard value.hasSuffix("m") else { return "" }
let monthStr = value.replacingOccurrences(of: "m", with: "")
guard !monthStr.isEmpty, let month = Int(monthStr) else { return "" }
if month >= 12 {
let num = month / 12
return num > 1 ? "/\(num)年" : "/年"
} else if month % 3 == 0 {
let num = month / 3
return num > 1 ? "/\(num)季" : "/季"
} else {
return month > 1 ? "/\(month)月" : "/月"
}
}
/// 支付方式
var pay_type: String = ""
/// 选中状态
var checked: Bool = false
init?(map: Map) {
}
mutating func mapping(map: Map) {
goods_id <- map["goods_id"]
goods_name <- map["goods_name"]
price <- map["price"]
origin_price <- map["origin_price"]
tips <- map["tips"]
tips2 <- map["tips2"]
value <- map["value"]
checked <- map["checked"]
pay_type <- map["pay_type"]
}
}
extension VipExpenseModel: IdentifiableType {
public typealias Identity = String
public var identity: String {
return goods_id
}
}