//
//  gatherNetModel.m
//  Open
//
//  Created by 看看智能 on 2017/11/6.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//

#import "gatherNetModel.h"

@implementation gatherNetModel
+(id)getGatherSenderSocialMessageInsertInfo:(NSString *)path abd:(gather*)gatherdg  completionHandle:(void (^)( verifyAdressModel*, NSError *))complete{
    
    NSArray  <gather*>*gatArray = [[NSArray alloc]initWithObjects:gatherdg, nil];
    
    //取出所有的字典
//    gatherUtil *gat = [[gatherUtil alloc]init];
//  NSArray <gather*>*gatArray =  [gat checkDate];
    NSLog(@"number:%lu",(unsigned long)gatArray.count);
    for (int i = 0 ; i < 1 ; i++) {
        NSLog(@"%@",gatArray[i].Name);
        NSLog(@"%@",gatArray[i].identityName);
        NSLog(@"%@",gatArray[i].provinceGather);
        NSLog(@"%@",gatArray[i].city_name);
        NSLog(@"%@",gatArray[i].country_name);
        NSLog(@"%@",gatArray[i].townName);
        NSLog(@"%@",gatArray[i].village_name);
        NSLog(@"%@",gatArray[i].company_Name);
        NSLog(@"%ld",(long)gatArray[i].verifyType);
        NSLog(@"%@",gatArray[i].ocrImage);
        NSLog(@"%@",gatArray[i].ocrImage_);
        if (!gatArray[i].ocrImage) {
            gatArray[i].ocrImage = @"";
        }
        if (!gatArray[i].ocrImage_) {
            gatArray[i].ocrImage_ = @"";
        }
        
        if ([gatArray[i].company_Name isEqualToString:@""]) {
            gatArray[i].company_Name = @"";
        }
        else
        {
            gatArray[i].company_Name =[EnercryTool encryptUseDES:gatArray[i].company_Name key:DESKEY];
        }
        if ([gatArray[i].townName isEqualToString:@""]) {
            gatArray[i].townName = @"";
        }else
        {
            gatArray[i].townName =[EnercryTool encryptUseDES:gatArray[i].townName key:DESKEY];
        }
        
        
        if ([gatArray[i].village_name isEqualToString:@""]) {
            gatArray[i].village_name = @"";
        }else
        {
            gatArray[i].village_name=[EnercryTool encryptUseDES:gatArray[i].village_name key:DESKEY];
        }
        
        if (!gatArray[i].telephone) {
            gatArray[i].telephone = @"";
        }
        NSString *str1 = [NSString stringWithFormat:@"identityNumber=%@&name=%@&KkweInfo",[EnercryTool A:gatArray[i].identityName],[EnercryTool A:gatArray[i].Name]];
        NSLog(@"%@",str1);
        str1 =  [MyMD5 md5:str1];
        NSString * pathNew1 =  [path  stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        
        
        NSLog(@"%@",gatArray[i].Name);
        NSLog(@"%@",gatArray[i].identityName);
        NSLog(@"%@",gatArray[i].provinceGather);
        NSLog(@"%@",gatArray[i].city_name);
        NSLog(@"%@",gatArray[i].country_name);
        NSLog(@"%@",gatArray[i].townName);
        NSLog(@"%@",gatArray[i].village_name);
        NSLog(@"%@",gatArray[i].company_Name);
        NSLog(@"%ld",gatArray[i].verifyType);
        NSLog(@"%@",gatArray[i].ocrImage);
        NSLog(@"%@",gatArray[i].ocrImage_);
        NSLog(@"%@",str1);
        for (NSString *str11 in gatArray[i].imageCopy) {
                    NSLog(@"%@",str11);
        }
        
        NSDictionary *dictNew =@{
                                 @"flag":@2,
                                 @"name":[EnercryTool A:gatArray[i].Name],
                                 @"identityNumber":[EnercryTool A:gatArray[i].identityName],
                                 @"province_name":[EnercryTool encryptUseDES:gatArray[i].provinceGather key:DESKEY],
                                 @"city_name":[EnercryTool encryptUseDES:gatArray[i].city_name key:DESKEY],
                                 @"county_name":[EnercryTool encryptUseDES:gatArray[i].country_name key:DESKEY],
                                 @"town_name":gatArray[i].townName,
                                 @"village_name":gatArray[i].village_name,
                                 @"phone_number":[EnercryTool encryptUseDES:gatArray[i].telephone key:DESKEY],
                                 @"company_name":gatArray[i].company_Name,
                                 @"verify_type":@(gatArray[i].verifyType),
                                 @"image":[gatArray[i].imageCopy componentsJoinedByString:@","],
                                 @"ocrHeadImage":gatArray[i].ocrImage_,
                                 @"ocrTotalImage":gatArray[i].ocrImage,
                                 @"sign":str1,//md5
                                 @"userId":@([getPeopleID PeopleID]),
                                 @"iosVersion":@2
                                 };
        //可能要转
        NSLog(@"%@",dictNew);
        return [self  POST:pathNew1 parameters:dictNew completionHandler:^(verifyAdressModel* responseObj, NSError *error) {
            NSLog(@"response:%@",responseObj);
            
            if (error) {
                NSLog(@"打印错误:%@",error);
                [SVProgressHUD dismiss];
            }else
            {
                complete( [verifyAdressModel mj_objectWithKeyValues:responseObj],error);
            }
            
        }];
        
        
        
        
        
        
        
        
        
        
        
        
    }
    return nil;
}
@end
