payinRealityVC.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. //
  2. // payinRealityVC.m
  3. // LN_School
  4. //
  5. // Created by apple on 2017/4/21.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "payinRealityVC.h"
  9. #import "PayInRealityTableViewCell.h"
  10. @interface payinRealityVC ()<UITableViewDelegate,UITableViewDataSource>
  11. {
  12. UITableView *maintableView;
  13. UIView *examerView;
  14. UITableView *examertableView;
  15. NSArray *dataArray;
  16. NSArray *examDataArray;
  17. NSDictionary *examerDic;
  18. NSDictionary *orderDic;
  19. NSString *auditType;
  20. NSString *auditStatusString;//1同意 2不同意
  21. NSString *reasonString;
  22. //
  23. HolderView * holderV;
  24. }
  25. @end
  26. @implementation payinRealityVC
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. self.navigationItem.title = @"线下支付";
  30. self.view.backgroundColor = KBackGroundColor;
  31. [self goBackByNavigation];
  32. auditType = @"0";
  33. dataArray = [NSArray array];
  34. examDataArray = [NSArray array];
  35. orderDic = [NSDictionary dictionary];
  36. examerDic = [NSDictionary dictionary];
  37. reasonString = @"";
  38. maintableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain];
  39. maintableView.height -= kNavOffSet;
  40. maintableView.delegate = self;
  41. maintableView.dataSource = self;
  42. maintableView.rowHeight = 100;
  43. [self.view addSubview:maintableView];
  44. [self getStudentAuditOrders];
  45. [self getAuditUserInfo];
  46. holderV = [[HolderView alloc]initWithFrame:maintableView.frame];
  47. [holderV freshBlock:^{
  48. [self getStudentAuditOrders];
  49. }];
  50. [self.view addSubview:holderV];
  51. }
  52. - (void)setExamer {
  53. //懒加载 没有的时候就init一个
  54. if (!examerView) {
  55. examerView = [[UIView alloc] initWithFrame:kFrame];
  56. examerView.backgroundColor = windowBlockColor;
  57. examertableView = [[UITableView alloc] initWithFrame:CGRectMake(30, (kSize.height - kNavOffSet - 200)/2.0, kSize.width - 60, 200) style:UITableViewStylePlain];
  58. [examertableView borderCornorRadios:7];
  59. examertableView.backgroundColor = KBackGroundColor;
  60. examertableView.delegate = self;
  61. examertableView.dataSource = self;
  62. [examerView addSubview:examertableView];
  63. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width - 60, 50)];
  64. [label setText:@"请选择审核人" Font:Font18 TextColor:KSubTitleColor Alignment:NSTextAlignmentCenter];
  65. [label addSelfViewWithRect:CGRectMake(10, 48, kSize.width - 80, 2) Color:kLineColor];
  66. examertableView.tableHeaderView = label;
  67. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(30, examertableView.y + examertableView.height, kSize.width - 60, 40)];
  68. view.backgroundColor = KBackGroundColor;
  69. [examerView addSubview:view];
  70. [view borderCornorRadios:7];
  71. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kSize.width/3.0 - 20, 40)];
  72. [btn setTitle:@"取消" textColor:KTitleColor font:Font18 fotState:UIControlStateNormal];
  73. [btn target:self Tag:1];
  74. [view addSubview:btn];
  75. [btn addViewWithRect:CGRectMake(0, 0, kSize.width - 60, 1)];
  76. [btn addViewWithRect:CGRectMake(kSize.width/3.0 - 21, 0, 1, 40)];
  77. btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/3.0 - 20, 0, kSize.width/3.0 - 20, 40)];
  78. [btn setTitle:@"拒绝" textColor:defGreen font:Font18 fotState:UIControlStateNormal];
  79. [btn target:self Tag:2];
  80. [view addSubview:btn];
  81. [btn addViewWithRect:CGRectMake(kSize.width*2.0/3.0 - 41, 0, 1, 40)];
  82. btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width*2.0/3.0 - 40, 0, kSize.width/3.0 - 20, 40)];
  83. [btn setTitle:@"同意" textColor:defGreen font:Font18 fotState:UIControlStateNormal];
  84. [btn target:self Tag:2];
  85. [view addSubview:btn];
  86. }
  87. examerDic = [NSDictionary dictionary];
  88. [self.view addSubview:examerView];
  89. examDataArray = [NSArray array];
  90. [self getAuditUserInfo];
  91. }
  92. - (void)btnClick:(UIButton *)sender {
  93. if (sender.tag == 1) {
  94. //取消选择考核人
  95. examerDic = [NSDictionary dictionary];
  96. [examerView removeFromSuperview];
  97. return;
  98. }
  99. if (sender.tag == 2) {
  100. //拒绝
  101. if (examerDic.count < 1) {
  102. ShowMsg(@"请选择考核人");
  103. return;
  104. }
  105. [examerView removeFromSuperview];
  106. auditStatusString = @"2";
  107. //输入拒绝原因
  108. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"审核不通过" preferredStyle:UIAlertControllerStyleAlert];
  109. [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
  110. textField.placeholder = @"请输入原因:";
  111. }];
  112. [alertFind addAction:[UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleCancel handler:nil]];
  113. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  114. UITextField * tf = [[alertFind textFields]lastObject];
  115. if (tf.text.length == 0) {
  116. ShowMsg(@"审核失败!未输入不通过理由");
  117. }else{
  118. reasonString = tf.text;
  119. auditStatusString = @"2";
  120. [self auditOrderPay];
  121. }
  122. }]];
  123. [self presentViewController:alertFind animated:true completion:nil];
  124. return;
  125. }
  126. if (sender.tag == 3) {
  127. //同意
  128. if (examerDic.count < 1) {
  129. ShowMsg(@"请选择考核人");
  130. return;
  131. }
  132. [examerView removeFromSuperview];
  133. auditStatusString = @"1";
  134. [self auditOrderPay];
  135. return;
  136. }
  137. }
  138. #pragma mark tableview
  139. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  140. if (tableView == examertableView) {
  141. return examDataArray.count;
  142. }
  143. return dataArray.count;
  144. }
  145. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  146. if (tableView == examertableView) {
  147. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"examCell"];
  148. if (cell == nil) {
  149. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"examCell"];
  150. cell.backgroundColor = KBackGroundColor;
  151. [cell.textLabel setTextAlignment:NSTextAlignmentCenter];
  152. }
  153. NSDictionary *dic = examDataArray[indexPath.row];
  154. cell.textLabel.text = [NSString stringWithFormat:@"%d、%@",(int)indexPath.row+1,dic[@"text"]];
  155. return cell;
  156. }
  157. PayInRealityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"payCell"];
  158. if (!cell) {
  159. //加载xib文件创建cell
  160. cell = [[[NSBundle mainBundle] loadNibNamed:@"PayInRealityTableViewCell" owner:nil options:nil] lastObject];
  161. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  162. }
  163. NSDictionary *dic = dataArray[indexPath.row];
  164. cell.dataDic = dic;
  165. return cell;
  166. }
  167. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  168. if (tableView == examertableView) {
  169. examerDic = examDataArray[indexPath.row];
  170. }else {
  171. //选中某行
  172. orderDic = dataArray[indexPath.row];
  173. // [self setExamer];
  174. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"线下订单审核" preferredStyle:UIAlertControllerStyleAlert];
  175. [alertFind addAction:[UIAlertAction actionWithTitle:@"不同意" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  176. [self refuse];
  177. }]];
  178. [alertFind addAction:[UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  179. auditStatusString = @"1";
  180. [self auditOrderPay];
  181. }]];
  182. [self presentViewController:alertFind animated:true completion:nil];
  183. }
  184. }
  185. - (void)refuse{
  186. //输入拒绝原因
  187. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"审核不通过" preferredStyle:UIAlertControllerStyleAlert];
  188. [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
  189. textField.placeholder = @"请输入原因:";
  190. }];
  191. [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  192. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  193. UITextField * tf = [[alertFind textFields]lastObject];
  194. if (tf.text.length == 0) {
  195. ShowMsg(@"审核失败!未输入不通过理由");
  196. }else{
  197. reasonString = tf.text;
  198. auditStatusString = @"2";
  199. [self auditOrderPay];
  200. }
  201. }]];
  202. [self presentViewController:alertFind animated:true completion:nil];
  203. }
  204. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  205. return 10;
  206. }
  207. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  208. return [UIView new];
  209. }
  210. #pragma mark 数据请求
  211. - (void)getStudentAuditOrders {
  212. if (![NetManager connectedToNetWork]) {
  213. showMsgUnconnect();
  214. return;
  215. }
  216. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  217. [dic setObject:defUser.userDict[@"id"] forKey:@"userId"];
  218. [dic setObject:auditType forKey:@"status"];
  219. NSString *method = @"getStudentAuditOrders";
  220. [MBProgressHUD showLoadToView:self.view];
  221. [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  222. [MBProgressHUD hideHUDForView:self.view];
  223. holderV.hidden = NO;
  224. if (!root) {
  225. ShowErrorMsg(@"请求失败");
  226. return;
  227. }
  228. if ([root[@"code"] integerValue] == 1) {
  229. ShowMsg(root[@"msg"]);
  230. return;
  231. }
  232. dataArray = root[@"body"];
  233. if (dataArray.count > 0) {
  234. holderV.hidden = YES;
  235. }
  236. [maintableView reloadData];
  237. }];
  238. }
  239. -(void)getAuditUserInfo{
  240. if (![NetManager connectedToNetWork]) {
  241. showMsgUnconnect();
  242. return;
  243. }
  244. NSMutableDictionary * dic = [NSMutableDictionary new];
  245. [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
  246. [MBProgressHUD showLoadToView:self.view];
  247. [NetManager requestAnythingWithURL:@"getAuditUserInfo" dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  248. [MBProgressHUD hideHUDForView:self.view];
  249. if (!root) {
  250. ShowErrorMsg(@"请求失败!");
  251. return;
  252. }
  253. if ([root[@"code"] isEqualToString:@"1"]) {
  254. ShowErrorMsg(root[@"msg"]);
  255. return;
  256. }
  257. examDataArray = root[@"body"];
  258. [examertableView reloadData];
  259. }];
  260. }
  261. -(void)auditOrderPay{
  262. if (![NetManager connectedToNetWork]) {
  263. showMsgUnconnect();
  264. return;
  265. }
  266. NSMutableDictionary * dic = [NSMutableDictionary new];
  267. [dic setObject:orderDic[@"ID"] forKey:@"id"];
  268. [dic setObject:orderDic[@"ORDER_ID"] forKey:@"orderId"];
  269. [dic setObject:auditStatusString forKey:@"status"];
  270. [dic setObject:reasonString forKey:@"reason"];
  271. [dic setObject:defUser.userDict[@"id"] forKey:@"audituser"];
  272. [dic setObject:defUser.userDict[@"realName"] forKey:@"auditusername"];
  273. [MBProgressHUD showLoadToView:self.view];
  274. [NetManager requestAnythingWithURL:@"auditOrderPay" dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
  275. [MBProgressHUD hideHUDForView:self.view];
  276. if (!root) {
  277. ShowErrorMsg(@"请求失败!");
  278. return;
  279. }
  280. if ([root[@"code"] isEqualToString:@"1"]) {
  281. ShowErrorMsg(root[@"msg"]);
  282. return;
  283. }
  284. }];
  285. }
  286. - (void)didReceiveMemoryWarning {
  287. [super didReceiveMemoryWarning];
  288. }
  289. @end