123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- //
- // 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
|