//
//  getAppleyPayGeogle.m
//  Open
//
//  Created by 看看智能 on 2017/12/15.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//

#import "getAppleyPayGeogle.h"
@implementation getAppleyPayGeogle

-(void)get:(UIViewController *)vc ApplePayCity:(getAppleyPayCity)completionHandle{
    [[XWLocationManager sharedXWLocationManager] getCurrentLocation:^(CLLocation *location, CLPlacemark *placeMark, NSString *error) {
             AppDelegate *dele=(AppDelegate*)[[UIApplication sharedApplication]delegate];
        //反向地理编码
        if (error) {
            self.gpsOpen =@"";
             dele.isLogin=NO;
            [SVProgressHUD showErrorWithStatus:@"当前网络状态不佳,请在设置-看看生活-开启定位功能"];
            return;
        }else{
            NSDictionary *addressDic = placeMark.addressDictionary;
            NSString *state=[addressDic objectForKey:@"State"];
            NSString *city=[addressDic objectForKey:@"City"];
            NSString *subLocality=[addressDic objectForKey:@"SubLocality"];
            NSString *street=[addressDic objectForKey:@"Street"];
            NSLog(@"所在城市====%@ %@ %@ %@", state, city, subLocality, street);
            //记录异地的地址
            [getPeopleID getAppleyPay:MHSafeStrings(city)];
            if ([getPeopleID applePaycity]) {
                dele.isLogin=YES;
            }else{
              dele.isLogin=NO;
            }
        }
    } onViewController:vc];
         completionHandle();
}
+(id)getValidateIsOrNotPay:(NSString *)path abd:(NSString *)numberID completionHandle:(void (^)(ApplePays *, NSError *))complete{

//    NSString * pathNew_1 =@"http://172.16.10.207:8081/socialsecurity/kankan/orderservice/validateIsOrNotPay";
    NSString * pathNew_1 =[IPAPPLEPAY stringByAppendingString:@"/socialsecurity/orderservice/validateIsOrNotPay"];
    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSDictionary *dictNew =@{
                             @"identityNumber": [EnercryTool A:numberID],
                             @"requestType":@1004,
                             @"flag":@2
                             };
    NSLog(@"dictNew:%@",dictNew);
    NSLog(@"Path:%@",pathNew1);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        NSLog(@"response:%@",responseObj);
        if (error) {
            NSLog(@"打印错误:%@",error);
        }else
        {
            complete( [ApplePays mj_objectWithKeyValues:responseObj],error);
        }
    }];
    
    
    
    
    
}
+(id)get:(NSString *)path abd:(NSString*)bianHao andBase64:(NSString*)base64 andID:(NSString*)ID  completionHandle:(void (^)( ApplePays*, NSError *))complete;
{

      NSString * pathNew_1 =[IPAPPLEPAY stringByAppendingString:@"/socialsecurity/orderservice/getOrderStateFromApple"];
    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    //我改动的地方
    if (!ID) {
        ID =@"";
    }else{
         ID= [EnercryTool A:ID];
    }
    
    if (!base64) {
        base64 = @"";
    }
    
    if (!bianHao) {
        bianHao = @"";
    }
    
    NSDictionary *dictNew =@{
                             @"conditionStr": ID,
                             @"payOrderStr":base64,
                             @"userId":@([getPeopleID PeopleID]),
                             @"orderNo":bianHao
                             };
    
    
    
    NSLog(@"dictNew:%@",@([getPeopleID PeopleID]));
    NSLog(@"Path:%@",pathNew1);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        NSLog(@"response:%@",responseObj);
        if (error) {
            NSLog(@"打印错误:%@",error);
        }else
        {
            complete( [ApplePays mj_objectWithKeyValues:responseObj],error);
        }
    }];
    
    
    
    
}



@end
