|
|
@@ -707,7 +707,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
- NSString* sqlQuery = [NSString stringWithFormat:@"delete from wishlist where _id in (%@);",collectId];
|
|
|
+// NSString* sqlQuery = [NSString stringWithFormat:@"delete from wishlist where _id in (%@);",collectId];
|
|
|
+ NSString* sqlQuery = [NSString stringWithFormat:@"update wishlist set is_delete = 1 where _id in (%@);",collectId];
|
|
|
[iSalesDB execSql:sqlQuery db:db];
|
|
|
int count=[iSalesDB get_recordcount:db table:@"wishlist" where:@"is_delete is NULL or is_delete != 1"];
|
|
|
[iSalesDB close_db:db];
|
|
|
@@ -3724,23 +3725,25 @@
|
|
|
// NSString *sql = @"";
|
|
|
for(int i=0;i<arr.count;i++)
|
|
|
{
|
|
|
- NSString* where=[NSString stringWithFormat:@"product_id=%@ and is_delete is NULL or is_delete != 1",arr[i]];
|
|
|
+ NSString* where=[NSString stringWithFormat:@"product_id=%@",arr[i]];
|
|
|
int count=[iSalesDB get_recordcount:db table:@"wishlist" where:where];
|
|
|
+
|
|
|
+ __block int cart_count = 0;
|
|
|
+ if (!item_count_str) {
|
|
|
+ NSString *product_sold_qty_sql = [NSString stringWithFormat:@"select model_set from product where product_id = %@",arr[i]];
|
|
|
+ [iSalesDB jk_query:product_sold_qty_sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+
|
|
|
+ NSString *model_set = [self textAtColumn:0 statement:stmt];
|
|
|
+ NSArray *model_set_components = [model_set componentsSeparatedByString:@" "];
|
|
|
+ cart_count = [[model_set_components lastObject] integerValue];
|
|
|
+
|
|
|
+ }];
|
|
|
+ }
|
|
|
+
|
|
|
if(count==0)
|
|
|
{
|
|
|
|
|
|
sqlQuery = [NSString stringWithFormat:@"insert into wishlist(product_id,qty) values(?,?);"];
|
|
|
- __block int cart_count = 0;
|
|
|
- if (!item_count_str) {
|
|
|
- NSString *product_sold_qty_sql = [NSString stringWithFormat:@"select model_set from product where product_id = %@",arr[i]];
|
|
|
- [iSalesDB jk_query:product_sold_qty_sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
-
|
|
|
- NSString *model_set = [self textAtColumn:0 statement:stmt];
|
|
|
- NSArray *model_set_components = [model_set componentsSeparatedByString:@" "];
|
|
|
- cart_count = [[model_set_components lastObject] integerValue];
|
|
|
-
|
|
|
- }];
|
|
|
- }
|
|
|
|
|
|
sqlite3_stmt *stmt;
|
|
|
sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &stmt, nil);
|
|
|
@@ -3760,7 +3763,13 @@
|
|
|
return ret;
|
|
|
}
|
|
|
} else {
|
|
|
- sqlQuery = [NSString stringWithFormat:@"update wishlist set qty = 1 where product_id = %@;",arr[i]];
|
|
|
+ int qty = 0;
|
|
|
+ if (item_count_arr) {
|
|
|
+ qty = [item_count_arr[i] integerValue];
|
|
|
+ } else {
|
|
|
+ qty = cart_count;
|
|
|
+ }
|
|
|
+ sqlQuery = [NSString stringWithFormat:@"update wishlist set qty = 1 where product_id = %@ and (is_delete is null or is_delete != 1);update wishlist set qty = %d,is_delete = 0 where product_id = %@ and is_delete = 1;",arr[i],qty,arr[i]];
|
|
|
|
|
|
if ([iSalesDB execSql:sqlQuery db:db] == RESULT_FALSE) {
|
|
|
[iSalesDB execSql:@"ROLLBACK" db:db];
|
|
|
@@ -3778,8 +3787,8 @@
|
|
|
int count=[iSalesDB get_recordcount:db table:@"wishlist" where:@"is_delete is NULL or is_delete != 1"];
|
|
|
[iSalesDB execSql:@"END TRANSACTION" db:db];
|
|
|
|
|
|
- int wish_count = [iSalesDB get_recordcount:db table:@"wishlist" where:@"1=1"];
|
|
|
- [ret setValue:[NSNumber numberWithInteger:wish_count] forKey:@"wish_count"];
|
|
|
+// int wish_count = [iSalesDB get_recordcount:db table:@"wishlist" where:@"1=1"];
|
|
|
+ [ret setValue:[NSNumber numberWithInteger:count] forKey:@"wish_count"];
|
|
|
[iSalesDB close_db:db];
|
|
|
|
|
|
appDelegate.wish_count =count;
|
|
|
@@ -9561,6 +9570,8 @@
|
|
|
return [RAUtils dict2data:ret];
|
|
|
}
|
|
|
|
|
|
+#pragma mark move wish list to cart
|
|
|
+
|
|
|
+ (NSData*)offline_movewish2cart:(NSMutableDictionary *)params {
|
|
|
|
|
|
NSString *collectId = params[@"collectId"];
|
|
|
@@ -9594,9 +9605,10 @@
|
|
|
|
|
|
if ([retDic[@"result"] integerValue] == RESULT_TRUE) {
|
|
|
|
|
|
- NSString *deleteSQL = [NSString stringWithFormat:@"delete from wishlist where _id in (%@);",collectId];
|
|
|
-
|
|
|
- int ret = [iSalesDB execSql:deleteSQL];
|
|
|
+// NSString *deleteSQL = [NSString stringWithFormat:@"delete from wishlist where _id in (%@);",collectId];
|
|
|
+//
|
|
|
+// int ret = [iSalesDB execSql:deleteSQL];
|
|
|
+ int ret = [[[self offline_deletewishlist:@{@"collectId" : collectId}.mutableCopy] valueForKey:@"result"] integerValue];
|
|
|
|
|
|
retDic[@"result"] = [NSNumber numberWithInteger:ret];
|
|
|
|