|
@@ -646,7 +646,54 @@ static dispatch_semaphore_t _lock;
|
|
|
|
|
|
|
|
Unlock();
|
|
Unlock();
|
|
|
|
|
|
|
|
- return [titleDic objectForKey:[NSString stringWithFormat:@"%ld",(long)actionIndex]];
|
|
|
|
|
|
|
+ NSString *title = [titleDic objectForKey:[NSString stringWithFormat:@"%ld",(long)actionIndex]];
|
|
|
|
|
+
|
|
|
|
|
+ if (!title) {
|
|
|
|
|
+ title = @"";
|
|
|
|
|
+ }
|
|
|
|
|
+ return title;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (NSString *)homeSectionTitleForStatus:(NSInteger)status {
|
|
|
|
|
+
|
|
|
|
|
+ Lock();
|
|
|
|
|
+
|
|
|
|
|
+ NSString *path = [self.offlineDir stringByAppendingPathComponent:@"home_section_title.json"];
|
|
|
|
|
+ NSDictionary *titleDic = [self _loadCacheData:path];
|
|
|
|
|
+
|
|
|
|
|
+ Unlock();
|
|
|
|
|
+
|
|
|
|
|
+ NSString *title = [titleDic objectForKey:[NSString stringWithFormat:@"%ld",(long)status]];
|
|
|
|
|
+
|
|
|
|
|
+ if (!title) {
|
|
|
|
|
+ title = @"";
|
|
|
|
|
+ }
|
|
|
|
|
+ return title;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)homeSection:(NSMutableDictionary *)section addOrder:(NSDictionary *)curOrder forActionIndex:(NSInteger)actionIdx {
|
|
|
|
|
+
|
|
|
|
|
+ if (curOrder == nil) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableArray<NSDictionary *> *orders = [[section objectForKey:@"orders"] mutableCopy];
|
|
|
|
|
+
|
|
|
|
|
+ if (orders == nil) {
|
|
|
|
|
+ orders = [NSMutableArray array];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 修改order状态为Processing
|
|
|
|
|
+ [curOrder setValue:@(RAOrderStatusProcessing) forKey:@"status"];
|
|
|
|
|
+ [curOrder setValue:@(NO) forKey:@"backendFlag"];
|
|
|
|
|
+ [curOrder setValue:[self statusTitleForActionIndex:actionIdx] forKey:@"title"];
|
|
|
|
|
+
|
|
|
|
|
+ // 将当前order插入第一个位置
|
|
|
|
|
+ [orders insertObject:curOrder atIndex:0];
|
|
|
|
|
+
|
|
|
|
|
+ [section setObject:orders forKey:@"orders"];
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Update Data
|
|
#pragma mark - Update Data
|
|
@@ -794,28 +841,36 @@ static dispatch_semaphore_t _lock;
|
|
|
// 如果是Accept则将order添加到Processing Order
|
|
// 如果是Accept则将order添加到Processing Order
|
|
|
if (action == RADetailActionSubTypeAccept) {
|
|
if (action == RADetailActionSubTypeAccept) {
|
|
|
|
|
|
|
|
|
|
+ BOOL findSection = NO;
|
|
|
for (int i = 0; i < sections.count; i++) {
|
|
for (int i = 0; i < sections.count; i++) {
|
|
|
NSMutableDictionary *section = [[sections objectAtIndex:i] mutableCopy];
|
|
NSMutableDictionary *section = [[sections objectAtIndex:i] mutableCopy];
|
|
|
|
|
|
|
|
RAOrderStatus type = [[section objectForKey:@"type"] intValue];
|
|
RAOrderStatus type = [[section objectForKey:@"type"] intValue];
|
|
|
if (type == RAOrderStatusProcessing) {
|
|
if (type == RAOrderStatusProcessing) {
|
|
|
- NSMutableArray<NSDictionary *> *orders = [[section objectForKey:@"orders"] mutableCopy];
|
|
|
|
|
-
|
|
|
|
|
- // 修改order状态为Processing
|
|
|
|
|
- [curOrder setValue:@(RAOrderStatusProcessing) forKey:@"status"];
|
|
|
|
|
- [curOrder setValue:@(NO) forKey:@"backendFlag"];
|
|
|
|
|
- [curOrder setValue:[self statusTitleForActionIndex:actionIdx] forKey:@"title"];
|
|
|
|
|
-
|
|
|
|
|
- // 将当前order插入第一个位置
|
|
|
|
|
- [orders insertObject:curOrder atIndex:0];
|
|
|
|
|
-
|
|
|
|
|
- [section setObject:orders forKey:@"orders"];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ [self homeSection:section addOrder:curOrder forActionIndex:actionIdx];
|
|
|
|
|
|
|
|
// 重新生成section
|
|
// 重新生成section
|
|
|
[sections replaceObjectAtIndex:i withObject:section];
|
|
[sections replaceObjectAtIndex:i withObject:section];
|
|
|
|
|
+
|
|
|
|
|
+ findSection = YES;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (!findSection) {
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary *section = [@{
|
|
|
|
|
+ @"type" : @(RAOrderStatusProcessing),
|
|
|
|
|
+ @"totalCount" : @0,
|
|
|
|
|
+ @"backendFlagCount" : @0,
|
|
|
|
|
+ @"title" : [self homeSectionTitleForStatus:RAOrderStatusProcessing]
|
|
|
|
|
+ } mutableCopy];
|
|
|
|
|
+
|
|
|
|
|
+ [self homeSection:section addOrder:curOrder forActionIndex:actionIdx];
|
|
|
|
|
+
|
|
|
|
|
+ [sections addObject:section];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 重新生成sections
|
|
// 重新生成sections
|
|
@@ -978,6 +1033,7 @@ static dispatch_semaphore_t _lock;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
|
|
|
+ [curOrder setValue:@(NO) forKey:@"backendFlag"];
|
|
|
[curOrder setValue:[self statusTitleForActionIndex:idx] forKey:@"title"];
|
|
[curOrder setValue:[self statusTitleForActionIndex:idx] forKey:@"title"];
|
|
|
}
|
|
}
|
|
|
|
|
|