Commit 4f34f0e9 authored by Sandy's avatar Sandy

核销订单列表的查询接口调用,登录model修改“

git status
parent e6bc26cb
This diff is collapsed.
This diff is collapsed.
//
// AccountRecordTableViewCell.h
// Car
//
// Created by Javen on 2017/2/10.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AccountRecordTableViewCell : UITableViewCell
/**
单号
*/
@property (weak, nonatomic) IBOutlet UILabel *labelTitle;
/**
提现工分
*/
@property (weak, nonatomic) IBOutlet UILabel *labelCash;
/**
申请时间
*/
@property (weak, nonatomic) IBOutlet UILabel *labelTime;
/**
状态图片
*/
@property (weak, nonatomic) IBOutlet UIImageView *imgState;
/**
转账时间
*/
@property (weak, nonatomic) IBOutlet UILabel *labelTransferTime;
- (void)configCell:(DrawCashBillEntity *)model;
@end
//
// AccountRecordTableViewCell.m
// Car
//
// Created by Javen on 2017/2/10.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "AccountRecordTableViewCell.h"
#import "AccountStateModel.h"
@implementation AccountRecordTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)configCell:(DrawCashBillEntity *)model {
self.labelTitle.text = model.billNumber;
self.imgState.image = [UIImage imageNamed:[AccountStateModel stateFrom:model.state].imgName];
self.labelTime.text = model.createDate;
self.labelCash.text = [NSString stringWithFormat:@"%@分 (金额%@元)",
[CalculateHelper getMoneyStringFrom:model.workpoint],
[CalculateHelper getMoneyStringFrom:model.cash]];
self.labelTransferTime.text = model.finishDate ? model.finishDate : @"__ __ __ __ —:—:—";
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
// AccountRecordViewController.h
// Car
//
// Created by Javen on 2017/2/9.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "BaseViewController.h"
@interface AccountRecordViewController : BaseListViewController
@end
//
// AccountRecordViewController.m
// Car
//
// Created by Javen on 2017/2/9.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "AccountRecordViewController.h"
#import "AccountRecordTableViewCell.h"
@interface AccountRecordViewController ()
@property (strong, nonatomic) WithdrawQueryDefintion *param;
@end
@implementation AccountRecordViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"提现记录";
[self httpRequest];
// Do any additional setup after loading the view.
}
- (void)httpRequest {
WS(weakSelf);
[MBProgressHUD j_loading];
[kHttp POST:kUserCashRecord parameters:[self.param toDictionary] complete:^(id _Nullable response, NSError * _Nullable error) {
[MBProgressHUD j_hideLoadingView];
if (kRsSuccess(response)) {
for (NSDictionary *dict in response[@"data"][@"records"]) {
DrawCashBillEntity *model = [[DrawCashBillEntity alloc] initWithDictionary:dict error:nil];
[weakSelf.arrData addObject:model];
}
[weakSelf listTableViewReloadData];
}else{
kFalseHttpTips;
}
}];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
AccountRecordTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccountRecordTableViewCell" forIndexPath:indexPath];
DrawCashBillEntity *model = self.arrData[indexPath.row];
[cell configCell:model];
return cell;
}
- (void)listDidSelect:(id)model {
}
- (WithdrawQueryDefintion *)param {
if (!_param) {
_param = [[WithdrawQueryDefintion alloc] init];
QueryOrder *order = [[QueryOrder alloc] init];
order.field = @"createDate";
order.direction = @"desc";
_param.orders = (NSArray<QueryOrder> *)@[order];
_param.userId = kUser.fid;
_param.pageSize = self.pageSize;
}
_param.pageNumber = self.page;
return _param;
}
- (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
//
// AccountViewController.h
// Car
//
// Created by Javen on 2017/2/8.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "BaseViewController.h"
typedef NS_ENUM(NSInteger, AccountViewControllerType) {
AccountViewControllerTypeBinding,
AccountViewControllerTypeUnBing
};
@interface AccountViewController : BaseViewController
@property (nonatomic, assign) AccountViewControllerType type;
@end
//
// AccountViewController.m
// Car
//
// Created by Javen on 2017/2/8.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "AccountViewController.h"
#import "UMSocialManager.h"
#import <UMSocialCore/UMSocialCore.h>
#import "AccountRecordViewController.h"
@interface AccountViewController ()
/**
工分总额
*/
@property (weak, nonatomic) IBOutlet UILabel *labelTotalScore;
/**
可换工分
*/
@property (weak, nonatomic) IBOutlet UILabel *labelValidScore;
/**
工分
*/
@property (weak, nonatomic) IBOutlet UITextField *textFieldScore;
/**
工分提现说明
*/
@property (weak, nonatomic) IBOutlet UILabel *labelInfo;
/**
提醒绑定微信提示
*/
@property (weak, nonatomic) IBOutlet UILabel *labelToWechatInfo;
@property (weak, nonatomic) IBOutlet UIView *scoreView;
@property (weak, nonatomic) IBOutlet UIButton *btnBottom;
/**
请求体
*/
@property (strong, nonatomic) DrawCashBillEntity *param;
@end
@implementation AccountViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self configUI];
switch (self.type) {
case AccountViewControllerTypeUnBing:
[self unBinding];
break;
case AccountViewControllerTypeBinding:
[self isBinding];
break;
default:
break;
}
// Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self httpGetWorkPoint];
}
//已绑定
- (void)isBinding {
self.scoreView.hidden = NO;
UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"提现记录" style:UIBarButtonItemStyleDone target:self action:@selector(actionRecods)];
self.navigationItem.rightBarButtonItem = rightBtn;
[self.btnBottom setTitle:@"提交申请" forState:UIControlStateNormal];
[self httpGetWorkPoint];
}
//未绑定
- (void)unBinding {
self.scoreView.hidden = YES;
}
//界面设置
- (void)configUI {
self.title = @"工分提现";
//未绑定微信的底部的提示
NSString *contentStr = @"亲,您还没有绑定微信哦,工分提现需要先绑定微信哦,我们的提现金额会提到微信钱包中。";
NSRange range = [contentStr rangeOfString:@"提现金额会提到微信钱包中"];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:contentStr];
//设置:在0-3个单位长度内的内容显示成红色
[str addAttribute:NSForegroundColorAttributeName value:kMainColor range:range];
self.labelToWechatInfo.attributedText = str;
//输入工分动态计算金额
[self.textFieldScore addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventAllEditingEvents];
}
- (void)textFieldDidChange:(UITextField *)textField {
NSDecimalNumber *number = [CalculateHelper mul:textField.text num2:@(0.01)];
NSString *money = [CalculateHelper getMoneyStringFrom:number];
NSString *info = [NSString stringWithFormat:@"对应金额 %@元", money];
self.labelInfo.text = info;
}
#pragma mark - actions
- (void)actionRecods {
AccountRecordViewController *recordVC = [AccountRecordViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_MAIN];
[self.navigationController pushViewController:recordVC animated:YES];
}
- (IBAction)actionBottom:(id)sender {
switch (self.type) {
case AccountViewControllerTypeUnBing: {
[self bindWeChat];
} break;
case AccountViewControllerTypeBinding: {
WS(weakSelf);
kCanNotBeNil(self.textFieldScore.text, @"请输入提现工分!");
if ([self.textFieldScore.text doubleValue] > [self.labelValidScore.text doubleValue]) {
[MBProgressHUD j_error:@"可用工分不足!" complete:nil];
break;
}
[self alertTitle:@"确认提交?"
msg:nil
okAction:^(UIAlertAction *_Nullable action) {
[weakSelf httpSubmit];
}
cancelAction:nil];
break;
}
default:
break;
}
}
/**
绑定微信 第三方登录
*/
- (void)bindWeChat {
WS(weakSelf);
[[UMSocialManager defaultManager] getUserInfoWithPlatform:UMSocialPlatformType_WechatSession currentViewController:self completion:^(id result, NSError *error) {
if (error) {
[MBProgressHUD j_error:@"绑定出错,请重试!" complete:nil];
return ;
}
UMSocialUserInfoResponse *resp = result;
// 第三方登录数据(为空表示平台未提供)
// 授权数据
NSLog(@" uid: %@", resp.uid);
[weakSelf httpUploadUnionId:resp.uid];
NSLog(@" openid: %@", resp.openid);
NSLog(@" accessToken: %@", resp.accessToken);
NSLog(@" refreshToken: %@", resp.refreshToken);
NSLog(@" expiration: %@", resp.expiration);
// 用户数据
NSLog(@" name: %@", resp.name);
NSLog(@" iconurl: %@", resp.iconurl);
NSLog(@" gender: %@", resp.gender);
// 第三方平台SDK原始数据
NSLog(@" originalResponse: %@", resp.originalResponse);
}];
}
- (void)httpUploadUnionId:(NSString *)uid {
NSDictionary *param = @{@"userId":kUser.fid,
@"unionId":uid};
WS(weakSelf);
[kHttp POST:kModifyUserWxUid parameters:param complete:^(id _Nullable response, NSError * _Nullable error) {
if (kRsSuccess(response)) {
[MBProgressHUD j_success:@"绑定成功!" complete:^{
kUser.wxOpenId = response[@"data"];
weakSelf.type = AccountViewControllerTypeBinding;
[weakSelf isBinding];
}];
}else{
kFalseHttpTips;
}
}];
}
- (void)httpSubmit {
[MBProgressHUD j_loading];
WS(weakSelf);
[kHttp POST:kCashApply
parameters:[self.param toDictionary]
complete:^(id _Nullable response, NSError *_Nullable error) {
if (kRsSuccess(response)) {
[MBProgressHUD j_success:@"提交成功!" complete:nil];
weakSelf.labelInfo.text = @"对应金额 0.00元";
weakSelf.textFieldScore.text = nil;
[weakSelf httpGetWorkPoint];
} else {
kFalseHttpTips;
}
}];
}
- (void)httpGetWorkPoint {
NSDictionary *param = @{ @"userId" : kUser.fid };
WS(weakSelf);
[kHttp GET:kAccountGetUrl
parameters:param
complete:^(id _Nullable response, NSError *_Nullable error) {
if (kRsSuccess(response)) {
StationUserAcctEntity *acc = [[StationUserAcctEntity alloc] initWithDictionary:response[@"data"] error:nil];
weakSelf.labelTotalScore.text = [NSString stringWithFormat:@"%@", acc.balance];
weakSelf.labelValidScore.text = [NSString stringWithFormat:@"%@", acc.drawBalance ? acc.drawBalance : @"0"];
}
}];
}
- (DrawCashBillEntity *)param {
if (!_param) {
_param = [[DrawCashBillEntity alloc] init];
_param.applicantId = kUser.fid;
_param.applicantName = kUser.realName;
}
_param.workpoint = [NSDecimalNumber decimalNumberWithString:self.textFieldScore.text];
_param.cash = [CalculateHelper mul:self.textFieldScore.text num2:@(0.01)];
return _param;
}
- (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
//
// AccountStateModel.h
// Car
//
// Created by Javen on 2017/2/10.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "BaseStateModel.h"
@interface AccountStateModel : BaseStateModel
@end
//
// AccountStateModel.m
// Car
//
// Created by Javen on 2017/2/10.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "AccountStateModel.h"
@implementation AccountStateModel
+ (BaseStateModel *)stateFrom:(NSString *)state {
BaseStateModel *model = [BaseStateModel stateModel];
if ([state isEqualToString:@"approving"]) {
model.text = @"待审核";
model.imgName = @"state_audit";
}else if ([state isEqualToString:@"approved"]){
model.text = @"转账中";
model.imgName = @"state_transfer_account";
}else if ([state isEqualToString:@"rejected"]){
model.text = @"已拒绝";
model.imgName = @"state_reject";
}else if ([state isEqualToString:@"finished"]){
model.text = @"已完成";
model.imgName = @"state_complete";
}else if ([state isEqualToString:@"returned"]){
model.text = @"已退还";
model.imgName = @"state_returned";
}
return model;
}
@end
//
// BillListViewController.h
// Car
//
// Created by Javen on 2016/12/27.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import "BaseListViewController.h"
@interface BillListViewController : BaseListViewController
@end
//
// BillListViewController.m
// Car
//
// Created by Javen on 2016/12/27.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import "BillListViewController.h"
#import "HttpCilent.h"
#import "BillListTableViewCell.h"
#import "BillHeaderModel.h"
@interface BillListViewController ()
@property (nonatomic, strong) NSMutableDictionary *dicMonthData;
@property (nonatomic, strong) NSMutableArray *arrSortedData;
@property (nonatomic, strong) NSMutableArray *arrSortedMonths;
@end
@implementation BillListViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"工分账单";
[self httpRequest];
self.tableView.mj_header = nil;
WS(weakSelf);
self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
weakSelf.page++;
[weakSelf httpRequest];
}];
// Do any additional setup after loading the view.
}
- (void)httpRequest {
NSDictionary *myDictionary = @{@"userId" : kUser.fid,
@"pageNumber" : @(self.page),
@"pageSize" : @(self.pageSize)};
[MBProgressHUD j_loading];
WS(weakSelf);
[kHttp POST:kAccountQueryUrl parameters:myDictionary complete:^(id _Nullable response, NSError * _Nullable error) {
[MBProgressHUD j_hideLoadingView];
if (kRsSuccess(response)) {
for (NSDictionary *dict in response[@"data"][@"records"]) {
StationUserAcctHisEntity *model = [[StationUserAcctHisEntity alloc] initWithDictionary:dict error:nil];
[weakSelf.dicMonthData setObject:model forKey:[model.createDate substringToIndex:7]];
[weakSelf.arrData addObject:model];
}
[weakSelf configData];
[weakSelf listTableViewReloadData];
}else{
kShowRsMsg(response);
if (self.page > 0) {
self.page--;
}
}
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.arrSortedMonths.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.arrSortedData[section] count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 30;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UITableViewCell *header = [tableView dequeueReusableCellWithIdentifier:@"headerCell"];
BillHeaderModel *model = self.arrSortedMonths[section];
UILabel *month = (UILabel *)[header viewWithTag:1111];
month.text = model.date;
UILabel *money = (UILabel *)[header viewWithTag:2222];
money.text = model.total;
return header.contentView;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
BillListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BillListTableViewCell" forIndexPath:indexPath];
[cell configWithArray:self.arrSortedData indexPath:indexPath];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
kDebugIndex(indexPath);
}
- (void)listDidSelect:(id)model {
}
- (void)configData {
[self.arrSortedData removeAllObjects];
[self.arrSortedMonths removeAllObjects];
//先把整体倒序排序一遍
NSArray *tempSortData = [self.arrData sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
StationUserAcctHisEntity *a = (StationUserAcctHisEntity *)obj1;
StationUserAcctHisEntity *b = (StationUserAcctHisEntity *)obj2;
return [b.createDate compare:a.createDate];
}];
NSArray *months = self.dicMonthData.allKeys;
NSArray *sortMonths = [months sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
return [obj2 compare:obj1];
}];
NSInteger count = sortMonths.count;
for (NSInteger i = 0; i < count; i++) {
NSDecimalNumber *monthTotal = [CalculateHelper decimalNumber:0];
NSMutableArray *array = [NSMutableArray array];
for (StationUserAcctHisEntity *model in tempSortData) {
NSString *timeStr = [model.createDate substringToIndex:7];
if ([timeStr isEqualToString:sortMonths[i]]) {
CLog(@"%@", model.createDate);
monthTotal = [CalculateHelper add:monthTotal num2:model.occur];
[array addObject:model];
}
}
BillHeaderModel *headerModel = [[BillHeaderModel alloc] init];
headerModel.date = sortMonths[i];
headerModel.total = [CalculateHelper moneyStringWithPrefix:monthTotal];
[self.arrSortedMonths addObject:headerModel];
[self.arrSortedData addObject:array];
}
}
#pragma mark - lazy
- (NSMutableDictionary *)dicMonthData {
if (!_dicMonthData) {
_dicMonthData = [NSMutableDictionary dictionary];
}
return _dicMonthData;
}
- (NSMutableArray *)arrSortedData {
if (!_arrSortedData) {
_arrSortedData = [NSMutableArray array];
}
return _arrSortedData;
}
- (NSMutableArray *)arrSortedMonths {
if (!_arrSortedMonths) {
_arrSortedMonths = [NSMutableArray array];
}
return _arrSortedMonths;
}
- (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
......@@ -56,7 +56,7 @@
}
- (void)configUI {
self.title = @"核销卡券";
self.title = @"核销订单";
UIBarButtonItem *rightBtn =
[[UIBarButtonItem alloc] initWithTitle:@"确认查询"
style:UIBarButtonItemStyleDone
......@@ -109,22 +109,22 @@
*/
- (void)httpCheckCard {
CheckTicketRequest *param = [[CheckTicketRequest alloc] init];
[MBProgressHUD j_loading];
param.checkDate = [[NSDate date] httpParameterString];
param.checkManId = kUser.fid;
param.checkManName = kUser.realName;
param.ticketNumber = self.card.ticketNumber;
WS(weakSelf);
[kHttp POST:kCheckTicketUrl parameters:[param toDictionary] complete:^(id _Nullable response, NSError * _Nullable error) {
[MBProgressHUD j_hideLoadingView];
if (kRsSuccess(response)) {
[MBProgressHUD j_textOnly:@"销券成功!"];
weakSelf.card.state = @"used";
[weakSelf configUIWithCard];
}else{
kShowRsMsg(response);
}
}];
// [MBProgressHUD j_loading];
// param.checkDate = [[NSDate date] httpParameterString];
// param.checkManId = kUser.fid;
// param.checkManName = kUser.realName;
// param.ticketNumber = self.card.ticketNumber;
// WS(weakSelf);
// [kHttp POST:kCheckTicketUrl parameters:[param toDictionary] complete:^(id _Nullable response, NSError * _Nullable error) {
// [MBProgressHUD j_hideLoadingView];
// if (kRsSuccess(response)) {
// [MBProgressHUD j_textOnly:@"销券成功!"];
// weakSelf.card.state = @"used";
// [weakSelf configUIWithCard];
// }else{
// kShowRsMsg(response);
// }
// }];
}
- (void)didReceiveMemoryWarning {
......
......@@ -9,9 +9,7 @@
#import "LeftTableViewController.h"
#import "HttpCilent.h"
#import "ModifyPswTableViewController.h"
#import "BillListViewController.h"
#import "ScanViewController.h"
#import "AccountViewController.h"
@interface LeftTableViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imgUserIcon;
@property (weak, nonatomic) IBOutlet UILabel *labelName;
......@@ -34,19 +32,19 @@
}
- (void)httpRequest {
NSDictionary *param = @{@"userId":kUser.fid};
WS(weakSelf);
[kHttp GET:kAccountGetUrl parameters:param complete:^(id _Nullable response, NSError * _Nullable error) {
if (kRsSuccess(response)) {
weakSelf.acct = [[StationUserAcctEntity alloc] initWithDictionary:response[@"data"] error:nil];
[weakSelf configUIWithAcct];
}
}];
// NSDictionary *param = @{@"userId":kUser.fid};
// WS(weakSelf);
// [kHttp GET:kAccountGetUrl parameters:param complete:^(id _Nullable response, NSError * _Nullable error) {
// if (kRsSuccess(response)) {
// weakSelf.acct = [[StationUserAcctEntity alloc] initWithDictionary:response[@"data"] error:nil];
// [weakSelf configUIWithAcct];
// }
// }];
}
- (void)configUIWithAcct {
self.labelName.text = kUser.realName;
self.labelScore.text = [CalculateHelper getMoneyStringFrom:self.acct.balance];
// self.labelName.text = kUser.realName;
// self.labelScore.text = [CalculateHelper getMoneyStringFrom:self.acct.balance];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
......
......@@ -100,7 +100,7 @@
andRightView:nil
andBackgroundImage:[UIImage imageNamed:@"side_bg"]];
kGlobal.loginResult =
[[LoginResult alloc] initWithDictionary:response[@"data"]
[[MerchantLoginResult alloc] initWithDictionary:response[@"data"]
error:nil];
kGlobal.sideSlipVC = sideVC;
kGlobal.mainNaVC = mainNaVC;
......
......@@ -14,18 +14,8 @@
#import "OrderDetailViewController.h"
@interface MainViewController ()
@property (strong, nonatomic) OrderListFilterViewController *filterVC;
@property (strong, nonatomic) OrderQueryDefintion *param;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintTop;
@property (weak, nonatomic) IBOutlet UIButton *btnSelectAll;
@property (weak, nonatomic) IBOutlet UIButton *btnCheck;
@property (strong, nonatomic) NSMutableSet *setBillToCheck;
@property (weak, nonatomic) IBOutlet UILabel *labelCount;
@property (weak, nonatomic) IBOutlet UILabel *labelAmount;
@property (strong, nonatomic) ProductOrderQueryDefintion *param;
/**
底部的面板
*/
@property (weak, nonatomic) IBOutlet UIView *bottomBoard;
@property (strong, nonatomic) TradeStatisticsResult *total;
@end
......@@ -34,8 +24,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self httpRequest];
self.constraintTop.constant = 0;
[self.view layoutIfNeeded];
self.view.backgroundColor = [UIColor whiteColor];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionNoti:) name:kNotiSelectBill object:nil];
}
......@@ -58,14 +46,7 @@
if (kRsSuccess(response)) {
weakSelf.total = [[TradeStatisticsResult alloc] initWithDictionary:response[@"data"][@"total"] error:nil];
for (NSDictionary *dict in response[@"data"][@"records"]) {
OrderListModel *model = [[OrderListModel alloc] initWithDictionary:dict error:nil];
if (weakSelf.btnSelectAll.isSelected) {
model.isSelected = YES;
}
[weakSelf.arrData addObject:model];
}
weakSelf.bottomBoard.hidden = weakSelf.arrData.count == 0;
[weakSelf listTableViewReloadData];
} else {
......@@ -90,7 +71,7 @@
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
OrderListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OrderListTableViewCell" forIndexPath:indexPath];
[cell configCellArray:self.arrData indexPath:indexPath isShow:self.btnCheck.isSelected isAll:self.btnSelectAll.selected];
// [cell configCellArray:self.arrData indexPath:indexPath isShow:self.btnCheck.isSelected isAll:self.btnSelectAll.selected];
return cell;
}
......@@ -102,9 +83,7 @@
}
- (void)listDidSelect:(id)model {
// if (self.btnCheck.isSelected) {
// return;
// }
OrderDetailViewController *detailVC = [OrderDetailViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_MAIN];
detailVC.model = model;
[self.navigationController pushViewController:detailVC animated:YES];
......@@ -128,93 +107,7 @@
[self.filterVC showFilterView];
}
}
- (IBAction)actionCheck:(UIButton *)sender {
if (!sender.isSelected) {
sender.selected = YES;
[self.tableView reloadData];
self.constraintTop.constant = 44;
[UIView animateWithDuration:0.3
animations:^{
[self.view layoutIfNeeded];
}];
} else {
if (self.btnSelectAll.isSelected && self.setBillToCheck.count == 0) {
[self actionCancelCheck:nil];
return;
}
if (self.setBillToCheck.count == 0) {
[MBProgressHUD j_error:@"请选择对账的单据!" complete:nil];
return;
}
[self httpCheckBill];
}
}
/**
全选操作
@param isAll 是否全选
*/
- (void)configSelectData:(BOOL)isAll {
for (OrderListModel *model in self.arrData) {
if (![model.checkState isEqualToString:@"checked"]) {
model.isSelected = isAll;
}
}
[self.tableView reloadData];
}
- (void)setTotal:(TradeStatisticsResult *)total {
_total = total;
self.labelCount.text = [NSString stringWithFormat:@"%lld", total.orderCount];
self.labelAmount.text = [NSString stringWithFormat:@"¥ %.2f", total.totalAmount ? total.totalAmount : 0];
}
- (IBAction)actionSelectAll:(UIButton *)sender {
sender.selected = !sender.isSelected;
[self configSelectData:sender.isSelected];
}
- (IBAction)actionCancelCheck:(id)sender {
self.constraintTop.constant = 0;
[UIView animateWithDuration:0.3
animations:^{
[self.view layoutIfNeeded];
}];
self.btnCheck.selected = NO;
[self.tableView reloadData];
}
- (void)actionNoti:(NSNotification *)noti {
NSLog(@"%@", noti);
OrderListModel *model = noti.object;
if (model.isSelected) {
[self.setBillToCheck addObject:model];
} else {
[self.setBillToCheck removeObject:model];
}
self.btnSelectAll.selected = [self configIsAll];
}
/**
判断是否全选
*/
- (BOOL)configIsAll {
for (OrderListModel *model in self.arrData) {
if (![model.checkState isEqualToString:@"checked"]) {
if (!model.isSelected) {
return NO;
}
}
}
return YES;
}
- (void)showShadow {
self.shadow.hidden = NO;
......@@ -224,32 +117,6 @@
self.shadow.hidden = YES;
}
- (void)httpCheckBill {
CheckOrderRequest *request = [[CheckOrderRequest alloc] init];
request.userId = kUser.fid;
NSMutableArray *arr = [NSMutableArray array];
for (OrderListModel *model in self.setBillToCheck.allObjects) {
[arr addObject:model.fid];
}
request.orderIds = arr;
WS(weakSelf);
[kHttp POST:kUrlCheck
parameters:request.toDictionary
complete:^(id _Nullable response, NSError *_Nullable error) {
if (kRsSuccess(response)) {
[MBProgressHUD j_success:@"对账成功!" complete:nil];
for (OrderListModel *model in weakSelf.setBillToCheck.allObjects) {
model.checkState = @"checked";
}
[weakSelf.setBillToCheck removeAllObjects];
[weakSelf.tableView reloadData];
} else {
kShowRsMsg(response);
}
}];
}
#pragma mark - lazy
- (OrderListFilterViewController *)filterVC {
if (!_filterVC) {
......@@ -264,35 +131,20 @@
return _filterVC;
}
- (OrderQueryDefintion *)param {
- (ProductOrderQueryDefintion *)param {
if (!_param) {
_param = [[OrderQueryDefintion alloc] init];
_param = [[ProductOrderQueryDefintion alloc] init];
QueryOrder *order = [[QueryOrder alloc] init];
order.field = @"payTime";
order.direction = @"desc";
_param.orders = (NSArray<QueryOrder> *) @[ order ];
_param.userId = kUser.fid;
_param.state = @"paid, invalid";
_param.merchantId = kUser.fid;
// _param.state = @"paid, invalid";
_param.beginDate = [[[NSDate date] yearMonthDayString] stringByAppendingString:@" 00:00:00"];
_param.endDate = [[[NSDate date] yearMonthDayString] stringByAppendingString:@" 23:59:59"];
}
return _param;
}
//
//- (NSMutableArray *)arrBillIdToCheck {
// if (!_arrBillIdToCheck) {
// _arrBillIdToCheck = [NSMutableArray array];
// }
//
// return _arrBillIdToCheck;
//}
- (NSMutableSet *)setBillToCheck {
if (!_setBillToCheck) {
_setBillToCheck = [NSMutableSet set];
}
return _setBillToCheck;
}
- (UIView *)shadow {
if (!_shadow) {
......
......@@ -42,22 +42,22 @@
- (void)httpChangePsw {
ModifyPasswordRequest *param = [[ModifyPasswordRequest alloc] init];
param.userName = kUser.userName;
param.oldPassword = self.textFieldOldPsw.text;
param.fnewPassword = self.textFieldNewPsw.text;
[MBProgressHUD j_loading:@"修改中…"];
WS(weakSelf);
[kHttp POST:kModifyPswUrl parameters:[param toDictionary] complete:^(id _Nullable response, NSError * _Nullable error) {
[MBProgressHUD j_hideLoadingView];
if (kRsSuccess(response)) {
[MBProgressHUD j_success:@"密码修改成功!" complete:^{
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
}else{
kShowRsMsg(response);
}
}];
// param.userName = kUser.userName;
// param.oldPassword = self.textFieldOldPsw.text;
// param.fnewPassword = self.textFieldNewPsw.text;
// [MBProgressHUD j_loading:@"修改中…"];
// WS(weakSelf);
// [kHttp POST:kModifyPswUrl parameters:[param toDictionary] complete:^(id _Nullable response, NSError * _Nullable error) {
// [MBProgressHUD j_hideLoadingView];
// if (kRsSuccess(response)) {
// [MBProgressHUD j_success:@"密码修改成功!" complete:^{
// [weakSelf.navigationController popViewControllerAnimated:YES];
// }];
// }else{
// kShowRsMsg(response);
//
// }
// }];
}
......
......@@ -10,7 +10,7 @@
@interface OrderListFilterViewController : BaseViewController
@property (nonatomic, assign) BOOL isOpen;
@property (strong, nonatomic) OrderQueryDefintion *param;
@property (strong, nonatomic) ProductOrderQueryDefintion *param;
@property (nonatomic, copy) void (^blockSubmit)(void);
- (void)showFilterView;
......
......@@ -14,7 +14,7 @@
/**
阴影
*/
@property (weak, nonatomic) IBOutlet UIView *shadow;
@property (strong, nonatomic) UIView *shadow;
/**
整个输入面板
......@@ -32,11 +32,6 @@
@property (weak, nonatomic) IBOutlet DateTextField *textFieldDate;
@property (weak, nonatomic) IBOutlet DateTextField *textFieldEndDate;
/**
加油员
*/
@property (weak, nonatomic) IBOutlet UITextField *textFieldStationUser;
@end
@implementation OrderListFilterViewController
......@@ -48,6 +43,9 @@
self.textFieldDate.type = DateTextFieldTime;
self.textFieldEndDate.type = DateTextFieldTime;
self.textFieldDate.text = [[[NSDate date] yearMonthDayString] stringByAppendingString:@" 00:00:00"];
self.shadow = [[UIView alloc] initWithFrame:self.view.bounds];
self.shadow.backgroundColor = [UIColor clearColor];
[self.view insertSubview:self.shadow belowSubview:self.board];
}
- (IBAction)actionBac:(id)sender {
......@@ -56,7 +54,7 @@
- (void)configParam {
self.param.billNumberLike = self.textFieldBillNumber.text;
self.param.userNameLike = self.textFieldStationUser.text;
// self.param.userNameLike = self.textFieldStationUser.text;
self.param.beginDate = self.textFieldDate.text;
self.param.endDate = self.textFieldEndDate.text;;
}
......@@ -68,10 +66,10 @@
*/
- (IBAction)actionReset:(id)sender {
self.param.billNumberLike = nil;
self.param.userNameLike = nil;
// self.param.userNameLike = nil;
self.param.endDate = nil;
self.textFieldDate.text = nil;
self.textFieldStationUser.text = nil;
// self.textFieldStationUser.text = nil;
self.textFieldBillNumber.text = nil;
}
......@@ -86,53 +84,18 @@
}
}
- (IBAction)actionChooseIsChecked:(UIButton *)sender {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请选择" message:nil preferredStyle:UIAlertControllerStyleAlert];
WS(weakSelf);
UIAlertAction *actionAll = [UIAlertAction actionWithTitle:@"全部"
style:(UIAlertActionStyleDefault)
handler:^(UIAlertAction *_Nonnull action) {
[sender setTitle:@"全部" forState:UIControlStateNormal];
weakSelf.param.checkState = nil;
}];
[alert addAction:actionAll];
UIAlertAction *actionChecked = [UIAlertAction actionWithTitle:@"已对账"
style:(UIAlertActionStyleDefault)
handler:^(UIAlertAction *_Nonnull action) {
[sender setTitle:@"已对账" forState:UIControlStateNormal];
weakSelf.param.checkState = @"checked";
}];
[alert addAction:actionChecked];
UIAlertAction *actionUnchecked = [UIAlertAction actionWithTitle:@"未对账"
style:(UIAlertActionStyleDefault)
handler:^(UIAlertAction *_Nonnull action) {
[sender setTitle:@"未对账" forState:UIControlStateNormal];
weakSelf.param.checkState = @"unchecked";
}];
[alert addAction:actionUnchecked];
UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:nil];
[alert addAction:actionCancel];
[self presentViewController:alert animated:YES completion:nil];
}
- (void)hideFilterView {
HIDE_KEYBOARD;
self.isOpen = NO;
// self.constraintHeight.constant = 0;
self.constraintHeight.constant = 0;
[UIView animateWithDuration:0.7
delay:0
usingSpringWithDamping:0.9
initialSpringVelocity:1.0
options:UIViewAnimationOptionCurveLinear
animations:^{
self.board.transform = CGAffineTransformMakeScale(1, 0);
self.shadow.backgroundColor = [UIColor clearColor];
// [self.view layoutIfNeeded];
[self.view layoutIfNeeded];
}
completion:^(BOOL finished) {
[self.view removeFromSuperview];
......@@ -141,7 +104,7 @@
- (void)showFilterView {
self.isOpen = YES;
// self.constraintHeight.constant = 320;
self.constraintHeight.constant = 220;
[UIView animateWithDuration:0.7
delay:0
usingSpringWithDamping:0.9
......@@ -149,8 +112,7 @@
options:UIViewAnimationOptionCurveLinear
animations:^{
self.shadow.backgroundColor = [UIColor colorWithWhite:0.3 alpha:0.3];
// [self.view layoutIfNeeded];
self.board.transform = CGAffineTransformMakeScale(1, 0);
[self.view layoutIfNeeded];
}
completion:nil];
}
......
......@@ -26,7 +26,8 @@ static NSString *const kModifyPswUrl = @"stationUser/modifyPassword";
static NSString *const kResetPswUrl = @"stationUser/resetPassword";
static NSString *const kGetUserInfoUrl = @"account/get";
static NSString *const kOrderQueryUrl = @"order/query";
//查询核销订单
static NSString *const kOrderQueryUrl = @"productorder/query";
//查询账户信息
static NSString *const kAccountGetUrl = @"account/get";
//查询加油员账户流水列表
......
This diff is collapsed.
This diff is collapsed.
......@@ -11,7 +11,7 @@
#import "WWSideslipViewController.h"
#import "MainViewController.h"
#define kGlobal [GlobalInstance shareInstance]
#define kUser kGlobal.loginResult.user
#define kUser kGlobal.loginResult.merchantUser
@interface GlobalInstance : NSObject
{
......@@ -24,7 +24,7 @@
/**
登录时返回的数据
*/
@property (strong, nonatomic) LoginResult *loginResult;
@property (strong, nonatomic) MerchantLoginResult *loginResult;
/**
全局可访问的侧边栏vc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment