فهرست منبع

1.修改iOS Apex Drivers离线。

Pen Li 7 سال پیش
والد
کامیت
06949904a5

+ 7 - 0
Redant Drivers/Apex And Drivers/Offline/RAOfflineHandler.h

@@ -87,6 +87,13 @@ NS_ASSUME_NONNULL_BEGIN
  */
  */
 - (NSDictionary *)updateOrder:(NSString *)orderId action:(NSInteger)actionId title:(NSString *)title index:(NSInteger)idx withParams:(NSDictionary *)params photos:(NSArray<RAEditImageBaseModel *> *)photos cacheDir:(NSString *)dir;
 - (NSDictionary *)updateOrder:(NSString *)orderId action:(NSInteger)actionId title:(NSString *)title index:(NSInteger)idx withParams:(NSDictionary *)params photos:(NSArray<RAEditImageBaseModel *> *)photos cacheDir:(NSString *)dir;
 
 
+/**
+ * @brief 更新order最后一次操作标记
+ * @param actionIdx 操作索引
+ * @param orderId 订单号
+ */
+- (void)updateLastAction:(NSInteger)actionIdx forOrder:(NSString *)orderId;
+
 @end
 @end
 
 
 NS_ASSUME_NONNULL_END
 NS_ASSUME_NONNULL_END

+ 68 - 12
Redant Drivers/Apex And Drivers/Offline/RAOfflineHandler.m

@@ -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"];
                     }
                     }
                     
                     

+ 1 - 1
Redant Drivers/Apex And Drivers/RADataProvider.h

@@ -25,7 +25,7 @@
 
 
 + (NSDictionary *)reportOrder:(NSString *)orderId type:(NSInteger)type actionType:(NSInteger)action actionIndex:(NSInteger)actionIndex actionName:(NSString *)actionName toURL:(NSString *)url withParams:(NSMutableDictionary *)params;
 + (NSDictionary *)reportOrder:(NSString *)orderId type:(NSInteger)type actionType:(NSInteger)action actionIndex:(NSInteger)actionIndex actionName:(NSString *)actionName toURL:(NSString *)url withParams:(NSMutableDictionary *)params;
 
 
-+ (NSDictionary *)submitEditOrder:(NSMutableDictionary *)params;
++ (NSDictionary *)submitEditOrder:(NSString *)orderId actionIndex:(NSInteger)actionIndex withParams:(NSMutableDictionary *)params;
 
 
 + (NSDictionary *)uploadFile:(NSString *)filePath parameters:(NSMutableDictionary *)params;///<同步上传文件
 + (NSDictionary *)uploadFile:(NSString *)filePath parameters:(NSMutableDictionary *)params;///<同步上传文件
 
 

+ 17 - 3
Redant Drivers/Apex And Drivers/RADataProvider.m

@@ -283,7 +283,14 @@
     
     
     NSData* json=[self get_json:url parameters:params  file:nil];
     NSData* json=[self get_json:url parameters:params  file:nil];
     
     
-    return [self handleJsonData:json];
+    NSDictionary *dic = [self handleJsonData:json];
+    
+    int result = [[dic objectForKey:@"result"] intValue];
+    if (result == RESULT_TRUE) {
+        [[RAOfflineHandler defaultHandler] updateLastAction:actionIndex forOrder:orderId];
+    }
+    
+    return dic;
 }
 }
 
 
 + (NSDictionary *)offlineSubmitOrder:(NSString *)orderId action:(NSInteger)actionId title:(NSString *)title index:(NSInteger)idx withParams:(NSDictionary *)params photos:(NSArray<RAEditImageBaseModel *> *)photos cacheDir:(NSString *)dir {
 + (NSDictionary *)offlineSubmitOrder:(NSString *)orderId action:(NSInteger)actionId title:(NSString *)title index:(NSInteger)idx withParams:(NSDictionary *)params photos:(NSArray<RAEditImageBaseModel *> *)photos cacheDir:(NSString *)dir {
@@ -291,7 +298,7 @@
     return [[RAOfflineHandler defaultHandler] updateOrder:orderId action:actionId title:title index:idx withParams:params photos:photos cacheDir:dir];
     return [[RAOfflineHandler defaultHandler] updateOrder:orderId action:actionId title:title index:idx withParams:params photos:photos cacheDir:dir];
 }
 }
 
 
-+ (NSDictionary *)submitEditOrder:(NSMutableDictionary *)params {
++ (NSDictionary *)submitEditOrder:(NSString *)orderId actionIndex:(NSInteger)actionIndex withParams:(NSMutableDictionary *)params {
     
     
     if (![params isKindOfClass:[NSMutableDictionary class]]) {
     if (![params isKindOfClass:[NSMutableDictionary class]]) {
         params = [params mutableCopy];
         params = [params mutableCopy];
@@ -299,7 +306,14 @@
     
     
     NSData* json=[self get_json:URL_SUBMIT parameters:params  file:nil];
     NSData* json=[self get_json:URL_SUBMIT parameters:params  file:nil];
     
     
-    return [self handleJsonData:json];
+    NSDictionary *dic = [self handleJsonData:json];
+    
+    int result = [[dic objectForKey:@"result"] intValue];
+    if (result == RESULT_TRUE) {
+        [[RAOfflineHandler defaultHandler] updateLastAction:actionIndex forOrder:orderId];
+    }
+    
+    return dic;
 }
 }
 
 
 + (NSDictionary *)upload:(NSString*)url parameters:(NSMutableDictionary *)params file:(NSString*)file_path {
 + (NSDictionary *)upload:(NSString*)url parameters:(NSMutableDictionary *)params file:(NSString*)file_path {

+ 1 - 1
Redant Drivers/Apex And Drivers/Update/RAOrderEditViewController.m

@@ -461,7 +461,7 @@
         }
         }
         else { // 在线
         else { // 在线
             
             
-            NSDictionary *json = [RADataProvider submitEditOrder:params];
+            NSDictionary *json = [RADataProvider submitEditOrder:weakSelf.orderID actionIndex:weakSelf.actionIdx withParams:params];
             
             
             if (weakSelf) {
             if (weakSelf) {
                 __strong typeof(weakSelf) strongSelf = weakSelf;
                 __strong typeof(weakSelf) strongSelf = weakSelf;