//
//  QSLMemberModel.swift
//  QuickSearchLocation
//
//  Created by Destiny on 2024/12/9.
//

import MoyaMapper
import SwiftyJSON

struct QSLMemberModel: Modelable {
    
    var userId: String = ""
    
    var level: Int = 0
    
    var startTimestamp: Int = 0
    
    var endTimestamp: Int = 0
    
    var expired: Bool = true
    
    var permanent: Bool = false
    
    var deviceId: String = ""
    
    var subscriptionGroup: String = ""
    
    var autoRenewStatus: Int = 0
    
    var subscriptionExpired: Bool?
    
    mutating func mapping(_ json: JSON) {
              
    }
    
    func memberLevelString() -> String {
        
        var level = ""
        
        if self.expired {
            level = "未开通"
        }
        
        if self.permanent {
            level = "终身会员"
        }
        
        switch self.level {
        case 0:
            level = "未开通"
            break;
        case 100:
            level = "日卡VIP"
            break;
        case 700:
            level = "周卡VIP"
            break;
        case 3100:
            level = "月度VIP"
            break;
        case 9200:
            level = "季度VIP"
            break;
        case 36600:
            level = "年度VIP"
            break;
        case 3660000:
            level = "终身VIP"
            break;
        default:
            level = "未开通"
            break;
        }
        
        return level
    }
    
    func endTimestampString() -> String {
        return Date.timestampToFormatterTimeString(timestamp: "\(endTimestamp)", format: "yyyy-MM-dd")
    }
}
