No Description

FKProductItem.m 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // FKProductItem.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/1/21.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProductItem.h"
  9. @implementation FKProductItem
  10. - (instancetype)init{
  11. if (self = [super init]) {
  12. _selectedAmount = 0;
  13. }
  14. return self;
  15. }
  16. + (NSDictionary *)mts_mapping{
  17. return @{
  18. @"id": mts_key(goodsID),
  19. @"title": mts_key(title),
  20. @"pic_url": mts_key(picUrl),
  21. @"spec_ids": mts_key(specIdList),
  22. @"price": mts_key(price),
  23. @"price_activity": mts_key(activityPrice),
  24. @"activity_price_desc": mts_key(activityDesc),
  25. @"original_price": mts_key(originPrice),
  26. @"weight": mts_key(weight),
  27. @"stock": mts_key(stock),
  28. @"sell_side": mts_key(sellSide),
  29. @"pay_tax": mts_key(needPayTax),
  30. @"online_status": mts_key(isOnline),
  31. };
  32. }
  33. + (BOOL)mts_shouldSetUndefinedKeys{
  34. return NO;
  35. }
  36. - (id)copyWithZone:(NSZone *)zone{
  37. FKProductItem *newItem = [[FKProductItem allocWithZone:zone]init];
  38. newItem.goodsID = self.goodsID;
  39. newItem.title = self.title;
  40. newItem.picUrl = self.picUrl;
  41. newItem.specIdList = self.specIdList;
  42. newItem.price = self.price;
  43. newItem.stock = self.stock;
  44. newItem.needPayTax = self.needPayTax;
  45. newItem.weight = self.weight;
  46. newItem.selectedAmount = self.selectedAmount;
  47. newItem.realStockCount = self.realStockCount;
  48. newItem.fullSpecName = self.fullSpecName;
  49. return newItem;
  50. }
  51. - (NSUInteger)realStockCount{
  52. if ([self.stock isKindOfClass:[NSString class]]){
  53. return self.stock.integerValue;
  54. }
  55. return NSIntegerMax;
  56. }
  57. - (NSInteger)getSingleWeight{
  58. if ([self.weight isKindOfClass:[NSString class]]){
  59. return self.weight.integerValue;
  60. }
  61. return 0;
  62. }
  63. - (BOOL)hasContainBasicId:(NSString *)specID{
  64. if ([self.specIdList rangeOfString:specID].length > 0) return YES;
  65. return NO;
  66. }
  67. - (BOOL)isContainBasicIdArray:(NSArray *)basicIdArray{
  68. if (!basicIdArray.count) return NO;
  69. for (NSString *basicID in basicIdArray) {
  70. if (![basicID isKindOfClass:[NSString class]]) return NO;
  71. if ([self.specIdList rangeOfString:basicID].length == 0) return NO;
  72. }
  73. return YES;
  74. }
  75. - (NSUInteger)getRealStock{
  76. if ([self.stock isKindOfClass:[NSString class]]){
  77. return self.stock.integerValue;
  78. }
  79. return NSIntegerMax;
  80. }
  81. - (FKPriceWarnItem *)createPriceWarnItem{
  82. FKPriceWarnItem *warnItem = [[FKPriceWarnItem alloc]init];
  83. warnItem.goodsID = self.goodsID;
  84. warnItem.specName = self.fullSpecName;
  85. warnItem.currentPrice = self.price;
  86. warnItem.notifyType = kNotifyTypeNone;
  87. return warnItem;
  88. }
  89. - (ProductType)productType{
  90. if (self.sellSide.integerValue == 2){
  91. return ProductTypeThird;
  92. } else if (self.sellSide.integerValue == 3){
  93. return ProductTypeVIP;
  94. }
  95. return ProductTypeDefault;
  96. }
  97. @end