|
@@ -2147,15 +2147,19 @@
|
|
|
|
|
|
|
|
NSString* product_id=params[@"product_id"];
|
|
NSString* product_id=params[@"product_id"];
|
|
|
NSString* orderCode=params[@"orderCode"];
|
|
NSString* orderCode=params[@"orderCode"];
|
|
|
-
|
|
|
|
|
|
|
+ NSString *qty = params[@"qty"];
|
|
|
|
|
|
|
|
NSArray* arr_id=[RAUtils string2arr:product_id separator:@","];
|
|
NSArray* arr_id=[RAUtils string2arr:product_id separator:@","];
|
|
|
|
|
+ NSArray *qty_arr = [RAUtils string2arr:qty separator:@","];
|
|
|
|
|
|
|
|
for(int i=0;i<arr_id.count;i++)
|
|
for(int i=0;i<arr_id.count;i++)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
int _id=[iSalesDB get_recordid:db table:@"offline_cart" where:[NSString stringWithFormat:@"so_no='%@' and product_id=%@",orderCode,arr_id[i]]];
|
|
int _id=[iSalesDB get_recordid:db table:@"offline_cart" where:[NSString stringWithFormat:@"so_no='%@' and product_id=%@",orderCode,arr_id[i]]];
|
|
|
int item_qty= count;
|
|
int item_qty= count;
|
|
|
|
|
+ if (qty) {
|
|
|
|
|
+ item_qty = [qty_arr[i] integerValue];
|
|
|
|
|
+ }
|
|
|
if(item_qty==0)
|
|
if(item_qty==0)
|
|
|
item_qty=[self model_stockUom:[arr_id[i] intValue] db:db];
|
|
item_qty=[self model_stockUom:[arr_id[i] intValue] db:db];
|
|
|
|
|
|
|
@@ -2165,10 +2169,9 @@
|
|
|
|
|
|
|
|
if(_id<0)
|
|
if(_id<0)
|
|
|
{
|
|
{
|
|
|
- // NSString* bundle_serialno= [self model_bundle:[arr_id[i] intValue] db:db];
|
|
|
|
|
|
|
+
|
|
|
int item_id=[self product_itemid:[arr_id[i] intValue] db:db];
|
|
int item_id=[self product_itemid:[arr_id[i] intValue] db:db];
|
|
|
|
|
|
|
|
-// sql=[NSString stringWithFormat:@"insert into offline_cart(product_id,so_no,item_count,item_id,create_time) values(%@,'%@',%d,%d,datetime('now', 'localtime'))",arr_id[i],orderCode,item_qty,item_id];
|
|
|
|
|
|
|
|
|
|
sql=[NSString stringWithFormat:@"insert into offline_cart(product_id,so_no,item_count,item_id,create_time) values(?,?,?,?,datetime('now', 'localtime'))"];
|
|
sql=[NSString stringWithFormat:@"insert into offline_cart(product_id,so_no,item_count,item_id,create_time) values(?,?,?,?,datetime('now', 'localtime'))"];
|
|
|
|
|
|
|
@@ -2181,15 +2184,24 @@
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
-// sql=[NSString stringWithFormat:@"update offline_cart set item_count=item_count+%d,create_time = datetime('now', 'localtime') where _id=%d",item_qty,_id];
|
|
|
|
|
|
|
+ if (qty) {
|
|
|
|
|
+ sql=[NSString stringWithFormat:@"update offline_cart set item_count=1,modify_time = datetime('now', 'localtime') where _id=?"];
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_prepare_v2(db, [sql UTF8String], -1, &stmt, nil);
|
|
|
|
|
+ sqlite3_bind_int(stmt, 1, _id);
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- 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);
|
|
|
|
|
}
|
|
}
|
|
|
-// [iSalesDB execSql:sql db:db];
|
|
|
|
|
|
|
+
|
|
|
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 ];
|
|
@@ -3665,6 +3677,7 @@
|
|
|
if(count==0)
|
|
if(count==0)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
+ sqlQuery = [NSString stringWithFormat:@"insert into wishlist(product_id,qty) values(?,?);"];
|
|
|
__block int cart_count = 0;
|
|
__block int cart_count = 0;
|
|
|
if (!item_count_str) {
|
|
if (!item_count_str) {
|
|
|
NSString *product_sold_qty_sql = [NSString stringWithFormat:@"select model_set from product where product_id = %@",arr[i]];
|
|
NSString *product_sold_qty_sql = [NSString stringWithFormat:@"select model_set from product where product_id = %@",arr[i]];
|
|
@@ -3694,6 +3707,18 @@
|
|
|
DebugLog(@"add to wishlist error");
|
|
DebugLog(@"add to wishlist error");
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sqlQuery = [NSString stringWithFormat:@"update wishlist set qty = 1 where product_id = %@;",arr[i]];
|
|
|
|
|
+
|
|
|
|
|
+ if ([iSalesDB execSql:sqlQuery db:db] == RESULT_FALSE) {
|
|
|
|
|
+ [iSalesDB execSql:@"ROLLBACK" db:db];
|
|
|
|
|
+ ret[@"result"]=[NSNumber numberWithInt:RESULT_ERROR];
|
|
|
|
|
+
|
|
|
|
|
+ [iSalesDB close_db:db];
|
|
|
|
|
+ DebugLog(@"add to wishlist error");
|
|
|
|
|
+ return ret;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -9208,41 +9233,6 @@
|
|
|
|
|
|
|
|
+(NSData*) offline_add2cartbyname :(NSMutableDictionary *) params
|
|
+(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 *orderCode = [params objectForKey:@"orderCode"];
|
|
|
NSString *product_name = [params objectForKey:@"product_name"];
|
|
NSString *product_name = [params objectForKey:@"product_name"];
|
|
@@ -9380,4 +9370,49 @@
|
|
|
return [RAUtils dict2data:ret];
|
|
return [RAUtils dict2data:ret];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
++ (NSData*)offline_movewish2cart:(NSMutableDictionary *)params {
|
|
|
|
|
+
|
|
|
|
|
+ NSString *collectId = params[@"collectId"];
|
|
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select product_id,qty from wishlist where _id in (%@);",collectId];
|
|
|
|
|
+
|
|
|
|
|
+ __block NSString *product_id = @"";
|
|
|
|
|
+ __block NSString *qty = @"";
|
|
|
|
|
+ [iSalesDB jk_query:sql completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
+
|
|
|
|
|
+ int productId = sqlite3_column_int(stmt, 0);
|
|
|
|
|
+
|
|
|
|
|
+ int item_qty = sqlite3_column_int(stmt, 1);
|
|
|
|
|
+
|
|
|
|
|
+ product_id = [product_id stringByAppendingString:[NSString stringWithFormat:@",%d",productId]];
|
|
|
|
|
+
|
|
|
|
|
+ qty = [qty stringByAppendingString:[NSString stringWithFormat:@",%d",item_qty]];
|
|
|
|
|
+
|
|
|
|
|
+ }];
|
|
|
|
|
+
|
|
|
|
|
+ product_id = [product_id substringFromIndex:1];
|
|
|
|
|
+ qty = [qty substringFromIndex:1];
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary *newParams = @{
|
|
|
|
|
+ @"product_id" : product_id,
|
|
|
|
|
+ @"orderCode" : params[@"orderCode"],
|
|
|
|
|
+ @"qty" : qty
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ NSData *data = [self offline_add2cart:newParams.mutableCopy];
|
|
|
|
|
+ NSMutableDictionary *retDic = [[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] mutableCopy];
|
|
|
|
|
+
|
|
|
|
|
+ if ([retDic[@"result"] integerValue] == RESULT_TRUE) {
|
|
|
|
|
+
|
|
|
|
|
+ NSString *deleteSQL = [NSString stringWithFormat:@"delete from wishlist where _id in (%@);",collectId];
|
|
|
|
|
+
|
|
|
|
|
+ int ret = [iSalesDB execSql:deleteSQL];
|
|
|
|
|
+
|
|
|
|
|
+ retDic[@"result"] = [NSNumber numberWithInteger:ret];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return [RAUtils dict2data:retDic];
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
@end
|
|
@end
|