Aucune description

FKRefundDetailViewModel.m 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //
  2. // FKRefundDetailViewModel.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 16/3/15.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKRefundDetailViewModel.h"
  9. #import "FKRefundDetailItem.h"
  10. #import "FKRefundPriceItem.h"
  11. int const FKRefundRequestDetail = 100;
  12. @implementation FKRefundDetailViewModel
  13. - (NSInteger)numberOfSectionsInTableView {
  14. return self.refundGoodsArray.count;
  15. }
  16. - (NSInteger)numberOfRowsInSection:(NSInteger)section {
  17. if (section < self.refundGoodsArray.count) {
  18. FKRefundDetailItem *item = self.refundGoodsArray[section];
  19. return (item.goodsArray.count + 7);
  20. }
  21. return 0;
  22. }
  23. - (kRefundDetailCellType)refundCellTypeAtIndexPath:(NSIndexPath *)indexPath {
  24. FKRefundDetailItem *item = self.refundGoodsArray[indexPath.section];
  25. if (indexPath.row == 0) {
  26. return kRefundDetailCellTypeStatus;
  27. } else if (indexPath.row > 0 && indexPath.row < (item.goodsArray.count + 1)) {
  28. return kRefundDetailCellTypeProduct;
  29. } else {
  30. if (indexPath.row == (item.goodsArray.count + 1) ) {
  31. return kRefundDetailCellTypeChargeClear;
  32. } else {
  33. return kRefundDetailCellTypeEntry;
  34. }
  35. }
  36. return kRefundDetailCellTypeNone;
  37. }
  38. - (FKRefundDetailItem *)refundDetailItemAtIndex:(NSInteger)index {
  39. if (index < self.refundGoodsArray.count) {
  40. return self.refundGoodsArray[index];
  41. }
  42. return nil;
  43. }
  44. + (NSString *)getRefundStatusText:(int)status {
  45. switch (status) {
  46. case 0:
  47. return @"已取消";
  48. case 1:
  49. return @"待退款";
  50. case 2:
  51. return @"已退款";
  52. default:
  53. break;
  54. }
  55. return @"";
  56. }
  57. - (NSAttributedString *)chargeClearTitle {
  58. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"退款明细"];
  59. [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x999999) range:NSMakeRange(0, attributedString.length)];
  60. [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, attributedString.length)];
  61. return attributedString;
  62. }
  63. - (NSAttributedString *)priceDetailTitle:(NSIndexPath *)indexPath {
  64. NSString *title = @"";
  65. NSString *subTitle = @"";
  66. UIColor *titleColor = UIColorFromRGB(0x333333);
  67. UIColor *subTitleColor = UIColorFromRGB(0x999999);
  68. FKRefundDetailItem *item = self.refundGoodsArray[indexPath.section];
  69. NSInteger index = (indexPath.row - item.goodsArray.count - 2);
  70. switch (index) {
  71. case 0: {
  72. title = @"商品总价";
  73. break;
  74. }
  75. case 1: {
  76. title = @"官网运费";
  77. break;
  78. }
  79. case 2: {
  80. title = @"国际运费";
  81. break;
  82. }
  83. case 3: {
  84. title = @"关税";
  85. break;
  86. }
  87. case 4: {
  88. title = @"代金券";
  89. break;
  90. }
  91. default:
  92. break;
  93. }
  94. NSString *string = [NSString stringWithFormat:@"%@%@", title, subTitle];
  95. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
  96. [attributedString addAttribute:NSForegroundColorAttributeName
  97. value:titleColor
  98. range:NSMakeRange(0, title.length)];
  99. [attributedString addAttribute:NSForegroundColorAttributeName
  100. value:subTitleColor
  101. range:NSMakeRange(title.length, subTitle.length)];
  102. return attributedString;
  103. }
  104. - (NSAttributedString *)priceDetailText:(NSIndexPath *)indexPath {
  105. NSString *text = @"¥-.--";
  106. UIColor *textColor = UIColorFromRGB(0x333333);
  107. FKRefundDetailItem *item = self.refundGoodsArray[indexPath.section];
  108. NSInteger index = (indexPath.row - item.goodsArray.count - 2);
  109. switch (index) {
  110. case 0: {
  111. text = [NSString stringWithFormat:@"¥%.2f", item.refundPriceItem.totalPrice.floatValue / 100.0f];
  112. break;
  113. }
  114. case 1: {
  115. text = [NSString stringWithFormat:@"¥%.2f", item.refundPriceItem.officialPostage.floatValue / 100.0f];
  116. break;
  117. }
  118. case 2: {
  119. text = [NSString stringWithFormat:@"¥%.2f", item.refundPriceItem.internationalPostage.floatValue / 100.0f];
  120. break;
  121. }
  122. case 3: {
  123. text = [NSString stringWithFormat:@"¥%.2f", item.refundPriceItem.taxFee.floatValue / 100.0f];
  124. break;
  125. }
  126. case 4: {
  127. text = [NSString stringWithFormat:@"-¥%.2f", item.refundPriceItem.derateFee.floatValue / 100.0f];
  128. break;
  129. }
  130. default:
  131. break;
  132. }
  133. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
  134. [attributedString addAttribute:NSForegroundColorAttributeName
  135. value:textColor
  136. range:NSMakeRange(0, text.length)];
  137. return attributedString;
  138. }
  139. @end