Просмотр исходного кода

修复恢复Place Order时不能提交订单,修改Common Editor中Block内部使用weakself

Pen Li 9 лет назад
Родитель
Сommit
6df14eb892

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 65 - 56
RedAnt ERP Mobile/common/CommonEditor/CommonEditorViewController.m

@@ -36,6 +36,7 @@
 #define NUMBERS @"0123456789.\n"
 #import "OLDataProvider.h"
 #import <objc/objc.h>
+#import "MainViewController.h"
 
 
 @interface subitem_data ()
@@ -59,6 +60,7 @@
     
     [appDelegate.urgencyDic removeObjectForKey:[NSString stringWithFormat:@"level_%d",self.level]];
     [appDelegate.urgencyDic setValue:[NSNumber numberWithInteger:self.level] forKey:@"count"];
+    
 }
 
 - (NSString *)class_name {
@@ -202,7 +204,9 @@
 
             
             [urgencyDic setValue:appDelegate.order_code forKey:@"order_code"];
-
+            MainViewController *mainVC = (MainViewController *)appDelegate.main_vc;
+            NSString *so = [mainVC.labelSo.text substringFromIndex:5];
+            [urgencyDic setValue:so forKey:@"order_so"];
             [urgencyDic setValue:[NSNumber numberWithInt:appDelegate.order_status ] forKey:@"order_status"];
             
             [urgencyDic setValue:appDelegate.order_customer_id forKey:@"order_customer_id"];
@@ -259,14 +263,14 @@
     //    //    closeButton.title = @"Close";
     //
     //    self.navigationItem.leftBarButtonItem = closeButton;
-    
+    __weak typeof(self) weakself = self;
     if(self.url_type==URL_REMOTE)
     {
         
         UIAlertView * waitalert = [RAUtils waiting_alert:self.loading_msg title:self.loading_title];
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             
-            NSDictionary* editor_json = [iSalesNetwork request_Editor:self.request_url params:self.params];
+            NSDictionary* editor_json = [iSalesNetwork request_Editor:weakself.request_url params:weakself.params];
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 
@@ -276,26 +280,26 @@
                 if([[editor_json valueForKey:@"result"] intValue]==2)
                 {
                     
-                    self.content_data_download = [editor_json mutableCopy];
+                    weakself.content_data_download = [editor_json mutableCopy];
                     
-                    self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
+                    weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed: weakself.changed_data];
                     
                     //                self.content_data = [editor_json mutableCopy];
                     //                    self.content_data = [self translate_json:editor_json];
                     
                     //                  NSMutableDictionary* content_data1 = [self translate_json:self.content_data];
                     
-                    [self download_success];
+                    [weakself download_success];
                     
-                    [self.editorTable reloadData];
+                    [weakself.editorTable reloadData];
                     
                     //                NSString * ttt=[self.content_data valueForKey:@"title"] ;
                     
-                    self.navigationItem.title =  [self.content_data_download valueForKey:@"title"] ;
+                    weakself.navigationItem.title =  [weakself.content_data_download valueForKey:@"title"] ;
                 }
                 else
                 {
-                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:self] ;
+                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:weakself] ;
                 }
                 
                 
@@ -962,20 +966,21 @@
         UIAlertView * waitalert = [RAUtils waiting_alert:self.loading_msg title:self.loading_title];
         
         self.params[@"refresh_trigger"]=trigger;
+        __weak typeof(self) weakself = self;
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
             
             
             
-            NSDictionary* refresh_params=[self get_refresh_param];
+            NSDictionary* refresh_params=[weakself get_refresh_param];
             
             NSArray* changed_key=[refresh_params allKeys];
             for(int i=0;i<changed_key.count;i++)
             {
                 NSString* obj_str=[NSString stringWithFormat:@"%@",[refresh_params valueForKey:(NSString*)changed_key[i]]];
-                [self.params setObject:obj_str forKey:(NSString*)changed_key[i]];
+                [weakself.params setObject:obj_str forKey:(NSString*)changed_key[i]];
             }
             
