123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //
- // SPSBDiscountCouponModel.m
- // 我的社保
- //
- // Created by shanp on 2021/5/24.
- //
- #import "SPSBDiscountCouponModel.h"
- #import <JXHSystemShortcut.h>
- typedef NS_ENUM(NSUInteger, SPSBDiscountCouponStatus) {
- SPSBDiscountCouponStatusUnuse = 1,
- SPSBDiscountCouponStatusUsed
- };
- typedef NS_ENUM(NSUInteger, SPSBDiscountCouponExpired) {
- SPSBDiscountCouponExpiredNo = 0,
- SPSBDiscountCouponExpiredYes
- };
- @implementation SPSBDiscountCouponModel
- - (bool)handleAdditionalProperty {
- [super handleAdditionalProperty];
-
- NSString *endDate;
- if (_spsb_end_time.length > 10) {
- endDate = [_spsb_end_time substringToIndex:10];
- } else {
- endDate = [[jxh_dateFormatter() stringFromDate:[NSDate new]] substringToIndex:10];
- }
-
- if (_spsb_status.integerValue == SPSBDiscountCouponStatusUsed) {
- _spsba_status = @"已使用";
- _spsba_canUse = false;
- } else if (_spsb_expired.integerValue == SPSBDiscountCouponExpiredYes) {
- _spsba_status = @"已过期";
- _spsba_canUse = false;
- } else {
- NSString *today = [jxh_dateFormatter() stringFromDate:[NSDate new]];
- NSString *todayDate = [today substringToIndex:10];
- if ([todayDate isEqualToString:endDate]) {
- _spsba_status = @"今天过期";
- } else {
- NSString *tempToday = [NSString stringWithFormat:@"%@ 00:00:00", todayDate];
- NSDate *tempTodayTime = [jxh_dateFormatter() dateFromString:tempToday];
- NSString *tempEndDate = [NSString stringWithFormat:@"%@ 00:00:00", endDate];
- NSDate *tempEndTime = [jxh_dateFormatter() dateFromString:tempEndDate];
- NSInteger diff = (NSInteger)([tempEndTime timeIntervalSinceDate:tempTodayTime] / 3600 / 24);
- if ([_spsb_end_time isEqualToString: tempEndDate]) {
- diff --;
- }
- if (diff == 0) {
- _spsba_status = @"今天过期";
- } else {
- _spsba_status = [NSString stringWithFormat:@"还有%ld天过期", (long)diff];
- }
- }
- _spsba_canUse = true;
- }
- _spsb_end_time = endDate;
-
- return true;
- }
- @end
|