|
@@ -6230,7 +6230,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
itemjson[@"Subtotal"] = [NSString stringWithFormat:@"%.2f",subTotal];
|
|
itemjson[@"Subtotal"] = [NSString stringWithFormat:@"%.2f",subTotal];
|
|
|
- NSLog(@"item unite price: %@ \n discount: %f item count: %d subTotal: %f",Price,discount,item_count,subTotal);
|
|
|
|
|
|
|
+// NSLog(@"item unite price: %@ \n discount: %f item count: %d subTotal: %f",Price,discount,item_count,subTotal);
|
|
|
|
|
|
|
|
|
|
|
|
|
ret[[NSString stringWithFormat:@"item_%ld",(*count)++]]=itemjson;
|
|
ret[[NSString stringWithFormat:@"item_%ld",(*count)++]]=itemjson;
|
|
@@ -6349,20 +6349,28 @@
|
|
|
// sqlite3 *db1 = [iSalesDB get_db];
|
|
// sqlite3 *db1 = [iSalesDB get_db];
|
|
|
|
|
|
|
|
if (so_id) {
|
|
if (so_id) {
|
|
|
- NSString *modelSql = [NSString stringWithFormat:@"select c.product_id,c.price,c.discount,c.item_count,c.line_note,m.name,m.description,c.item_id,m.stockUom,c._id from (select _id,product_id,decrypt(str_price) as price,discount,item_count,line_note,item_id from offline_cart where so_no='%@') c left join product m on c.product_id=m.product_id",so_id];
|
|
|
|
|
|
|
+// NSString *modelSql = [NSString stringWithFormat:@"select c.product_id,c.price,c.discount,c.item_count,c.line_note,m.name,m.description,c.item_id,m.stockUom,c._id from (select _id,product_id,decrypt(str_price) as price,discount,item_count,line_note,item_id from offline_cart where so_no='%@') c left join product m on c.product_id=m.product_id",so_id];
|
|
|
|
|
+
|
|
|
|
|
+ NSString *modelSql = [NSString stringWithFormat:@"select product_id,price,discount,item_count,item_id from (select product_id,decrypt(str_price) as price,discount,item_count,item_id from offline_cart where so_no='%@');",so_id];
|
|
|
|
|
|
|
|
|
|
|
|
|
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
|
|
|
|
|
[iSalesDB jk_query:modelSql db:db1 close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
[iSalesDB jk_query:modelSql db:db1 close:NO completion:^(sqlite3_stmt *stmt, NSMutableDictionary *container, long *count) {
|
|
|
|
|
|
|
|
|
|
+
|
|
|
NSMutableDictionary* itemjson = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary* itemjson = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
int product_id = sqlite3_column_int(stmt, 0);
|
|
int product_id = sqlite3_column_int(stmt, 0);
|
|
|
|
|
|
|
|
char *str_price = (char*)sqlite3_column_text(stmt, 1);
|
|
char *str_price = (char*)sqlite3_column_text(stmt, 1);
|
|
|
|
|
|
|
|
- int item_id = sqlite3_column_int(stmt, 7);
|
|
|
|
|
|
|
+ int discount = sqlite3_column_int(stmt, 2);
|
|
|
|
|
+ int item_count = sqlite3_column_int(stmt, 3);
|
|
|
|
|
+
|
|
|
|
|
+// int item_id = sqlite3_column_int(stmt, 7);
|
|
|
|
|
+
|
|
|
|
|
+ int item_id = sqlite3_column_int(stmt, 4);
|
|
|
|
|
|
|
|
NSString* Price=nil;
|
|
NSString* Price=nil;
|
|
|
if(str_price==nil)
|
|
if(str_price==nil)
|
|
@@ -6380,8 +6388,7 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- int discount = sqlite3_column_int(stmt, 2);
|
|
|
|
|
- int item_count = sqlite3_column_int(stmt, 3);
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
itemjson[@"combine"]=[self model_bundle:item_id db:db1 compute_part:false];
|
|
itemjson[@"combine"]=[self model_bundle:item_id db:db1 compute_part:false];
|
|
@@ -6412,6 +6419,7 @@
|
|
|
|
|
|
|
|
allItemPrice += subTotal;
|
|
allItemPrice += subTotal;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
}];
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
@@ -6456,7 +6464,6 @@
|
|
|
|
|
|
|
|
+(NSData*) offline_orderlist :(NSMutableDictionary *) params
|
|
+(NSData*) offline_orderlist :(NSMutableDictionary *) params
|
|
|
{
|
|
{
|
|
|
- NSLog(@"order list: %@",params);
|
|
|
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
int limit = [[params valueForKey:@"limit"] intValue];
|
|
int limit = [[params valueForKey:@"limit"] intValue];
|
|
@@ -6506,11 +6513,14 @@
|
|
|
|
|
|
|
|
NSString* sqlQuery=[NSString stringWithFormat:@"SELECT o._id,o.so_id,o.status,o.sales_rep,o.create_by,decrypt(c.company_name),o.create_time,o.total_price,o.customer_contact,o.erpOrderStatus,o.order_id is null from offline_order o left join offline_contact c on o.customer_cid=c.contact_id where %@ order by o.create_time desc limit %d offset %d" ,where, limit, offset];
|
|
NSString* sqlQuery=[NSString stringWithFormat:@"SELECT o._id,o.so_id,o.status,o.sales_rep,o.create_by,decrypt(c.company_name),o.create_time,o.total_price,o.customer_contact,o.erpOrderStatus,o.order_id is null from offline_order o left join offline_contact c on o.customer_cid=c.contact_id where %@ order by o.create_time desc limit %d offset %d" ,where, limit, offset];
|
|
|
|
|
|
|
|
- DebugLog(@"order list sql: %@",sqlQuery);
|
|
|
|
|
|
|
+// DebugLog(@"order list sql: %@",sqlQuery);
|
|
|
|
|
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
|
sqlite3_stmt * statement;
|
|
sqlite3_stmt * statement;
|
|
|
|
|
|
|
|
|
|
+ [iSalesDB execSql:@"BEGIN TRANSACTION" db:db];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
if (sqlite3_prepare_v2(db, [sqlQuery UTF8String], -1, &statement, nil) == SQLITE_OK)
|
|
|
{
|
|
{
|
|
@@ -6518,7 +6528,7 @@
|
|
|
int count=0;
|
|
int count=0;
|
|
|
while (sqlite3_step(statement) == SQLITE_ROW)
|
|
while (sqlite3_step(statement) == SQLITE_ROW)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
NSMutableDictionary* item=[[NSMutableDictionary alloc]init];
|
|
NSMutableDictionary* item=[[NSMutableDictionary alloc]init];
|
|
@@ -6553,11 +6563,14 @@
|
|
|
if(create_time==nil)
|
|
if(create_time==nil)
|
|
|
create_time= "";
|
|
create_time= "";
|
|
|
NSString *nscreate_time= [[NSString alloc]initWithUTF8String:create_time];
|
|
NSString *nscreate_time= [[NSString alloc]initWithUTF8String:create_time];
|
|
|
- DebugLog(@"time: %@",nscreate_time);
|
|
|
|
|
|
|
+
|
|
|
nscreate_time = [self changeDateTimeFormate:nscreate_time]; // 与在线统一
|
|
nscreate_time = [self changeDateTimeFormate:nscreate_time]; // 与在线统一
|
|
|
// double total_price = sqlite3_column_double(statement, 7);
|
|
// double total_price = sqlite3_column_double(statement, 7);
|
|
|
|
|
+
|
|
|
double total_price = [self orderTotalPrice:[NSString stringWithUTF8String:soid] db:db close:NO];
|
|
double total_price = [self orderTotalPrice:[NSString stringWithUTF8String:soid] db:db close:NO];
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
NSString *customer_contact = [self textAtColumn:8 statement:statement];
|
|
NSString *customer_contact = [self textAtColumn:8 statement:statement];
|
|
|
|
|
|
|
|
NSString* nsstatus = [self orderStatus:status erpStatus:erpStatus];
|
|
NSString* nsstatus = [self orderStatus:status erpStatus:erpStatus];
|
|
@@ -6596,6 +6609,8 @@
|
|
|
ret[[NSString stringWithFormat:@"item_%d",count]]= item;
|
|
ret[[NSString stringWithFormat:@"item_%d",count]]= item;
|
|
|
count++;
|
|
count++;
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ret[@"count"]= [NSNumber numberWithInt:count];
|
|
ret[@"count"]= [NSNumber numberWithInt:count];
|
|
@@ -6610,12 +6625,16 @@
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
int total_count = [iSalesDB get_recordcount:db table:@"offline_order o left join offline_contact c on o.customer_cid=c.contact_id" where:where];
|
|
int total_count = [iSalesDB get_recordcount:db table:@"offline_order o left join offline_contact c on o.customer_cid=c.contact_id" where:where];
|
|
|
|
|
|
|
|
ret[@"total_count"] = [NSNumber numberWithInteger:total_count];
|
|
ret[@"total_count"] = [NSNumber numberWithInteger:total_count];
|
|
|
|
|
|
|
|
|
|
+ [iSalesDB execSql:@"END TRANSACTION" db:db];
|
|
|
[iSalesDB close_db:db];
|
|
[iSalesDB close_db:db];
|
|
|
- NSLog(@"order list return");
|
|
|
|
|
|
|
+
|
|
|
return [RAUtils dict2data:ret];
|
|
return [RAUtils dict2data:ret];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -6648,8 +6667,10 @@
|
|
|
NSString *_id = [self valueInParams:params key:@"cartItemId"];
|
|
NSString *_id = [self valueInParams:params key:@"cartItemId"];
|
|
|
|
|
|
|
|
NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
|
|
+
|
|
|
|
|
+ _id = [NSString stringWithFormat:@"(%@)",_id];
|
|
|
|
|
|
|
|
- NSString *sql = [NSString stringWithFormat:@"select product_id,item_count,item_id from offline_cart where so_no = '%@' and _id = %@;",orderCode,_id];
|
|
|
|
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select product_id,item_count,item_id from offline_cart where so_no = '%@' and _id in %@;",orderCode,_id];
|
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
sqlite3 *db = [iSalesDB get_db];
|
|
|
|
|
|
|
|
__block NSString *product_id = nil;
|
|
__block NSString *product_id = nil;
|
|
@@ -6679,7 +6700,8 @@
|
|
|
[dic setValue:[NSNumber numberWithInteger:wish_count] forKey:@"wish_count"];
|
|
[dic setValue:[NSNumber numberWithInteger:wish_count] forKey:@"wish_count"];
|
|
|
|
|
|
|
|
// 删除
|
|
// 删除
|
|
|
- NSString *deleteSql = [NSString stringWithFormat:@"delete from offline_cart where _id = %@;",_id];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ NSString *deleteSql = [NSString stringWithFormat:@"delete from offline_cart where _id in %@;",_id];
|
|
|
[iSalesDB execSql:deleteSql db:db];
|
|
[iSalesDB execSql:deleteSql db:db];
|
|
|
|
|
|
|
|
[iSalesDB close_db:db];
|
|
[iSalesDB close_db:db];
|
|
@@ -6697,7 +6719,9 @@
|
|
|
NSString *_id = [self valueInParams:params key:@"cartItemId"];
|
|
NSString *_id = [self valueInParams:params key:@"cartItemId"];
|
|
|
NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
NSString *orderCode = [self valueInParams:params key:@"orderCode"];
|
|
|
|
|
|
|
|
- NSString *sql = [NSString stringWithFormat:@"delete from offline_cart where _id = %@ and so_no = '%@';",_id,orderCode];
|
|
|
|
|
|
|
+ _id = [NSString stringWithFormat:@"(%@)",_id];
|
|
|
|
|
+
|
|
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"delete from offline_cart where so_no = '%@' and _id in %@ ;",orderCode,_id];
|
|
|
int ret = [iSalesDB execSql:sql];
|
|
int ret = [iSalesDB execSql:sql];
|
|
|
|
|
|
|
|
|
|
|
|
@@ -7511,7 +7535,7 @@
|
|
|
__block int TotalCarton = 0;
|
|
__block int TotalCarton = 0;
|
|
|
__block double payments = 0;
|
|
__block double payments = 0;
|
|
|
|
|
|
|
|
- NSString *sql = [NSString stringWithFormat:@"select c.item_id,c.item_count,m.stockUom,c.price,c.discount,m.name,m.description,c.line_note from (select _id,product_id,decrypt(str_price) as price,discount,item_count,line_note,item_id from offline_cart where so_no='%@') c left join product m on c.product_id=m.product_id;",orderCode];
|
|
|
|
|
|
|
+ NSString *sql = [NSString stringWithFormat:@"select c.item_id,c.item_count,m.stockUom,c.price,c.discount,m.name,m.description,c.line_note,m.availability from (select _id,product_id,decrypt(str_price) as price,discount,item_count,line_note,item_id from offline_cart where so_no='%@') c left join product m on c.product_id=m.product_id;",orderCode];
|
|
|
|
|
|
|
|
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
|
|
|
|
@@ -7557,6 +7581,9 @@
|
|
|
// line note
|
|
// line note
|
|
|
NSString *line_note = [self textAtColumn:7 statement:stmt];
|
|
NSString *line_note = [self textAtColumn:7 statement:stmt];
|
|
|
|
|
|
|
|
|
|
+ int avaulability = sqlite3_column_int(stmt, 8);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// img
|
|
// img
|
|
|
NSString *img = [self item_image:[NSString stringWithFormat:@"%@",[NSNumber numberWithInt:item_id]] db:db];
|
|
NSString *img = [self item_image:[NSString stringWithFormat:@"%@",[NSNumber numberWithInt:item_id]] db:db];
|
|
|
|
|
|
|
@@ -7588,6 +7615,7 @@
|
|
|
[model_dic setValue:[NSString stringWithFormat:@"%.2f",subTotal] forKey:@"total_price"];
|
|
[model_dic setValue:[NSString stringWithFormat:@"%.2f",subTotal] forKey:@"total_price"];
|
|
|
[model_dic setValue:Price forKey:@"unit_price"];
|
|
[model_dic setValue:Price forKey:@"unit_price"];
|
|
|
[model_dic setValue:[NSString stringWithFormat:@"%.2f",discount] forKey:@"discount"];
|
|
[model_dic setValue:[NSString stringWithFormat:@"%.2f",discount] forKey:@"discount"];
|
|
|
|
|
+ [model_dic setValue:[NSNumber numberWithInt:avaulability] forKey:@"quantity_available"];
|
|
|
if (combine) {
|
|
if (combine) {
|
|
|
[model_dic setValue:combine forKey:@"combine"];
|
|
[model_dic setValue:combine forKey:@"combine"];
|
|
|
}
|
|
}
|