Ver código fonte

Scan order 1.09 修复bug,增加打开加密离线文件

Ray Zhang 3 anos atrás
pai
commit
d7af29b9ec

+ 4 - 4
RedAnt ERP Mobile/HMLG Scan Order.xcodeproj/project.pbxproj

@@ -2713,7 +2713,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 51252;
+				CURRENT_PROJECT_VERSION = 51261;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2730,7 +2730,7 @@
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",
 				);
-				MARKETING_VERSION = 1.08;
+				MARKETING_VERSION = 1.09;
 				OTHER_LDFLAGS = (
 					"$(inherited)",
 					"-ObjC",
@@ -2757,7 +2757,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 51252;
+				CURRENT_PROJECT_VERSION = 51261;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2774,7 +2774,7 @@
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",
 				);
-				MARKETING_VERSION = 1.08;
+				MARKETING_VERSION = 1.09;
 				OTHER_LDFLAGS = (
 					"$(inherited)",
 					"-ObjC",

+ 7 - 1
RedAnt ERP Mobile/HMLG Scan Order/MainViewController.m

@@ -621,7 +621,7 @@
     
     
            NSString* str2 = [AESCrypt encrypt:strof password:@"usai2010"];
-            NSString * str3 = [AESCrypt decrypt:str2 password:@"usai2010"];
+    NSString * str3 = [AESCrypt decrypt:@"x6P5P+DUN+s4mYoSoipdmvaPtU1mGvGGHtoqQF3GlMg=" password:@"usai2010"];
     
     NSString * str123 = [AESCrypt decrypt:@"706dZ9zTqNPauH3j2S7MQg==" password:@"usai"];
 //    NSString * str333 = [AESCrypt decrypt:@"RQtrNBCGKxNq6Bk5QGkPiw==" password:@"usai2010\0\0\0\0\0\0\0\0"];
@@ -713,6 +713,12 @@
     
 
     [super viewDidLoad];
+    
+//    NSString * str3 = [AESCrypt AES128Decrypt:@"" key:@"usai2010"];
+//    NSString * str4 = [AESCrypt AES128Decrypt:@"" key:@"usai2010"];
+    
+//    NSString * str5 = [AESCrypt AES128Decrypt:@"" key:@"usai2010"];
+    
 //    NSLog(@"decrypt:%@",[AESCrypt fastdecrypt:@"vafHUwfRPIUbPNVnKhLc5aAVK7sOFRztlfJVRHW7QVa/qGgm11E5UwfYWZEBTQpH"]);
  
     

+ 4 - 4
RedAnt ERP Mobile/HMLG Scan Order/SO.storyboard

@@ -1882,14 +1882,14 @@ Stock</string>
                                         <nil key="textColor"/>
                                         <nil key="highlightedColor"/>
                                     </label>
-                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dx2-do-qf9" userLabel="val_total">
-                                        <rect key="frame" x="605" y="55" width="124" height="21"/>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dx2-do-qf9" userLabel="val_total">
+                                        <rect key="frame" x="605" y="65.5" width="124" height="0.0"/>
                                         <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                         <nil key="textColor"/>
                                         <nil key="highlightedColor"/>
                                     </label>
-                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dd5-g0-8Ub" userLabel="val_surcharge">
-                                        <rect key="frame" x="605" y="30" width="124" height="21"/>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Dd5-g0-8Ub" userLabel="val_surcharge">
+                                        <rect key="frame" x="605" y="19.5" width="124" height="42"/>
                                         <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                         <nil key="textColor"/>
                                         <nil key="highlightedColor"/>

+ 1 - 1
RedAnt ERP Mobile/HMLG Scan Order/ScanHomeViewController.m

@@ -95,7 +95,7 @@
     MainViewController * mainvc = (MainViewController*)appDelegate.main_vc;
     
     [ActiveViewController Notify:@"ScanOrderListViewController" Message:@"NewOrder"];
-    [mainvc switchToOrder];
+    [mainvc switchToCart];
 }
 
 - (IBAction)onSubmit:(id)sender {

+ 9 - 3
RedAnt ERP Mobile/HMLG Scan Order/ScanListCell.m

@@ -86,7 +86,9 @@
             jitem[@"cart_item_id"]=[NSUUID UUID].UUIDString;
             
             NSString * unit_price;
-            if(_modelJson [@"net_price"])
+            if(RASingleton.sharedInstance.price_type==0)
+                unit_price=_modelJson[@"price0"];
+            else if(_modelJson [@"net_price"])
                 unit_price=_modelJson[@"price3"];
             else if(_modelJson [@"special_price"])
             {
@@ -164,6 +166,8 @@
     NSString* price2=_modelJson[@"price2"]; //SHOW
     NSString* price3=_modelJson[@"price3"]; //%25
  
+    
+    
     if(![price0 isEqualToString: @"N/A"])
         price0 = [NSString stringWithFormat:@"%.2f",[_modelJson[@"price0"] doubleValue]];
     if(![price1 isEqualToString: @"N/A"])
@@ -171,14 +175,16 @@
     if(![price2 isEqualToString: @"N/A"])
     {
         price2 = [NSString stringWithFormat:@"%.2f",[_modelJson[@"price2"] doubleValue]];
-        _modelJson [@"special_price"] = @true;
+//        if(RASingleton.sharedInstance.price_type==1)
+            _modelJson [@"special_price"] = @true;
     }
     if(![price3 isEqualToString: @"N/A"])
         price3 = [NSString stringWithFormat:@"%.2f",[_modelJson[@"price3"] doubleValue]];
 
     if(![_modelJson [@"special_price"] boolValue]&& ![price1 isEqualToString: @"N/A"] && [price1 isEqual:price3])
     {
-        _modelJson [@"net_price"] = @true;
+//        if(RASingleton.sharedInstance.price_type==1)
+            _modelJson [@"net_price"] = @true;
     }
     
     

+ 55 - 21
RedAnt ERP Mobile/HMLG Scan Order/ScanModelListCell.m

@@ -46,39 +46,73 @@
     _labelOrigin.text=_modelJson[@"origin"];
     _labelPort.text=_modelJson[@"port"];
     
-    NSString * cell_price;
-    if(RASingleton.sharedInstance.price_type==1)
+//    NSString * cell_price;
+//    if(RASingleton.sharedInstance.price_type==1)
+//    {
+////        if(_modelJson [@"net_price"])
+//            cell_price=_modelJson[@"price3"];
+////            jitem[@"unit_price"] =jitem[@"price3"];
+////            jitem[@"erp_unit_price"] =jitem[@"price3"];
+////        else if(_modelJson [@"special_price"])
+////        {
+////            unit_price= _modelJson[@"price2"];
+////        }
+////        else
+////        {
+////            unit_price= _modelJson[@"price1"];
+////        }
+//    }
+//    else
+//    {
+//        cell_price=_modelJson[@"price0"];
+////            jitem[@"unit_price"] =jitem[@"price0"];
+////            jitem[@"erp_unit_price"] =jitem[@"price0"];
+//    }
+    
+    
+    NSString* price0=_modelJson[@"price0"]; //DDP
+    NSString* price1=_modelJson[@"price1"]; //WHSE
+    NSString* price2=_modelJson[@"price2"]; //SHOW
+    NSString* price3=_modelJson[@"price3"]; //%25
+ 
+    
+    
+    if(![price0 isEqualToString: @"N/A"])
+        price0 = [NSString stringWithFormat:@"%.2f",[_modelJson[@"price0"] doubleValue]];
+    if(![price1 isEqualToString: @"N/A"])
+        price1 = [NSString stringWithFormat:@"%.2f",[_modelJson[@"price1"] doubleValue]];
+    if(![price2 isEqualToString: @"N/A"])
     {
-//        if(_modelJson [@"net_price"])
-            cell_price=_modelJson[@"price3"];
-//            jitem[@"unit_price"] =jitem[@"price3"];
-//            jitem[@"erp_unit_price"] =jitem[@"price3"];
-//        else if(_modelJson [@"special_price"])
-//        {
-//            unit_price= _modelJson[@"price2"];
-//        }
-//        else
-//        {
-//            unit_price= _modelJson[@"price1"];
-//        }
+        price2 = [NSString stringWithFormat:@"%.2f",[_modelJson[@"price2"] doubleValue]];
+//        if(RASingleton.sharedInstance.price_type==1)
+            _modelJson [@"special_price"] = @true;
     }
-    else
+    if(![price3 isEqualToString: @"N/A"])
+        price3 = [NSString stringWithFormat:@"%.2f",[_modelJson[@"price3"] doubleValue]];
+
+    if(![_modelJson [@"special_price"] boolValue]&& ![price1 isEqualToString: @"N/A"] && [price1 isEqual:price3])
     {
-        cell_price=_modelJson[@"price0"];
-//            jitem[@"unit_price"] =jitem[@"price0"];
-//            jitem[@"erp_unit_price"] =jitem[@"price0"];
+//        if(RASingleton.sharedInstance.price_type==1)
+            _modelJson [@"net_price"] = @true;
     }
     
     
+    
     if([_modelJson[@"price0"] isEqualToString:@"N/A"])
         _labelPriceCTNR.text=_modelJson[@"price0"];
     else
         _labelPriceCTNR.text=[RAConvertor currencyNumber:[_modelJson[@"price0"] floatValue]];
     
-    if([cell_price isEqualToString:@"N/A"])
-        _labelPriceNCA.text=cell_price;//_modelJson[@"unit_price"];
+    if([price3 isEqualToString:@"N/A"])
+        _labelPriceNCA.text= price3;
     else
-        _labelPriceNCA.text=[RAConvertor currencyNumber:[cell_price floatValue]];
+        _labelPriceNCA.text=[RAConvertor currencyNumber:[price3 floatValue]];
+    
+//
+//    if([cell_price isEqualToString:@"N/A"])
+//        _labelPriceNCA.text=cell_price;//_modelJson[@"unit_price"];
+//    else
+//        _labelPriceNCA.text=[RAConvertor currencyNumber:[cell_price floatValue]];
     _labelPrice25p.text=_modelJson[@"price2"];
     _labelAvailable.text=_modelJson[@"available"];
         _editQTY.text=[_modelJson[@"count"] stringValue];

+ 3 - 1
RedAnt ERP Mobile/HMLG Scan Order/ScanOrderModelListViewController.m

@@ -160,7 +160,9 @@
         }
         
         NSString * unit_price;
-        if(jitem [@"net_price"])
+        if(RASingleton.sharedInstance.price_type==0)
+            unit_price=jitem[@"price0"];
+        else if(jitem [@"net_price"])
             unit_price=jitem[@"price3"];
         else if(jitem [@"special_price"])
         {

+ 4 - 0
RedAnt ERP Mobile/HMLG Scan Order/ServerSettingViewController.m

@@ -245,6 +245,9 @@
                 
                 if(download_data!=nil)
                 {
+                    
+                    [RAUtils deletefiles:[documents stringByAppendingPathComponent:@"download"]];
+                    
                     NSString* file_name=[appDelegate.downloadurl lastPathComponent];
                     NSString* path = [documents stringByAppendingPathComponent:file_name];
                     [RAUtils saveData:download_data toPath:path];
@@ -293,6 +296,7 @@
                             [fileManager removeItemAtPath:path error:nil];
                             [RAUtils message_alert:@"Update template file successful." title:@"Message" controller:self];
                             
+//                            [RADataProvider encrypt_scan_models];
 
                             NSMutableDictionary *templateDic = [NSMutableDictionary dictionary];
                             NSString* datetime= [RAUtils current_date_time];

+ 4 - 1
RedAnt ERP Mobile/HMLG Scan Order/SetupServerViewController.m

@@ -81,6 +81,7 @@
                         
                 AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
                 appDelegate.address = [addressDic objectForKey:@"serverAddress"];
+                
                 [self updateTemplate];
                 if(self.returnValue)
                     self.returnValue();
@@ -115,6 +116,8 @@
         NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
         NSString *documents = [paths objectAtIndex:0];
         
+        [RAUtils deletefiles:[documents stringByAppendingPathComponent:@"download"]];
+        
 //        NSString* file_name=[appDelegate.downloadurl lastPathComponent];
         
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
@@ -174,7 +177,7 @@
                             [fileManager removeItemAtPath:path error:nil];
                             [RAUtils message_alert:@"Update template file successful." title:@"Message" controller:self];
                             
-
+//                            [RADataProvider encrypt_scan_models];
                             NSMutableDictionary *templateDic = [NSMutableDictionary dictionary];
                             NSString* datetime= [RAUtils current_date_time];
                             templateDic[@"updatetime"]= datetime;

+ 9 - 0
RedAnt ERP Mobile/common/AppDelegateBase.m

@@ -1193,6 +1193,15 @@ void UncaughtExceptionHandler(NSException *exception) {
     });
     
 }
+-(void)setOrder_code:(NSString *)order_code
+{
+    _order_code = order_code;
+    
+    if(order_code==nil)
+        NSLog(@"Clear order code");
+    else
+        NSLog(@"New order code %@",order_code);
+}
 
 - (void)checkLogin:(BOOL)reloadCurVC {
     

+ 10 - 10
RedAnt ERP Mobile/common/Functions/OLO/ScanOrderListViewController.m

@@ -440,11 +440,11 @@
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
 //    appDelegate.order_code = order_code;
     
-    if(appDelegate.user.length==0)
-    {
-        [RAUtils message_alert:@"Please login first." title:@"Warring" controller:self];
-        return;
-    }
+//    if(appDelegate.user.length==0)
+//    {
+//        [RAUtils message_alert:@"Please login first." title:@"Warring" controller:self];
+//        return;
+//    }
     
     //    NSData* json =[NSData dataWithContentsOfFile:[[NSBundle mainBundle]  pathForResource:URL_SO_CART ofType:@"json" ]];
     //    NSMutableDictionary* cartTemplate=[OLDataProvider loadScanTemplate:@"scan_cart.json"];
@@ -530,11 +530,11 @@
     
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
     
-    if(appDelegate.user.length<=0)
-    {
-        [RAUtils message_alert:@"Please login first." title:@"Warring" controller:self];
-        return;
-    }
+//    if(appDelegate.user.length<=0)
+//    {
+//        [RAUtils message_alert:@"Please login first." title:@"Warring" controller:self];
+//        return;
+//    }
     
     if(appDelegate.order_code.length>0)
     {

+ 30 - 3
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -1465,6 +1465,7 @@
                 NSMutableDictionary* item = [section[[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
                 item[@"price"]= item[@"price0"];
                 item[@"unit_price"]= item[@"price0"];
+                item[@"erp_unit_price"]= item[@"price0"];
                 section[[NSString stringWithFormat:@"item_%d",i]] = item;
             }
         RASingleton.sharedInstance.scan_cart[@"section_0"]  = section;
@@ -1484,8 +1485,34 @@
             for(int i=0;i<count;i++)
             {
                 NSMutableDictionary* item = [section[[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
-                item[@"price"]= item[@"price1"];
-                item[@"unit_price"]= item[@"price1"];
+                
+                NSString * unit_price;
+   
+                if(item [@"net_price"])
+                    unit_price=item[@"price3"];
+                else if(item [@"special_price"])
+                {
+                    unit_price= item[@"price2"];
+                }
+                else
+                {
+                    unit_price= item[@"price1"];
+                }
+
+                if([unit_price isEqualToString:@"N/A"])
+                    unit_price = @"0";
+                else
+                {
+                    
+                    unit_price = [NSString stringWithFormat:@"%.2f", [unit_price doubleValue]];
+                }
+                
+                
+                item[@"unit_price"] = unit_price;
+                item[@"erp_unit_price"] = unit_price;
+                
+                item[@"price"]= unit_price;//item[@"price1"];
+//                item[@"unit_price"]= item[@"price1"];
                 section[[NSString stringWithFormat:@"item_%d",i]] = item;
             }
         RASingleton.sharedInstance.scan_cart[@"price_type"] = @1;
@@ -3217,7 +3244,7 @@
  //   cell.from=indexPath;
     
     
-    if([item_json[@"net_price"] boolValue]||[item_json[@"special_price"] boolValue]||discount>0)
+    if(RASingleton.sharedInstance.price_type==1&&([item_json[@"net_price"] boolValue]||[item_json[@"special_price"] boolValue]||discount>0))
     {
                 cell.labelUnitPrice.textColor= [UIColor redColor];
         if([item_json[@"special_price"] boolValue]||discount>0)

+ 2 - 0
RedAnt ERP Mobile/common/data_provider/RADataProvider.h

@@ -29,6 +29,8 @@ NS_ASSUME_NONNULL_BEGIN
 +(void)request_change_password:(NSString*) pwd completionHandler:(resultHandler)result;
 +(void)load_scan_models;
 +(NSArray*)request_scan_model_by_names:(NSString*)names;
+
+//+(void)encrypt_scan_models;
 @end
 
 NS_ASSUME_NONNULL_END

+ 22 - 2
RedAnt ERP Mobile/common/data_provider/RADataProvider.m

@@ -10,6 +10,26 @@
 
 @implementation RADataProvider
 
++(void)encrypt_scan_models
+{
+    return;
+    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+    NSString *documents = [paths objectAtIndex:0];
+    NSString* unZipTo=[documents stringByAppendingPathComponent:@"download"];
+    NSString* templatefile = [unZipTo stringByAppendingPathComponent:@"offline_models.json"];
+
+    NSString* str = [NSString stringWithContentsOfFile:templatefile encoding:NSUTF8StringEncoding error:nil];
+    NSString * stre = [AESCrypt encrypt:str password:@"usai2010"];
+//    NSString *writePath = [NSHomeDirectory() stringByAppendingPathComponent:@"tmp/haha.txt"];
+    NSError *error;
+    [stre writeToFile:templatefile atomically:YES encoding:NSUTF8StringEncoding error:&error];
+    if (error) {
+        NSLog(@"导出失败");
+    }else {
+        NSLog(@"导出成功");
+    }
+}
+
 +(NSArray*)request_scan_model_by_names:(NSString*)names
 {
     AppDelegate *appDelegate = nil;
@@ -41,8 +61,8 @@
     NSString* templatefile = [unZipTo stringByAppendingPathComponent:@"offline_models.json"];
 
     NSString* str = [NSString stringWithContentsOfFile:templatefile encoding:NSUTF8StringEncoding error:nil];
-//    NSString * str3 = [AESCrypt decrypt:str password:@"usai2010"];
-    NSMutableDictionary* of = [[RAConvertor string2dict:str] mutableCopy];
+    NSString * str3 = [AESCrypt AES128Decrypt:str key:@"usai2010"];
+    NSMutableDictionary* of = [[RAConvertor string2dict:str3] mutableCopy];
 //    NSData *filedata = [NSData dataWithContentsOfFile:path];
 //    if(filedata == nil)
 //        return nil;