1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- //
- // FKVipBuyRuleItem.m
- // FirstLink
- //
- // Created by jack on 15/9/14.
- // Copyright (c) 2015年 FirstLink. All rights reserved.
- //
- #import "FKVipBuyRuleItem.h"
- #import "FKVipCouponItem.h"
- #import "FKVipDiscountItem.h"
- @implementation FKVipBuyRuleItem
- + (NSDictionary *)mts_mapping
- {
- return @{@"id" : mts_key(itemID),
- @"price" : mts_key(price),
- @"title" : mts_key(title),
- @"description" : mts_key(desc),
- @"days" : mts_key(days),
- @"coupons": mts_key(couponArray),
- @"vip_discount": mts_key(discountItem),
- };
- }
- + (BOOL)mts_shouldSetUndefinedKeys
- {
- return NO;
- }
- + (NSDictionary*)mts_arrayClassMapping
- {
- return @{mts_key(couponArray): FKVipCouponItem.class};
- }
- - (NSString *)realPrice{
- if ([self.price isKindOfClass:[NSString class]]) {
- CGFloat price = self.price.floatValue / 100;
- return [NSString stringWithFormat:@"%.f", price];
- }
- return @"0";
- }
- - (NSString *)timeToMonth{
- if (self.buyId == 1) {
- return @"1个月多收帮会员";
- }else if (self.buyId == 2){
- return @"6个月多收帮会员";
- }else if (self.buyId == 3){
- return @"12个月多收帮会员";
- }
- return @"0";
- }
- - (NSString *)couponString {
- NSMutableString *mutString = [NSMutableString string];
-
- for (FKVipCouponItem *item in self.couponArray) {
- if ([self.couponArray indexOfObject:item] > 0) {
- [mutString appendString:@"+"];
- }
- if (item.amount.length > 0 && item.quantity.length > 0) {
- [mutString appendString:@"¥"];
- [mutString appendString:[NSString stringWithFormat:@"%ld*%@", item.amount.integerValue/100, item.quantity]];
- }
- }
- return mutString;
- }
- - (NSString *)discountString {
- FKVipDiscountItem *item = self.discountItem;
- if (item.discount.length > 0 && item.quantity.length > 0) {
- NSString *text = (item.quantity.integerValue > 999 ? @"不限" : item.quantity);
- return [NSString stringWithFormat:@"%@折*%@次", item.discount, text];
- }
- return nil;
- }
- - (NSString *)validTimeString {
- if ([self.days isEqualToString:@"30"]) {
- return @"1个月";
- } else if ([self.days isEqualToString:@"90"]) {
- return @"3个月";
- } else if ([self.days isEqualToString:@"180"]) {
- return @"6个月";
- }
- return @"1年";
- }
- @end
|