Преглед изворни кода

实现方法offline_add2cartbyname

Pen Li пре 9 година
родитељ
комит
5112ec1f01

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


+ 78 - 4
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -2077,10 +2077,7 @@
     
     return [RAUtils dict2data:ret];
 }
-+(NSData*) offline_add2cartbyname :(NSMutableDictionary *) params
-{
-    return [RAUtils dict2data:[self offline_notimpl]];
-}
+
 +(NSDictionary*) model_bundle:(int) item_id db:(sqlite3*)db compute_part:(bool)compute
 {
     UIApplication * app = [UIApplication sharedApplication];
@@ -8632,4 +8629,81 @@
 
 }
 
+#pragma mark add to cart by name
+
++(NSData*) offline_add2cartbyname :(NSMutableDictionary *) params
+{
+//    {
+//        count = 1;
+//        customerInfo =     {
+//            "business_card_0" = "";
+//            "business_card_1" = "";
+//            "business_card_2" = "";
+//            "customer_address1" = "1815 PEARL ST";
+//            "customer_address2" = "";
+//            "customer_address3" = "";
+//            "customer_address4" = "";
+//            "customer_cid" = 3RDVIN0001;
+//            "customer_city" = BOULDER;
+//            "customer_contact" = "CONNIE DRUNNER";
+//            "customer_contact_ext" = "1815 PEARL ST
+//            \n BOULDER, CO, 80302, US United States";
+//            "customer_contact_notes" = "Remark:    Please review your order carefully and make sure EVERYTHING is correct, including the SHIP TO address. Please sign to authorize NPD to ship. Thank you for your business.";
+//            "customer_country" = "US United States";
+//            "customer_email" = "3RDANDVINEDESIGN@GMAIL.COM";
+//            "customer_fax" = "303.442.0672";
+//            "customer_first_name" = CONNIE;
+//            "customer_last_name" = DRUNNER;
+//            "customer_name" = "3rd & Vine Desgin";
+//            "customer_phone" = "303.442.0669";
+//            "customer_price_type" = "West Dealer Price;Special Customer Price;West Wholesale Price;East Wholesale Price;";
+//            "customer_sales_rep" = "";
+//            "customer_state" = CO;
+//            "customer_zipcode" = 80302;
+//        };
+//        mode = RM;
+//        orderCode = MOB1608240002;
+//        password = 123456;
+//        "product_name" = "108239B-23,108239B-01";
+//        result = 2;
+//        user = EvanK;
+//    }
+
+    NSString *orderCode = [params objectForKey:@"orderCode"];
+    NSString *product_name = [params objectForKey:@"product_name"];
+    product_name = [self translateSingleQuote:product_name];
+    NSArray *product_name_array = [product_name componentsSeparatedByString:@","];
+    
+    sqlite3 *db = [iSalesDB get_db];
+    
+    __block NSMutableString *product_id_string = [NSMutableString string];
+    for (int i = 0; i < product_name_array.count; i++) {
+        NSString *name = [product_name_array objectAtIndex:i];
+        
+        NSString *sql = [NSString stringWithFormat:@"select product_id from product where name = '%@';",name];
+        
+        [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
+            
+            int product_id = sqlite3_column_int(stmt, 0);
+            if (i == product_name_array.count - 1) {
+                [product_id_string appendFormat:@"%d",product_id];
+            } else {
+                [product_id_string appendFormat:@"%d,",product_id];
+            }
+            
+        }];
+    }
+    
+    NSDictionary *newParams = @{
+                                @"product_id" : product_id_string,
+                                @"orderCode"  : orderCode
+                                };
+    
+    [iSalesDB close_db:db];
+    
+    
+    
+    return [self offline_add2cart:[newParams mutableCopy]];
+}
+
 @end