|
@@ -3648,11 +3648,14 @@
|
|
|
[iSalesDB execSql:@"BEGIN TRANSACTION" db:db];
|
|
[iSalesDB execSql:@"BEGIN TRANSACTION" db:db];
|
|
|
|
|
|
|
|
NSString* product_id=params[@"product_id"];
|
|
NSString* product_id=params[@"product_id"];
|
|
|
|
|
+ NSString *item_count_str = params[@"item_count"];
|
|
|
|
|
|
|
|
|
|
|
|
|
NSArray* arr=[RAUtils string2arr:product_id separator:@","];
|
|
NSArray* arr=[RAUtils string2arr:product_id separator:@","];
|
|
|
|
|
+
|
|
|
|
|
+ NSArray *item_count_arr = item_count_str ? [item_count_str componentsSeparatedByString:@","] : nil;
|
|
|
|
|
|
|
|
- NSString* sqlQuery = [NSString stringWithFormat:@"insert into wishlist(product_id) values(?);"];
|
|
|
|
|
|
|
+ NSString* sqlQuery = [NSString stringWithFormat:@"insert into wishlist(product_id,qty) values(?,?);"];
|
|
|
// NSString *sql = @"";
|
|
// NSString *sql = @"";
|
|
|
for(int i=0;i<arr.count;i++)
|
|
for(int i=0;i<arr.count;i++)
|
|
|
{
|
|
{
|
|
@@ -3660,12 +3663,28 @@
|
|
|
int count=[iSalesDB get_recordcount:db table:@"wishlist" where:where];
|
|
int count=[iSalesDB get_recordcount:db table:@"wishlist" where:where];
|
|
|
if(count==0)
|
|
if(count==0)
|
|
|
{
|
|
{
|
|
|
-// NSString* sqlQuery = [NSString stringWithFormat:@"insert into wishlist(product_id) values(%@);",arr[i]];
|
|
|
|
|
-// sql = [sql stringByAppendingString:sqlQuery];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ __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_stmt *stmt;
|
|
|
sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &stmt, nil);
|
|
sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &stmt, nil);
|
|
|
sqlite3_bind_text(stmt,1,[arr[i] UTF8String],[arr[i] length],NULL);
|
|
sqlite3_bind_text(stmt,1,[arr[i] UTF8String],[arr[i] length],NULL);
|
|
|
|
|
+ if (item_count_arr) {
|
|
|
|
|
+ sqlite3_bind_int(stmt,2,[item_count_arr[i] integerValue]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sqlite3_bind_int(stmt,2,cart_count);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (sqlite3_step(stmt) == SQLITE_ERROR) {
|
|
if (sqlite3_step(stmt) == SQLITE_ERROR) {
|
|
|
[iSalesDB execSql:@"ROLLBACK" db:db];
|
|
[iSalesDB execSql:@"ROLLBACK" db:db];
|
|
|
ret[@"result"]=[NSNumber numberWithInt:RESULT_ERROR ];
|
|
ret[@"result"]=[NSNumber numberWithInt:RESULT_ERROR ];
|
|
@@ -6829,15 +6848,18 @@
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
|
|
|
__block NSString *product_id = @"";
|
|
__block NSString *product_id = @"";
|
|
|
-// __block int item_count = 0;
|
|
|
|
|
|
|
+ __block NSString *item_count_str = @"";
|
|
|
// __block NSString *item_id = nil;
|
|
// __block NSString *item_id = nil;
|
|
|
[iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
[iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
// product_id = [self textAtColumn:0 statement:stmt];
|
|
// product_id = [self textAtColumn:0 statement:stmt];
|
|
|
-// item_count = sqlite3_column_int(stmt, 1);
|
|
|
|
|
|
|
+ int item_count = sqlite3_column_int(stmt, 1);
|
|
|
// item_id = [self textAtColumn:2 statement:stmt];
|
|
// item_id = [self textAtColumn:2 statement:stmt];
|
|
|
NSString *p_id = [self textAtColumn:0 statement:stmt];
|
|
NSString *p_id = [self textAtColumn:0 statement:stmt];
|
|
|
|
|
+ item_count_str = [NSString stringWithFormat:@"%d",item_count];
|
|
|
|
|
+
|
|
|
if (p_id.length) {
|
|
if (p_id.length) {
|
|
|
product_id = [product_id stringByAppendingString:[NSString stringWithFormat:@",%@",p_id]];
|
|
product_id = [product_id stringByAppendingString:[NSString stringWithFormat:@",%@",p_id]];
|
|
|
|
|
+ item_count_str = [item_count_str stringByAppendingString:[NSString stringWithFormat:@",%d",item_count]];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}];
|
|
}];
|
|
@@ -6845,7 +6867,7 @@
|
|
|
|
|
|
|
|
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
product_id = [product_id substringFromIndex:1];
|
|
product_id = [product_id substringFromIndex:1];
|
|
|
- dic = [self offline_add2wishlist:@{@"product_id" : product_id}.mutableCopy].mutableCopy;
|
|
|
|
|
|
|
+ dic = [self offline_add2wishlist:@{@"product_id" : product_id,@"item_count" : item_count_str}.mutableCopy].mutableCopy;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -6857,7 +6879,7 @@
|
|
|
int wish_count = [iSalesDB get_recordcount:db1 table:@"wishlist" where:@"1=1"];
|
|
int wish_count = [iSalesDB get_recordcount:db1 table:@"wishlist" where:@"1=1"];
|
|
|
|
|
|
|
|
[dic setValue:@"Regular Mode" forKey:@"mode"];
|
|
[dic setValue:@"Regular Mode" forKey:@"mode"];
|
|
|
-// [dic setValue:@"160409" forKey:@"min_ver"];
|
|
|
|
|
|
|
+
|
|
|
[dic setValue:[NSNumber numberWithInteger:wish_count] forKey:@"wish_count"];
|
|
[dic setValue:[NSNumber numberWithInteger:wish_count] forKey:@"wish_count"];
|
|
|
|
|
|
|
|
// 删除
|
|
// 删除
|