SPSBQueryListDetailsTransactionViewViewController.m 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. //
  2. // SPSBQueryListDetailsTransactionViewViewController.m
  3. //
  4. //
  5. // Created by jiaxian_he on 2021/5/29.
  6. //
  7. #import "SPSBQueryListDetailsTransactionViewViewController.h"
  8. #import "SPSBUIGeneralHeader.h"
  9. #import "SPSBQueryListDetailsTransactionTableViewController.h"
  10. #import <JXHClassifyView.h>
  11. #import "UIViewController+SPSBNetworkManager.h"
  12. #import "UIViewController+SPSBDefault.h"
  13. #import "SPSBQueryListDetailsTransactionModel.h"
  14. @interface SPSBQueryListDetailsTransactionViewViewController () {
  15. JXHClassifyView *_classifyView;
  16. SPSBQueryListDetailsTransactionTableViewController *_tableVC;
  17. }
  18. @end
  19. @implementation SPSBQueryListDetailsTransactionViewViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. [self setupUI];
  23. [self getOrderBalanceAndRefund];
  24. }
  25. #pragma mark - Action
  26. - (void)classifyViewAction:(NSInteger)index {
  27. [_classifyView scrollClassifyForIndex:index];
  28. if (index == 0) {
  29. _tableVC.spsb_type = SPSBQueryListDetailsTransactionTypeOrderBalance;
  30. } else {
  31. _tableVC.spsb_type = SPSBQueryListDetailsTransactionTypeRefund;
  32. }
  33. [_tableVC.tableView reloadData];
  34. }
  35. #pragma mark - NetworkAction
  36. - (void)getOrderBalanceAndRefund {
  37. @weakify(self)
  38. [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:@"正在加载" isLogin:true url:spsb_appUrl(SPSBUrlQueryPriceDifferencePaymentAndRefund) urlParameters:nil parameters:^NSDictionary * _Nonnull{
  39. return @{@"order_no": self->_spsb_orderNo};
  40. } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
  41. @strongify(self)
  42. [self getOrderBalanceAndRefundSuccess:data];
  43. return @"";
  44. } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
  45. [self getOrderBalanceAndRefundFailure:error];
  46. return @"加载失败";
  47. }];
  48. }
  49. - (void)getOrderBalanceAndRefundSuccess:(id)data {
  50. [self removeDefaultView];
  51. bool isHaveWaitForPay = false;
  52. NSArray *orderBalanceArray = [SPSBQueryListDetailsTransactionOrderBalanceModel getModelListWithArray:data[@"data"][@"repay"] isHaveWaitForPay:&isHaveWaitForPay];
  53. NSArray *refundArray = [SPSBQueryListDetailsTransactionRefundModel getModelListWithArray:data[@"data"][@"refund"]];
  54. SPSBQueryListDetailsTransactionType type = SPSBQueryListDetailsTransactionTypeOrderBalance;
  55. if (orderBalanceArray.count == 0 && refundArray.count == 0) {
  56. [self createNoDataView];
  57. return;
  58. }
  59. if (orderBalanceArray.count != 0 && refundArray.count != 0) {
  60. [self createClassifyView];
  61. } else if (refundArray.count != 0) {
  62. type = SPSBQueryListDetailsTransactionTypeRefund;
  63. }
  64. [self createTableViewWithType:type orderBalanceData:orderBalanceArray refundData:refundArray isHaveWaitForPay:isHaveWaitForPay];
  65. }
  66. - (void)getOrderBalanceAndRefundFailure:(NSError *)error {
  67. @weakify(self)
  68. [self setDefaultViewWithError:error image:nil action:^{
  69. @strongify(self)
  70. [self getOrderBalanceAndRefund];
  71. }];
  72. }
  73. #pragma mark - UI
  74. - (void)setupUI {
  75. self.title = @"交易详情";
  76. }
  77. - (void)createTableViewWithType:(SPSBQueryListDetailsTransactionType)type orderBalanceData:(NSArray *)orderBalanceData refundData:(NSArray *)refundData isHaveWaitForPay:(bool)isHaveWaitForPay {
  78. _tableVC = SPSBQueryListDetailsTransactionTableViewController.new;
  79. _tableVC.spsb_type = type;
  80. _tableVC.spsb_refundData = refundData;
  81. _tableVC.spsb_orderBalanceData = orderBalanceData;
  82. _tableVC.spsb_isHaveWaitForPay = isHaveWaitForPay;
  83. [self addChildViewController:_tableVC];
  84. [self.view addSubview:_tableVC.tableView];
  85. [_tableVC.tableView makeConstraints:^(JXHConstraintMaker *make) {
  86. make.leading.and.trailing.and.bottom.equalTo(0);
  87. if (self->_classifyView) {
  88. make.top.equalTo(self->_classifyView.bottom);
  89. } else {
  90. make.top.equalTo(self.view.safetop);
  91. }
  92. }];
  93. }
  94. - (void)createClassifyView {
  95. JXHClassifyViewConfiguration *configuration = ({
  96. JXHClassifyViewConfiguration *configuration = JXHClassifyViewConfiguration.new;
  97. configuration.jxh_titleArray = @[@"补差额", @"退款"];
  98. configuration.jxh_height = 50;
  99. configuration.jxh_font = spsb_font(16);
  100. configuration.jxh_normalColor = spsb_666666_color();
  101. configuration.jxh_selectedColor = spsb_3296FB_color();
  102. configuration.jxh_margen = 0.f;
  103. configuration.jxh_interval = 0.f;
  104. configuration.jxh_selectedViewSize = (CGSize){60, 2.5};
  105. configuration.jxh_selectedViewColor = spsb_3296FB_color();
  106. configuration.jxh_equalWidth = jxh_screenWidth() / 2;
  107. configuration.jxh_isNeedSelectedView = true;
  108. configuration;
  109. });
  110. @weakify(self)
  111. _classifyView = [[JXHClassifyView alloc] initWithConfiguration:configuration chooseAction:^(JXHClassifyView * _Nonnull classifyView, NSInteger index) {
  112. @strongify(self)
  113. [self classifyViewAction:index];
  114. }];
  115. [self.view addSubview:_classifyView];
  116. [_classifyView makeConstraints:^(JXHConstraintMaker *make) {
  117. make.leading.and.trailing.equalTo(0);
  118. make.top.equalTo(self.view.safetop);
  119. make.height.equalTo(configuration.jxh_height);
  120. }];
  121. }
  122. - (void)createNoDataView {
  123. UIImageView *noDataView = [[UIImageView alloc] initWithImage:jxh_getImage(bujiaoxiangqing_qs)];
  124. [self.view addSubview:noDataView];
  125. [noDataView makeConstraints:^(JXHConstraintMaker *make) {
  126. make.centerX.equalTo(0);
  127. make.centerY.equalTo(-64);
  128. }];
  129. UILabel *tips = [UILabel convenienceWithFont:spsb_font(14) text:@"此订单没有退补缴" textColor:spsb_9197A3_color() textAlignment:NSTextAlignmentCenter];
  130. [self.view addSubview:tips];
  131. [tips makeConstraints:^(JXHConstraintMaker *make) {
  132. make.centerX.equalTo(0);
  133. make.top.equalTo(noDataView.bottom);
  134. }];
  135. }
  136. @end