| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- //
- // JXMemberService.h
- // AICity
- //
- // Feature: 003-ios-api-https
- // Task: T051 - iOS会员状态检查
- // Created on 2025-10-14.
- //
- #import <Foundation/Foundation.h>
- @class JXMemberStatus, JXAccessCheckResult;
- NS_ASSUME_NONNULL_BEGIN
- /**
- * 会员状态数据模型
- */
- @interface JXMemberStatus : NSObject
- @property (nonatomic, assign) NSInteger userId;
- @property (nonatomic, strong) NSString *localMemberType; // free/basic/premium/vip
- @property (nonatomic, strong) NSString *juXingMemberType; // 0/1/2/3
- @property (nonatomic, assign) NSInteger accessLevel; // 0-3
- @property (nonatomic, assign) NSTimeInterval expireAt; // 过期时间戳
- @property (nonatomic, strong) NSString *syncStatus; // pending/synced/failed
- @property (nonatomic, assign) NSTimeInterval lastSyncAt; // 最后同步时间
- @property (nonatomic, assign) NSInteger retryCount; // 重试次数
- @property (nonatomic, assign) NSTimeInterval createdAt; // 创建时间
- @property (nonatomic, assign) NSTimeInterval updatedAt; // 更新时间
- /**
- * 检查是否过期
- */
- - (BOOL)isExpired;
- /**
- * 检查是否为VIP
- */
- - (BOOL)isVip;
- /**
- * 获取剩余天数
- */
- - (NSInteger)getRemainingDays;
- /**
- * 获取会员类型显示名称
- */
- - (NSString *)getDisplayName;
- @end
- /**
- * 权限检查结果
- */
- @interface JXAccessCheckResult : NSObject
- @property (nonatomic, assign) BOOL hasAccess;
- @property (nonatomic, strong) JXMemberStatus *memberStatus;
- @property (nonatomic, strong) NSString *contentType;
- @property (nonatomic, assign) NSInteger requiredLevel;
- @property (nonatomic, strong, nullable) NSString *contentId;
- @property (nonatomic, assign) NSTimeInterval checkTime;
- @property (nonatomic, strong) NSString *reason;
- @end
- /**
- * 剧星会员服务
- *
- * 功能:
- * - 会员状态检查和缓存
- * - 权限验证
- * - 状态实时更新
- */
- @interface JXMemberService : NSObject
- /**
- * 单例实例
- */
- + (instancetype)sharedService;
- /**
- * 当前会员状态(可能为nil)
- */
- @property (nonatomic, strong, readonly, nullable) JXMemberStatus *currentMemberStatus;
- /**
- * 获取当前用户会员状态
- * @param forceRefresh 是否强制刷新
- * @param completion 完成回调
- */
- - (void)getCurrentMemberStatusWithForceRefresh:(BOOL)forceRefresh
- completion:(void(^)(JXMemberStatus * _Nullable memberStatus, NSError * _Nullable error))completion;
- /**
- * 检查内容访问权限
- * @param contentType 内容类型
- * @param requiredLevel 所需权限级别
- * @param contentId 内容ID(可选)
- * @param completion 完成回调
- */
- - (void)checkContentAccessWithContentType:(NSString *)contentType
- requiredLevel:(NSInteger)requiredLevel
- contentId:(nullable NSString *)contentId
- completion:(void(^)(JXAccessCheckResult * _Nullable result, NSError * _Nullable error))completion;
- /**
- * 检查剧集访问权限
- * @param episodeId 剧集ID
- * @param requiredLevel 所需权限级别
- * @param completion 完成回调
- */
- - (void)checkEpisodeAccessWithEpisodeId:(NSString *)episodeId
- requiredLevel:(NSInteger)requiredLevel
- completion:(void(^)(JXAccessCheckResult * _Nullable result, NSError * _Nullable error))completion;
- /**
- * 检查剧访问权限
- * @param dramaId 剧ID
- * @param requiredLevel 所需权限级别
- * @param completion 完成回调
- */
- - (void)checkDramaAccessWithDramaId:(NSString *)dramaId
- requiredLevel:(NSInteger)requiredLevel
- completion:(void(^)(JXAccessCheckResult * _Nullable result, NSError * _Nullable error))completion;
- /**
- * 同步会员状态到服务器
- * @param completion 完成回调
- */
- - (void)syncMemberStatusWithCompletion:(void(^)(BOOL success, NSError * _Nullable error))completion;
- /**
- * 检查是否为VIP用户
- * @param completion 完成回调
- */
- - (void)isVipUserWithCompletion:(void(^)(BOOL isVip, NSError * _Nullable error))completion;
- /**
- * 检查会员是否过期
- * @param memberStatus 会员状态
- * @return 是否过期
- */
- - (BOOL)isMemberExpired:(JXMemberStatus *)memberStatus;
- /**
- * 获取会员到期时间
- * @param completion 完成回调
- */
- - (void)getMemberExpireTimeWithCompletion:(void(^)(NSTimeInterval expireTime, NSError * _Nullable error))completion;
- /**
- * 获取会员类型显示名称
- * @param memberType 会员类型
- * @return 显示名称
- */
- - (NSString *)getMemberTypeDisplayName:(NSString *)memberType;
- /**
- * 获取访问级别显示名称
- * @param accessLevel 访问级别
- * @return 显示名称
- */
- - (NSString *)getAccessLevelDisplayName:(NSInteger)accessLevel;
- /**
- * 清除会员状态缓存
- */
- - (void)clearMemberStatusCache;
- /**
- * 更新会员状态(用于购买成功后立即更新)
- * @param memberStatus 新的会员状态
- */
- - (void)updateMemberStatus:(JXMemberStatus *)memberStatus;
- /**
- * 添加会员状态变更监听
- * @param observer 观察者
- * @param selector 回调方法
- */
- - (void)addMemberStatusObserver:(id)observer selector:(SEL)selector;
- /**
- * 移除会员状态变更监听
- * @param observer 观察者
- */
- - (void)removeMemberStatusObserver:(id)observer;
- @end
- NS_ASSUME_NONNULL_END
|