|
|
@@ -1676,14 +1676,8 @@
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
-+(NSDictionary*) offline_search:(NSMutableDictionary *) params
|
|
|
-{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
++ (NSDictionary *) search:(NSMutableDictionary *)params limited:(BOOL)limited {
|
|
|
NSString* orderCode = [params valueForKey:@"orderCode"];
|
|
|
|
|
|
NSString* keyword = [params valueForKey:@"keyword"];
|
|
|
@@ -1698,8 +1692,10 @@
|
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ NSString *limit_str = @"";
|
|
|
+ if (limited) {
|
|
|
+ limit_str = [NSString stringWithFormat:@"limit %d offset %d ",limit,offset];
|
|
|
+ }
|
|
|
|
|
|
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
|
@@ -1709,10 +1705,10 @@
|
|
|
|
|
|
NSString *sqlQuery = nil;
|
|
|
if(exactMatch )
|
|
|
- sqlQuery=[NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from product m left join wishlist w on m.product_id=w.product_id where lower(name) like'%@%%' and m.is_active = 1 order by m.name limit %d offset %d ;",keyword,limit, offset]; // select m.name,m.description,m.product_id,w._id,m.closeout from model m left join wishlist w on m.product_id=w.product_id where lower(name) like'%@%%' order by m.name limit %d offset %d ;
|
|
|
+ sqlQuery=[NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from product m left join wishlist w on m.product_id=w.product_id where lower(name) like'%@%%' and m.is_active = 1 order by m.name %@;",keyword,limit_str]; // select m.name,m.description,m.product_id,w._id,m.closeout from model m left join wishlist w on m.product_id=w.product_id where lower(name) like'%@%%' order by m.name limit %d offset %d ;
|
|
|
else
|
|
|
-
|
|
|
- sqlQuery=[NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from product m left join wishlist w on m.product_id=w.product_id where (lower(name) like'%%%@%%' or lower(description) like'%%%@%%') and m.is_active = 1 order by m.name limit %d offset %d ;",keyword,keyword,limit, offset];// select m.name,m.description,m.product_id,w._id,m.closeout from model m left join wishlist w on m.product_id=w.product_id where lower(name) like'%%%@%%' or
|
|
|
+
|
|
|
+ sqlQuery=[NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from product m left join wishlist w on m.product_id=w.product_id where (lower(name) like'%%%@%%' or lower(description) like'%%%@%%') and m.is_active = 1 order by m.name %@ ;",keyword,keyword,limit_str];// select m.name,m.description,m.product_id,w._id,m.closeout from model m left join wishlist w on m.product_id=w.product_id where lower(name) like'%%%@%%' or
|
|
|
|
|
|
DebugLog(@"offline_search sql:%@",sqlQuery);
|
|
|
sqlite3_stmt * statement;
|
|
|
@@ -1789,6 +1785,11 @@
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
+
|
|
|
++(NSDictionary*) offline_search:(NSMutableDictionary *) params
|
|
|
+{
|
|
|
+ return [self search:params limited:YES];
|
|
|
+}
|
|
|
+(NSDictionary*) offline_logout :(NSMutableDictionary *) params
|
|
|
{
|
|
|
|
|
|
@@ -3447,17 +3448,93 @@
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
+
|
|
|
++ (NSData *) addAll:(NSMutableDictionary *) params from:(int)from {
|
|
|
+
|
|
|
+ // 0 category
|
|
|
+ // 1 search
|
|
|
+ // 2 itemsearch
|
|
|
+
|
|
|
+ NSData *ret = nil;
|
|
|
+
|
|
|
+ NSDictionary *items = nil;
|
|
|
+
|
|
|
+ switch (from) {
|
|
|
+ case 0:{
|
|
|
+ items = [[self categoryList:params limited:NO] objectForKey:@"items"];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1:{
|
|
|
+ items = [[self search:params limited:NO] objectForKey:@"items"];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:{
|
|
|
+ items = [[self itemsearch:params limited:NO] objectForKey:@"items"];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!items) {
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ int count = [[items objectForKey:@"count"] intValue];
|
|
|
+ NSMutableString *product_id_str = [@"" mutableCopy];
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
+ NSString *key = [NSString stringWithFormat:@"item_%d",i];
|
|
|
+ NSDictionary *item = [items objectForKey:key];
|
|
|
+ NSString *product_id = [item objectForKey:@"product_id"];
|
|
|
+ if (i == 0) {
|
|
|
+ [product_id_str appendString:product_id];
|
|
|
+ } else {
|
|
|
+ [product_id_str appendString:[NSString stringWithFormat:@",%@",product_id]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *add_to = [self valueInParams:params key:@"addTo"];
|
|
|
+ if ([add_to isEqualToString:@"cart"]) {
|
|
|
+
|
|
|
+ NSString *order_code = [params objectForKey:@"orderCode"];
|
|
|
+ if (order_code.length) {
|
|
|
+ NSDictionary *newParams = @{
|
|
|
+ @"product_id" : product_id_str,
|
|
|
+ @"orderCode" : order_code
|
|
|
+ };
|
|
|
+ ret = [self offline_add2cart:newParams.mutableCopy];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else if([add_to isEqualToString:@"wishlist"]) {
|
|
|
+
|
|
|
+ NSDictionary *newParams = @{
|
|
|
+ @"product_id" : product_id_str
|
|
|
+ };
|
|
|
+
|
|
|
+ ret = [RAUtils dict2data:[self offline_add2wishlist:newParams.mutableCopy]];
|
|
|
+
|
|
|
+
|
|
|
+ } else if([add_to isEqualToString:@"portfolio"]) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+(NSData*) offline_categoryaddall :(NSMutableDictionary *) params
|
|
|
{
|
|
|
- return [RAUtils dict2data:[self offline_notimpl]];
|
|
|
+ return [self addAll:params from:0];
|
|
|
}
|
|
|
+(NSData*) offline_searchaddall :(NSMutableDictionary *) params
|
|
|
{
|
|
|
- return [RAUtils dict2data:[self offline_notimpl]];
|
|
|
+ return [self addAll:params from:1];
|
|
|
}
|
|
|
+(NSData*) offline_itemsearchaddall :(NSMutableDictionary *) params
|
|
|
{
|
|
|
- return [RAUtils dict2data:[self offline_notimpl]];
|
|
|
+ return [self addAll:params from:2];
|
|
|
}
|
|
|
#pragma mark - Jack
|
|
|
#warning 做SQL操作时转义!!
|
|
|
@@ -5006,8 +5083,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-+(NSDictionary*) offline_category :(NSMutableDictionary *) params
|
|
|
-{
|
|
|
++ (NSDictionary *)categoryList:(NSMutableDictionary *)params limited:(BOOL)limited {
|
|
|
// NSString* orderCode = [params valueForKey:@"orderCode"];
|
|
|
|
|
|
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
@@ -5022,6 +5098,10 @@
|
|
|
int offset = [[params valueForKey:@"offset"] intValue];
|
|
|
|
|
|
// NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
+ NSString *limit_str = @"";
|
|
|
+ if (limited) {
|
|
|
+ limit_str = [NSString stringWithFormat:@"limit %d offset %d ",limit,offset];
|
|
|
+ }
|
|
|
|
|
|
|
|
|
NSMutableDictionary *ret = [self dictionaryFileName:@"category.json"];
|
|
|
@@ -5034,25 +5114,10 @@
|
|
|
int count;
|
|
|
NSString *where = [NSString stringWithFormat:@"category like'%%#%@#%%' and is_active = 1",category];
|
|
|
|
|
|
-
|
|
|
- NSString *sqlQuery = [NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from product m left join wishlist w on m.product_id=w.product_id where m.category like'%%#%@#%%' and m.is_active = 1 order by m.name limit %d offset %d ;",category,limit, offset];
|
|
|
-
|
|
|
|
|
|
- // {
|
|
|
- // alert = SP;
|
|
|
- // available = "Available Now";
|
|
|
- // bestseller = No;
|
|
|
- // category = 001;
|
|
|
- // "custom_id" = 0;
|
|
|
- // limit = 20;
|
|
|
- // offset = 0;
|
|
|
- // password = 123456;
|
|
|
- // price = "Display All";
|
|
|
- // "price_template" = 0;
|
|
|
- // "sold_by_qty" = "Display All";
|
|
|
- // "sort_by" = 0;
|
|
|
- // user = EvanK;
|
|
|
- // }
|
|
|
+ NSString *sqlQuery = [NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from product m left join wishlist w on m.product_id=w.product_id where m.category like'%%#%@#%%' and m.is_active = 1 order by m.name %@ ;",category,limit_str];
|
|
|
+
|
|
|
+
|
|
|
double price_min = 0;
|
|
|
double price_max = 0;
|
|
|
if ([params.allKeys containsObject:@"alert"]) {
|
|
|
@@ -5137,9 +5202,9 @@
|
|
|
|
|
|
// where bestseller > 0 order by bestseller desc
|
|
|
// sql query: alert availability(int) best_seller(int) price qty
|
|
|
-
|
|
|
- sqlQuery = [NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from (select name,description,product_id,closeout,best_seller from product where %@ %@ %@ %@ %@ %@ and is_active = 1) m left join wishlist w on m.product_id=w.product_id order by %@ limit %d offset %d;",cateWhere,best_seller,alert,available_condition,qty,price,order_best_seller,limit,offset];
|
|
|
-
|
|
|
+
|
|
|
+ sqlQuery = [NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from (select name,description,product_id,closeout,best_seller from product where %@ %@ %@ %@ %@ %@ and is_active = 1) m left join wishlist w on m.product_id=w.product_id order by %@ %@;",cateWhere,best_seller,alert,available_condition,qty,price,order_best_seller,limit_str];
|
|
|
+
|
|
|
|
|
|
where =[NSString stringWithFormat:@"%@ %@ %@ %@ %@ %@ and is_active = 1",cateWhere,best_seller,alert,available_condition,qty,price];
|
|
|
|
|
|
@@ -5224,11 +5289,17 @@
|
|
|
DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
|
|
|
return ret;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-# pragma mark item search
|
|
|
-+(NSDictionary*) offline_itemsearch:(NSMutableDictionary *) params
|
|
|
++(NSDictionary*) offline_category :(NSMutableDictionary *) params
|
|
|
{
|
|
|
+ return [self categoryList:params limited:YES];
|
|
|
+}
|
|
|
+
|
|
|
+# pragma mark item search
|
|
|
+
|
|
|
++ (NSDictionary *) itemsearch:(NSMutableDictionary *)params limited:(BOOL)limited {
|
|
|
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
|
|
|
BOOL filterSearch = ![params.allKeys containsObject:@"covertype"];
|
|
|
@@ -5278,6 +5349,10 @@
|
|
|
int limit = [[params valueForKey:@"limit"] intValue];
|
|
|
int offset = [[params valueForKey:@"offset"] intValue];
|
|
|
|
|
|
+ NSString *limit_str = @"";
|
|
|
+ if (limited) {
|
|
|
+ limit_str = [NSString stringWithFormat:@"limit %d offset %d",limit,offset];
|
|
|
+ }
|
|
|
|
|
|
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
|
@@ -5287,8 +5362,8 @@
|
|
|
|
|
|
NSString *sqlQuery = nil;
|
|
|
where = [where stringByAppendingString:@" and m.is_active = 1"];
|
|
|
- sqlQuery=[NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from product m left join wishlist w on m.product_id=w.product_id where %@ order by %@ limit %d offset %d ;",where,orderby,limit, offset];
|
|
|
-
|
|
|
+ sqlQuery=[NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from product m left join wishlist w on m.product_id=w.product_id where %@ order by %@ %@;",where,orderby,limit_str];
|
|
|
+
|
|
|
|
|
|
double price_min = 0;
|
|
|
double price_max = 0;
|
|
|
@@ -5428,9 +5503,9 @@
|
|
|
|
|
|
// where bestseller > 0 order by bestseller desc
|
|
|
// sql query: alert availability(int) best_seller(int) price qty
|
|
|
-
|
|
|
- sqlQuery = [NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from (select name,description,product_id,closeout,best_seller from product where %@ %@ %@ %@ %@ %@ and is_active = 1) m left join wishlist w on m.product_id=w.product_id order by %@ limit %d offset %d;",cateWhere,best_seller,alert,available_condition,qty,price,order_best_seller,limit,offset];
|
|
|
-
|
|
|
+
|
|
|
+ sqlQuery = [NSString stringWithFormat:@"select m.name,m.description,m.product_id,w._id,m.closeout from (select name,description,product_id,closeout,best_seller from product where %@ %@ %@ %@ %@ %@ and is_active = 1) m left join wishlist w on m.product_id=w.product_id order by %@ %@;",cateWhere,best_seller,alert,available_condition,qty,price,order_best_seller,limit_str];
|
|
|
+
|
|
|
|
|
|
// count
|
|
|
where =[NSString stringWithFormat:@"%@ %@ %@ %@ %@ %@ and m.is_active = 1",cateWhere,best_seller,alert,available_condition,qty,price];
|
|
|
@@ -5514,6 +5589,12 @@
|
|
|
DebugLog(@"data string: %@",[RAUtils dict2string:ret] );
|
|
|
|
|
|
return ret;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
++(NSDictionary*) offline_itemsearch:(NSMutableDictionary *) params
|
|
|
+{
|
|
|
+ return [self itemsearch:params limited:YES];
|
|
|
}
|
|
|
|
|
|
#pragma mark order detail
|