-            NSDictionary* editor_json = [iSalesNetwork request_Editor:self.request_url params:self.params];
+            NSDictionary* editor_json = [iSalesNetwork request_Editor:weakself.request_url params:weakself.params];
             
             dispatch_async(dispatch_get_main_queue(), ^{
                 [waitalert dismissWithClickedButtonIndex:0 animated:FALSE];
@@ -984,18 +989,18 @@
                 if([[editor_json valueForKey:@"result"] intValue]==2)
                 {
                     
-                    self.content_data_download = [self CopyDirty:self.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
+                    weakself.content_data_download = [weakself CopyDirty:weakself.content_data_download to:[editor_json mutableCopy]];//[editor_json mutableCopy];
                     
-                    self.content_data_control = [self translate_json:self.content_data_download changed: self.changed_data];
+                    weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed: weakself.changed_data];
                     
                     
-                    [self download_success];
-                    [self.editorTable reloadData];
+                    [weakself download_success];
+                    [weakself.editorTable reloadData];
                     
                 }
                 else
                 {
-                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:self] ;
+                    [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:weakself] ;
                 }
                 
                 
@@ -2110,6 +2115,7 @@
             
             
             UIAlertView * waitalert = [RAUtils waiting_alert:self.loading_msg title:self.loading_title];
+            __weak typeof(self) weakself = self;
             dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                 
                 NSDictionary* editor_json = [iSalesNetwork commoneditor_partialrefresh:params url:url];
@@ -2129,14 +2135,14 @@
                             NSString* name = [pr_item valueForKey:@"name"];
                             NSString* value = [pr_item valueForKey:@"value"];
                             
-                            [self setValue:name value:value];
+                            [weakself setValue:name value:value];
                         }
                         
                         
                     }
                     else
                     {
-                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:self] ;
+                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:weakself] ;
                     }
                     
                     
@@ -2229,6 +2235,7 @@
             
             
             UIAlertView * waitalert = [RAUtils waiting_alert:self.loading_msg title:self.loading_title];
+            __weak typeof(self) weakself = self;
             dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                 
                 NSDictionary* editor_json = [iSalesNetwork commoneditor_partialrefresh:params url:url];
@@ -2248,13 +2255,13 @@
                             NSString* name = [pr_item valueForKey:@"name"];
                             NSString* value = [pr_item valueForKey:@"value"];
                             
-                            [self setValue:name value:value];
+                            [weakself setValue:name value:value];
                         }
                         
                     }
                     else
                     {
-                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:self] ;
+                        [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:nil controller:weakself] ;
                     }
                     
                     
@@ -2784,10 +2791,10 @@
             cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
             cvc.showNavibar = true;
             cvc.contact_type = value;
-            
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -2808,10 +2815,10 @@
             cvc.contact_type = value;
             cvc.is_subaction = @"true";
             cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
-            
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -2832,10 +2839,10 @@
             cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
             cvc.showNavibar = true;
             cvc.contact_type = value;
-            
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -2856,10 +2863,10 @@
             cvc.subaction_tag =[NSString stringWithFormat:@"%ld",(long)sender.tag];
             cvc.showNavibar = true;
             cvc.contact_type = value;
-            
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -3314,12 +3321,12 @@
                 cell.editable=true;
             cell.labelTitle.text = title;
             cell.labelDescription.text = value;
-            
+            __weak typeof(self) weakself = self;
             cell.imgChanged = ^(NSString* url_down,NSString* url_up,int index ,NSString* url_index)
             {
                 //            NSMutableDictionary* editjson = [item_json mutableCopy];
                 //            editjson[@"img_url"]=url;
-                [self imgIsChanged:url_down url_up:url_up indexPath:indexPath index:index url_index:url_index];
+                [weakself imgIsChanged:url_down url_up:url_up indexPath:indexPath index:index url_index:url_index];
                 
                 
             };
