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

修复Cart中Select All Move To WishList 只成功一个Product

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

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


+ 26 - 19
RedAnt ERP Mobile/common/Functions/offline/OLDataProvider.m

@@ -6673,28 +6673,34 @@
     NSString *sql = [NSString stringWithFormat:@"select product_id,item_count,item_id from offline_cart where so_no = '%@' and _id in %@;",orderCode,_id];
     sqlite3 *db = [iSalesDB get_db];
     
-    __block NSString *product_id = nil;
-    __block int item_count = 0;
-    __block NSString *item_id = nil;
+    __block NSString *product_id = @"";
+//    __block int item_count = 0;
+//    __block NSString *item_id = nil;
     [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
-        product_id = [self textAtColumn:0 statement:stmt];
-        item_count = sqlite3_column_int(stmt, 1);
-        item_id = [self textAtColumn:2 statement:stmt];
+//        product_id = [self textAtColumn:0 statement:stmt];
+//        item_count = sqlite3_column_int(stmt, 1);
+//        item_id = [self textAtColumn:2 statement:stmt];
+        NSString *p_id = [self textAtColumn:0 statement:stmt];
+        if (p_id.length) {
+            product_id = [product_id stringByAppendingString:[NSString stringWithFormat:@",%@",p_id]];
+        }
+        
     }];
+    [iSalesDB close_db:db];
     
-    //
-//    NSString *contactIdSql = [NSString stringWithFormat:@"select customer_cid from offline_order where so_id = '%@';",orderCode];
-//    __block NSString *contact_id = nil;
-//    [iSalesDB jk_query:contactIdSql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
-//        contact_id = [self textAtColumn:0 statement:stmt];
-//    }];
+    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
+    product_id = [product_id substringFromIndex:1];
+    dic = [self offline_add2wishlist:@{@"product_id" : product_id}.mutableCopy].mutableCopy;
+
     
-    NSString *insertIntoWishlistSql = [NSString stringWithFormat:@"insert into wishlist (product_id,item_id,qty) values (%@,%@,%d);",product_id,item_id,item_count];
-    int ret = [iSalesDB execSql:insertIntoWishlistSql db:db];
     
-    int wish_count = [iSalesDB get_recordcount:db table:@"wishlist" where:nil];
-    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
-    [dic setValue:[NSNumber numberWithInteger:ret] forKey:@"result"];
+//    NSString *insertIntoWishlistSql = [NSString stringWithFormat:@"insert into wishlist (product_id,item_id,qty) values (%@,%@,%d);",product_id,item_id,item_count];
+//    int ret = [iSalesDB execSql:insertIntoWishlistSql db:db];
+    
+    sqlite3 *db1 = [iSalesDB get_db];
+    
+    int wish_count = [iSalesDB get_recordcount:db1 table:@"wishlist" where:nil];
+
     [dic setValue:@"Regular Mode" forKey:@"mode"];
 //    [dic setValue:@"160409" forKey:@"min_ver"];
     [dic setValue:[NSNumber numberWithInteger:wish_count] forKey:@"wish_count"];
@@ -6702,9 +6708,10 @@
     // 删除
     
     NSString *deleteSql = [NSString stringWithFormat:@"delete from offline_cart where _id in %@;",_id];
-    [iSalesDB execSql:deleteSql db:db];
+    int ret = [iSalesDB execSql:deleteSql db:db1];
+    [dic setValue:[NSNumber numberWithInteger:ret] forKey:@"result"];
     
-    [iSalesDB close_db:db];
+    [iSalesDB close_db:db1];
     
     return [RAUtils dict2data:dic];
 }