ModelWallet.m 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // ModelWallet.m
  3. //
  4. // Created by on 2021/8/10
  5. // Copyright (c) 2021 __MyCompanyName__. All rights reserved.
  6. //
  7. #import "ModelWallet.h"
  8. NSString *const kModelWalletProfitBalance = @"profitBalance";
  9. NSString *const kModelWalletAccount = @"account";
  10. NSString *const kModelWalletMerchantNum = @"merchantNum";
  11. NSString *const kModelWalletRecCode = @"recCode";
  12. NSString *const kModelWalletCardHoldFront = @"cardHoldFront";
  13. NSString *const kModelWalletAgentCode = @"agentCode";
  14. NSString *const kModelWalletGesturePassword = @"gesturePassword";
  15. NSString *const kModelWalletNickName = @"nickName";
  16. NSString *const kModelWalletProfitPos = @"profitPos";
  17. NSString *const kModelWalletHeadPortrait = @"headPortrait";
  18. NSString *const kModelWalletRealName = @"realName";
  19. NSString *const kModelWalletIsAuthentication = @"isAuthentication";
  20. NSString *const kModelWalletUnallocatedBalance = @"UnallocatedBalance";
  21. NSString *const kModelWalletCardFront = @"cardFront";
  22. NSString *const kModelWalletUserLevel = @"userLevel";
  23. NSString *const kModelWalletId = @"id";
  24. NSString *const kModelWalletProfitActivation = @"profitActivation";
  25. NSString *const kModelWalletProfitCard = @"profitCard";
  26. NSString *const kModelWalletProfitIntegral = @"profitIntegral";
  27. NSString *const kModelWalletCardReverse = @"cardReverse";
  28. NSString *const kModelWalletPhone = @"phone";
  29. NSString *const kModelWalletProfitTotal = @"profitTotal";
  30. NSString *const kModelWalletTransactionTotal = @"transactionTotal";
  31. NSString *const kModelWalletCardNo = @"cardNo";
  32. NSString *const kModelWalletAgentNum = @"agentNum";
  33. NSString *const kModelWalletAuditTime = @"auditTime";
  34. NSString *const kModelWalletRemark = @"remark";
  35. NSString *const kModelWalletCardHoldReverse = @"cardHoldReverse";
  36. @interface ModelWallet ()
  37. - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
  38. @end
  39. @implementation ModelWallet
  40. @synthesize profitBalance = _profitBalance;
  41. @synthesize account = _account;
  42. @synthesize merchantNum = _merchantNum;
  43. @synthesize recCode = _recCode;
  44. @synthesize cardHoldFront = _cardHoldFront;
  45. @synthesize agentCode = _agentCode;
  46. @synthesize gesturePassword = _gesturePassword;
  47. @synthesize nickName = _nickName;
  48. @synthesize profitPos = _profitPos;
  49. @synthesize headPortrait = _headPortrait;
  50. @synthesize realName = _realName;
  51. @synthesize isAuthentication = _isAuthentication;
  52. @synthesize unallocatedBalance = _unallocatedBalance;
  53. @synthesize cardFront = _cardFront;
  54. @synthesize userLevel = _userLevel;
  55. @synthesize internalBaseClassIdentifier = _internalBaseClassIdentifier;
  56. @synthesize profitActivation = _profitActivation;
  57. @synthesize profitCard = _profitCard;
  58. @synthesize profitIntegral = _profitIntegral;
  59. @synthesize cardReverse = _cardReverse;
  60. @synthesize phone = _phone;
  61. @synthesize profitTotal = _profitTotal;
  62. @synthesize transactionTotal = _transactionTotal;
  63. @synthesize cardNo = _cardNo;
  64. @synthesize agentNum = _agentNum;
  65. @synthesize auditTime = _auditTime;
  66. @synthesize remark = _remark;
  67. @synthesize cardHoldReverse = _cardHoldReverse;
  68. + (instancetype)modelObjectWithDictionary:(NSDictionary *)dict {
  69. return [[self alloc] initWithDictionary:dict];
  70. }
  71. - (instancetype)initWithDictionary:(NSDictionary *)dict {
  72. self = [super init];
  73. // This check serves to make sure that a non-NSDictionary object
  74. // passed into the model class doesn't break the parsing.
  75. if (self && [dict isKindOfClass:[NSDictionary class]]) {
  76. self.profitBalance = [[self objectOrNilForKey:kModelWalletProfitBalance fromDictionary:dict] doubleValue];
  77. self.account = [self objectOrNilForKey:kModelWalletAccount fromDictionary:dict];
  78. self.merchantNum = [[self objectOrNilForKey:kModelWalletMerchantNum fromDictionary:dict] doubleValue];
  79. self.recCode = [self objectOrNilForKey:kModelWalletRecCode fromDictionary:dict];
  80. self.cardHoldFront = [self objectOrNilForKey:kModelWalletCardHoldFront fromDictionary:dict];
  81. self.agentCode = [self objectOrNilForKey:kModelWalletAgentCode fromDictionary:dict];
  82. self.gesturePassword = [self objectOrNilForKey:kModelWalletGesturePassword fromDictionary:dict];
  83. self.nickName = [self objectOrNilForKey:kModelWalletNickName fromDictionary:dict];
  84. self.profitPos = [[self objectOrNilForKey:kModelWalletProfitPos fromDictionary:dict] doubleValue];
  85. self.headPortrait = [self objectOrNilForKey:kModelWalletHeadPortrait fromDictionary:dict];
  86. self.realName = [self objectOrNilForKey:kModelWalletRealName fromDictionary:dict];
  87. self.isAuthentication = [[self objectOrNilForKey:kModelWalletIsAuthentication fromDictionary:dict] doubleValue];
  88. self.unallocatedBalance = [[self objectOrNilForKey:kModelWalletUnallocatedBalance fromDictionary:dict] doubleValue];
  89. self.cardFront = [self objectOrNilForKey:kModelWalletCardFront fromDictionary:dict];
  90. self.userLevel = [[self objectOrNilForKey:kModelWalletUserLevel fromDictionary:dict] doubleValue];
  91. self.internalBaseClassIdentifier = [self objectOrNilForKey:kModelWalletId fromDictionary:dict];
  92. self.profitActivation = [[self objectOrNilForKey:kModelWalletProfitActivation fromDictionary:dict] doubleValue];
  93. self.profitCard = [[self objectOrNilForKey:kModelWalletProfitCard fromDictionary:dict] doubleValue];
  94. self.profitIntegral = [[self objectOrNilForKey:kModelWalletProfitIntegral fromDictionary:dict] doubleValue];
  95. self.cardReverse = [self objectOrNilForKey:kModelWalletCardReverse fromDictionary:dict];
  96. self.phone = [self objectOrNilForKey:kModelWalletPhone fromDictionary:dict];
  97. self.profitTotal = [[self objectOrNilForKey:kModelWalletProfitTotal fromDictionary:dict] doubleValue];
  98. self.transactionTotal = [[self objectOrNilForKey:kModelWalletTransactionTotal fromDictionary:dict] doubleValue];
  99. self.cardNo = [self objectOrNilForKey:kModelWalletCardNo fromDictionary:dict];
  100. self.agentNum = [[self objectOrNilForKey:kModelWalletAgentNum fromDictionary:dict] doubleValue];
  101. self.auditTime = [self objectOrNilForKey:kModelWalletAuditTime fromDictionary:dict];
  102. self.remark = [self objectOrNilForKey:kModelWalletRemark fromDictionary:dict];
  103. self.cardHoldReverse = [self objectOrNilForKey:kModelWalletCardHoldReverse fromDictionary:dict];
  104. }
  105. return self;
  106. }
  107. - (NSDictionary *)dictionaryRepresentation {
  108. NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
  109. [mutableDict setValue:[NSNumber numberWithDouble:self.profitBalance] forKey:kModelWalletProfitBalance];
  110. [mutableDict setValue:self.account forKey:kModelWalletAccount];
  111. [mutableDict setValue:[NSNumber numberWithDouble:self.merchantNum] forKey:kModelWalletMerchantNum];
  112. [mutableDict setValue:self.recCode forKey:kModelWalletRecCode];
  113. [mutableDict setValue:self.cardHoldFront forKey:kModelWalletCardHoldFront];
  114. [mutableDict setValue:self.agentCode forKey:kModelWalletAgentCode];
  115. [mutableDict setValue:self.gesturePassword forKey:kModelWalletGesturePassword];
  116. [mutableDict setValue:self.nickName forKey:kModelWalletNickName];
  117. [mutableDict setValue:[NSNumber numberWithDouble:self.profitPos] forKey:kModelWalletProfitPos];
  118. [mutableDict setValue:self.headPortrait forKey:kModelWalletHeadPortrait];
  119. [mutableDict setValue:self.realName forKey:kModelWalletRealName];
  120. [mutableDict setValue:[NSNumber numberWithDouble:self.isAuthentication] forKey:kModelWalletIsAuthentication];
  121. [mutableDict setValue:[NSNumber numberWithDouble:self.unallocatedBalance] forKey:kModelWalletUnallocatedBalance];
  122. [mutableDict setValue:self.cardFront forKey:kModelWalletCardFront];
  123. [mutableDict setValue:[NSNumber numberWithDouble:self.userLevel] forKey:kModelWalletUserLevel];
  124. [mutableDict setValue:self.internalBaseClassIdentifier forKey:kModelWalletId];
  125. [mutableDict setValue:[NSNumber numberWithDouble:self.profitActivation] forKey:kModelWalletProfitActivation];
  126. [mutableDict setValue:[NSNumber numberWithDouble:self.profitCard] forKey:kModelWalletProfitCard];
  127. [mutableDict setValue:[NSNumber numberWithDouble:self.profitIntegral] forKey:kModelWalletProfitIntegral];
  128. [mutableDict setValue:self.cardReverse forKey:kModelWalletCardReverse];
  129. [mutableDict setValue:self.phone forKey:kModelWalletPhone];
  130. [mutableDict setValue:[NSNumber numberWithDouble:self.profitTotal] forKey:kModelWalletProfitTotal];
  131. [mutableDict setValue:[NSNumber numberWithDouble:self.transactionTotal] forKey:kModelWalletTransactionTotal];
  132. [mutableDict setValue:self.cardNo forKey:kModelWalletCardNo];
  133. [mutableDict setValue:[NSNumber numberWithDouble:self.agentNum] forKey:kModelWalletAgentNum];
  134. [mutableDict setValue:self.auditTime forKey:kModelWalletAuditTime];
  135. [mutableDict setValue:self.remark forKey:kModelWalletRemark];
  136. [mutableDict setValue:self.cardHoldReverse forKey:kModelWalletCardHoldReverse];
  137. return [NSDictionary dictionaryWithDictionary:mutableDict];
  138. }
  139. - (NSString *)description {
  140. return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
  141. }
  142. #pragma mark - Helper Method
  143. - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict {
  144. id object = [dict objectForKey:aKey];
  145. return [object isEqual:[NSNull null]] ? nil : object;
  146. }
  147. @end