No Description

FKSubmitOrderReform.m 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // FKSubmitOrderReform.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/9/15.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "FKSubmitOrderReform.h"
  9. #import "CashCouponUseItem.h"
  10. @implementation FKSubmitOrderReform
  11. + (NSArray *)parserDiscountUseRuleWithDict:(NSDictionary *)dict{
  12. if ([dict[@"data"][@"list"] isKindOfClass:[NSArray class]]) {
  13. NSArray *array = dict[@"data"][@"list"];
  14. if (array.count == 0) return nil;
  15. NSMutableArray *cashUseArrayM = [NSMutableArray arrayWithCapacity:array.count];
  16. for (NSDictionary *itemDict in array) {
  17. CashCouponUseItem *useItem = [[CashCouponUseItem alloc]init];
  18. [useItem mts_setValuesForKeysWithDictionary:itemDict];
  19. [cashUseArrayM addObject:useItem];
  20. }
  21. return cashUseArrayM;
  22. // 筛选代金券
  23. // [self ruledDiscount];
  24. }
  25. return nil;
  26. }
  27. + (ShipAddress *)parserAddresModelWithDict:(NSDictionary *)dict{
  28. NSArray *modelArray = dict[@"data"][@"list"];
  29. if ([modelArray isKindOfClass:[NSArray class]] && [modelArray.firstObject isKindOfClass:[NSDictionary class]] && modelArray.count > 0){
  30. ShipAddress *addressModel = [[ShipAddress alloc]init];
  31. [addressModel mts_setValuesForKeysWithDictionary:modelArray.firstObject];
  32. return addressModel;
  33. }
  34. return nil;
  35. }
  36. + (CGFloat)parserCarriagePriceWithDict:(NSDictionary *)dict{
  37. if ([dict[@"data"][@"postage"] isKindOfClass:[NSNumber class]]) {
  38. return [dict[@"data"][@"postage"] floatValue] / 100.0f;
  39. }
  40. return 0;
  41. }
  42. + (SubmitDiscountItem *)parserDiscountItemWithDict:(NSDictionary *)dict{
  43. SubmitDiscountItem *model = [[SubmitDiscountItem alloc]init];
  44. if ([dict isKindOfClass:[NSDictionary class]]){
  45. [model mts_setValuesForKeysWithDictionary:dict[@"data"]];
  46. // 解析代金券
  47. NSArray *discountArray = dict[@"data"][@"cash_coupon_list"];
  48. if ([discountArray isKindOfClass:[NSArray class]] && discountArray.count) {
  49. NSMutableArray *arrayM = [NSMutableArray arrayWithCapacity:discountArray.count];
  50. for (int i = 0; i < discountArray.count; i++) {
  51. CashCouponItem *cash = [[CashCouponItem alloc]init];
  52. [cash mts_setValuesForKeysWithDictionary:discountArray[i]];
  53. [arrayM addObject:cash];
  54. }
  55. model.disCountArray = arrayM;
  56. }
  57. }
  58. return model;
  59. }
  60. + (CGFloat)parserInviteCutFeeWithDict:(NSDictionary *)dict{
  61. NSNumber *inviteCut = dict[@"data"][@"invite_code_discount"];
  62. if ([inviteCut isKindOfClass:[NSNumber class]]) return inviteCut.floatValue / 100.0f;
  63. return 0;
  64. }
  65. + (SubmitPaymentItem *)parserPaymentItemWithDict:(NSDictionary *)dict{
  66. if ([dict[@"data"][@"payment"] isKindOfClass:[NSDictionary class]]) {
  67. SubmitPaymentItem *model = [[SubmitPaymentItem alloc]init];
  68. [model mts_setValuesForKeysWithDictionary:dict[@"data"][@"payment"]];
  69. return model;
  70. }
  71. return nil;
  72. }
  73. + (BOOL)parserInviteResWithDict:(NSDictionary *)dict{
  74. if ([dict[@"data"][@"is_valid"] isKindOfClass:[NSNumber class]]){
  75. return [dict[@"data"][@"is_valid"] boolValue];
  76. }
  77. return false;
  78. }
  79. + (BOOL)parseInternationalPostageFree:(NSDictionary *)dict {
  80. NSString *text = [FKSubmitOrderReform parseActivityText:dict];
  81. if (text && text.length > 0) {
  82. return YES;
  83. }
  84. return NO;
  85. }
  86. + (NSString *)parseActivityText:(NSDictionary *)dict {
  87. if ([dict[@"data"][@"msg"] isKindOfClass:[NSString class]]){
  88. NSString *text = [NSString stringWithFormat:@"%@", dict[@"data"][@"msg"]];
  89. if (text.length > 0) {
  90. return text;
  91. }
  92. }
  93. return nil;
  94. }
  95. @end