//
//  PrizeExchangeDetailsViewController.m
//  Lighting
//
//  Created by 曹云霄 on 2016/11/22.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "PrizeExchangeDetailsViewController.h"
#import "PrizeExchangeBillTableViewCell.h"
#import "PrizeExchangeSectionTableViewCell.h"
#import "PrizeExchangeInformationTableViewCell.h"
#import "PrizeExchangeConsigneeTableViewCell.h"

@interface PrizeExchangeDetailsViewController ()<UITableViewDelegate,UITableViewDataSource>


/**
 兑奖单详情
 */
@property (nonatomic,strong) RsPrizeBill *prizeBillResult;

@end

@implementation PrizeExchangeDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpTableView];
    [self getPrizeDetailsDataAction];
}

#pragma mark - UITableView
- (void)setUpTableView
{
    self.prizeExchangeDetailsTableView.tableFooterView = [UIView new];
}

#pragma mark - 兑奖记录详情
- (void)getPrizeDetailsDataAction
{
    WS(weakSelf);
    [self CreateMBProgressHUDLoding];
    NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(PRIZEBILLDETAILS),@"demo11611221750244"];
    [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:url WithCallClass:weakSelf WithRequestType:ONE WithParameter:nil WithReturnValueBlock:^(id returnValue) {
        
        [weakSelf RemoveMBProgressHUDLoding];
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
            weakSelf.prizeBillResult = [[RsPrizeBill alloc]initWithDictionary:returnValue[@"data"] error:nil];
        }else {
            [weakSelf ErrorMBProgressView:returnValue[@"message"]];
        }
        [weakSelf.prizeExchangeDetailsTableView reloadData];
    } WithErrorCodeBlock:^(id errorCodeValue) {
        [weakSelf RemoveMBProgressHUDLoding];
        [weakSelf ErrorMBProgressView:NETWORK];
    } WithFailureBlock:^(NSError *error) {
        [weakSelf RemoveMBProgressHUDLoding];
        [weakSelf ErrorMBProgressView:error.localizedDescription];
    }];
}

#pragma mark - <UITableViewDelegate,UITableViewDataSource>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case ExchangeBillInformation:
        {
            PrizeExchangeBillTableViewCell *billCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeBillTableViewCell" forIndexPath:indexPath];
            billCell.billEntity = self.prizeBillResult.bill;
            return billCell;
        }
            break;
        case ReceivingInformation:
        {
            PrizeExchangeConsigneeTableViewCell *consigneeCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeConsigneeTableViewCell" forIndexPath:indexPath];
            consigneeCell.consigneeEntity = self.prizeBillResult.bill;
            return consigneeCell;
        }
            break;
        case RewardInformation:
        {
            PrizeExchangeInformationTableViewCell *rewardCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeInformationTableViewCell" forIndexPath:indexPath];
            return rewardCell;
        }
            break;
            
        default:
            break;
    }
    return nil;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}





















@end