| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072 |
- #include "dialogselectsegment.h"
- #include "zxshdb.h"
- #include "sncdatabase.h"
- #include "ui_dialogselectsegment.h"
- #include "numberreg.h"
- #include "respsubmithmyy.h"
- #include "respsubmitzxshtask.h"
- #include "respuserserviceverify.h"
- #include "respgetuserzxshserviceinfo.h"
- #include "querypackrealpnum.h"
- #include "respgetservertime.h"
- #include "respencrypt.h"
- #include "wssso.h"
- #include "xlabel.h"
- DialogSelectSegment::DialogSelectSegment(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DialogSelectSegment)
- {
- ui->setupUi(this);
- initVariables();
- initUI();
- this->m_isRerve = false;
- loadCity();
- ui->labelSelect->setText(QString("已选择<font size=5 color =red><strong>%1</strong></font>个实号包\
- <font size=5 color=red><strong>%2</strong></font>个实号").arg(0).arg(0));
- ui->labelRealCount->setText(QString("共<font color=red>%1</font>个实号包<font color=red>%2</font>个实号").\
- arg(0).arg(0));
- ui->labelCount->setText("共" + QString::number(SNCDataBase::getSegCount()) + "个号段");
- }
- void DialogSelectSegment::saveToFile()
- {
- QString path = QDir::tempPath() + QString("/SNCTempFile/");
- QDir dir(path);
- if(!dir.exists())
- {
- dir.mkpath(path);
- }
- QList<QStringList> segs = getSelectedSegmentsInfo();
- QString fileName = QString("号码推荐_%1_%2_(共%3个号段).txt").arg(currentProvince).\
- arg(currentCity).\
- arg(segs.size());
- m_filename.clear();
- QString fullPath = path + fileName;
- m_filename.insert("fullpath",fullPath);
- m_filename.insert("filename",fileName);
- QFile file(fullPath);
- if(!file.open(QIODevice::WriteOnly))
- return ;
- QTextStream out(&file);
- for(int i=0;i<segs.size();i++)
- {
- out<<segs.at(i).at(1)+"\r\n";
- }
- file.close();
- }
- void DialogSelectSegment::initUI()
- {
- ui->widget1->setProperty("class","blackborder");
- ui->widget2->setProperty("class","blackborder");
- ui->widget3->setProperty("class","blackborder");
- ui->radioButton1->setVisible(false);
- ui->radioButton2->setVisible(false);
- ui->radioButton3->setVisible(false);
- ui->radioButton4->setVisible(false);
- ui->radioButton5->setVisible(false);
- ui->radioButton6->setVisible(false);
- ui->radioButton180->setVisible(false);
- ui->cmccRB->setIcon(QIcon(":/ispimage/isp10"));
- ui->cutcRB->setIcon(QIcon(":/ispimage/isp20"));
- ui->ctccRB->setIcon(QIcon(":/ispimage/isp30"));
- ui->xnRB->setIcon(QIcon(":/ispimage/isp60"));
- ui->label_2->setStyleSheet("font-weight:bold");
- ui->labelTip->setText(QString("<font color=red>点选时间选择单选框,获取资费信息</font>"));
- ui->pushButtonDetail->setProperty("class","txt-green");
- }
- void DialogSelectSegment::initVariables()
- {
- m_cube = new WSCube2();
- m_model = new QStringListModel();
- m_movie = new QMovie(":/fetchfromserver.gif");
- m_movie->start();
- m_state = NotLogin;
- m_timer = new QTimer();
- m_timer->setInterval(50);
- m_timer->stop();
- connect(m_timer,SIGNAL(timeout()),this,SLOT(onTimeOut()));
- connect(ui->tableWidget->verticalScrollBar(),SIGNAL(valueChanged(int)),\
- this,SLOT(onSlideValueChanged(int)));
- ui->tableWidget->setColumnCount(4);
- ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
- ui->tableWidget->setShowGrid(false);
- ui->tableWidget->setSelectionMode(QAbstractItemView::MultiSelection);
- ui->tableWidget->verticalHeader()->setVisible(false);
- ui->tableWidget->horizontalHeader()->setVisible(false);
- ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
- ui->tableWidget->verticalHeader()->setResizeMode(QHeaderView::Fixed);
- ui->tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- ui->tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
- ui->tableWidget->verticalHeader()->setDefaultSectionSize(45);
- int col = 0;
- ui->tableWidget->setColumnWidth(col++,145);
- ui->tableWidget->setColumnWidth(col++,145);
- ui->tableWidget->setColumnWidth(col++,145);//
- ui->tableWidget->setColumnWidth(col++,145);
- ui->tableWidget->installEventFilter(this);
- }
- QString DialogSelectSegment::getIsp()
- {
- QString isp;
- if(ui->allRB->isChecked())
- isp = "0";
- if(ui->cmccRB->isChecked())
- isp = "1";
- if(ui->cutcRB->isChecked())
- isp = "2";
- if(ui->ctccRB->isChecked())
- isp = "3";
- if(ui->xnRB->isChecked())
- isp = "6";
- return isp;
- }
- int DialogSelectSegment::getUpday()
- {
- int days;
- if(ui->radioButton1->isChecked())
- days = 1;
- else if(ui->radioButton2->isChecked())
- days = 2;
- else if(ui->radioButton3->isChecked())
- days = 3;
- else if(ui->radioButton4->isChecked())
- days = 4;
- else if(ui->radioButton5->isChecked())
- days = 5;
- else if(ui->radioButton6->isChecked())
- days = 6;
- else if(ui->radioButton7->isChecked())
- days = 7;
- else if(ui->radioButton30->isChecked())
- days = 30;
- else if(ui->radioButton90->isChecked())
- days = 90;
- else if(ui->radioButton180->isChecked())
- days = 180;
- else
- days = 0;
- return days;
- }
- QString DialogSelectSegment::getIsDown()
- {
- QString isdown;
- if(ui->radioButtonAll->isChecked())
- isdown = "0";
- else if(ui->radioButtonDown->isChecked())
- isdown = "1";
- else if(ui->radioButtonNoDown->isChecked())
- isdown = "2";
- else
- isdown = "0";
- return isdown;
- }
- void DialogSelectSegment::queryPackRpnum()
- {
- showQueryAnimation();
- QueryPackRealPnum *query = new QueryPackRealPnum();
- connect(query,SIGNAL(queryFinished()),this,SLOT(onSegmentUpdateFinished()));
- query->setAccountInfo(m_account);
- query->setAreaInfo(currentProvince,currentCity);
- query->start();
- ui->treeView->setEnabled(false);
- }
- void DialogSelectSegment::delayLoadLabel(int value)
- {
- for(int row = qMax(0,value - 1);row < qMin(value + 7,ui->tableWidget->rowCount());row++)
- {
- for(int col =0;col < 4;col++)
- {
- if(!ui->tableWidget->cellWidget(row,col))
- {
- QTableWidgetItem *item = this->ui->tableWidget->item(row,col);
- if(item)
- {
- QStringList list = item->data(Qt::UserRole).toString().split(":");
- QWidget *widget = new QWidget();
- QHBoxLayout *layout = new QHBoxLayout();
- widget->setLayout(layout);
- QLabel *label1 = new QLabel();
- //QLabel *label2 = new QLabel();
- XLabel *label2 = new XLabel();
- label2->setFixedSize(35,35);
- layout->addWidget(label2);
- layout->addWidget(label1);
- layout->addStretch(1);
- if(list.size()==4)
- {
- QString packno = list.at(0);
- int days = packno.right(9).left(4).toInt();
- QDateTime dt;
- dt.setDate(QDate(2014,1,1));
- dt = dt.addDays(days);
- QString date = dt.toString("yyyy-MM-dd");
- label1->setText(QString("%1[<font color =red>%2</font>]")\
- .arg(date)\
- .arg(list.at(1)));
- label1->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
- label1->setFixedSize(100,30);
- int dlcount= list.at(3).toInt();
- QString isselect;
- if(ZxshDB::validatePacknoSelected(list.at(0),m_account.value("usercode")))
- {
- isselect = "1";
- }
- else
- {
- isselect = "0";
- }
- //isp10:yd.png isp11:yd2.png ......
- QString pixmap = QString(":/ispimage/isp%1%2").arg(list.at(2)).arg(isselect);
- label2->setPixmap(QPixmap(pixmap));
- //modify by xxw on 2016-5-24
- //用户不登录就看不到其他用户下载的数字
- if(!this->m_account.value("usercode").isEmpty())
- {
- if(dlcount>0)
- {
- //dlcount = qMin(dlcount,99);
- label2->setValue(dlcount);
- }
- else
- {
- if(isselect=="1")
- label2->setValue(1);
- }
- }
- }
- //delete item;
- ui->tableWidget->setCellWidget(row,col,widget);
- }
- }
- }
- }
- }
- void DialogSelectSegment::showQueryAnimation()
- {
- ui->tableWidget->setRowCount(0);
- ui->tableWidget->setRowCount(4);
- QLabel *lbl = new QLabel();
- QTableWidgetItem *item = new QTableWidgetItem("正在读取...");
- lbl->setMovie(m_movie);
- lbl->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
- item->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
- ui->tableWidget->setItem(2,2,item);
- ui->tableWidget->setCellWidget(2,1,lbl);
- }
- void DialogSelectSegment::onSegmentUpdateFinished()
- {
- ui->treeView->setEnabled(true);
- fetchSegmentData();
- getUserServiceInfo(getUpday());
- }
- void DialogSelectSegment::onSlideValueChanged(int value)
- {
- delayLoadLabel(value);
- }
- void DialogSelectSegment::onTimeOut()
- {
- getUserServiceInfo(getUpday());
- }
- DialogSelectSegment::~DialogSelectSegment()
- {
- m_cube->abort();
- delete m_cube;
- delete m_movie;
- delete m_model;
- delete segmentModel;
- delete ui;
- }
- void DialogSelectSegment::loadCity()
- {
- segmentModel = new QStandardItemModel();
- segmentModel->setHorizontalHeaderItem(0,new QStandardItem("号码地区"));
- QString current;
- QStandardItem *parentItem = new QStandardItem();
- QList<QStringList> maps= SNCDataBase::getRegionInfo();
- if(maps.size()!=2)
- return ;
- ui->treeView->header()->setStyleSheet("font:12px");
- for(int i=0;i<maps.at(0).size();i++)
- {
- QString province = maps.at(1).at(i);
- QString city = maps.at(0).at(i);
- QStandardItem *provinceItem;
- QStandardItem *cityItem;
- if(current!=province)
- {
- provinceItem= new QStandardItem(province);
- cityItem= new QStandardItem(city);
- parentItem = provinceItem;
- current = province;
- segmentModel->appendRow(provinceItem);
- parentItem->appendRow(cityItem);
- }
- else
- {
- cityItem= new QStandardItem(city);
- parentItem->appendRow(cityItem);
- }
- }
- ui->treeView->setModel(segmentModel);
- }
- void DialogSelectSegment::on_treeView_clicked(const QModelIndex &index)
- {
- if(index.parent().isValid())
- {
- this->currentProvince = index.parent().data().toString();
- this->currentCity = index.data().toString();
- queryPackRpnum();
- }
- }
- void DialogSelectSegment::fetchSegmentData()
- {
- if(this->currentCity.isEmpty())
- return ;
- QStringList list,segs;
- QString corp,isdown;
- int days,count,index;
- corp = getIsp();
- days = getUpday();
- isdown = getIsDown();
- setCursor(Qt::WaitCursor);
- list = ZxshDB::getShkjZxshPackRealPnum(days,corp,this->currentCity,\
- this->m_account.value("usercode"),isdown);
- setCursor(Qt::ArrowCursor);
- count = 0;
- index = 0;
- if(days<=7)
- index = days;
- else if(days==30)
- index = 8;
- else if(days==90)
- index = 9;
- else if(days==180)
- index = 10;
- ui->tableWidget->setRowCount(0);
- ui->tableWidget->clear();
- ui->tableWidget->setRowCount(list.size()/ui->tableWidget->columnCount()+1);
- for(int row=0;row<ui->tableWidget->rowCount();row++)
- {
- for(int col = 0;col<ui->tableWidget->columnCount();col++)
- {
- int idx = row * ui->tableWidget->columnCount()+col;
- if(idx<list.size())
- {
- QString seg = list.at(idx).split(",").at(0);
- QString num = list.at(idx).split(",").at(1);
- QString isp = list.at(idx).split(",").at(2);
- QString dlcount = list.at(idx).split(",").at(4);
- if(dlcount.isEmpty())
- dlcount="0";
- else if(dlcount=="9+")
- dlcount = 10;
- count+=list.at(idx).split(",").at(1).toInt();
- segs<<seg+num;
- QTableWidgetItem *item = new QTableWidgetItem();
- item->setData(Qt::UserRole,QString("%1:%2:%3:%4").arg(seg).arg(num).arg(isp).arg(dlcount));
- //item->setTextAlignment(Qt::AlignRight);
- ui->tableWidget->setItem(row,col,item);
- }
- }
- }
- delayLoadLabel(ui->tableWidget->verticalScrollBar()->value());
- ui->labelRealCount->setText(QString("共<font color=red>%1</font>个实号包<font color=red>%2</font>个实号").\
- arg(segs.count()).arg(count));
- }
- void DialogSelectSegment::on_allRB_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_cmccRB_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_cutcRB_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_ctccRB_clicked()
- {
- fetchSegmentData();
- }
- QList<QStringList> DialogSelectSegment::getSelectedSegmentsInfo()
- {
- }
- QMap<QString,QString> DialogSelectSegment::getSaveFileName()
- {
- return m_filename;
- }
- bool DialogSelectSegment::isReserve()
- {
- return m_isRerve;
- }
- void DialogSelectSegment::setAccountInfo(QMap<QString, QString> info)
- {
- m_account = info;
- QString ssoHash = info.value("ssohash");
- if(!ssoHash.isEmpty())
- {
- m_state = LoginOk;
- m_timer->start();
- }
- else
- {
- m_state = NotLogin;
- }
- }
- void DialogSelectSegment::setAreaInfo(QString province, QString city)
- {
- int rows = ui->treeView->model()->rowCount();
- int cols = ui->treeView->model()->columnCount();
- for(int row=0;row<rows;row++)
- {
- QModelIndex index = ui->treeView->model()->index(row,0);
- if(index.data().toString()==province)
- {
- ui->treeView->expand(index);
- int i=0;
- while(true)
- {
- QModelIndex index2 = ui->treeView->model()->index(i,0,index);
- if(index2.isValid())
- {
- if(index2.data().toString()==city)
- {
- ui->treeView->setCurrentIndex(index2);
- currentCity = city;
- currentProvince = province;
- queryPackRpnum();
- }
- }
- else
- {
- break;
- }
- i++;
- }
- }
- }
- }
- void DialogSelectSegment::setCustomInfo(QMap<QString, QString> info)
- {
- QString isp = info.value("isp");
- QString updatedays = info.value("updatedays");
- if(updatedays=="1")
- ui->radioButton1->setChecked(true);
- else if(updatedays=="2")
- ui->radioButton2->setChecked(true);
- else if(updatedays=="3")
- ui->radioButton3->setChecked(true);
- else if(updatedays=="4")
- ui->radioButton4->setChecked(true);
- else if(updatedays=="5")
- ui->radioButton5->setChecked(true);
- else if(updatedays=="6")
- ui->radioButton6->setChecked(true);
- else if(updatedays=="7")
- ui->radioButton7->setChecked(true);
- else if(updatedays=="30")
- ui->radioButton30->setChecked(true);
- else if(updatedays=="90")
- ui->radioButton90->setChecked(true);
- else if(updatedays=="180")
- ui->radioButton180->setChecked(true);
- if(isp=="0")
- ui->allRB->setChecked(true);
- else if(isp=="1")
- ui->cmccRB->setChecked(true);
- else if(isp=="2")
- ui->cutcRB->setChecked(true);
- else if(isp=="3")
- ui->ctccRB->setChecked(true);
- }
- void DialogSelectSegment::on_pushButtonClose_clicked()
- {
- this->reject();
- }
- void DialogSelectSegment::onUpdateMessage(QString msg, int rtCode)
- {
- if(rtCode==-3)
- QMessageBox::critical(this,"系统通知",msg,QMessageBox::Ok);
- }
- void DialogSelectSegment::on_pushButtonToDown_clicked()
- {
- if(!chkAccountState(m_state))
- return;
- int updatedays,neednum,realnum;
- QString ssid,usercode,inserttime,finishtime,isp,segdata,slttype,packnos,province,city,userhash;
- slttype = "1";
- segdata = "";
- packnos = getSelectPackNoList();
- qDebug()<<packnos;
- updatedays = getUpday();
- isp = getIsp();
- segdata = "";
- province = this->currentProvince;
- city = this->currentCity;
- neednum = getSelectPackNums();
- realnum = 0;
- inserttime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
- usercode = m_account.value("usercode");
- userhash = m_account.value("ssohash");
- if(checkSelectPackno())
- {
- return ;
- }
- if(province.isEmpty()||city.isEmpty()||isp.isEmpty()||updatedays<=0)
- {
- QMessageBox::critical(this,"系统通知","您选择的数据不完整!",QMessageBox::Ok);
- return ;
- }
- QMap<QString,QString> srvparas = SNCDataBase::getSrvParam("cube2");
- int ZxshPnumMaxSize = srvparas.value("ZxshPnumMaxSize").toInt();
- if(neednum>ZxshPnumMaxSize)
- {
- QMessageBox::critical(this,"提示",QString("一次选择实号数量的最大值为[%1],请重新选择").arg(ZxshPnumMaxSize),QMessageBox::Ok);
- return ;
- }
- if(QMessageBox::Yes!=QMessageBox::question(NULL,
- "确认",
- QString("此次下载需要扣除下载量,是否继续?")
- ,QMessageBox::Yes,QMessageBox::No))
- {
- return ;
- }
- QString ssoHash = m_account.value("ssohash");
- this->setCursor(Qt::WaitCursor);
- QString json = m_cube->getUserZXSHServiceInfo(ssoHash);
- this->setCursor(Qt::ArrowCursor);
- RespGetUserZXSHServiceInfo resp0(json);
- if(resp0.getRtnCode()<=0)
- {
- QMessageBox::critical(this,"提示",resp0.getRtnMemo(),QMessageBox::Ok);
- return ;
- }
- int monthDownShzs = resp0.getMonthDownShzs().toInt();
- int monthMaxDownShzs = resp0.getMonthMaxDownShzs().toInt();
- neednum = qMin(neednum,monthMaxDownShzs-monthDownShzs);
- if(neednum<=0)
- {
- QMessageBox::critical(this,"提示",QString("您的余额已不足,已经下载%1条实号").arg(monthDownShzs),QMessageBox::Ok);
- return ;
- }
- this->setCursor(Qt::WaitCursor);
- json = m_cube->userServiceVerify("SubmitZxshTask",QString("%1,%2").arg(neednum).arg(updatedays),ssoHash);
- this->setCursor(Qt::ArrowCursor);
- RespUserServiceVerify response1(json);
- if(response1.getRtnCode()<=0)
- {
- QMessageBox::critical(this,"提示",response1.getRtnMemo(),QMessageBox::Ok);
- return ;
- }
- this->setCursor(Qt::WaitCursor);
- ui->pushButtonToDown->setEnabled(false);
- json = m_cube->submitZxshTask(province,city,QString::number(updatedays),\
- isp,slttype,packnos,segdata,QString::number(neednum),userhash);
- this->setCursor(Qt::ArrowCursor);
- RespSubmitZxshTask resp(json);
- if(resp.getRtnCode()==1)
- {
- ssid = resp.getSSID();
- ZxshDB::addShkjZxshTask(ssid,usercode,province,city,inserttime,finishtime,\
- updatedays,isp,slttype,packnos,segdata,neednum,realnum);
- QMessageBox::information(this,"系统通知",QString("您选择的%1%2的号码已经添加下载列表!").arg(province).arg(city),QMessageBox::Ok);
- m_isRerve = false;
- //this->accept();
- }
- else
- {
- QMessageBox::critical(this,"系统通知",resp.getRtnMemo(),QMessageBox::Ok);
- }
- refreshUserInfo();
- emit zxshDownDataUpdated();
- ui->pushButtonToDown->setEnabled(true);
- }
- void DialogSelectSegment::on_pushButtonOrder_clicked()
- {
- if(!chkAccountState(m_state))
- return;
- QString province,city,isp,userHash;
- province = this->currentProvince;
- city = this->currentCity;
- isp = getIsp();
- userHash = m_account.value("ssohash");
- if(province.isEmpty()||city.isEmpty()||isp.isEmpty())
- {
- QMessageBox::critical(this,"系统通知","您选择的数据不完整!",QMessageBox::Ok);
- return;
- }
- if(QMessageBox::Yes!=QMessageBox::question(NULL,
- "确认",
- QString("您需要预约[%1][%2]地区吗?").arg(province).arg(city)
- ,QMessageBox::Yes,QMessageBox::No))
- {
- return ;
- }
- this->setCursor(Qt::WaitCursor);
- QString json = m_cube->submitHmyy(province,city,isp,userHash);
- this->setCursor(Qt::ArrowCursor);
- RespSubmitHmyy resp(json);
- if(resp.getRtnCode()==1)
- {
- QMessageBox::information(this,"系统通知",QString("您预约的%1%2的号码成功!").arg(province).arg(city),QMessageBox::Ok);
- m_isRerve = true;
- emit zxshReserveDataUpdated();
- this->accept();
- }
- else
- {
- QMessageBox::critical(this,"系统通知",resp.getRtnMemo(),QMessageBox::Ok);
- }
- }
- void DialogSelectSegment::on_radioButton1_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_radioButton2_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_radioButton3_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_radioButton4_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_radioButton5_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_radioButton6_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_radioButton7_clicked()
- {
- fetchSegmentData();
- getUserServiceInfo(7);
- }
- void DialogSelectSegment::on_radioButton30_clicked()
- {
- fetchSegmentData();
- getUserServiceInfo(30);
- }
- void DialogSelectSegment::on_radioButton90_clicked()
- {
- fetchSegmentData();
- getUserServiceInfo(90);
- }
- void DialogSelectSegment::on_radioButton180_clicked()
- {
- fetchSegmentData();
- getUserServiceInfo(180);
- }
- QString DialogSelectSegment::getSelectPackNoList()
- {
- QString infos;
- QString select;
- for(int row=0;row<ui->tableWidget->rowCount();row++)
- {
- for(int col=0;col<4;col++)
- {
- QTableWidgetItem *item;
- item = ui->tableWidget->item(row,col);
- if(item)
- {
- if(item->isSelected())
- {
- QString data = item->data(Qt::UserRole).toString();
- QString packno;
- if(data.split(":").size()>0)
- {
- packno = data.split(":").at(0);
- if(ZxshDB::validatePacknoSelected(packno,m_account.value("usercode")))
- select+=packno+"\r\n";
- infos +=packno+",";
- }
- }
- }
- }
- }
- if(!infos.isEmpty())
- {
- infos+="end";
- }
- return infos;
- }
- bool DialogSelectSegment::checkSelectPackno()
- {
- QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
- int count = 0;
- for(int i=0;i<items.size();i++)
- {
- QTableWidgetItem *item = items.at(i);
- QString data = item->data(Qt::UserRole).toString();
- QString packno;
- if(data.split(":").size()>0)
- {
- packno = data.split(":").at(0);
- if(ZxshDB::validatePacknoSelected(packno,m_account.value("usercode")))
- {
- count++;
- }
- }
- }
- if(items.size()==0)
- {
- QMessageBox::critical(this,"提示","你至少要选择一个实号包!",QMessageBox::Ok);
- return true;
- }
- if(count>0)
- {
- if(QMessageBox::Yes==QMessageBox::question(NULL,
- "确认",
- QString("您选择的实号包中,其中%1个已经下载过,是否重复下载?").arg(count)
- ,QMessageBox::Yes,QMessageBox::No))
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- else
- {
- return false;
- }
- }
- bool DialogSelectSegment::chkAccountState(AccountLoginState state)
- {
- bool ret = false;
- switch(state)
- {
- case NotLogin:
- QMessageBox::critical(this,"提示","您现在还没有登录系统,请登录后再操作!",QMessageBox::Ok);
- break;
- case NotBind:
- QMessageBox::critical(this,"提示","此项服务尚未开通,请开通后再操作!",QMessageBox::Ok);
- break;
- case LoginError:
- QMessageBox::critical(this,"提示","此项服务暂时无法连接,请稍候重试!",QMessageBox::Ok);
- break;
- default:
- ret = true;
- }
- return ret;
- }
- void DialogSelectSegment::getUserServiceInfo(int day)
- {
- //同步查询用户端服务器信息
- if(m_account.value("ssohash").isEmpty())
- {
- ui->labelTip->setText(QString("<font color=red>您需要登录后才能获得资费信息</font>"));
- return ;
- }
- WSCube2 cube;
- setCursor(Qt::WaitCursor);
- QString json = cube.getUserZXSHServiceInfo(m_account.value("ssohash"));
- setCursor(Qt::ArrowCursor);
- RespGetUserZXSHServiceInfo resp(json);
- if(resp.getRtnCode()==1)
- {
- int total = resp.getMonthMaxDownShzs().toInt();
- int already = resp.getMonthDownShzs().toInt();
- int total2 = resp.getZxshMonthMaxDownShzs().toInt();
- int already2 = resp.getZxshMonthDownShzs().toInt();
- int day7inmax = resp.getZxshMonthMaxDownIn7dayShzs().toInt();
- int day7insubmit = resp.getZxshMonthDownIn7dayShzs().toInt();
- int day30inmax = resp.getZxshMonthMaxDownIn1MonthShzs().toInt();
- int day30insubmit = resp.getZxshMonthDownIn1MonthShzs().toInt();
- int day90inmax = resp.getZxshMonthMaxDownIn3MonthShzs().toInt();
- int day90insubmit = resp.getZxshMonthDownIn3MonthShzs().toInt();
- int day7 = qMin(qMin(total-already,day7inmax-day7insubmit),total2-already2);
- int day30= qMin(qMin(total-already,day30inmax-day30insubmit),total2-already2);
- int day90= qMin(qMin(total-already,day90inmax-day90insubmit),total2-already2);
- if(day<=7)
- ui->labelTip->setText(QString("[7天内实号数]已下载<font size=5 color=red><strong>%1</strong></font>个,还可下载<font size=5 color=red><strong>%2</strong></font>个").\
- arg(day7insubmit).arg(day7));
- else if(day==30)
- ui->labelTip->setText(QString("[1月内实号数]已下载<font size=5 color=red><strong>%1</strong></font>个,还可下载<font size=5 color=red><strong>%2</strong></font>个").\
- arg(day30insubmit).arg(day30));
- else if(day==90)
- ui->labelTip->setText(QString("[3月内实号数]已下载<font size=5 color=red><strong>%1</strong></font>个,还可下载<font size=5 color=red><strong>%2</strong></font>个").\
- arg(day90insubmit).arg(day90));
- else
- ui->labelTip->setText(QString("<font color=red>未知信息</font>"));
- }
- else
- {
- ui->labelTip->setText(QString("<font color=red>无法获取资费信息,错误原因:%1</font>").arg(resp.getRtnMemo()));
- }
- m_timer->stop();
- }
- int DialogSelectSegment::getSelectPackNums()
- {
- QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
- int count=0;
- int nums = 0;
- for(int i=0;i<items.size();i++)
- {
- QTableWidgetItem *item = items.at(i);
- count++;
- QString data = item->data(Qt::UserRole).toString();
- if(data.split(":").size()>2)
- {
- nums += data.split(":").at(1).toInt();
- }
- }
- return nums;
- }
- void DialogSelectSegment::refreshUserInfo()
- {
- if(ui->radioButton7->isChecked())
- {
- on_radioButton7_clicked();
- }
- else if(ui->radioButton30->isChecked())
- {
- on_radioButton30_clicked();
- }
- else if(ui->radioButton90->isChecked())
- {
- on_radioButton90_clicked();
- }
- }
- void DialogSelectSegment::on_tableWidget_itemSelectionChanged()
- {
- QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
- int count=0;
- int nums = 0;
- for(int i=0;i<items.size();i++)
- {
- QTableWidgetItem *item = items.at(i);
- count++;
- QString data = item->data(Qt::UserRole).toString();
- if(data.split(":").size()>2)
- {
- nums += data.split(":").at(1).toInt();
- }
- }
- ui->labelSelect->setText(QString("已选择<font size=5 color =red><strong>%1</strong></font>个实号包\
- <font size=5 color=red><strong>%2</strong></font>个实号").arg(count).arg(nums));
- }
- void DialogSelectSegment::on_pushButtonClearSelect_clicked()
- {
- QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
- if(items.size()==0)
- return ;
- for(int i=0;i<items.size();i++)
- {
- QTableWidgetItem *item = items.at(i);
- item->setSelected(false);
- }
- ui->labelSelect->setText(QString("已选择<font size=5 color =red><strong>%1</strong></font>个实号包\
- <font size=5 color=red><strong>%2</strong></font>个实号").arg(0).arg(0));
- }
- void DialogSelectSegment::on_xnRB_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_radioButtonAll_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_radioButtonDown_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_radioButtonNoDown_clicked()
- {
- fetchSegmentData();
- }
- void DialogSelectSegment::on_tableWidget_cellClicked(int row, int column)
- {
- // QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
- // QTableWidgetItem *item = items.at(items.size()-2);
- // if(!item)
- // {
- // return ;
- // }
- // int startrow = item->row();
- // int startcol = item->column();
- }
- void DialogSelectSegment::on_pushButtonDetail_clicked()
- {
- QString ssoHash = m_account.value("ssohash");
- if(ssoHash.isEmpty())
- {
- QMessageBox::critical(this,"提示","您现在还没有登录系统,请登录后再操作!",QMessageBox::Ok);
- return;
- }
- WSSSO sso;
- QString json = sso.encrypt(ssoHash);
- RespEncrypt resp1(json);
- QString data = resp1.getEncryptData();
- json = sso.getServerTime();
- RespGetServerTime resp2(json);
- QString authCode;
- QByteArray ba;
- QString str = SNCDataBase::getAuthCodeUrl().arg(resp2.getServerTime().mid(0,16));
- ba = QCryptographicHash::hash ( str.toAscii(), QCryptographicHash::Md5 );
- authCode.append(ba.toHex());
- QString url = SNCDataBase::getSSOPayUrl() + "?s=mf&r="+authCode+"&u="+data+"&p=xq_zxsh";
- QDesktopServices::openUrl(QUrl(url));
- }
- bool DialogSelectSegment::eventFilter(QObject *object, QEvent *event)
- {
- if( event->type() == QEvent::KeyPress)
- {
- // if yes, we need to cast the event into a QMouseEvent type
- QKeyEvent * pKeyEvent = static_cast<QKeyEvent *>(event);
- // check whether it's mid button pressed
- if (pKeyEvent->key() == Qt::Key_Control||pKeyEvent->key() == Qt::Key_Shift)
- {
- //do the processing and return true
- //textBrowserErrorInfo->setText(tr("clicked"));
- ui->tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
- return true; //一定要返回true,如果你不想别的object也能接收到这个event
- }
- }
- else if( event->type() == QEvent::KeyRelease)
- {
- QKeyEvent * pKeyEvent = static_cast<QKeyEvent *>(event);
- // check whether it's mid button pressed
- if (pKeyEvent->key() == Qt::Key_Control||pKeyEvent->key() == Qt::Key_Shift)
- {
- //do the processing and return true
- //textBrowserErrorInfo->setText(tr("clicked"));
- ui->tableWidget->setSelectionMode(QAbstractItemView::MultiSelection);
- return true; //一定要返回true,如果你不想别的object也能接收到这个event
- }
- }
- return QWidget::eventFilter(object, event);
- }/**/
- void DialogSelectSegment::on_pushButtonSync_clicked()
- {
- ui->pushButtonSync->setEnabled(false);
- onTimeOut();
- ui->pushButtonSync->setEnabled(true);
- }
|