|
@@ -1247,27 +1247,103 @@
|
|
|
|
|
|
|
|
if (!contain) {
|
|
if (!contain) {
|
|
|
|
|
|
|
|
- // 锁订单
|
|
|
|
|
- NSDictionary *lock_dic = [iSalesNetwork open_Order:orderCode];
|
|
|
|
|
-
|
|
|
|
|
- if ([[lock_dic objectForKey:@"result"] integerValue] == RESULT_TRUE) {
|
|
|
|
|
|
|
+ __block BOOL closeOrder = NO;
|
|
|
|
|
+ // 检查是否被自己打开
|
|
|
|
|
+ if ([orderCode isEqualToString:appDelegate.order_code]) {
|
|
|
|
|
|
|
|
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
|
|
+ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:@"can not add to merge list because current order is opened. Do you want to close order and add to merge list?" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
|
|
|
- [dic setValue:orderid forKey:@"order_id"];
|
|
|
|
|
- [dic setValue:so forKey:@"so_id"];
|
|
|
|
|
- [dic setValue:customer_name forKey:@"company_name"];
|
|
|
|
|
- [dic setValue:[NSNumber numberWithInteger:0] forKey:@"check"]; // 合并到
|
|
|
|
|
|
|
+ UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+
|
|
|
|
|
+ closeOrder = NO;
|
|
|
|
|
+ [alertVC dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
|
|
|
- [self.mergeList addObject:dic];
|
|
|
|
|
|
|
+ UIAlertAction *closeOrderAction = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [alertVC dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
+ // 关闭订单
|
|
|
|
|
+ UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Release Order"];
|
|
|
|
|
+ NSDictionary* order_json = [iSalesNetwork release_Order:orderCode];
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+
|
|
|
|
|
+ [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
|
|
|
|
|
+ if([[order_json valueForKey:@"result"] intValue]==2)
|
|
|
|
|
+ {
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+
|
|
|
|
|
+ [appDelegate closeOrder];
|
|
|
|
|
+ closeOrder = YES;
|
|
|
|
|
+
|
|
|
|
|
+ // 锁订单/检查是否被别人锁定
|
|
|
|
|
+ NSDictionary *lock_dic = [iSalesNetwork lock_order:orderCode]; // 和open一样,只不过不用更新car count
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if ([[lock_dic objectForKey:@"result"] integerValue] == RESULT_TRUE) {
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
+
|
|
|
|
|
+ [dic setValue:orderid forKey:@"order_id"];
|
|
|
|
|
+ [dic setValue:so forKey:@"so_id"];
|
|
|
|
|
+ [dic setValue:customer_name forKey:@"company_name"];
|
|
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:0] forKey:@"check"]; // 合并到
|
|
|
|
|
+
|
|
|
|
|
+ [self.mergeList addObject:dic];
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ [RAUtils message_alert:[lock_dic objectForKey:@"err_msg"] title:@"Warning" controller:self];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ closeOrder = NO;
|
|
|
|
|
+ [RAUtils message_alert:[order_json valueForKey:@"err_msg"] title:@"Release Order" controller:self] ;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+ [alertVC addAction:cancelAction];
|
|
|
|
|
+ [alertVC addAction:closeOrderAction];
|
|
|
|
|
+
|
|
|
|
|
+ [self presentViewController:alertVC animated:YES completion:nil];
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
|
- [RAUtils message_alert:[lock_dic objectForKey:@"err_msg"] title:nil controller:self];
|
|
|
|
|
|
|
+ closeOrder = YES;
|
|
|
|
|
+ // 锁订单/检查是否被别人锁定
|
|
|
|
|
+ NSDictionary *lock_dic = [iSalesNetwork lock_order:orderCode]; // 和open一样,只不过不用更新car count
|
|
|
|
|
|
|
|
|
|
+ if ([[lock_dic objectForKey:@"result"] integerValue] == RESULT_TRUE) {
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
+
|
|
|
|
|
+ [dic setValue:orderid forKey:@"order_id"];
|
|
|
|
|
+ [dic setValue:so forKey:@"so_id"];
|
|
|
|
|
+ [dic setValue:customer_name forKey:@"company_name"];
|
|
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:0] forKey:@"check"]; // 合并到
|
|
|
|
|
+
|
|
|
|
|
+ [self.mergeList addObject:dic];
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ [RAUtils message_alert:[lock_dic objectForKey:@"err_msg"] title:@"Warning" controller:self];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationFade];
|
|
[tableView reloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationFade];
|
|
@@ -1409,7 +1485,7 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:
|
|
|
if([[ret objectForKey:@"result"]integerValue] == RESULT_TRUE) {
|
|
if([[ret objectForKey:@"result"]integerValue] == RESULT_TRUE) {
|
|
|
|
|
|
|
|
[weakself.mergeList removeAllObjects];
|
|
[weakself.mergeList removeAllObjects];
|
|
|
- [strongself loadpage];
|
|
|
|
|
|
|
+ [strongself ReloadData];
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|