|
|
@@ -9627,28 +9627,6 @@
|
|
|
|
|
|
+ (NSData *)offline_portfolioList:(NSMutableDictionary *)params {
|
|
|
|
|
|
-// {
|
|
|
-// "result": 2,
|
|
|
-// "min_ver": "160514",
|
|
|
-// "count": 1,
|
|
|
-// "can_see_price": true,
|
|
|
-// "item_0": {
|
|
|
-// "linenotes": "恢复肌肤就不会就附近",
|
|
|
-// "check": 1,
|
|
|
-// "product_id": "3732",
|
|
|
-// "available_qty": 787,
|
|
|
-// "description": "108237-SH-B\nCharlotte Fabric Chair Black Legs, Shark",
|
|
|
-// "item_id": "13405",
|
|
|
-// "fashion_id": "4858",
|
|
|
-// "img": "http://192.168.0.112:8080/site//u/NPD/20151211/108237-SH-B_2916_s.jpg",
|
|
|
-// "tear_sheet_discount": "20.00",
|
|
|
-// "tear_sheet_price": "3109.00"
|
|
|
-// },
|
|
|
-// "email_content": "",
|
|
|
-// "total_count": 1,
|
|
|
-// "mode": "Regular Mode"
|
|
|
-// }
|
|
|
-
|
|
|
int sort = [[params valueForKey:@"sort"] integerValue];
|
|
|
int offset = [[params valueForKey:@"offset"] integerValue];
|
|
|
int limit = [[params valueForKey:@"limit"] integerValue];
|
|
|
@@ -9680,11 +9658,15 @@
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- NSString *sql = [NSString stringWithFormat:@"select product_id,name,description,sheet_price,sheet_discount,available_qty,percentage,item_id,fashion_id,img,line_note,percent from offline_portfolio order by %@ limit %d offset %d;",orderBy,limit,offset];
|
|
|
+
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select product_id,name,description,ifnull(sheet_price,'null'),sheet_discount,available_qty,percentage,item_id,fashion_id,img,line_note,percent from offline_portfolio order by %@ limit %d offset %d;",orderBy,limit,offset];
|
|
|
|
|
|
__block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
|
- [iSalesDB jk_query:sql completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
+
|
|
|
+ sqlite3 *db = [iSalesDB get_db];
|
|
|
+ NSDictionary *resultDic = [iSalesDB jk_query:sql db:db close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
|
[dic setValue:[NSNumber numberWithInteger:RESULT_TRUE] forKey:@"result"];
|
|
|
|
|
|
@@ -9702,19 +9684,24 @@
|
|
|
NSString *line_note = [self textAtColumn:10 statement:stmt];
|
|
|
double percent = sqlite3_column_double(stmt, 11);
|
|
|
|
|
|
+ NSString *price_null = [self textAtColumn:3 statement:stmt];
|
|
|
+ if ([price_null isEqualToString:@"null"]) {
|
|
|
+ price = [[self get_model_default_price:appDelegate.contact_id product_id:nil item_id:@(item_id) db:db] doubleValue];
|
|
|
+ }
|
|
|
+
|
|
|
NSMutableDictionary *item = @{
|
|
|
- @"linenotes": line_note,
|
|
|
- @"check": @(1),
|
|
|
- @"product_id": product_id_string,
|
|
|
- @"available_qty": @(qty),
|
|
|
- @"available_percent" : @(percent),
|
|
|
- @"description": description,
|
|
|
- @"item_id": [NSString stringWithFormat:@"%d",item_id],
|
|
|
- @"fashion_id": [NSString stringWithFormat:@"%d",fashion_id],
|
|
|
- @"img": img_path,
|
|
|
- @"tear_sheet_discount": [NSString stringWithFormat:@"%f",discount],
|
|
|
- @"tear_sheet_price": [NSString stringWithFormat:@"%f",price]
|
|
|
- }.mutableCopy;
|
|
|
+ @"linenotes": line_note,
|
|
|
+ @"check": @(1),
|
|
|
+ @"product_id": product_id_string,
|
|
|
+ @"available_qty": @(qty),
|
|
|
+ @"available_percent" : @(percent),
|
|
|
+ @"description": [NSString stringWithFormat:@"%@\n%@",name,description],
|
|
|
+ @"item_id": [NSString stringWithFormat:@"%d",item_id],
|
|
|
+ @"fashion_id": [NSString stringWithFormat:@"%d",fashion_id],
|
|
|
+ @"img": img_path,
|
|
|
+ @"tear_sheet_discount": [NSString stringWithFormat:@"%f",discount],
|
|
|
+ @"tear_sheet_price": [NSString stringWithFormat:@"%f",price]
|
|
|
+ }.mutableCopy;
|
|
|
if (percentage) {
|
|
|
[item removeObjectForKey:@"available_qty"];
|
|
|
} else {
|
|
|
@@ -9725,17 +9712,20 @@
|
|
|
[dic setObject:item forKey:[NSString stringWithFormat:@"item_%ld",*count]];
|
|
|
[dic setValue:[NSNumber numberWithLong:++(*count)] forKey:@"count"];
|
|
|
|
|
|
- } failure:^(NSMutableDictionary *container, NSString *err_msg) {
|
|
|
-
|
|
|
+ }];
|
|
|
+
|
|
|
+ if ([[resultDic objectForKey:@"result"] integerValue] == RESULT_FALSE) {
|
|
|
[dic setValue:[NSNumber numberWithInteger:RESULT_FALSE] forKey:@"result"];
|
|
|
|
|
|
[dic setValue:[NSNumber numberWithInteger:0] forKey:@"count"];
|
|
|
- }];
|
|
|
+ }
|
|
|
+
|
|
|
+ [iSalesDB close_db:db];
|
|
|
+
|
|
|
|
|
|
- AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
|
|
|
[dic setValue:[NSNumber numberWithBool:appDelegate.can_see_price] forKey:@"can_see_price"];
|
|
|
- [dic setValue:@"" forKey:@"emial_content"];
|
|
|
+ [dic setValue:@"" forKey:@"email_content"];
|
|
|
[dic setValue:[dic objectForKey:@"count"] forKey:@"total_count"];
|
|
|
[dic setValue:@"Regular Mode" forKey:@"mode"];
|
|
|
|
|
|
@@ -9744,12 +9734,6 @@
|
|
|
|
|
|
+ (NSData *)offline_direct_save_TearSheet:(NSMutableDictionary *)params {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return nil;
|
|
|
}
|
|
|
|
|
|
@@ -9764,7 +9748,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- NSString *sql = [NSString stringWithFormat:@"select tear_name,tear_note,createtime,create_user,pdf_path,tearsheets_id from offline_pdf %@ order by createtime desc;",where];
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select tear_name,tear_note,createtime,create_user,pdf_path,tearsheets_id from offline_pdf %@ order by createtime desc limit %d offset %d;",where,limit,offset];
|
|
|
|
|
|
__block NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
|
|
|
@@ -9806,4 +9790,39 @@
|
|
|
return [RAUtils dict2data:dic];
|
|
|
}
|
|
|
|
|
|
++ (NSData *)offline_add2Portfolio:(NSMutableDictionary *)params {
|
|
|
+
|
|
|
+ NSString *prodct_ids = [params objectForKey:@"product_id"];
|
|
|
+// NSString *user = [params objectForKey:@"user"];
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"insert into offline_portfolio (product_id,name,description,item_id,img) select * from (select p.product_id,p.name,p.description,p.item_id,i.url from product as p left join model_image as i on i.product_id = p.product_id where p.product_id in (%@) and p.product_id not in (select product_id from offline_portfolio) and i.type = 1 group by p.product_id order by i.default_img desc, i._id asc );",prodct_ids];
|
|
|
+
|
|
|
+ int result = [iSalesDB execSql:sql];
|
|
|
+
|
|
|
+ NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:result] forKey:@"result"];
|
|
|
+
|
|
|
+ if (result == RESULT_TRUE) {
|
|
|
+ NSArray *product_id_arr = [prodct_ids componentsSeparatedByString:@","];
|
|
|
+ [dic setValue:[NSNumber numberWithInteger:product_id_arr.count] forKey:@"portfolio_count"];
|
|
|
+ }
|
|
|
+
|
|
|
+ [dic setValue:@"Regular Mode" forKey:@"mode"];
|
|
|
+ return [RAUtils dict2data:dic];
|
|
|
+}
|
|
|
+
|
|
|
++ (NSData *)offline_createTearSheet:(NSMutableDictionary *)params {
|
|
|
+
|
|
|
+
|
|
|
+// {
|
|
|
+// "item_ids" = "249,3859,5360,2662";
|
|
|
+// password = 123456;
|
|
|
+// "product_ids" = "3321,3804,4045,3732";
|
|
|
+// user = EvanK;
|
|
|
+// }
|
|
|
+
|
|
|
+ NSMutableDictionary *dic = [self dictionaryFileName:@"TearSheet.json"];
|
|
|
+
|
|
|
+ return [RAUtils dict2data:dic];
|
|
|
+}
|
|
|
+
|
|
|
@end
|