123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- //
- // payinRealityVC.m
- // LN_School
- //
- // Created by apple on 2017/4/21.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import "payinRealityVC.h"
- #import "PayInRealityTableViewCell.h"
- @interface payinRealityVC ()<UITableViewDelegate,UITableViewDataSource>
- {
- UITableView *maintableView;
- UIView *examerView;
- UITableView *examertableView;
-
-
-
- NSArray *dataArray;
- NSArray *examDataArray;
- NSDictionary *examerDic;
- NSDictionary *orderDic;
-
- NSString *auditType;
-
- NSString *auditStatusString;//1同意 2不同意
- NSString *reasonString;
-
- //
- HolderView * holderV;
- }
- @end
- @implementation payinRealityVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.navigationItem.title = @"线下支付";
- self.view.backgroundColor = KBackGroundColor;
- [self goBackByNavigation];
-
-
- auditType = @"";
- dataArray = [NSArray array];
- examDataArray = [NSArray array];
- orderDic = [NSDictionary dictionary];
- examerDic = [NSDictionary dictionary];
- reasonString = @"";
- [self creatRightNavigationItem];
-
- // UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"筛选" style:UIBarButtonItemStyleDone target:self action:@selector(selectAuditType)];
- // self.navigationItem.rightBarButtonItem = item;
- // [self.navigationItem.rightBarButtonItem setTintColor:RQMianColor];
-
- maintableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStyleGrouped];
- maintableView.height -= kNavOffSet;
- maintableView.delegate = self;
- maintableView.dataSource = self;
- maintableView.rowHeight = UITableViewAutomaticDimension;
- maintableView.estimatedRowHeight = 125;
- maintableView.estimatedSectionHeaderHeight = CGFLOAT_MIN;
- maintableView.estimatedSectionFooterHeight = CGFLOAT_MIN;
- maintableView.backgroundColor = [UIColor whiteColor];
- maintableView.contentInset = UIEdgeInsetsMake(-20, 0, 0, 0);
- maintableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, CGFLOAT_MIN)];
- [self.view addSubview:maintableView];
-
- [self getStudentAuditOrders];
- [self getAuditUserInfo];
-
- holderV = [[HolderView alloc]initWithFrame:maintableView.frame];
- [holderV freshBlock:^{
- [self getStudentAuditOrders];
- }];
- [self.view addSubview:holderV];
- }
- - (void)setExamer {
-
- //懒加载 没有的时候就init一个
- if (!examerView) {
-
- examerView = [[UIView alloc] initWithFrame:kFrame];
- examerView.backgroundColor = windowBlockColor;
-
- examertableView = [[UITableView alloc] initWithFrame:CGRectMake(30, (kSize.height - kNavOffSet - 200)/2.0, kSize.width - 60, 200) style:UITableViewStylePlain];
- [examertableView borderCornorRadios:7];
- examertableView.backgroundColor = KBackGroundColor;
- examertableView.delegate = self;
- examertableView.dataSource = self;
- [examerView addSubview:examertableView];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width - 60, 50)];
- [label setText:@"请选择审核人" Font:Font18 TextColor:KSubTitleColor Alignment:NSTextAlignmentCenter];
- [label addSelfViewWithRect:CGRectMake(10, 48, kSize.width - 80, 2) Color:kLineColor];
- examertableView.tableHeaderView = label;
-
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(30, examertableView.y + examertableView.height, kSize.width - 60, 40)];
- view.backgroundColor = KBackGroundColor;
- [examerView addSubview:view];
- [view borderCornorRadios:7];
-
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kSize.width/3.0 - 20, 40)];
- [btn setTitle:@"取消" textColor:KTitleColor font:Font18 fotState:UIControlStateNormal];
- [btn target:self Tag:1];
- [view addSubview:btn];
- [btn addViewWithRect:CGRectMake(0, 0, kSize.width - 60, 1)];
- [btn addViewWithRect:CGRectMake(kSize.width/3.0 - 21, 0, 1, 40)];
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/3.0 - 20, 0, kSize.width/3.0 - 20, 40)];
- [btn setTitle:@"拒绝" textColor:RQMianColor font:Font18 fotState:UIControlStateNormal];
- [btn target:self Tag:2];
- [view addSubview:btn];
- [btn addViewWithRect:CGRectMake(kSize.width*2.0/3.0 - 41, 0, 1, 40)];
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width*2.0/3.0 - 40, 0, kSize.width/3.0 - 20, 40)];
- [btn setTitle:@"同意" textColor:RQMianColor font:Font18 fotState:UIControlStateNormal];
- [btn target:self Tag:2];
- [view addSubview:btn];
- }
-
- examerDic = [NSDictionary dictionary];
- [self.view addSubview:examerView];
-
- examDataArray = [NSArray array];
- [self getAuditUserInfo];
- }
- - (void)btnClick:(UIButton *)sender {
-
- if (sender.tag == 1) {
- //取消选择考核人
- examerDic = [NSDictionary dictionary];
- [examerView removeFromSuperview];
- return;
- }
-
- if (sender.tag == 2) {
- //拒绝
- if (examerDic.count < 1) {
- ShowMsg(@"请选择考核人");
- return;
- }
- [examerView removeFromSuperview];
- auditStatusString = @"2";
-
- //输入拒绝原因
- UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"审核不通过" preferredStyle:UIAlertControllerStyleAlert];
-
- [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- textField.placeholder = @"请输入原因:";
- }];
- [alertFind addAction:[UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleCancel handler:nil]];
- [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
-
- UITextField * tf = [[alertFind textFields]lastObject];
- if (tf.text.length == 0) {
- ShowMsg(@"审核失败!未输入不通过理由");
- }else{
- reasonString = tf.text;
- auditStatusString = @"2";
- [self auditOrderPay];
- }
-
- }]];
- [self presentViewController:alertFind animated:true completion:nil];
-
- return;
- }
-
- if (sender.tag == 3) {
- //同意
- if (examerDic.count < 1) {
- ShowMsg(@"请选择考核人");
- return;
- }
- [examerView removeFromSuperview];
- auditStatusString = @"1";
- [self auditOrderPay];
- return;
- }
- }
- - (void)selectAuditType {
- }
- - (void)creatRightNavigationItem {
- self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"筛选" style:UIBarButtonItemStylePlain target:self action:@selector(rightNavigationItemClick)];
- [self.navigationItem.rightBarButtonItem setTintColor:RQMianColor];
- }
- - (void)rightNavigationItemClick {
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"筛选" message:nil alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:@[@"未审核",@"审核通过",@"审核拒绝"] otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
- switch (selectedOtherButtonIndex) {
- case 0:
- case 1:
- case 2: {
- auditType = [NSString stringWithFormat:@"%lu",(unsigned long)selectedOtherButtonIndex];
- [self getStudentAuditOrders];
- break;
- }
- default:
- break;
- }
-
- }];
- }
- #pragma mark tableview
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if (tableView == examertableView) {
- return examDataArray.count;
- }
- return dataArray.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- if (tableView == examertableView) {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"examCell"];
- if (cell == nil) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"examCell"];
- cell.backgroundColor = KBackGroundColor;
- [cell.textLabel setTextAlignment:NSTextAlignmentCenter];
- }
-
- NSDictionary *dic = examDataArray[indexPath.row];
- cell.textLabel.text = [NSString stringWithFormat:@"%d、%@",(int)indexPath.row+1,dic[@"text"]];
-
- return cell;
- }
-
- PayInRealityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"payCell"];
- if (!cell) {
- //加载xib文件创建cell
- cell = [[[NSBundle mainBundle] loadNibNamed:@"PayInRealityTableViewCell" owner:nil options:nil] lastObject];
- cell.selectionStyle = UITableViewCellSelectionStyleDefault;
- }
-
- NSDictionary *dic = dataArray[indexPath.row];
- cell.dataDic = dic;
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- if (tableView == examertableView) {
- examerDic = examDataArray[indexPath.row];
- }else {
- //选中某行
- orderDic = dataArray[indexPath.row];
- // [self setExamer];
- [RQ_SHARE_FUNCTION showAlertWithTitle:@"线下订单审核" message:nil alertControllerStyle:UIAlertControllerStyleActionSheet cancelButtonTitle:@"取消" otherButtonTitles:@[@"同意",@"不同意"] otherButtonStyles:nil completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex == 0) {
- auditStatusString = @"1";
- [self auditOrderPay];
- }else if (selectedOtherButtonIndex == 1) {
- [self refuse];
- }
- }];
- }
- }
- - (void)refuse {
-
- //输入拒绝原因
- UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:@"审核不通过" preferredStyle:UIAlertControllerStyleAlert];
-
- [alertFind addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
- textField.placeholder = @"请输入原因:";
- }];
- [alertFind addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
-
- UITextField * tf = [[alertFind textFields]lastObject];
- if (tf.text.length == 0) {
- ShowMsg(@"审核失败!未输入不通过理由");
- }else{
- reasonString = tf.text;
- auditStatusString = @"2";
- [self auditOrderPay];
- }
-
- }]];
- [self presentViewController:alertFind animated:true completion:nil];
- }
- #pragma mark 数据请求
- - (void)getStudentAuditOrders {
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setObject:defUser.userDict[@"id"] forKey:@"userId"];
- [dic setObject:auditType forKey:@"status"];
-
- NSString *method = @"getStudentAuditOrders";
- [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
-
- holderV.hidden = NO;
-
- if (!root) {
- ShowErrorMsg(@"请求失败");
- return;
- }
- if ([root[@"code"] integerValue] == 1) {
- ShowMsg(root[@"msg"]);
- return;
- }
-
- dataArray = root[@"body"];
-
- if (dataArray.count > 0) {
- holderV.hidden = YES;
- }
-
- [maintableView reloadData];
- }];
- }
- -(void)getAuditUserInfo{
-
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
- NSMutableDictionary * dic = [NSMutableDictionary new];
- [dic setObject:defUser.userDict[@"school"] forKey:@"schoolId"];
- [NetManager requestAnythingWithURL:@"getAuditUserInfo" dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
-
- if (!root) {
- ShowErrorMsg(@"请求失败!");
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowErrorMsg(root[@"msg"]);
- return;
- }
-
- examDataArray = root[@"body"];
- [examertableView reloadData];
- }];
- }
- -(void)auditOrderPay{
-
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
- NSMutableDictionary * dic = [NSMutableDictionary new];
- [dic setObject:orderDic[@"ID"] forKey:@"id"];
- [dic setObject:orderDic[@"ORDER_ID"] forKey:@"orderId"];
- [dic setObject:auditStatusString forKey:@"status"];
- [dic setObject:reasonString forKey:@"reason"];
- [dic setObject:defUser.userDict[@"id"] forKey:@"audituser"];
- [dic setObject:defUser.userDict[@"realName"] forKey:@"auditusername"];
-
- [NetManager requestAnythingWithURL:@"auditOrderPay" dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
-
- if (!root) {
- ShowErrorMsg(@"请求失败!");
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowErrorMsg(root[@"msg"]);
- return;
- }
- [maintableView reloadData];
- }];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|