//
//  SaleInputViewModel.m
//  HDMall
//
//  Created by Javen on 2017/7/31.
//  Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//

#import "SaleInputViewModel.h"

@implementation SaleInputViewModel

/**
 获取全部支付方式
 
 @param callBack 获取到支付方式的回调（如果arrPayments = nil， 则代表请求失败）
 */
- (void)httpAllPayments:(void (^)(NSMutableArray<HMSaleInputDetail_payments *> *arrPayments))callBack {
    [ZJHttpManager GET:@"hdmall/salesinput/getAllPayments" parameters:nil complete:^(id responseObject, NSError *error) {
        if (kIsResponse) {
            NSMutableArray *arrData = [HMSaleInputDetail_payments_payment modelsFromArray:responseObject[@"data"]];
            
            //后台返回的结构是HMSaleInputDetail_payments_payment，需要处理一下，变成HMSaleInputDetail_payments才符合使用需求
            NSMutableArray *arrPayments = [NSMutableArray array];
            for (HMSaleInputDetail_payments_payment *pay in arrData) {
                HMSaleInputDetail_payments *payments = [HMSaleInputDetail_payments new];
                payments.payment = pay;
                [arrPayments addObject:payments];
            }
            callBack(arrPayments);
        }else{
            callBack(nil);
            kFalseHttpTips;
        }
    }];
}
@end
