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
}
}