@@ -3346,7 +3353,7 @@
                     }
                     else
                     {
-                        
+                        __weak typeof(self) weakself = self;
                         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                             
                             NSData*  downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url0]];
@@ -4610,9 +4617,10 @@
             ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
             cvc.showNavibar = true;
             cvc.contact_type = value;
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -4631,10 +4639,10 @@
             ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
             cvc.showNavibar = true;
             cvc.contact_type = value;
-            
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -4654,9 +4662,10 @@
             
             cvc.contact_type = value;
             cvc.showNavibar = true;
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -4675,10 +4684,10 @@
             ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
             cvc.showNavibar = true;
             cvc.contact_type = value;
-            
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -4697,10 +4706,10 @@
             ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
             cvc.showNavibar = true;
             cvc.contact_type = value;
-            
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -4719,10 +4728,10 @@
             ContactListViewController* cvc = [self.storyboard instantiateViewControllerWithIdentifier:@"ContactListViewController" ];
             cvc.showNavibar = true;
             cvc.contact_type = value;
-            
+            __weak typeof(self) weakself = self;
             cvc.returnValue = ^(NSMutableDictionary* value,NSIndexPath* source){
                 
-                [self handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
+                [weakself handle_action_return:value indexPath:indexPath action:ACTION_FILL_SECTION];
                 
                 //
                 //                if(self.returnValue)
@@ -4837,7 +4846,7 @@
         
         __block UIImage* signimg=nil;
         SignatureViewController * vc =[ self.storyboard instantiateViewControllerWithIdentifier:@"SignatureViewController"];
-        
+        __weak typeof(self) weakself = self;
         vc.onReturnImg = ^(UIImage* img)
         {
             signimg = img;
@@ -4875,19 +4884,19 @@
                         //                            if(img_url_up.length==0)
                         //                                img_url_up=@"";
                         
-                        NSMutableDictionary* item_json =((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row];
+                        NSMutableDictionary* item_json =((NSMutableArray*)weakself.content_data_control[indexPath.section])[indexPath.row];
                         
                         [item_json setValue:img_url_down forKey:@"avalue"];
                         [item_json setValue:img_url_up forKey:@"value"];
                         [item_json setValue:@"true" forKey:@"dirty"];
-                        NSMutableDictionary* section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+                        NSMutableDictionary* section_json = [[weakself.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
                         [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%d",indexPath.row]];
                         
-                        [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
-                        self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
+                        [weakself.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+                        weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed:weakself.changed_data];
                         
                         
-                        CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [self.editorTable cellForRowAtIndexPath:indexPath];
+                        CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [weakself.editorTable cellForRowAtIndexPath:indexPath];
                         
                         cell.imageviewSignature.image = signimg;
                         
@@ -4895,7 +4904,7 @@
                     }
                     else
                     {
-                        [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
+                        [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:weakself] ;
                     }
                 }
             else
@@ -4946,7 +4955,7 @@
                         
                         DebugLog(@"data string: %@",str);
                         
-                        [RAUtils message_alert:@"Can not connect to server please try again." title:@"Upload Image" controller:self] ;
+                        [RAUtils message_alert:@"Can not connect to server please try again." title:@"Upload Image" controller:weakself] ;
                         
                     } else {
                         DebugLog(@"response ");
@@ -4975,19 +4984,19 @@
                             //                            if(img_url_up.length==0)
                             //                                img_url_up=@"";
                             
-                            NSMutableDictionary* item_json =((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row];
+                            NSMutableDictionary* item_json =((NSMutableArray*)weakself.content_data_control[indexPath.section])[indexPath.row];
                             
                             [item_json setValue:img_url_down forKey:@"avalue"];
                             [item_json setValue:img_url_up forKey:@"value"];
                             [item_json setValue:@"true" forKey:@"dirty"];
-                            NSMutableDictionary* section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
+                            NSMutableDictionary* section_json = [[weakself.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
                             [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%d",indexPath.row]];
                             
-                            [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
-                            self.content_data_control = [self translate_json:self.content_data_download changed:self.changed_data];
+                            [weakself.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
+                            weakself.content_data_control = [weakself translate_json:weakself.content_data_download changed:weakself.changed_data];
                             
                             
-                            CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [self.editorTable cellForRowAtIndexPath:indexPath];
+                            CommonEditorCellSignature* cell = (CommonEditorCellSignature*) [weakself.editorTable cellForRowAtIndexPath:indexPath];
                             
                             cell.imageviewSignature.image = signimg;
                             
@@ -4995,7 +5004,7 @@
                         }
                         else
                         {
-                            [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:self] ;
+                            [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Upload Image" controller:weakself] ;
                         }
                         
                         

+ 6 - 5
RedAnt ERP Mobile/common/Functions/contact/CustomerEditViewController.m

@@ -257,6 +257,7 @@
     if(self.cancommit==false)
         return;
     UIAlertView * waitalert = [RAUtils waiting_alert:@"Please wait" title:@"Saving Contact"];
+    __weak typeof(self) weakself = self;
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         NSDictionary* editor_json = nil;
@@ -281,11 +282,11 @@
                 //    //     self.labelContact.text=appDelegate.contact_name;
                 //
                 //    NSDictionary * customerinfo = appDelegate.customerInfo;
-                [self prepareReturn:nil];
-                if(self.bnewcustomer  )
-                    [self.navigationController popViewControllerAnimated:false];
+                [weakself prepareReturn:nil];
+                if(weakself.bnewcustomer  )
+                    [weakself.navigationController popViewControllerAnimated:false];
                 else
-                    [self.navigationController popToRootViewControllerAnimated:false];
+                    [weakself.navigationController popToRootViewControllerAnimated:false];
                 
                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                 [((MainViewController*)appDelegate.main_vc) reloadContact:true immediately:false];
@@ -295,7 +296,7 @@
             }
             else
             {
-                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:self] ;
+                [RAUtils message_alert:[editor_json valueForKey:@"err_msg"] title:@"Save Order" controller:weakself] ;
             }
             
             

+ 16 - 5
RedAnt ERP Mobile/common/Functions/order/CreateOrderViewController.m

@@ -19,16 +19,25 @@
 #define CLOSE_ACTION 567
 @interface CreateOrderViewController ()
 // static const char associatedkey;
+@property (nonatomic,assign) BOOL isResume;///<恢复
+@property (nonatomic,assign) NSInteger userType;///<恢复使用
+
 @end
 
 @implementation CreateOrderViewController
 
+- (void)dealloc {
+    if (self.isResume && self.userType == USER_ROLE_CUSTOMER) {
+        [self releaseOrderAfterSave];
+    }
+}
+
 -(void) viewWillAppear:(BOOL)animated
 {
     [super viewWillAppear:animated];
     
-    BOOL isResume = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_resume"] boolValue];
-    NSInteger userType = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_userType"] integerValue];
+    self.isResume = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_resume"] boolValue];
+    self.userType = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_userType"] integerValue];
     BOOL canSubmit = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_submitOrder"] boolValue];
     
     // 检查权限
@@ -62,7 +71,7 @@
         [items addObject:fixedItem];
     }
     
-    if (!isResume) {
+    if (!self.isResume) {
         // 正常情况
         if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
             // customer的订单必须是Sales Order并且有提交权限才能提交
@@ -75,7 +84,7 @@
         
     } else {
         // 恢复
-        if (userType == USER_ROLE_CUSTOMER) {
+        if (self.userType == USER_ROLE_CUSTOMER) {
             // customer的订单必须是Sales Order并且有提交权限才能提交
             if (canSubmit) {
                 [items addObject:self.btnSubmitOrder];
@@ -147,7 +156,9 @@
 - (void)onCommitOrderClick:(id)sender {
     // get customer info
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
+    id var = nil;
+    NSMutableArray *foo = @[].mutableCopy;
+    [foo addObject:var];
 //    if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
 //        
 //        // 检查价格类型

+ 18 - 16
RedAnt ERP Mobile/iSales-NPD/AppDelegate.m

@@ -554,12 +554,11 @@ void UncaughtExceptionHandler(NSException *exception) {
 }
 
 - (void)dealWithUrgencyFile {
-    [self readUrgencyCache];
     
-//    DebugLog(@"urgencyDic: %@",self.urgencyDic);
-    if (self.urgencyDic.allKeys.count > 2) {
+    NSDictionary *tmp_urgencyDic = [self readUrgencyCache];
+    
+    if (tmp_urgencyDic.allKeys.count > 2) {
         
-        NSDictionary *tmp_urgencyDic = [self.urgencyDic copy];// 避免恢复后再次写入
         [self.urgencyDic removeAllObjects];
         [self.urgencyDic setObject:[NSNumber numberWithInt:0] forKey:@"count"];
         
@@ -628,7 +627,8 @@ void UncaughtExceptionHandler(NSException *exception) {
                     NSString *order_code = [urgencyDic objectForKey:@"order_code"];
                     int order_status = [[urgencyDic objectForKey:@"order_status"] intValue];
                     NSString *order_customer_id = [urgencyDic objectForKey:@"order_customer_id"];
-                    
+                    NSInteger userType = [[[NSUserDefaults standardUserDefaults] objectForKey:@"urgency_userType"] integerValue];
+                    NSString *so = [urgencyDic objectForKey:@"order_so"];
                     self.order_customer_id = order_customer_id;
                     
                     // 首先通过order code 打开订单
@@ -641,12 +641,14 @@ void UncaughtExceptionHandler(NSException *exception) {
                             
                             self.order_code = order_code;
                             self.order_status = order_status;
-                            [self SetSo:order_code];
-                            
-                            
-                            self.customerInfo = [[[iSalesNetwork request_CustomerInfo:order_customer_id] objectForKey:@"customerInfo"] mutableCopy];
+                            [self SetSo:so];
                             
-                            self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
+                            if (userType != USER_ROLE_CUSTOMER) {
+                                self.customerInfo = [[[iSalesNetwork request_CustomerInfo:order_customer_id] objectForKey:@"customerInfo"] mutableCopy];
+                                
+                                self.contact_id=[self.customerInfo valueForKey:@"customer_cid"];
+                            }
+                           
                             
                             [mainVC reloadOrder:true immediately:false];
                             [mainVC reloadCart:true immediately:false];
@@ -743,22 +745,22 @@ void UncaughtExceptionHandler(NSException *exception) {
     }
 }
 
-- (void)readUrgencyCache {
+- (NSMutableDictionary *)readUrgencyCache {
     // 检查本地urgency文件,存在则加载进_urgencyDic
     NSFileManager *manager = [NSFileManager defaultManager];
     NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
     NSString *urgencyFile = [cachePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_urgency",self.user]];
-    
+    NSMutableDictionary *resultDic = [NSMutableDictionary dictionary];
     if ([manager fileExistsAtPath:urgencyFile]) {
         
-//        _urgencyDic = [NSKeyedUnarchiver unarchiveObjectWithFile:urgencyFile];
-        _urgencyDic = [NSMutableDictionary dictionaryWithContentsOfFile:urgencyFile];
+        resultDic = [NSMutableDictionary dictionaryWithContentsOfFile:urgencyFile];
         [manager removeItemAtPath:urgencyFile error:nil];
         
-    } else {
-        _urgencyDic = [NSMutableDictionary dictionary];
     }
+    
+    _urgencyDic = [NSMutableDictionary dictionary];
 
+    return resultDic;
 }
 
 - (void)initialExceptionHandler {