Quellcode durchsuchen

修改离线解锁,清除表Contact、Order以及Cart。
已修改ModelDetail超时重新请求没有传Model ID。
修改ModelDetail Recent Model Product ID比较,比较前转为String。
修改Add To Cart提示消息。

Pen Li vor 9 Jahren
Ursprung
Commit
283a3ef8d5

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


+ 3 - 25
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -4,35 +4,13 @@
    version = "2.0">
    <Breakpoints>
       <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
          <BreakpointContent
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "common/Functions/category/CategoryViewController.m"
-            timestampString = "509943678.44584"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1285"
-            endingLineNumber = "1285"
-            landmarkName = "-showCategory"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            shouldBeEnabled = "No"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "common/Functions/contact/ContactListViewController.m"
-            timestampString = "509946416.462715"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "716"
-            endingLineNumber = "716"
-            landmarkName = "-tableView:cellForRowAtIndexPath:"
-            landmarkType = "7">
+            scope = "0"
+            stopOnStyle = "0">
          </BreakpointContent>
       </BreakpointProxy>
    </Breakpoints>

+ 3 - 1
RedAnt ERP Mobile/common/CartUtils.m

@@ -736,7 +736,9 @@
     for(int i=0;i<count;i++)
     {
         NSMutableDictionary * mitem= appDelegate.recent_model[[NSString stringWithFormat:@"item_%d",i]];
-        if([mitem[@"product_id"] isEqualToString:model[@"product_id"]])
+        NSString *mitemProductID = [NSString stringWithFormat:@"%@",mitem[@"product_id"]];
+        NSString *modelProductID = [NSString stringWithFormat:@"%@",model[@"product_id"]];
+        if([mitemProductID isEqualToString:modelProductID])
             continue;
         [newdict setObject:mitem forKey:[NSString stringWithFormat:@"item_%lu",(unsigned long)newdict.allKeys.count]];
 

+ 41 - 5
RedAnt ERP Mobile/common/Functions/modelDetail/DetailHeaderCell.m

@@ -657,7 +657,14 @@
                             else
                             {
                                 UIViewController *vc= [RAUtils getViewController:self];
-                                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:vc] ;
+                                NSString *msg = [return_json valueForKey:@"err_msg"];
+                                NSString *title = @"Add To Cart";
+                                if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                                    title = @"Add To Cart: Out of Stock";
+                                    msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                                }
+                                
+                                [RAUtils message_alert:msg title:title controller:vc] ;
                             }
                             
                             
@@ -724,7 +731,14 @@
                                     else
                                     {
                                         UIViewController *vc= [RAUtils getViewController:self];
-                                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:vc] ;
+                                        NSString *msg = [return_json valueForKey:@"err_msg"];
+                                        NSString *title = @"Add To Cart";
+                                        if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                                            title = @"Add To Cart: Out of Stock";
+                                            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                                        }
+                                        
+                                        [RAUtils message_alert:msg title:title controller:vc] ;
                                     }
                                     
                                     
@@ -865,7 +879,14 @@
                         else
                         {
                             UIViewController *vc= [RAUtils getViewController:self];
-                            [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:vc] ;
+                            NSString *msg = [return_json valueForKey:@"err_msg"];
+                            NSString *title = @"Add To Cart";
+                            if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                                title = @"Add To Cart: Out of Stock";
+                                msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                            }
+                            
+                            [RAUtils message_alert:msg title:title controller:vc] ;
                         }
                         
                         
@@ -936,7 +957,15 @@
                     else
                     {
                         UIViewController *vc= [RAUtils getViewController:self];
-                        [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:vc] ;
+                        
+                        NSString *msg = [return_json valueForKey:@"err_msg"];
+                        NSString *title = @"Add To Cart";
+                        if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                            title = @"Add To Cart: Out of Stock";
+                            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                        }
+                        
+                        [RAUtils message_alert:msg title:title controller:vc] ;
                     }
                     
                     
@@ -1121,7 +1150,14 @@
             else
             {
                 UIViewController *vc= [RAUtils getViewController:self];
-                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:vc] ;
+                NSString *msg = [return_json valueForKey:@"err_msg"];
+                NSString *title = @"Add To Cart";
+                if ([msg hasPrefix:@"Out of Stock.\n"]) {
+                    title = @"Add To Cart: Out of Stock";
+                    msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+                }
+                
+                [RAUtils message_alert:msg title:title controller:vc] ;
             }
             
             

+ 1 - 1
RedAnt ERP Mobile/common/Functions/modelDetail/DetailViewController.m

