Ei kuvausta

FKVipBuyRuleItem.m 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // FKVipBuyRuleItem.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/9/14.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "FKVipBuyRuleItem.h"
  9. #import "FKVipCouponItem.h"
  10. #import "FKVipDiscountItem.h"
  11. @implementation FKVipBuyRuleItem
  12. + (NSDictionary *)mts_mapping
  13. {
  14. return @{@"id" : mts_key(itemID),
  15. @"price" : mts_key(price),
  16. @"title" : mts_key(title),
  17. @"description" : mts_key(desc),
  18. @"days" : mts_key(days),
  19. @"coupons": mts_key(couponArray),
  20. @"vip_discount": mts_key(discountItem),
  21. };
  22. }
  23. + (BOOL)mts_shouldSetUndefinedKeys
  24. {
  25. return NO;
  26. }
  27. + (NSDictionary*)mts_arrayClassMapping
  28. {
  29. return @{mts_key(couponArray): FKVipCouponItem.class};
  30. }
  31. - (NSString *)realPrice{
  32. if ([self.price isKindOfClass:[NSString class]]) {
  33. CGFloat price = self.price.floatValue / 100;
  34. return [NSString stringWithFormat:@"%.f", price];
  35. }
  36. return @"0";
  37. }
  38. - (NSString *)timeToMonth{
  39. if (self.buyId == 1) {
  40. return @"1个月多收帮会员";
  41. }else if (self.buyId == 2){
  42. return @"6个月多收帮会员";
  43. }else if (self.buyId == 3){
  44. return @"12个月多收帮会员";
  45. }
  46. return @"0";
  47. }
  48. - (NSString *)couponString {
  49. NSMutableString *mutString = [NSMutableString string];
  50. for (FKVipCouponItem *item in self.couponArray) {
  51. if ([self.couponArray indexOfObject:item] > 0) {
  52. [mutString appendString:@"+"];
  53. }
  54. if (item.amount.length > 0 && item.quantity.length > 0) {
  55. [mutString appendString:@"¥"];
  56. [mutString appendString:[NSString stringWithFormat:@"%ld*%@", item.amount.integerValue/100, item.quantity]];
  57. }
  58. }
  59. return mutString;
  60. }
  61. - (NSString *)discountString {
  62. FKVipDiscountItem *item = self.discountItem;
  63. if (item.discount.length > 0 && item.quantity.length > 0) {
  64. NSString *text = (item.quantity.integerValue > 999 ? @"不限" : item.quantity);
  65. return [NSString stringWithFormat:@"%@折*%@次", item.discount, text];
  66. }
  67. return nil;
  68. }
  69. - (NSString *)validTimeString {
  70. if ([self.days isEqualToString:@"30"]) {
  71. return @"1个月";
  72. } else if ([self.days isEqualToString:@"90"]) {
  73. return @"3个月";
  74. } else if ([self.days isEqualToString:@"180"]) {
  75. return @"6个月";
  76. }
  77. return @"1年";
  78. }
  79. @end