123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- //
- // TradeViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/4/13.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class TradeViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate {
- @IBOutlet weak var btnSort: UIButton!
- @IBOutlet weak var tableView: UITableView!
- @IBOutlet weak var imgBackgroud: UIImageView!
- @IBOutlet weak var txtCode: UITextField!
- @IBOutlet weak var viewMenu: UIView!
- @IBOutlet weak var viewRemark: UIView!
- @IBOutlet weak var viewMoney: UIView!
- @IBOutlet weak var allNumLabel: UILabel!
- @IBOutlet weak var allMoneyLabel: UILabel!
- var rightMenu: CommonRightMenu!
- var rightMenuhk: CommonRightMenuHK!
- var rightMenuky: CommonRightMenuKY!
- var rightMenuks: CommonRightMenuKS!
- var rightMenuhhsf: CommonRightMenuHSF!
- var queryEntity: QueryEntity!
- var machineTypeId: String!
- var machineType: String?
- var titleStr: String?
- override func viewDidLoad() {
- super.viewDidLoad()
- let index: NSInteger = brandIdList.lastIndex(of: machineTypeId) ?? 0
- machineType = brandList[index]
- queryEntity = QueryEntity()
- let viewNav = (CommonViewUntils.getViewForXIB(xibName: "NavView") as! NavView)
- viewNav.initView(title: titleStr ?? "") {[weak self] (index, _) in
- if index == 0 {
- self!.handleBack()
- }
- }
- self.view.addSubview(viewNav)
- viewNav.marginTop(top: 0)
- self.view.addSubview(viewNav)
- viewNav.marginTop(top: 0)
- viewMenu.marginTop(top: viewNav.bottom())
- txtCode.setCornerRadius(size: 4)
- txtCode.setContentMarginLeft(leftWidth: 15)
- txtCode.setContentMarginRight(rightWidth: 30)
- imgBackgroud.setSizeHeight(height: viewMenu.bottom())
- viewRemark.marginTop(top: 0, view: imgBackgroud)
- viewMoney.frame.size.width = SCREEN_WIDTH
- viewMoney.marginTop(top: 0, view: viewRemark)
- tableView.marginTop(top: 1, view: viewMoney)
- tableView.setSizeHeight(height: ScreenHeight - imgBackgroud.height() - 49 - 35)
- tableView.register(UINib(nibName: "TradeTableViewCell", bundle: nil), forCellReuseIdentifier: "TradeTableViewCell")
- tableView.delegate = self
- tableView.dataSource = self
- tableView.separatorStyle = .none
- tableView.showsVerticalScrollIndicator = false
- tableView.estimatedRowHeight = 100
- txtCode.delegate = self
- txtCode.returnKeyType = .search
- tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
- self!.currentPage = 1
- self!.loadData()
- })
- tableView.mj_header?.lastUpdatedTimeKey = "ShowTableViewCell"
- tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
- self!.currentPage += 1
- self!.loadData()
- })
- tableView.mj_header?.beginRefreshing()
- }
- // MARK: =============加载数据===============
- func loadData() {
- let url = RequestURL.transactionListPage
- let params = NSMutableDictionary()
- params.setValue(machineTypeId, forKey: "machineTypeId")
- params.setValue(queryEntity.startTime == "选择开始日期" ? "" : queryEntity.startTime, forKey: "timeStart")
- params.setValue(queryEntity.endTime == "选择截止日期" ? "" : queryEntity.endTime, forKey: "timeEnd")
- params.setValue(queryEntity.cardType, forKey: "cardType")
- params.setValue(queryEntity.busType, forKey: "busType")
- params.setValue(queryEntity.payType, forKey: "payType")
- params.setValue(queryEntity.depositTrade, forKey: "depositTrade")
- params.setValue(queryEntity.settleWay, forKey: "settleWay")
- params.setValue(queryEntity.deviceType, forKey: "deviceType")
- if btnSort.isSelected {
- params.setValue("asc", forKey: "sortType")
- } else {
- params.setValue("desc", forKey: "sortType")
- }
- params.setValue(txtCode.text!, forKey: "likeStr")
- loadDataList(url: url, params: params, tableView: tableView, tag: 1001)
- }
- func loadProType() {
- if arrType.count > 0 {
- returnData(tag: 1002)
- return
- }
- let url = RequestURL.machineTypeList
- let params = NSMutableDictionary()
- params.setValue(CommonValue.getUserId(), forKey: "userId")
- loadDataList(url: url, params: params, tag: 1002, array: arrType)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- self.allNumLabel.text = self.dicData["XTransactionDataCount"] as? String
- self.allMoneyLabel.text = self.dicData["XTransactionDataTotal"] as? String
- tableView.reloadData()
- } else if tag == 1002 {
- if rightMenu == nil || rightMenuhk == nil || rightMenuky == nil || rightMenuks == nil || rightMenuhhsf == nil{
- if machineTypeId == "2" {
- rightMenu = (CommonViewUntils.getViewForXIB(xibName: "CommonRightMenu") as! CommonRightMenu)
- rightMenu.initView(arrType: arrType) {[weak self] (queryEntityTemp) in
- self!.queryEntity.typeID = queryEntityTemp.typeID
- self!.queryEntity.startTime = queryEntityTemp.startTime
- self!.queryEntity.endTime = queryEntityTemp.endTime
- self!.queryEntity.cardType = queryEntityTemp.cardType
- self!.queryEntity.busType = queryEntityTemp.busType
- self!.queryEntity.payType = queryEntityTemp.payType
- self!.queryEntity.depositTrade = queryEntityTemp.depositTrade
- self!.queryEntity.settleWay = queryEntityTemp.settleWay
- self!.tableView.mj_header?.beginRefreshing()
- }
- rightMenu.showMenu(paretnView: self.view)
- }else if machineTypeId == "4" {
- rightMenuky = (CommonViewUntils.getViewForXIB(xibName: "CommonRightMenuKY") as! CommonRightMenuKY)
- rightMenuky.initView(arrType: arrType) {[weak self] (queryEntityTemp) in
- self!.queryEntity.typeID = queryEntityTemp.typeID
- self!.queryEntity.startTime = queryEntityTemp.startTime
- self!.queryEntity.endTime = queryEntityTemp.endTime
- self!.queryEntity.cardType = queryEntityTemp.cardType
- self!.queryEntity.busType = queryEntityTemp.busType
- self!.queryEntity.payType = queryEntityTemp.payType
- self!.queryEntity.depositTrade = queryEntityTemp.depositTrade
- self!.queryEntity.settleWay = queryEntityTemp.settleWay
- self!.tableView.mj_header?.beginRefreshing()
- }
- rightMenuky.showMenu(paretnView: self.view)
- }else if machineTypeId == "4e7c6d802cf149e9b8e1fc0efca4e965" {
- rightMenuks = (CommonViewUntils.getViewForXIB(xibName: "CommonRightMenuKS") as! CommonRightMenuKS)
- rightMenuks.initView(arrType: arrType) {[weak self] (queryEntityTemp) in
- self!.queryEntity.typeID = queryEntityTemp.typeID
- self!.queryEntity.startTime = queryEntityTemp.startTime
- self!.queryEntity.endTime = queryEntityTemp.endTime
- self!.queryEntity.cardType = queryEntityTemp.cardType
- self!.queryEntity.busType = queryEntityTemp.busType
- self!.queryEntity.depositTrade = queryEntityTemp.depositTrade
- self!.queryEntity.settleWay = queryEntityTemp.settleWay
- self!.queryEntity.deviceType = queryEntityTemp.deviceType
- self!.tableView.mj_header?.beginRefreshing()
- }
- rightMenuks.showMenu(paretnView: self.view)
- }else if machineTypeId == "777" || machineTypeId == "888" || machineTypeId == "999" || machineTypeId == "9999" {
- rightMenuhhsf = (CommonViewUntils.getViewForXIB(xibName: "CommonRightMenuHSF") as! CommonRightMenuHSF)
- rightMenuhhsf.initView(arrType: arrType) {[weak self] (queryEntityTemp) in
- self!.queryEntity.typeID = queryEntityTemp.typeID
- self!.queryEntity.startTime = queryEntityTemp.startTime
- self!.queryEntity.endTime = queryEntityTemp.endTime
- self!.queryEntity.cardType = queryEntityTemp.cardType
- self!.queryEntity.depositTrade = queryEntityTemp.depositTrade
- self!.tableView.mj_header?.beginRefreshing()
- }
- rightMenuhhsf.showMenu(paretnView: self.view)
- }else {
- rightMenuhk = (CommonViewUntils.getViewForXIB(xibName: "CommonRightMenuHK") as! CommonRightMenuHK)
- rightMenuhk.initView(arrType: arrType) {[weak self] (queryEntityTemp) in
- self!.queryEntity.typeID = queryEntityTemp.typeID
- self!.queryEntity.startTime = queryEntityTemp.startTime
- self!.queryEntity.endTime = queryEntityTemp.endTime
- self!.queryEntity.cardType = queryEntityTemp.cardType
- self!.queryEntity.busType = queryEntityTemp.busType
- self!.queryEntity.payType = queryEntityTemp.payType
- self!.queryEntity.depositTrade = queryEntityTemp.depositTrade
- self!.queryEntity.settleWay = queryEntityTemp.settleWay
- self!.tableView.mj_header?.beginRefreshing()
- }
- rightMenuhk.showMenu(paretnView: self.view)
- }
- }
- }
- }
- override func returnError(tag: Int, type: String) {
- }
- var arrType = NSMutableArray()
- @IBAction func btnMenuClick(_ sender: AnyObject) {
- switch (sender as! UIButton).tag {
- case 1001: // 排序
- btnSort.isSelected = !btnSort.isSelected
- self.currentPage = 1
- loadData()
- break
- case 1002: // 筛选
- loadProType()
- break
- case 1003: //
- break
- case 1004: //
- break
- case 1005: //
- break
- case 1006: //
- break
- default:
- break
- }
- }
- @IBAction func btnQuery(_ sender: Any) {
- self.currentPage = 1
- loadData()
- }
- func textFieldShouldReturn(_ textField: UITextField) -> Bool {
- self.currentPage = 1
- loadData()
- return true
- }
- // MARK: TABLEVLEW 实现
- // MARK: TABLEVLEW 实现
- func numberOfSections(in tableView: UITableView) -> Int {
- return 1
- }
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return self.arrData.count
- }
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 111
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "TradeTableViewCell", for: indexPath as IndexPath) as! TradeTableViewCell
- cell.lblName.text = getString(current: indexPath.row, key: "shopName")
- cell.lblMachineTypename.text = machineType
- cell.lblMoney.text = "¥\(getString(current: indexPath.row, key: "tradeAmount") )"
- cell.lblCard.text = getString(current: indexPath.row, key: "cardNo")
- let payType = getString(current: indexPath.row, key: "payType")
- // if(payType == "00")
- // {
- // cell.lblTransactionType.text = "T0"
- // }
- // else if(payType == "01")
- // {
- // cell.lblTransactionType.text = "T1"
- // }
- if payTypeDic[payType] as? String == nil {
- cell.lblTransactionType.text = payType
- }else{
- cell.lblTransactionType.text = payTypeDic[payType] as? String
- }
- let cardType1 = getString(current: indexPath.row, key: "cardType")
- var cardType = ""
- if machineTypeId == "4e7c6d802cf149e9b8e1fc0efca4e965" {
- cardType = cardTypeTradeDic1[cardType1] as? String ?? ""
- }else{
- cardType = cardTypeTradeDic[cardType1] as? String ?? ""
- }
- let depositTrade1 = getString(current: indexPath.row, key: "depositTrade")
- let depositTrade = depositTradeDic[depositTrade1] as? String
- if getString(current: indexPath.row, key: "cardType") != "" {
- let index = Int(getString(current: indexPath.row, key: "cardType")) ?? -1
- if index >= 0 {
- cell.lblRemark.text = "卡类型:\(cardType ) 交易类型:\(depositTrade ?? "")"
- } else {
- cell.lblRemark.text = "卡类型:\(getString(current: indexPath.row, key: "cardType")) 交易类型:\(getString(current: indexPath.row, key: "depositTrade"))"
- }
- } else {
- if Int(getString(current: indexPath.row, key: "depositTrade")) != 0 {
- cell.lblRemark.text = "交易类型:\(depositTrade ?? "")"
- } else {
- cell.lblRemark.text = "交易类型:\(getString(current: indexPath.row, key: "depositTrade"))"
- }
- }
- cell.lblDate.text = getString(current: indexPath.row, key: "tradeDate")
- return cell
- }
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- // let view = UIViewController()
- // view.oneGoId = self.arrData[indexPath.row]["ItemId"] as! Int
- // self.navigationController?.pushViewController(view, animated: true)
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- appDelegate.setNavigationBarHidden(isHidden: true)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "TradeViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- var payTypeDic: NSDictionary = ["POSPAY": "刷卡", "QR_WECHAT": "微信", "QR_ALIPAY": "支付宝", "QR_UNIONPAY": "银联二维码", "QR_QQPAY": "QQ钱包", "00": "消费", "01": "收款", "02": "云闪付", "03": "智能消费", "04": "微信", "05": "支付宝", "云闪付借记卡": "云闪付借记卡", "云闪付贷记卡": "云闪付贷记卡", "刷卡交易借记卡": "刷卡交易借记卡", "刷卡交易贷记卡标准类": "刷卡交易贷记卡标准类", "刷卡交易贷记卡优惠类": "刷卡交易贷记卡优惠类", "刷卡交易贷记卡优享类": "刷卡交易贷记卡优享类", "刷卡交易贷记卡特殊计费类": "刷卡交易贷记卡特殊计费类", "刷卡交易贷记卡减免类": "刷卡交易贷记卡减免类", "微信": "微信", "支付宝": "支付宝", "刷卡": "刷卡", "挥卡": "挥卡", "闪付": "闪付", "海收付": "刷卡"]
- var depositTradeDic: NSDictionary = ["03": "消费", "19": "押金", "20": "智能消费", "21": "抵扣消费", "1": "押金", "consume": "消费", "0": "消费", "01": "刷卡", "02": "挥卡", "03": "芯片插卡", "04": "扫码", "05": "押金"]
- var cardTypeTradeDic: NSDictionary = ["1": "借记卡", "2": "贷记卡", "3": "准贷记卡", "4": "预付费卡", "5": "银联双免", "01": "借记卡", "02": "信用卡"]
- var cardTypeTradeDic1: NSDictionary = ["1": "借记卡", "2": "贷记卡", "3": "准贷记卡", "4": "预付费卡", "5": "银联双免", "01": "借记卡", "02": "贷记卡"]
- }
|