|
|
@@ -52,6 +52,8 @@
|
|
|
|
|
|
@property (nonatomic,copy) NSString *print_url;
|
|
|
|
|
|
+@property (nonatomic,assign) BOOL available;///<所有Model均有库存,才能Place Order。
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation CartViewController
|
|
|
@@ -597,18 +599,36 @@
|
|
|
[[self navigationController] setNavigationBarHidden:YES animated:NO];
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+- (void)checkProductAvailable:(NSArray *)contents {
|
|
|
+
|
|
|
+ [contents enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+
|
|
|
+ if ([obj isKindOfClass:[NSDictionary class]]) {
|
|
|
+
|
|
|
+ NSDictionary *item_json = (NSDictionary *)obj;
|
|
|
+ BOOL isAvailable = ![[item_json valueForKey:@"available"] isEqualToString:@"In Production"] || [[item_json valueForKey:@"available"] integerValue] != 0;
|
|
|
+ self.available = self.available && isAvailable;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
-(void) operation_reload_data
|
|
|
{
|
|
|
if (self.dataOperationQueue.operationCount > 1) {
|
|
|
return;
|
|
|
}
|
|
|
+ __weak typeof(self) weakself = self;
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- if(self.isrefreshing)
|
|
|
+ if(weakself.isrefreshing)
|
|
|
return;
|
|
|
|
|
|
- self.itemListTable.hidden = true;
|
|
|
- self.label_net_err.hidden=true;
|
|
|
- self.isrefreshing=true;
|
|
|
+ weakself.available = YES;
|
|
|
+ weakself.itemListTable.hidden = true;
|
|
|
+ weakself.label_net_err.hidden=true;
|
|
|
+ weakself.isrefreshing=true;
|
|
|
// [self.content_data removeAllObjects];
|
|
|
// [self.itemListTable reloadData];
|
|
|
// UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];
|
|
|
@@ -617,15 +637,15 @@
|
|
|
//
|
|
|
// reF.attributedTitle = [[NSAttributedString alloc]initWithString:@"Pull to refresh"];
|
|
|
|
|
|
- self.mum.center = self.view.center;
|
|
|
- self.mum.hidden = YES;
|
|
|
+ weakself.mum.center = weakself.view.center;
|
|
|
+ weakself.mum.hidden = YES;
|
|
|
// [self.mum startAnimating];
|
|
|
DebugLog(@"reloading...");
|
|
|
UIAlertView *loadingView = [RAUtils waiting_alert:@"Please Wait" title:@"Loading"];
|
|
|
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
DebugLog(@"BEGIN LOAD CART");
|
|
|
- NSDictionary* cart_json = [iSalesNetwork request_Cart:self.sortIndex];
|
|
|
+ NSDictionary* cart_json = [iSalesNetwork request_Cart:weakself.sortIndex];
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
//
|
|
|
@@ -633,48 +653,52 @@
|
|
|
[loadingView dismissWithClickedButtonIndex:0 animated:YES];
|
|
|
|
|
|
// self.content_data = [cart_json mutableCopy];
|
|
|
- self.freejson = [cart_json objectForKey:@"freeGiveaway"];
|
|
|
- self.notes = [cart_json valueForKey:@"general_note"];
|
|
|
- self.content_arr = [RAUtils dictionary2array:cart_json count_fields:@"count" item_mark:@"item_" items_mark:nil];
|
|
|
- self.currentOrderIsMerged = [[cart_json valueForKey:@"is_merged_order"] boolValue];
|
|
|
- [self.itemListTable reloadData];
|
|
|
- self.print_url = [cart_json valueForKey:@"cart_print_url"];
|
|
|
+ weakself.freejson = [cart_json objectForKey:@"freeGiveaway"];
|
|
|
+ weakself.notes = [cart_json valueForKey:@"general_note"];
|
|
|
+ weakself.content_arr = [RAUtils dictionary2array:cart_json count_fields:@"count" item_mark:@"item_" items_mark:nil];
|
|
|
+ weakself.currentOrderIsMerged = [[cart_json valueForKey:@"is_merged_order"] boolValue];
|
|
|
+ [weakself.itemListTable reloadData];
|
|
|
+ weakself.print_url = [cart_json valueForKey:@"cart_print_url"];
|
|
|
|
|
|
- [self refresh_total];
|
|
|
+
|
|
|
+ [weakself checkProductAvailable:weakself.content_arr];
|
|
|
+
|
|
|
+
|
|
|
+ [weakself refresh_total];
|
|
|
|
|
|
int result=[[cart_json valueForKey:@"result"] intValue];
|
|
|
|
|
|
- if (self.dataOperationQueue.operationCount > 1) {
|
|
|
- self.isrefreshing=false;
|
|
|
+ if (weakself.dataOperationQueue.operationCount > 1) {
|
|
|
+ weakself.isrefreshing=false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if(result==2||result==1||result==0)
|
|
|
{
|
|
|
|
|
|
- [self.edit_select_arr removeAllObjects];
|
|
|
+ [weakself.edit_select_arr removeAllObjects];
|
|
|
|
|
|
- self.itemListTable.hidden = false;
|
|
|
+ weakself.itemListTable.hidden = false;
|
|
|
UIApplication * app = [UIApplication sharedApplication];
|
|
|
AppDelegate *appDelegate = (AppDelegate *)[app delegate];
|
|
|
- appDelegate.cart_count =self.content_arr.count;//[[self.content_data valueForKey:@"count"] intValue];
|
|
|
- self.itemListTable.hidden=false;
|
|
|
- if(self.onFinishLoad)
|
|
|
- self.onFinishLoad();
|
|
|
+ appDelegate.cart_count =weakself.content_arr.count;//[[self.content_data valueForKey:@"count"] intValue];
|
|
|
+ weakself.itemListTable.hidden=false;
|
|
|
+ if(weakself.onFinishLoad)
|
|
|
+ weakself.onFinishLoad();
|
|
|
}
|
|
|
else
|
|
|
if(result==RESULT_NET_ERROR)
|
|
|
{
|
|
|
- self.label_net_err.hidden=false;
|
|
|
- self.itemListTable.hidden=true;
|
|
|
+ weakself.label_net_err.hidden=false;
|
|
|
+ weakself.itemListTable.hidden=true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if(result!=1)
|
|
|
- [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Loading Cart" controller:self] ;
|
|
|
+ [RAUtils message_alert:[cart_json valueForKey:@"err_msg"] title:@"Loading Cart" controller:weakself] ;
|
|
|
}
|
|
|
|
|
|
- self.isrefreshing=false;
|
|
|
+ weakself.isrefreshing=false;
|
|
|
DebugLog(@"FINISH LOAD CART");
|
|
|
|
|
|
});
|
|
|
@@ -809,9 +833,18 @@
|
|
|
{
|
|
|
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
if (appDelegate.user_type == USER_ROLE_CUSTOMER) {
|
|
|
+
|
|
|
+
|
|
|
if (![Singleton sharedInstance].permissions_edit_order) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+// if (!self.available) {
|
|
|
+//
|
|
|
+// [RAUtils message_alert:@"There are some products is not available" title:@"Warning" controller:self];
|
|
|
+// return;
|
|
|
+// }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// NSMutableArray* checked = [[NSMutableArray alloc] init];
|