payinRealityVC.m 13 KB

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