@@ -117,7 +117,7 @@ dispatch_async(dispatch_get_main_queue(), ^{
         dispatch_async(dispatch_get_main_queue(), ^{
             [self.mum stopAnimating];
             self.detail_data = [detail_json mutableCopy];
-            self.product_id = [NSString stringWithFormat:@"%d",[[detail_json valueForKey:@"product_id"] intValue] ];
+//            self.product_id = [NSString stringWithFormat:@"%d",[[detail_json valueForKey:@"product_id"] intValue] ];
             NSDictionary* imgsection = [detail_json objectForKey:@"img_section"];
             //          AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
             if(/*appDelegate.user_type==USER_ROLE_CUSTOMER*/true)

+ 12 - 11
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -3847,7 +3847,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     for(int i=0;i<arr_id.count;i++)
     {
         
-        int item_qty= count;
+        NSInteger item_qty= count;
         if (qty) {
             item_qty = [qty_arr[i] integerValue];
         }
@@ -3888,10 +3888,10 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
             sql=[NSString stringWithFormat:@"insert into offline_cart(product_id,so_no,item_count,item_id,create_time) values(?,?,?,?,datetime('now', 'localtime'))"];
             
             sqlite3_prepare_v2(db, [sql UTF8String], -1, &stmt, nil);
-            sqlite3_bind_text(stmt,1,[arr_id[i] UTF8String],[arr_id[i] length],NULL);
-            sqlite3_bind_text(stmt,2,[orderCode UTF8String],[orderCode length],NULL);
-            sqlite3_bind_text(stmt,3,[[NSString stringWithFormat:@"%d",item_qty] UTF8String],[[NSString stringWithFormat:@"%d",item_qty] length],NULL);
-            sqlite3_bind_text(stmt,4,[[NSString stringWithFormat:@"%d",item_id] UTF8String],[[NSString stringWithFormat:@"%d",item_id] length],NULL);
+            sqlite3_bind_text(stmt,1,[arr_id[i] UTF8String],(int)[arr_id[i] length],NULL);
+            sqlite3_bind_text(stmt,2,[orderCode UTF8String],(int)[orderCode length],NULL);
+            sqlite3_bind_text(stmt,3,[[NSString stringWithFormat:@"%ld",item_qty] UTF8String],(int)[[NSString stringWithFormat:@"%ld",item_qty] length],NULL);
+            sqlite3_bind_text(stmt,4,[[NSString stringWithFormat:@"%d",item_id] UTF8String],(int)[[NSString stringWithFormat:@"%d",item_id] length],NULL);
             shouldStep = YES;
         }
         else
@@ -3904,7 +3904,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
                 shouldStep = YES;
             } else {
                 
-                sql = [NSString stringWithFormat:@"select c.item_count + %d,p.availability from product as p left join offline_cart as c on c.item_id = p.item_id where c._id = %d;",item_qty,_id];
+                sql = [NSString stringWithFormat:@"select c.item_count + %ld,p.availability from product as p left join offline_cart as c on c.item_id = p.item_id where c._id = %d;",item_qty,_id];
                 __block BOOL update = YES;
                 [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
                     
@@ -3923,8 +3923,8 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
                     sql=[NSString stringWithFormat:@"update offline_cart set item_count=item_count+?,create_time = datetime('now', 'localtime') where _id=?"];
                     
                     sqlite3_prepare_v2(db, [sql UTF8String], -1, &stmt, nil);
-                    sqlite3_bind_text(stmt,1,[[NSString stringWithFormat:@"%d",item_qty] UTF8String],[[NSString stringWithFormat:@"%d",item_qty] length],NULL);
-                    sqlite3_bind_text(stmt,2,[[NSString stringWithFormat:@"%d",_id] UTF8String],[[NSString stringWithFormat:@"%d",_id] length],NULL);
+                    sqlite3_bind_text(stmt,1,[[NSString stringWithFormat:@"%ld",item_qty] UTF8String],(int)[[NSString stringWithFormat:@"%ld",item_qty] length],NULL);
+                    sqlite3_bind_text(stmt,2,[[NSString stringWithFormat:@"%d",_id] UTF8String],(int)[[NSString stringWithFormat:@"%d",_id] length],NULL);
                     shouldStep = YES;
                 }
             }
@@ -3959,7 +3959,8 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
     ret[@"result"]=[NSNumber numberWithInt:RESULT_TRUE ];
     if (number_of_outOfStock > 0) {
         ret[@"result"]=[NSNumber numberWithInt:8];
-        ret[@"err_msg"] = [NSString stringWithFormat:@"%d item is out of stock",number_of_outOfStock];
+        ret[@"err_msg"] = @"Out of Stock.\nNo more quantity available.\nPlease try again after sync.";
+        /*[NSString stringWithFormat:@"%d item is out of stock",number_of_outOfStock]*/
     }
     
     [iSalesDB execSql:@"END TRANSACTION" db:db];
@@ -3970,8 +3971,8 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
 
 +(NSDictionary*) model_bundle:(int) item_id db:(sqlite3*)db compute_part:(bool)compute contactID:(NSString *)contactID
 {
-    UIApplication * app = [UIApplication sharedApplication];
-    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
+//    UIApplication * app = [UIApplication sharedApplication];
+//    AppDelegate *appDelegate = (AppDelegate *)[app delegate];
     
     NSMutableDictionary* ret = [[NSMutableDictionary alloc]init];
     

+ 2 - 0
RedAnt ERP Mobile/common/Functions/offline/OfflineSettingViewController.m

@@ -332,6 +332,8 @@
             else
             {
                 ver=nil;
+                NSString *clearTableSQL = @"delete from offline_contact;delete from offline_order;delete from offline_cart;";
+                [iSalesDB execSql:clearTableSQL];
                 
             }
         } else if (ver && self.bunlock) {

+ 9 - 2
RedAnt ERP Mobile/common/RAUtils.m

@@ -486,11 +486,18 @@
 {
     if(title==nil)
         title = @"Message";
+    if ([title isEqualToString:@"Add To Cart"]) {
+        if ([msg hasPrefix:@"Out of Stock.\n"]) {
+            title = @"Add To Cart: Out of Stock";
+            msg = [msg substringFromIndex:[@"Out of Stock.\n" length]];
+        }
+    }
+    
     
     
     return [self alert_view:msg title:title];
-//    
-//    
+//
+//
 //    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
 //    //block代码块取代了delegate
 //