// // FKProductItem.m // FirstLink // // Created by jack on 16/1/21. // Copyright © 2016年 FirstLink. All rights reserved. // #import "FKProductItem.h" @implementation FKProductItem - (instancetype)init{ if (self = [super init]) { _selectedAmount = 0; } return self; } + (NSDictionary *)mts_mapping{ return @{ @"id": mts_key(goodsID), @"title": mts_key(title), @"pic_url": mts_key(picUrl), @"spec_ids": mts_key(specIdList), @"price": mts_key(price), @"price_activity": mts_key(activityPrice), @"activity_price_desc": mts_key(activityDesc), @"original_price": mts_key(originPrice), @"weight": mts_key(weight), @"stock": mts_key(stock), @"sell_side": mts_key(sellSide), @"pay_tax": mts_key(needPayTax), @"online_status": mts_key(isOnline), }; } + (BOOL)mts_shouldSetUndefinedKeys{ return NO; } - (id)copyWithZone:(NSZone *)zone{ FKProductItem *newItem = [[FKProductItem allocWithZone:zone]init]; newItem.goodsID = self.goodsID; newItem.title = self.title; newItem.picUrl = self.picUrl; newItem.specIdList = self.specIdList; newItem.price = self.price; newItem.stock = self.stock; newItem.needPayTax = self.needPayTax; newItem.weight = self.weight; newItem.selectedAmount = self.selectedAmount; newItem.realStockCount = self.realStockCount; newItem.fullSpecName = self.fullSpecName; return newItem; } - (NSUInteger)realStockCount{ if ([self.stock isKindOfClass:[NSString class]]){ return self.stock.integerValue; } return NSIntegerMax; } - (NSInteger)getSingleWeight{ if ([self.weight isKindOfClass:[NSString class]]){ return self.weight.integerValue; } return 0; } - (BOOL)hasContainBasicId:(NSString *)specID{ if ([self.specIdList rangeOfString:specID].length > 0) return YES; return NO; } - (BOOL)isContainBasicIdArray:(NSArray *)basicIdArray{ if (!basicIdArray.count) return NO; for (NSString *basicID in basicIdArray) { if (![basicID isKindOfClass:[NSString class]]) return NO; if ([self.specIdList rangeOfString:basicID].length == 0) return NO; } return YES; } - (NSUInteger)getRealStock{ if ([self.stock isKindOfClass:[NSString class]]){ return self.stock.integerValue; } return NSIntegerMax; } - (FKPriceWarnItem *)createPriceWarnItem{ FKPriceWarnItem *warnItem = [[FKPriceWarnItem alloc]init]; warnItem.goodsID = self.goodsID; warnItem.specName = self.fullSpecName; warnItem.currentPrice = self.price; warnItem.notifyType = kNotifyTypeNone; return warnItem; } - (ProductType)productType{ if (self.sellSide.integerValue == 2){ return ProductTypeThird; } else if (self.sellSide.integerValue == 3){ return ProductTypeVIP; } return ProductTypeDefault; } @end