|
@@ -23,6 +23,7 @@
|
|
|
#import "RAConvertor.h"
|
|
#import "RAConvertor.h"
|
|
|
#import "ActiveViewController.h"
|
|
#import "ActiveViewController.h"
|
|
|
#import "RANetwork.h"
|
|
#import "RANetwork.h"
|
|
|
|
|
+#import "RADataProvider.h"
|
|
|
@interface OLDataProvider ()
|
|
@interface OLDataProvider ()
|
|
|
|
|
|
|
|
@end
|
|
@end
|
|
@@ -1912,30 +1913,59 @@
|
|
|
//
|
|
//
|
|
|
// return;
|
|
// return;
|
|
|
//}
|
|
//}
|
|
|
-+(void) save2submitScanOrder:(NSString*) soid company:(NSString*) company
|
|
|
|
|
|
|
+
|
|
|
|
|
++(void) saveScanSubmitList:(NSMutableDictionary*) submitlist
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
|
|
|
- // NSString *documents = [paths objectAtIndex:0];
|
|
|
|
|
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
|
|
+ if(submitlist==nil)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ NSString *userdir = [OLDataProvider getUserPath];
|
|
|
|
|
+ NSString *submitlistPath = [userdir stringByAppendingPathComponent:@"submitlist.json"];
|
|
|
|
|
+
|
|
|
|
|
+ [RAUtils dicttofile:submitlistPath dict:submitlist];
|
|
|
|
|
+}
|
|
|
|
|
++(void) saveScanOrderList:(NSMutableDictionary*) orderlist
|
|
|
|
|
+{
|
|
|
|
|
|
|
|
|
|
+ if(orderlist==nil)
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
NSString *userdir = [OLDataProvider getUserPath];
|
|
NSString *userdir = [OLDataProvider getUserPath];
|
|
|
- NSMutableDictionary* orderlist = nil;
|
|
|
|
|
NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
|
|
|
|
|
|
|
|
+ [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++(NSMutableDictionary*) getScanSubmitList
|
|
|
|
|
+{
|
|
|
|
|
+ NSString *userdir = [OLDataProvider getUserPath];
|
|
|
|
|
+ NSString *submitlistPath = [userdir stringByAppendingPathComponent:@"submitlist.json"];
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* submitlist = nil;
|
|
|
|
|
+ if (![[NSFileManager defaultManager] fileExistsAtPath:submitlistPath]) {
|
|
|
|
|
+
|
|
|
|
|
+ submitlist = [NSMutableDictionary new];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ submitlist=[[RAUtils dictfromfile:submitlistPath] mutableCopy];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return submitlist;
|
|
|
|
|
+}
|
|
|
|
|
++(NSMutableDictionary*) getScanOrderList{
|
|
|
|
|
+ NSString *userdir = [OLDataProvider getUserPath];
|
|
|
|
|
+ NSMutableDictionary* orderlist = nil;
|
|
|
|
|
+ NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
|
|
|
|
|
|
if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
|
|
|
|
|
|
- // order list 为空,不用维护
|
|
|
|
|
-#ifdef RA_NOTIFICATION
|
|
|
|
|
- [ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
|
|
|
-#else
|
|
|
|
|
|
|
|
|
|
- AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
- [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
|
|
|
-#endif
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ orderlist = [NSMutableDictionary new];
|
|
|
|
|
|
|
|
// [orderlist addObject:appDelegate.order_code];
|
|
// [orderlist addObject:appDelegate.order_code];
|
|
|
// [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
// [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
@@ -1949,11 +1979,56 @@
|
|
|
|
|
|
|
|
// [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
// [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
}
|
|
}
|
|
|
|
|
+ return orderlist;
|
|
|
|
|
+}
|
|
|
|
|
++(void) save2submitScanOrder:(NSString*) soid company:(NSString*) company
|
|
|
|
|
+{
|
|
|
|
|
|
|
|
|
|
+ // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
|
|
|
+ // NSString *documents = [paths objectAtIndex:0];
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
|
|
|
- //==================== order list 删除
|
|
|
|
|
|
|
+
|
|
|
|
|
+// NSString *userdir = [OLDataProvider getUserPath];
|
|
|
|
|
+ NSMutableDictionary* orderlist = [self getScanOrderList];
|
|
|
|
|
+// NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
|
|
|
|
|
|
int count = [orderlist[@"count"] intValue];
|
|
int count = [orderlist[@"count"] intValue];
|
|
|
|
|
+ if(count==0)
|
|
|
|
|
+ {
|
|
|
|
|
+ // order list 为空,不用维护
|
|
|
|
|
+#ifdef RA_NOTIFICATION
|
|
|
|
|
+ [ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
|
|
|
+#else
|
|
|
|
|
+
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
|
|
|
+#endif
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
|
|
|
+//
|
|
|
|
|
+// // order list 为空,不用维护
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// // [orderlist addObject:appDelegate.order_code];
|
|
|
|
|
+// // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
|
|
|
|
|
+//
|
|
|
|
|
+// // [orderlist insertObject:appDelegate.order_code atIndex:0];
|
|
|
|
|
+//
|
|
|
|
|
+// // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //==================== order list 删除
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
|
NSMutableDictionary* submititem =nil;
|
|
NSMutableDictionary* submititem =nil;
|
|
@@ -1973,35 +2048,45 @@
|
|
|
newcount++;
|
|
newcount++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if(submititem==nil)
|
|
|
|
|
+ {
|
|
|
|
|
+ //order list 里没有和当前打开的order code一致的order
|
|
|
|
|
+ //这种情况往往是因为重复点提交按钮,order已关闭。
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
newlist[@"count"] = @(newcount);
|
|
newlist[@"count"] = @(newcount);
|
|
|
- [RAUtils dicttofile:orderlistPath dict:newlist];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ [self saveScanOrderList:newlist];
|
|
|
|
|
+// [RAUtils dicttofile:orderlistPath dict:newlist];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////---=============================== submitlist 添加
|
|
//////////////////---=============================== submitlist 添加
|
|
|
- NSString *submitlistPath = [userdir stringByAppendingPathComponent:@"submitlist.json"];
|
|
|
|
|
|
|
+// NSString *submitlistPath = [userdir stringByAppendingPathComponent:@"submitlist.json"];
|
|
|
|
|
|
|
|
- NSMutableDictionary* submitlist = nil;
|
|
|
|
|
- if (![[NSFileManager defaultManager] fileExistsAtPath:submitlistPath]) {
|
|
|
|
|
-
|
|
|
|
|
- submitlist = [NSMutableDictionary new];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- submitlist=[[RAUtils dictfromfile:submitlistPath] mutableCopy];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ NSMutableDictionary* submitlist = [OLDataProvider getScanSubmitList];
|
|
|
|
|
+// if (![[NSFileManager defaultManager] fileExistsAtPath:submitlistPath]) {
|
|
|
|
|
+//
|
|
|
|
|
+// submitlist = [NSMutableDictionary new];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// submitlist=[[RAUtils dictfromfile:submitlistPath] mutableCopy];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
int submitcount =[submitlist[@"count"] intValue];
|
|
int submitcount =[submitlist[@"count"] intValue];
|
|
|
submititem[@"order_status"] = soid;//@"Submitted Order";
|
|
submititem[@"order_status"] = soid;//@"Submitted Order";
|
|
|
submititem[@"customer_name"] = company;//@"Submitted Order";
|
|
submititem[@"customer_name"] = company;//@"Submitted Order";
|
|
|
|
|
|
|
|
submitlist[[NSString stringWithFormat:@"item_%d",submitcount]]=submititem;
|
|
submitlist[[NSString stringWithFormat:@"item_%d",submitcount]]=submititem;
|
|
|
submitlist[@"count"] = @(submitcount+1);
|
|
submitlist[@"count"] = @(submitcount+1);
|
|
|
- [RAUtils dicttofile:submitlistPath dict:submitlist];
|
|
|
|
|
|
|
+// [RAUtils dicttofile:submitlistPath dict:submitlist];
|
|
|
|
|
+ [self saveScanSubmitList:submitlist];
|
|
|
|
|
|
|
|
#ifdef RA_NOTIFICATION
|
|
#ifdef RA_NOTIFICATION
|
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
@@ -2020,14 +2105,15 @@
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
|
|
|
|
|
|
|
|
- NSString *userdir = [OLDataProvider getUserPath];
|
|
|
|
|
- NSMutableDictionary* orderlist = nil;
|
|
|
|
|
- NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
|
|
|
|
|
+// NSString *userdir = [OLDataProvider getUserPath];
|
|
|
|
|
+ NSMutableDictionary* orderlist = [self getScanOrderList];
|
|
|
|
|
+// NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ int count = [orderlist[@"count"] intValue];
|
|
|
|
|
+ if(count==0)
|
|
|
|
|
+ {
|
|
|
// order list 为空,不用维护
|
|
// order list 为空,不用维护
|
|
|
|
|
+
|
|
|
#ifdef RA_NOTIFICATION
|
|
#ifdef RA_NOTIFICATION
|
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
|
#else
|
|
#else
|
|
@@ -2036,23 +2122,10 @@
|
|
|
[((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
[((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
|
#endif
|
|
#endif
|
|
|
return;
|
|
return;
|
|
|
-
|
|
|
|
|
- // [orderlist addObject:appDelegate.order_code];
|
|
|
|
|
- // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
|
|
|
|
|
-
|
|
|
|
|
- // [orderlist insertObject:appDelegate.order_code atIndex:0];
|
|
|
|
|
-
|
|
|
|
|
- // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- int count = [orderlist[@"count"] intValue];
|
|
|
|
|
-
|
|
|
|
|
NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2069,7 +2142,8 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
newlist[@"count"] = @(newcount);
|
|
newlist[@"count"] = @(newcount);
|
|
|
- [RAUtils dicttofile:orderlistPath dict:newlist];
|
|
|
|
|
|
|
+ [self saveScanOrderList:newlist];
|
|
|
|
|
+// [RAUtils dicttofile:orderlistPath dict:newlist];
|
|
|
#ifdef RA_NOTIFICATION
|
|
#ifdef RA_NOTIFICATION
|
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
|
#else
|
|
#else
|
|
@@ -2079,29 +2153,30 @@
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-+(void) createScanTempFolder
|
|
|
|
|
-{
|
|
|
|
|
- NSString* scanFilePath = [self getScanTempPath];
|
|
|
|
|
- BOOL bdir=YES;
|
|
|
|
|
- NSFileManager* fileManager = [NSFileManager defaultManager];
|
|
|
|
|
- if(! [fileManager fileExistsAtPath:scanFilePath isDirectory:&bdir])
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- NSError *error = nil;
|
|
|
|
|
- bool bsuccess=[fileManager createDirectoryAtPath:scanFilePath withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
|
|
-
|
|
|
|
|
- if(!bsuccess)
|
|
|
|
|
- DebugLog(@"Create cache folder failed");
|
|
|
|
|
-
|
|
|
|
|
- // if(bsuccess)
|
|
|
|
|
- // {
|
|
|
|
|
- // sqlite3 *db = [self get_db];
|
|
|
|
|
- //
|
|
|
|
|
- // [self execSql:[NSString stringWithFormat:@"insert into img_cache(name) values('%@')",name] db:db];
|
|
|
|
|
- // [iSalesDB close_db:db];
|
|
|
|
|
- // }
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+//+(void) createScanTempFolder
|
|
|
|
|
+//{
|
|
|
|
|
+// return;
|
|
|
|
|
+//// NSString* scanFilePath = [self getScanTempPath];
|
|
|
|
|
+//// BOOL bdir=YES;
|
|
|
|
|
+//// NSFileManager* fileManager = [NSFileManager defaultManager];
|
|
|
|
|
+//// if(! [fileManager fileExistsAtPath:scanFilePath isDirectory:&bdir])
|
|
|
|
|
+//// {
|
|
|
|
|
+////
|
|
|
|
|
+//// NSError *error = nil;
|
|
|
|
|
+//// bool bsuccess=[fileManager createDirectoryAtPath:scanFilePath withIntermediateDirectories:YES attributes:nil error:&error];
|
|
|
|
|
+////
|
|
|
|
|
+//// if(!bsuccess)
|
|
|
|
|
+//// DebugLog(@"Create cache folder failed");
|
|
|
|
|
+////
|
|
|
|
|
+//// // if(bsuccess)
|
|
|
|
|
+//// // {
|
|
|
|
|
+//// // sqlite3 *db = [self get_db];
|
|
|
|
|
+//// //
|
|
|
|
|
+//// // [self execSql:[NSString stringWithFormat:@"insert into img_cache(name) values('%@')",name] db:db];
|
|
|
|
|
+//// // [iSalesDB close_db:db];
|
|
|
|
|
+//// // }
|
|
|
|
|
+//// }
|
|
|
|
|
+//}
|
|
|
+(NSString*) getScanOrderPathByCode:(NSString*) order_code
|
|
+(NSString*) getScanOrderPathByCode:(NSString*) order_code
|
|
|
{
|
|
{
|
|
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
@@ -2170,30 +2245,33 @@
|
|
|
}
|
|
}
|
|
|
return orderpath;
|
|
return orderpath;
|
|
|
}
|
|
}
|
|
|
-+(NSString*) getScanTempPath
|
|
|
|
|
-{
|
|
|
|
|
-
|
|
|
|
|
- if(RASingleton.sharedInstance.scan_temp_code == nil)
|
|
|
|
|
- RASingleton.sharedInstance.scan_temp_code = [self createScanTempCode];
|
|
|
|
|
- return [NSTemporaryDirectory() stringByAppendingPathComponent:RASingleton.sharedInstance.scan_temp_code];
|
|
|
|
|
-}
|
|
|
|
|
-+(void) moveScanTemp2Order
|
|
|
|
|
-{
|
|
|
|
|
- NSString *orderdir = [OLDataProvider getScanOrderPath];
|
|
|
|
|
- NSError *error = nil;
|
|
|
|
|
- NSString* tempdir = [OLDataProvider getScanTempPath];
|
|
|
|
|
-
|
|
|
|
|
- // NSArray* arr_files=[RAUtils allFilesAtPath:tempdir];
|
|
|
|
|
- // for(int i=0;i<arr_files.count;i++)
|
|
|
|
|
- // {
|
|
|
|
|
- // NSString* file=arr_files[i];
|
|
|
|
|
- //
|
|
|
|
|
- //
|
|
|
|
|
- // }
|
|
|
|
|
- [ [NSFileManager defaultManager] moveItemAtPath:[tempdir stringByAppendingPathComponent:@"cart.json"] toPath:[orderdir stringByAppendingPathComponent:@"cart.json"] error:&error];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
|
|
+//+(NSString*) getScanTempPath
|
|
|
|
|
+//{
|
|
|
|
|
+// return nil;
|
|
|
|
|
+////
|
|
|
|
|
+//// if(RASingleton.sharedInstance.scan_temp_code == nil)
|
|
|
|
|
+//// RASingleton.sharedInstance.scan_temp_code = [self createScanTempCode];
|
|
|
|
|
+//// return [NSTemporaryDirectory() stringByAppendingPathComponent:RASingleton.sharedInstance.scan_temp_code];
|
|
|
|
|
+//}
|
|
|
|
|
+//+(void) moveScanTemp2Order
|
|
|
|
|
+//{
|
|
|
|
|
+// return;
|
|
|
|
|
+//// NSString *orderdir = [OLDataProvider getScanOrderPath];
|
|
|
|
|
+////
|
|
|
|
|
+//// NSError *error = nil;
|
|
|
|
|
+//// NSString* tempdir = [OLDataProvider getScanTempPath];
|
|
|
|
|
+////
|
|
|
|
|
+//// // NSArray* arr_files=[RAUtils allFilesAtPath:tempdir];
|
|
|
|
|
+//// // for(int i=0;i<arr_files.count;i++)
|
|
|
|
|
+//// // {
|
|
|
|
|
+//// // NSString* file=arr_files[i];
|
|
|
|
|
+//// //
|
|
|
|
|
+//// //
|
|
|
|
|
+//// // }
|
|
|
|
|
+//// [ [NSFileManager defaultManager] moveItemAtPath:[tempdir stringByAppendingPathComponent:@"cart.json"] toPath:[orderdir stringByAppendingPathComponent:@"cart.json"] error:&error];
|
|
|
|
|
+////
|
|
|
|
|
+//
|
|
|
|
|
+//}
|
|
|
|
|
|
|
|
+(NSString*) getUserPath
|
|
+(NSString*) getUserPath
|
|
|
{
|
|
{
|
|
@@ -2209,20 +2287,75 @@
|
|
|
userpath = [userpath stringByAppendingPathComponent:user];
|
|
userpath = [userpath stringByAppendingPathComponent:user];
|
|
|
return userpath;
|
|
return userpath;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
++(bool) isSavedScanOrder:(NSString*) order_code
|
|
|
|
|
+{
|
|
|
|
|
+ if(order_code == nil)
|
|
|
|
|
+ return false;
|
|
|
|
|
+ NSMutableDictionary * orderlist=[self getScanOrderList];
|
|
|
|
|
+ int count = [orderlist[@"count"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ for(int i=0;i<count;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSMutableDictionary* item = orderlist[[NSString stringWithFormat:@"item_%d",i]];
|
|
|
|
|
+ if([item[@"order_code"] isEqualToString: order_code ])
|
|
|
|
|
+ {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
+(NSString*) getScanPath
|
|
+(NSString*) getScanPath
|
|
|
{
|
|
{
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
- if(appDelegate.order_code!=nil)
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.order_code==nil)
|
|
|
{
|
|
{
|
|
|
- return [self getScanOrderPath];
|
|
|
|
|
|
|
+ appDelegate.order_code=[[NSUUID new] UUIDString];
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
|
|
+ return [self getScanOrderPath];
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// [self createScanTempFolder];
|
|
|
|
|
+// return [self getScanTempPath];
|
|
|
|
|
+// }
|
|
|
|
|
+}
|
|
|
|
|
++(void) scanCloseOrder
|
|
|
|
|
+{
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+
|
|
|
|
|
+// if(appDelegate.user.length<=0)
|
|
|
|
|
+// {
|
|
|
|
|
+// [RAUtils message_alert:@"Please login first." title:@"Warring" controller:self];
|
|
|
|
|
+// return;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// if(appDelegate.order_code.length>0)
|
|
|
{
|
|
{
|
|
|
- [self createScanTempFolder];
|
|
|
|
|
- return [self getScanTempPath];
|
|
|
|
|
|
|
+ // 当前订单先关闭
|
|
|
|
|
+ // [OLDataProvider deleteScanOrder:appDelegate.order_code];
|
|
|
|
|
+ appDelegate.order_code = nil;
|
|
|
|
|
+// RASingleton.sharedInstance.scan_temp_code = nil;
|
|
|
|
|
+ if(appDelegate.customer_type!=USER_ROLE_CUSTOMER ) //customer 角色不清空customer info
|
|
|
|
|
+ { appDelegate.customerInfo = nil;
|
|
|
|
|
+ appDelegate.contact_id = nil;
|
|
|
|
|
+ }
|
|
|
|
|
+ RASingleton.sharedInstance.scan_cart = nil;
|
|
|
|
|
+ RASingleton.sharedInstance.price_type = 1;
|
|
|
|
|
+ // [appDelegate updateScanButton:false];
|
|
|
|
|
+
|
|
|
|
|
+ [appDelegate update_count_mark];
|
|
|
|
|
+ [appDelegate closeOrder];
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
+(NSString*) createScanTempCode
|
|
+(NSString*) createScanTempCode
|
|
|
{
|
|
{
|
|
|
return [[NSUUID new] UUIDString];
|
|
return [[NSUUID new] UUIDString];
|
|
@@ -2265,28 +2398,25 @@
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
|
|
|
|
|
|
|
|
- if([appDelegate.order_code isEqualToString:order_code])
|
|
|
|
|
- {
|
|
|
|
|
- //要删除的订单是当前打开的订单;
|
|
|
|
|
- appDelegate.order_code = nil;
|
|
|
|
|
- appDelegate.customerInfo = nil;
|
|
|
|
|
- RASingleton.sharedInstance.scan_cart = nil;
|
|
|
|
|
- appDelegate.contact_id = nil;
|
|
|
|
|
- // [appDelegate updateScanButton:false];
|
|
|
|
|
-
|
|
|
|
|
- [appDelegate update_count_mark];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// if([appDelegate.order_code isEqualToString:order_code])
|
|
|
|
|
+// {
|
|
|
|
|
+// //要删除的订单是当前打开的订单;
|
|
|
|
|
+// appDelegate.order_code = nil;
|
|
|
|
|
+// appDelegate.customerInfo = nil;
|
|
|
|
|
+// RASingleton.sharedInstance.scan_cart = nil;
|
|
|
|
|
+// appDelegate.contact_id = nil;
|
|
|
|
|
+// // [appDelegate updateScanButton:false];
|
|
|
|
|
+//
|
|
|
|
|
+// [appDelegate update_count_mark];
|
|
|
|
|
+// }
|
|
|
//删除订单目录
|
|
//删除订单目录
|
|
|
[[NSFileManager defaultManager] removeItemAtPath:[userdir stringByAppendingPathComponent:order_code] error:nil];
|
|
[[NSFileManager defaultManager] removeItemAtPath:[userdir stringByAppendingPathComponent:order_code] error:nil];
|
|
|
//维护订单列表
|
|
//维护订单列表
|
|
|
- NSMutableDictionary* orderlist = nil;
|
|
|
|
|
|
|
+ NSMutableDictionary* submitlist = [self getScanSubmitList];
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"submitlist.json"];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ int count = [submitlist[@"count"] intValue];
|
|
|
|
|
+ if(count==0)
|
|
|
|
|
+ {
|
|
|
// order list 为空,不用维护
|
|
// order list 为空,不用维护
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2299,22 +2429,29 @@
|
|
|
[((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
[((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
|
#endif
|
|
#endif
|
|
|
return;
|
|
return;
|
|
|
-
|
|
|
|
|
- // [orderlist addObject:appDelegate.order_code];
|
|
|
|
|
- // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
|
|
|
|
|
-
|
|
|
|
|
- // [orderlist insertObject:appDelegate.order_code atIndex:0];
|
|
|
|
|
-
|
|
|
|
|
- // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+// NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"submitlist.json"];
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+// if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// // [orderlist addObject:appDelegate.order_code];
|
|
|
|
|
+// // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
|
|
|
|
|
+//
|
|
|
|
|
+// // [orderlist insertObject:appDelegate.order_code atIndex:0];
|
|
|
|
|
+//
|
|
|
|
|
+// // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
|
|
|
- int count = [orderlist[@"count"] intValue];
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
|
|
|
|
|
@@ -2322,7 +2459,7 @@
|
|
|
int newcount = 0;
|
|
int newcount = 0;
|
|
|
for(int i=0;i<count;i++)
|
|
for(int i=0;i<count;i++)
|
|
|
{
|
|
{
|
|
|
- NSMutableDictionary* item = orderlist[[NSString stringWithFormat:@"item_%d",i]];
|
|
|
|
|
|
|
+ NSMutableDictionary* item = submitlist[[NSString stringWithFormat:@"item_%d",i]];
|
|
|
if([item[@"order_code"] isEqualToString: order_code ])
|
|
if([item[@"order_code"] isEqualToString: order_code ])
|
|
|
continue;
|
|
continue;
|
|
|
else
|
|
else
|
|
@@ -2332,7 +2469,9 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
newlist[@"count"] = @(newcount);
|
|
newlist[@"count"] = @(newcount);
|
|
|
- [RAUtils dicttofile:orderlistPath dict:newlist];
|
|
|
|
|
|
|
+// [RAUtils dicttofile:orderlistPath dict:newlist];
|
|
|
|
|
+ [self saveScanSubmitList:newlist];
|
|
|
|
|
+
|
|
|
#ifdef RA_NOTIFICATION
|
|
#ifdef RA_NOTIFICATION
|
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
|
#else
|
|
#else
|
|
@@ -2354,14 +2493,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- NSMutableDictionary* orderlist = nil;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ NSMutableDictionary* orderlist = [self getScanOrderList];
|
|
|
|
|
+ int count = [orderlist[@"count"] intValue];
|
|
|
|
|
+ if(count==0)
|
|
|
|
|
+ {
|
|
|
// order list 为空,不用维护
|
|
// order list 为空,不用维护
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2370,22 +2505,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
|
-
|
|
|
|
|
- // [orderlist addObject:appDelegate.order_code];
|
|
|
|
|
- // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
|
|
|
|
|
-
|
|
|
|
|
- // [orderlist insertObject:appDelegate.order_code atIndex:0];
|
|
|
|
|
-
|
|
|
|
|
- // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
|
|
|
|
|
|
- int count = [orderlist[@"count"] intValue];
|
|
|
|
|
|
|
+
|
|
|
|
|
+// if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// // [orderlist addObject:appDelegate.order_code];
|
|
|
|
|
+// // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
|
|
|
|
|
+//
|
|
|
|
|
+// // [orderlist insertObject:appDelegate.order_code atIndex:0];
|
|
|
|
|
+//
|
|
|
|
|
+// // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// int count = [orderlist[@"count"] intValue];
|
|
|
|
|
|
|
|
// NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
// NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
|
|
|
|
|
@@ -2434,7 +2577,9 @@
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
// newlist[@"count"] = @(newcount);
|
|
// newlist[@"count"] = @(newcount);
|
|
|
- [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ [self saveScanOrderList:orderlist];
|
|
|
|
|
+// [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
|
|
|
[ActiveViewController Notify:@"ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
[ActiveViewController Notify:@"ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
|
|
|
|
|
@@ -2454,10 +2599,11 @@
|
|
|
if([appDelegate.order_code isEqualToString:order_code])
|
|
if([appDelegate.order_code isEqualToString:order_code])
|
|
|
{
|
|
{
|
|
|
//要删除的订单是当前打开的订单;
|
|
//要删除的订单是当前打开的订单;
|
|
|
- appDelegate.order_code = nil;
|
|
|
|
|
- appDelegate.customerInfo = nil;
|
|
|
|
|
- RASingleton.sharedInstance.scan_cart = nil;
|
|
|
|
|
- appDelegate.contact_id = nil;
|
|
|
|
|
|
|
+// appDelegate.order_code = nil;
|
|
|
|
|
+// appDelegate.customerInfo = nil;
|
|
|
|
|
+// RASingleton.sharedInstance.scan_cart = nil;
|
|
|
|
|
+// appDelegate.contact_id = nil;
|
|
|
|
|
+ [self scanCloseOrder];
|
|
|
// [appDelegate updateScanButton:false];
|
|
// [appDelegate updateScanButton:false];
|
|
|
|
|
|
|
|
[appDelegate update_count_mark];
|
|
[appDelegate update_count_mark];
|
|
@@ -2465,14 +2611,12 @@
|
|
|
//删除订单目录
|
|
//删除订单目录
|
|
|
[[NSFileManager defaultManager] removeItemAtPath:[userdir stringByAppendingPathComponent:order_code] error:nil];
|
|
[[NSFileManager defaultManager] removeItemAtPath:[userdir stringByAppendingPathComponent:order_code] error:nil];
|
|
|
//维护订单列表
|
|
//维护订单列表
|
|
|
- NSMutableDictionary* orderlist = nil;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
|
|
|
|
|
+ NSMutableDictionary* orderlist = [self getScanOrderList];
|
|
|
|
|
|
|
|
|
|
+ int count = [orderlist[@"count"] intValue];
|
|
|
|
|
|
|
|
- if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if(count==0)
|
|
|
|
|
+ {
|
|
|
// order list 为空,不用维护
|
|
// order list 为空,不用维护
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2485,22 +2629,29 @@
|
|
|
[((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
[((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
|
#endif
|
|
#endif
|
|
|
return;
|
|
return;
|
|
|
-
|
|
|
|
|
- // [orderlist addObject:appDelegate.order_code];
|
|
|
|
|
- // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
|
|
|
|
|
-
|
|
|
|
|
- // [orderlist insertObject:appDelegate.order_code atIndex:0];
|
|
|
|
|
-
|
|
|
|
|
- // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+// NSString *orderlistPath = [userdir stringByAppendingPathComponent:@"orderlist.json"];
|
|
|
|
|
|
|
|
|
|
|
|
|
- int count = [orderlist[@"count"] intValue];
|
|
|
|
|
|
|
+// if (![[NSFileManager defaultManager] fileExistsAtPath:orderlistPath]) {
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// // [orderlist addObject:appDelegate.order_code];
|
|
|
|
|
+// // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// orderlist=[[RAUtils dictfromfile:orderlistPath] mutableCopy];
|
|
|
|
|
+//
|
|
|
|
|
+// // [orderlist insertObject:appDelegate.order_code atIndex:0];
|
|
|
|
|
+//
|
|
|
|
|
+// // [RAUtils dicttofile:orderlistPath dict:orderlist];
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
NSMutableDictionary* newlist = [NSMutableDictionary new];
|
|
|
|
|
|
|
@@ -2518,7 +2669,8 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
newlist[@"count"] = @(newcount);
|
|
newlist[@"count"] = @(newcount);
|
|
|
- [RAUtils dicttofile:orderlistPath dict:newlist];
|
|
|
|
|
|
|
+ [self saveScanOrderList:newlist];
|
|
|
|
|
+// [RAUtils dicttofile:orderlistPath dict:newlist];
|
|
|
#ifdef RA_NOTIFICATION
|
|
#ifdef RA_NOTIFICATION
|
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
[ActiveViewController Notify:@"CartViewController,ScanOrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
|
|
|
#else
|
|
#else
|
|
@@ -2527,9 +2679,310 @@
|
|
|
[((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
[((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
++(void) scanRefreshCart
|
|
|
|
|
+{
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ NSMutableDictionary* cart =[[RAUtils copyDict: RASingleton.sharedInstance.scan_cart] mutableCopy];
|
|
|
|
|
+ NSMutableDictionary * section = cart[@"section_0"];
|
|
|
|
|
+ NSMutableDictionary* newsection = [NSMutableDictionary new];
|
|
|
|
|
+ int count = [section[@"count"] intValue];
|
|
|
|
|
+ int newcount = 0;
|
|
|
|
|
+ for(int i=0;i<count;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* item = [section[[NSString stringWithFormat:@"item_%d",i]] mutableCopy];
|
|
|
|
|
+ NSString* model = item[@"model"];
|
|
|
|
|
+ NSDictionary* modeljson=appDelegate.scan_model[model];
|
|
|
|
|
+
|
|
|
|
|
+ if(modeljson==nil)
|
|
|
|
|
+ continue;
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* cartitem = [[self scanmodel2cartitem:[modeljson mutableCopy]] mutableCopy];
|
|
|
|
|
+ cartitem[@"note"]=item[@"note"];
|
|
|
|
|
+ cartitem[@"discount"]=item[@"discount"];
|
|
|
|
|
+// [item removeObjectForKey:@"discount"];
|
|
|
|
|
+// [item removeObjectForKey:@"note"];
|
|
|
|
|
+ newsection[[NSString stringWithFormat:@"item_%d",newcount]]=cartitem;
|
|
|
|
|
+ newcount++;
|
|
|
|
|
+ }
|
|
|
|
|
+ RASingleton.sharedInstance.scan_cart[@"section_0"]=newsection;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++(NSDictionary*) scanmodel2cartitem:(NSMutableDictionary*) _modelJson
|
|
|
|
|
+{
|
|
|
|
|
+// _modelJson = modelJson;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+
|
|
|
|
|
+// self.labelPrice0.text = appDelegate.price0_name;
|
|
|
|
|
+// self.labelPrice1.text = appDelegate.price1_name;
|
|
|
|
|
+// self.labelPrice2.text = appDelegate.price2_name;
|
|
|
|
|
+// self.labelPrice3.text = appDelegate.price3_name;
|
|
|
|
|
+ NSDictionary* price_group = [RADataProvider get_price_group:appDelegate.price_group];
|
|
|
|
|
+// self.labelPrice0.text = price_group[@"price_0"][@"display"];//appDelegate.price0_name;
|
|
|
|
|
+// self.labelPrice1.text = price_group[@"price_1"][@"display"];//appDelegate.price1_name;
|
|
|
|
|
+// self.labelPrice2.text = price_group[@"price_2"][@"display"];//appDelegate.price2_name;
|
|
|
|
|
+// self.labelPrice3.text = price_group[@"price_3"][@"display"];//appDelegate.price3_name;
|
|
|
|
|
+
|
|
|
|
|
+ NSLog( [RAConvertor dict2string:_modelJson]);
|
|
|
|
|
+
|
|
|
|
|
+ NSString * port=_modelJson[@"port"];
|
|
|
|
|
+ if(port.length==0)
|
|
|
|
|
+ port = @"N/A";
|
|
|
|
|
+
|
|
|
|
|
+ NSString * origin=_modelJson[@"origin"];
|
|
|
|
|
+ if(origin.length==0)
|
|
|
|
|
+ origin = @"N/A";
|
|
|
|
|
+ NSString * dimension=_modelJson[@"dimension"];
|
|
|
|
|
+ if(dimension.length==0)
|
|
|
|
|
+ dimension = @"N/A";
|
|
|
|
|
+
|
|
|
|
|
+// _labelModel.text=_modelJson[@"model"];
|
|
|
|
|
+// _labelDescription.text=_modelJson[@"description"];
|
|
|
|
|
+// _labelDimension.text=dimension;
|
|
|
|
|
+// _labelCuft.text=_modelJson[@"unit_cuft"];
|
|
|
|
|
+// _labelOrigin.text=origin;
|
|
|
|
|
+// _labelPort.text=port;
|
|
|
|
|
+ NSString* price0=_modelJson[price_group[@"price_0"][@"name"]]; //DDP
|
|
|
|
|
+ NSString* price1=_modelJson[price_group[@"price_1"][@"name"]]; //WHSE
|
|
|
|
|
+ NSString* price2=_modelJson[price_group[@"price_2"][@"name"]]; //SHOW
|
|
|
|
|
+ NSString* price3=_modelJson[price_group[@"price_3"][@"name"]]; //NET
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(![price0 isEqualToString: @"N/A"])
|
|
|
|
|
+ price0 = [NSString stringWithFormat:@"%.2f",[_modelJson[price_group[@"price_0"][@"name"]] doubleValue]];
|
|
|
|
|
+ if(![price1 isEqualToString: @"N/A"])
|
|
|
|
|
+ price1 = [NSString stringWithFormat:@"%.2f",[_modelJson[price_group[@"price_1"][@"name"]] doubleValue]];
|
|
|
|
|
+ if(![price2 isEqualToString: @"N/A"])
|
|
|
|
|
+ {
|
|
|
|
|
+ price2 = [NSString stringWithFormat:@"%.2f",[_modelJson[price_group[@"price_2"][@"name"]] doubleValue]];
|
|
|
|
|
+// if(RASingleton.sharedInstance.price_type==1)
|
|
|
|
|
+ _modelJson [@"special_price"] = @true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(![price3 isEqualToString: @"N/A"])
|
|
|
|
|
+ price3 = [NSString stringWithFormat:@"%.2f",[_modelJson[price_group[@"price_3"][@"name"]] doubleValue]];
|
|
|
|
|
+
|
|
|
|
|
+// if(![_modelJson [@"special_price"] boolValue]&& ![price1 isEqualToString: @"N/A"] && [price1 isEqual:price3])
|
|
|
|
|
+ if((![price1 isEqualToString: @"N/A"] && [price1 isEqual:price3])||(![price2 isEqualToString: @"N/A"] && [price2 isEqual:price3]))
|
|
|
|
|
+ {
|
|
|
|
|
+// if(RASingleton.sharedInstance.price_type==1)
|
|
|
|
|
+ _modelJson [@"net_price"] = @true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+// if(![price1 isEqualToString:@"N/A"])
|
|
|
|
|
+// {
|
|
|
|
|
+// price2 = [NSString stringWithFormat:@"%.2f",[_modelJson[@"price1"] doubleValue] *1.25];
|
|
|
|
|
+// _modelJson[@"price2"]= price2;
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// price2=@"N/A";
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// if([price0 isEqualToString:@"N/A"])
|
|
|
|
|
+// _labelPriceCTNR.text= @"";//price0;
|
|
|
|
|
+// else
|
|
|
|
|
+// _labelPriceCTNR.text=[RAConvertor currencyNumber:[price0 floatValue]];
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+// if([price3 isEqualToString:@"N/A"])
|
|
|
|
|
+// _labelPriceNCA.text= price3;
|
|
|
|
|
+// else
|
|
|
|
|
+// _labelPriceNCA.text=[RAConvertor currencyNumber:[price3 floatValue]];
|
|
|
|
|
+// _labelPrice25p.text=price2;
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+// if([_modelJson [@"special_price"] boolValue])
|
|
|
|
|
+// {
|
|
|
|
|
+// if([_modelJson[price_group[@"price_2"][@"name"]] isEqualToString:@"N/A"])
|
|
|
|
|
+// _labelPriceSpecial.text=@"";//_modelJson[@"price2"];
|
|
|
|
|
+// else
|
|
|
|
|
+// _labelPriceSpecial.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_2"][@"name"]] floatValue]];
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// _labelPriceSpecial.text=@"";//@"N/A";
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+
|
|
|
|
|
+// if([_modelJson [@"net_price"] boolValue])
|
|
|
|
|
+// {
|
|
|
|
|
+//// if([_modelJson[@"price1"] isEqualToString:@"N/A"])
|
|
|
|
|
+//// {
|
|
|
|
|
+//// _labelPriceNet.text=_modelJson[@"price1"];
|
|
|
|
|
+////// _labelPriceNCA.text=@"N/A";
|
|
|
|
|
+//// }
|
|
|
|
|
+//// else
|
|
|
|
|
+//// {
|
|
|
|
|
+//// _labelPriceNet.text=[RAConvertor currencyNumber:[_modelJson[@"price1"] floatValue]];
|
|
|
|
|
+////// _labelPriceNCA.text=@"N/A";
|
|
|
|
|
+//// }
|
|
|
|
|
+//
|
|
|
|
|
+// if([_modelJson[price_group[@"price_3"][@"name"]] isEqualToString:@"N/A"])
|
|
|
|
|
+// {
|
|
|
|
|
+// _labelPriceNet.text=@"";//_modelJson[@"price3"];
|
|
|
|
|
+//// _labelPriceNCA.text=@"N/A";
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// _labelPriceNet.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_3"][@"name"]] floatValue]];
|
|
|
|
|
+//// _labelPriceNCA.text=@"N/A";
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// _labelPriceNet.text=@"";//@"N/A";
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// {
|
|
|
|
|
+// if([_modelJson[price_group[@"price_1"][@"name"]] isEqualToString:@"N/A"])
|
|
|
|
|
+// {
|
|
|
|
|
+// _labelPriceNCA.text=@"";//_modelJson[@"price1"];
|
|
|
|
|
+//// _labelPriceNCA.text=@"N/A";
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// _labelPriceNCA.text=[RAConvertor currencyNumber:[_modelJson[price_group[@"price_1"][@"name"]] floatValue]];
|
|
|
|
|
+//// _labelPriceNet.text=@"N/A";
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString * available=_modelJson[@"available"];
|
|
|
|
|
+ if(available.length==0)
|
|
|
|
|
+ available = @"N/A";
|
|
|
|
|
+
|
|
|
|
|
+// _labelAvailable.text=available;
|
|
|
|
|
+ NSString * unit_cuft=_modelJson[@"unit_cuft"];
|
|
|
|
|
+ if(unit_cuft.length==0)
|
|
|
|
|
+ unit_cuft = @"N/A";
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ unit_cuft = [NSString stringWithFormat:@"%.2f", [_modelJson[@"unit_cuft"] doubleValue]];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ NSString * cell_price;
|
|
|
|
|
+
|
|
|
|
|
+ if(RASingleton.sharedInstance.price_type==1)
|
|
|
|
|
+ {
|
|
|
|
|
+// if(_modelJson [@"net_price"])
|
|
|
|
|
+ cell_price=_modelJson[price_group[@"price_3"][@"name"]];
|
|
|
|
|
+// else if(_modelJson [@"special_price"])
|
|
|
|
|
+// {
|
|
|
|
|
+// unit_price= _modelJson[@"price2"];
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// unit_price= _modelJson[@"price1"];
|
|
|
|
|
+// }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ cell_price=_modelJson[price_group[@"price_0"][@"name"]];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString * mpack=_modelJson[@"stockUom"];
|
|
|
|
|
+ if([mpack isEqualToString:@"N/A"])
|
|
|
|
|
+ mpack=@"1";
|
|
|
|
|
+ _modelJson[@"count"]=_modelJson[@"stockUom"];
|
|
|
|
|
+ _modelJson[@"cuft"] = @([mpack intValue]* [unit_cuft doubleValue]);
|
|
|
|
|
+ _modelJson[@"subtotal_price"] = @([mpack intValue]* [cell_price doubleValue]);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* jitem = nil;
|
|
|
|
|
+ jitem = [_modelJson mutableCopy];
|
|
|
|
|
+int stockUom =[jitem[@"stockUom"] intValue];
|
|
|
|
|
+if(stockUom==0)
|
|
|
|
|
+ stockUom=1;
|
|
|
|
|
+ bool newitem = true;
|
|
|
|
|
+//AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+//NSDictionary* price_group = [RADataProvider get_price_group:appDelegate.price_group];
|
|
|
|
|
+// for(int i=0;i<count;i++)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// NSMutableDictionary* litem = [section[[NSString stringWithFormat:@"item_%i",i]] mutableCopy];
|
|
|
|
|
+//
|
|
|
|
|
+// if([litem[@"product_id"] isEqualToString:jitem[@"product_id"]])
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+//// int oldcount = [litem[@"stockUom"] intValue];
|
|
|
|
|
+// newitem = false;
|
|
|
|
|
+//
|
|
|
|
|
+// litem[@"count"]=@([litem[@"count"] intValue] +[jitem[@"count"] intValue]);
|
|
|
|
|
+// litem[@"cuft"]=@([litem[@"count"] intValue] * [litem[@"unit_cuft"] doubleValue]);
|
|
|
|
|
+//
|
|
|
|
|
+// section[[NSString stringWithFormat:@"item_%i",i]] = litem;
|
|
|
|
|
+// break;
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// if(true)
|
|
|
|
|
+// {
|
|
|
|
|
+ jitem[@"count"]=@(stockUom);
|
|
|
|
|
+ jitem[@"check"]=@(true);
|
|
|
|
|
+ jitem[@"cart_item_id"]=[NSUUID UUID].UUIDString;
|
|
|
|
|
+
|
|
|
|
|
+ NSString * unit_price;
|
|
|
|
|
+ if(RASingleton.sharedInstance.price_type==0)
|
|
|
|
|
+ unit_price=_modelJson[price_group[@"price_0"][@"name"]];
|
|
|
|
|
+ else if(_modelJson [@"special_price"])
|
|
|
|
|
+ {
|
|
|
|
|
+ unit_price= _modelJson[price_group[@"price_2"][@"name"]];
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(_modelJson [@"net_price"])
|
|
|
|
|
+ unit_price=_modelJson[price_group[@"price_3"][@"name"]];
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ unit_price= _modelJson[price_group[@"price_1"][@"name"]];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ if([unit_price isEqualToString:@"N/A"])
|
|
|
|
|
+ unit_price = @"0";
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ unit_price = [NSString stringWithFormat:@"%.2f", [unit_price doubleValue]];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ jitem[@"unit_price"] = unit_price;
|
|
|
|
|
+ jitem[@"erp_unit_price"] = unit_price;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// section[[NSString stringWithFormat:@"item_%i",count]] = jitem;
|
|
|
|
|
+// section[@"count"]= @(count+1);
|
|
|
|
|
+// count++;
|
|
|
|
|
+
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return jitem;
|
|
|
|
|
+}
|
|
|
+(void) saveScanCart:(NSMutableDictionary*) cart
|
|
+(void) saveScanCart:(NSMutableDictionary*) cart
|
|
|
{
|
|
{
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ if(appDelegate.order_code.length<=0)
|
|
|
|
|
+ return;
|
|
|
if(cart==nil)
|
|
if(cart==nil)
|
|
|
return;
|
|
return;
|
|
|
// NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
// NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|