123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- //
- // FKSubmitOrderReform.m
- // FirstLink
- //
- // Created by jack on 15/9/15.
- // Copyright (c) 2015年 FirstLink. All rights reserved.
- //
- #import "FKSubmitOrderReform.h"
- #import "CashCouponUseItem.h"
- @implementation FKSubmitOrderReform
- + (NSArray *)parserDiscountUseRuleWithDict:(NSDictionary *)dict{
- if ([dict[@"data"][@"list"] isKindOfClass:[NSArray class]]) {
- NSArray *array = dict[@"data"][@"list"];
- if (array.count == 0) return nil;
-
- NSMutableArray *cashUseArrayM = [NSMutableArray arrayWithCapacity:array.count];
- for (NSDictionary *itemDict in array) {
- CashCouponUseItem *useItem = [[CashCouponUseItem alloc]init];
- [useItem mts_setValuesForKeysWithDictionary:itemDict];
- [cashUseArrayM addObject:useItem];
- }
- return cashUseArrayM;
- // 筛选代金券
- // [self ruledDiscount];
- }
- return nil;
- }
- + (ShipAddress *)parserAddresModelWithDict:(NSDictionary *)dict{
- NSArray *modelArray = dict[@"data"][@"list"];
- if ([modelArray isKindOfClass:[NSArray class]] && [modelArray.firstObject isKindOfClass:[NSDictionary class]] && modelArray.count > 0){
- ShipAddress *addressModel = [[ShipAddress alloc]init];
- [addressModel mts_setValuesForKeysWithDictionary:modelArray.firstObject];
- return addressModel;
- }
- return nil;
- }
- + (CGFloat)parserCarriagePriceWithDict:(NSDictionary *)dict{
- if ([dict[@"data"][@"postage"] isKindOfClass:[NSNumber class]]) {
- return [dict[@"data"][@"postage"] floatValue] / 100.0f;
- }
- return 0;
- }
- + (SubmitDiscountItem *)parserDiscountItemWithDict:(NSDictionary *)dict{
- SubmitDiscountItem *model = [[SubmitDiscountItem alloc]init];
- if ([dict isKindOfClass:[NSDictionary class]]){
- [model mts_setValuesForKeysWithDictionary:dict[@"data"]];
- // 解析代金券
- NSArray *discountArray = dict[@"data"][@"cash_coupon_list"];
- if ([discountArray isKindOfClass:[NSArray class]] && discountArray.count) {
- NSMutableArray *arrayM = [NSMutableArray arrayWithCapacity:discountArray.count];
- for (int i = 0; i < discountArray.count; i++) {
- CashCouponItem *cash = [[CashCouponItem alloc]init];
- [cash mts_setValuesForKeysWithDictionary:discountArray[i]];
- [arrayM addObject:cash];
- }
- model.disCountArray = arrayM;
- }
- }
- return model;
- }
- + (CGFloat)parserInviteCutFeeWithDict:(NSDictionary *)dict{
- NSNumber *inviteCut = dict[@"data"][@"invite_code_discount"];
- if ([inviteCut isKindOfClass:[NSNumber class]]) return inviteCut.floatValue / 100.0f;
- return 0;
- }
- + (SubmitPaymentItem *)parserPaymentItemWithDict:(NSDictionary *)dict{
- if ([dict[@"data"][@"payment"] isKindOfClass:[NSDictionary class]]) {
- SubmitPaymentItem *model = [[SubmitPaymentItem alloc]init];
- [model mts_setValuesForKeysWithDictionary:dict[@"data"][@"payment"]];
- return model;
- }
- return nil;
- }
- + (BOOL)parserInviteResWithDict:(NSDictionary *)dict{
- if ([dict[@"data"][@"is_valid"] isKindOfClass:[NSNumber class]]){
- return [dict[@"data"][@"is_valid"] boolValue];
- }
- return false;
- }
- + (BOOL)parseInternationalPostageFree:(NSDictionary *)dict {
- NSString *text = [FKSubmitOrderReform parseActivityText:dict];
- if (text && text.length > 0) {
- return YES;
- }
- return NO;
- }
- + (NSString *)parseActivityText:(NSDictionary *)dict {
- if ([dict[@"data"][@"msg"] isKindOfClass:[NSString class]]){
- NSString *text = [NSString stringWithFormat:@"%@", dict[@"data"][@"msg"]];
- if (text.length > 0) {
- return text;
- }
- }
- return nil;
- }
- @end
|