OrderDetailViewController.m 4.88 KB
Newer Older
Sandy's avatar
Sandy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
//
//  OrderDetailViewController.m
//  Car
//
//  Created by Javen on 2016/12/27.
//  Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//

#import "OrderDetailViewController.h"
#import "HttpCilent.h"
@interface OrderDetailViewController ()
/** 单号 */
@property (weak, nonatomic) IBOutlet UILabel *labelBillNumber;
/** 状态 */
@property (weak, nonatomic) IBOutlet UILabel *labelState;
/** 油站 */
@property (weak, nonatomic) IBOutlet UILabel *labelStation;
/** 加油员 */
@property (weak, nonatomic) IBOutlet UILabel *labelStationUser;
/** 油枪 */
@property (weak, nonatomic) IBOutlet UILabel *labelGun;
/** 油品 */
@property (weak, nonatomic) IBOutlet UILabel *labelOil;
/** 顾客 */
@property (weak, nonatomic) IBOutlet UILabel *labelCustomer;
/** 支付方式 */
@property (weak, nonatomic) IBOutlet UILabel *labelPayment;
/** 支付时间 */
@property (weak, nonatomic) IBOutlet UILabel *labelPayTime;
/** 应付金额 */
@property (weak, nonatomic) IBOutlet UILabel *labelPrice;

/**
 抵用券金额
 */
@property (weak, nonatomic) IBOutlet UILabel *labelVoucher;
/** 实付金额 */
@property (weak, nonatomic) IBOutlet UILabel *labelRealPrice;
Sandy's avatar
Sandy committed
39
/** 工分 */
Sandy's avatar
Sandy committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
@property (weak, nonatomic) IBOutlet UILabel *labelDeduct;
/** 是否开票 */
@property (weak, nonatomic) IBOutlet UILabel *labelIsInvoice;
/** 是否打印 */
@property (weak, nonatomic) IBOutlet UILabel *labelIsPrint;
/** 最后一次打印时间 */
@property (weak, nonatomic) IBOutlet UILabel *labelLatestPrintTime;

@end

@implementation OrderDetailViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  
  [self configUI];
    // Do any additional setup after loading the view.
}

- (void)configUI {
60
  self.title = @"加油单详情";
Sandy's avatar
Sandy committed
61 62 63 64 65 66 67 68 69 70 71 72
  UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"重新打印" style:UIBarButtonItemStyleDone target:self action:@selector(actionRePrint)];
  self.navigationItem.rightBarButtonItem = rightBtn;
  
  self.labelBillNumber.text = kStrPrefix(self.model.billNumber, @"单号:");
  self.labelState.text = self.model.stateString;
  self.labelStation.text = self.model.stationName;
  self.labelStationUser.text = kStrPrefix(self.model.stationUserName, @"加油员:");
  self.labelGun.text = kStrPrefix(self.model.oilGunName, @"油枪:");
  self.labelOil.text = kStrPrefix(self.model.gasItemName, @"油品:");
  self.labelCustomer.text = kStrPrefix(self.model.memberName, @"顾客:");
  self.labelPayment.text = kStrPrefix(self.model.paymentString, @"支付方式:");
  self.labelPayTime.text = kStrPrefix(self.model.payTime, @"支付时间:");
Sandy's avatar
Sandy committed
73
  self.labelPrice.text = kStrPrefix([CalculateHelper getMoneyStringFrom:self.model.total], @"¥");
Sandy's avatar
Sandy committed
74 75 76
  //抵用券金额
  NSDecimalNumber *voucher = [CalculateHelper sub:self.model.total num2:self.model.realPayTotal];
  self.labelVoucher.text = kStrPrefix([CalculateHelper getMoneyStringFrom:voucher], @"¥");
77
  self.labelRealPrice.text = kStrPrefix([CalculateHelper getMoneyStringFrom:self.model.realPayTotal], @"¥");
Sandy's avatar
Sandy committed
78
  self.labelDeduct.text = [self.model.deduct stringValue];
Sandy's avatar
Sandy committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
  self.labelIsInvoice.text = kStrPrefix(self.model.invoiceString, @"是否开票:");
  self.labelIsPrint.text = kStrPrefix(self.model.printStateString, @"是否打印:");
  self.labelLatestPrintTime.text = kStrPrefix(self.model.lstPrintedTime, @"最后一次打印时间:");
}

#pragma mark - action

- (void)actionRePrint {
  UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"确认重新打印加油单吗?" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  WS(weakSelf);
  UIAlertAction *actionYes = [UIAlertAction actionWithTitle:@"重新打印" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    
    [weakSelf httpRePrint];
    
  }];
  [alert addAction:actionYes];
  
  UIAlertAction *actionNo = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
  [alert addAction:actionNo];
  
  [self.navigationController presentViewController:alert animated:YES completion:nil];
}

- (void)httpRePrint {
  NSDictionary *myDictionary = @{@"billId" : self.model.fid};
  [MBProgressHUD j_loading:@"打印中…"];
  [kHttp GET:kRePrintUrl parameters:myDictionary complete:^(id  _Nullable response, NSError * _Nullable error) {
    [MBProgressHUD j_hideLoadingView];
    if (kRsSuccess(response)) {
      [MBProgressHUD j_success:@"打印成功!" complete:nil];
    }else{
      kShowRsMsg(response);
    }
  }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end