|
@@ -3068,6 +3068,21 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
|
|
|
|
|
|
|
|
return ret;
|
|
return ret;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
++ (NSString *) categoryIdOfProduct:(NSString *)product_id name:(NSString *)product_name {
|
|
|
|
|
+
|
|
|
|
|
+ NSString *sql = nil;
|
|
|
|
|
+ if (product_id != nil) {
|
|
|
|
|
+ sql = [NSString stringWithFormat:@"select category from product where product_id = '%@';",product_id];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sql = [NSString stringWithFormat:@"select category from product where name = '%@';",product_name];
|
|
|
|
|
+ }
|
|
|
|
|
+ NSString *result_set = [iSalesDB jk_queryText:sql];
|
|
|
|
|
+ result_set = [result_set stringByReplacingOccurrencesOfString:@"%" withString:@""];
|
|
|
|
|
+ result_set = [result_set stringByReplacingOccurrencesOfString:@"#" withString:@""];
|
|
|
|
|
+ return result_set;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
+(NSDictionary*) offline_model :(NSMutableDictionary *) params
|
|
+(NSDictionary*) offline_model :(NSMutableDictionary *) params
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -3082,9 +3097,32 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
|
|
|
|
|
|
|
|
NSString* category = [params valueForKey:@"category"];
|
|
NSString* category = [params valueForKey:@"category"];
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- if(category==nil)
|
|
|
|
|
- category = [self model_default_category:product_id model_name:model_name];
|
|
|
|
|
|
|
+ NSString *default_category_id = [self model_default_category:product_id model_name:model_name];
|
|
|
|
|
+ if(category==nil) {
|
|
|
|
|
+ category = default_category_id;
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ NSArray *arr_0 = [category componentsSeparatedByString:@","];
|
|
|
|
|
+ // 参数重有多个category id
|
|
|
|
|
+ if (arr_0.count > 1) {
|
|
|
|
|
+ NSArray *arr_1 = [[self categoryIdOfProduct:product_id name:model_name] componentsSeparatedByString:@","];
|
|
|
|
|
+
|
|
|
|
|
+ // 取交集
|
|
|
|
|
+ NSMutableSet *set_0 = [NSMutableSet setWithArray:arr_0];
|
|
|
|
|
+ NSMutableSet *set_1 = [NSMutableSet setWithArray:arr_1];
|
|
|
|
|
+ [set_0 intersectSet:set_1];
|
|
|
|
|
+
|
|
|
|
|
+ if (set_0.count == 1) {
|
|
|
|
|
+ category = (NSString *)[set_0 anyObject];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if ([set_0 containsObject:default_category_id]) {
|
|
|
|
|
+ category = default_category_id;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ category = (NSString *)[set_0 anyObject];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
@@ -3095,7 +3133,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
|
|
|
|
|
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
|
|
|
- int count = [iSalesDB get_recordcount:db table:@"product" where:[NSString stringWithFormat:@"category like'#%%%@%%#'",category]];
|
|
|
|
|
|
|
+// int count = [iSalesDB get_recordcount:db table:@"product" where:[NSString stringWithFormat:@"category like'#%%%@%%#'",category]];
|
|
|
|
|
|
|
|
|
|
|
|
|
NSString *sqlQuery = nil;
|
|
NSString *sqlQuery = nil;
|
|
@@ -3398,7 +3436,7 @@ NSString* gprice = [self get_portfolio_price :appDelegate.contact_id item_id:ite
|
|
|
{
|
|
{
|
|
|
[ret setValue:@"8" forKey:@"result"];
|
|
[ret setValue:@"8" forKey:@"result"];
|
|
|
}
|
|
}
|
|
|
- DebugLog(@"count:%d",count);
|
|
|
|
|
|
|
+// DebugLog(@"count:%d",count);
|
|
|
|
|
|
|
|
|
|
|
|
|
[iSalesDB close_db:db];
|
|
[iSalesDB close_db:db];
|