//
//  UserInfo.m
//  ALand
//
//  Created by Z on 16/4/11.
//  Copyright © 2016年 Z. All rights reserved.
//

#import "UserInfo.h"
#import "UIImage+Helper.h"
@implementation UserInfo
+ (UserInfo *)shareInstance {
    static UserInfo *userInfo = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        userInfo = [[UserInfo alloc] init];
        [[JavenQNManager shareInstance] upLoadImage:[UIImage appIcon] isMD5Name:NO name:@"ios-test" commpelete:nil];
        
    });
    return userInfo;
}

- (NSDictionary *)getOperCtx
{
    NSDictionary *dic = @{@"time" : [[NSDate date] timeStampNumber],
                          @"domain" : self.domain,
                          @"operator" : @{@"id" : [UserInfo shareInstance].uuid,
                                          @"fullName" : [UserInfo shareInstance].name}};
    return  dic;
    
}

- (void)checkGoodIsAddedWithGoodUuid:(NSString *)uuid result:(void (^)(BOOL isAdded))result
{
    NSDictionary *myDictionary = @{@"operCtx" : @{@"time" : @0,
                                                  @"domain" : @"string",
                                                  @"operator" : @{@"id" : [UserInfo shareInstance].uuid,
                                                                  @"fullName" : [UserInfo shareInstance].name}},
                                   @"goodsUuid" : uuid,
                                   @"shopUuid" : [UserInfo shareInstance].shop.uuid};
    
    
    [[HTTPCilent shareCilent] POST:@"shop/shopGoodsExists" parameters:myDictionary success:^(NSURLSessionDataTask *task, id responseObject) {
        if ([responseObject[@"code"] isEqualToNumber:@0]) {
            BOOL select = [responseObject[@"value"] boolValue];
            
            result(select);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
    
    
}
@end
