dialogselectsegment.cpp 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. #include "dialogselectsegment.h"
  2. #include "zxshdb.h"
  3. #include "sncdatabase.h"
  4. #include "ui_dialogselectsegment.h"
  5. #include "numberreg.h"
  6. #include "respsubmithmyy.h"
  7. #include "respsubmitzxshtask.h"
  8. #include "respuserserviceverify.h"
  9. #include "respgetuserzxshserviceinfo.h"
  10. #include "querypackrealpnum.h"
  11. #include "respgetservertime.h"
  12. #include "respencrypt.h"
  13. #include "wssso.h"
  14. #include "xlabel.h"
  15. DialogSelectSegment::DialogSelectSegment(QWidget *parent) :
  16. QDialog(parent),
  17. ui(new Ui::DialogSelectSegment)
  18. {
  19. ui->setupUi(this);
  20. initVariables();
  21. initUI();
  22. this->m_isRerve = false;
  23. loadCity();
  24. ui->labelSelect->setText(QString("已选择<font size=5 color =red><strong>%1</strong></font>个实号包\
  25. <font size=5 color=red><strong>%2</strong></font>个实号").arg(0).arg(0));
  26. ui->labelRealCount->setText(QString("共<font color=red>%1</font>个实号包<font color=red>%2</font>个实号").\
  27. arg(0).arg(0));
  28. ui->labelCount->setText("共" + QString::number(SNCDataBase::getSegCount()) + "个号段");
  29. }
  30. void DialogSelectSegment::saveToFile()
  31. {
  32. QString path = QDir::tempPath() + QString("/SNCTempFile/");
  33. QDir dir(path);
  34. if(!dir.exists())
  35. {
  36. dir.mkpath(path);
  37. }
  38. QList<QStringList> segs = getSelectedSegmentsInfo();
  39. QString fileName = QString("号码推荐_%1_%2_(共%3个号段).txt").arg(currentProvince).\
  40. arg(currentCity).\
  41. arg(segs.size());
  42. m_filename.clear();
  43. QString fullPath = path + fileName;
  44. m_filename.insert("fullpath",fullPath);
  45. m_filename.insert("filename",fileName);
  46. QFile file(fullPath);
  47. if(!file.open(QIODevice::WriteOnly))
  48. return ;
  49. QTextStream out(&file);
  50. for(int i=0;i<segs.size();i++)
  51. {
  52. out<<segs.at(i).at(1)+"\r\n";
  53. }
  54. file.close();
  55. }
  56. void DialogSelectSegment::initUI()
  57. {
  58. ui->widget1->setProperty("class","blackborder");
  59. ui->widget2->setProperty("class","blackborder");
  60. ui->widget3->setProperty("class","blackborder");
  61. ui->radioButton1->setVisible(false);
  62. ui->radioButton2->setVisible(false);
  63. ui->radioButton3->setVisible(false);
  64. ui->radioButton4->setVisible(false);
  65. ui->radioButton5->setVisible(false);
  66. ui->radioButton6->setVisible(false);
  67. ui->radioButton180->setVisible(false);
  68. ui->cmccRB->setIcon(QIcon(":/ispimage/isp10"));
  69. ui->cutcRB->setIcon(QIcon(":/ispimage/isp20"));
  70. ui->ctccRB->setIcon(QIcon(":/ispimage/isp30"));
  71. ui->xnRB->setIcon(QIcon(":/ispimage/isp60"));
  72. ui->label_2->setStyleSheet("font-weight:bold");
  73. ui->labelTip->setText(QString("<font color=red>点选时间选择单选框,获取资费信息</font>"));
  74. ui->pushButtonDetail->setProperty("class","txt-green");
  75. }
  76. void DialogSelectSegment::initVariables()
  77. {
  78. m_cube = new WSCube2();
  79. m_model = new QStringListModel();
  80. m_movie = new QMovie(":/fetchfromserver.gif");
  81. m_movie->start();
  82. m_state = NotLogin;
  83. m_timer = new QTimer();
  84. m_timer->setInterval(50);
  85. m_timer->stop();
  86. connect(m_timer,SIGNAL(timeout()),this,SLOT(onTimeOut()));
  87. connect(ui->tableWidget->verticalScrollBar(),SIGNAL(valueChanged(int)),\
  88. this,SLOT(onSlideValueChanged(int)));
  89. ui->tableWidget->setColumnCount(4);
  90. ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
  91. ui->tableWidget->setShowGrid(false);
  92. ui->tableWidget->setSelectionMode(QAbstractItemView::MultiSelection);
  93. ui->tableWidget->verticalHeader()->setVisible(false);
  94. ui->tableWidget->horizontalHeader()->setVisible(false);
  95. ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Fixed);
  96. ui->tableWidget->verticalHeader()->setResizeMode(QHeaderView::Fixed);
  97. ui->tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  98. ui->tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  99. ui->tableWidget->verticalHeader()->setDefaultSectionSize(45);
  100. int col = 0;
  101. ui->tableWidget->setColumnWidth(col++,145);
  102. ui->tableWidget->setColumnWidth(col++,145);
  103. ui->tableWidget->setColumnWidth(col++,145);//
  104. ui->tableWidget->setColumnWidth(col++,145);
  105. ui->tableWidget->installEventFilter(this);
  106. }
  107. QString DialogSelectSegment::getIsp()
  108. {
  109. QString isp;
  110. if(ui->allRB->isChecked())
  111. isp = "0";
  112. if(ui->cmccRB->isChecked())
  113. isp = "1";
  114. if(ui->cutcRB->isChecked())
  115. isp = "2";
  116. if(ui->ctccRB->isChecked())
  117. isp = "3";
  118. if(ui->xnRB->isChecked())
  119. isp = "6";
  120. return isp;
  121. }
  122. int DialogSelectSegment::getUpday()
  123. {
  124. int days;
  125. if(ui->radioButton1->isChecked())
  126. days = 1;
  127. else if(ui->radioButton2->isChecked())
  128. days = 2;
  129. else if(ui->radioButton3->isChecked())
  130. days = 3;
  131. else if(ui->radioButton4->isChecked())
  132. days = 4;
  133. else if(ui->radioButton5->isChecked())
  134. days = 5;
  135. else if(ui->radioButton6->isChecked())
  136. days = 6;
  137. else if(ui->radioButton7->isChecked())
  138. days = 7;
  139. else if(ui->radioButton30->isChecked())
  140. days = 30;
  141. else if(ui->radioButton90->isChecked())
  142. days = 90;
  143. else if(ui->radioButton180->isChecked())
  144. days = 180;
  145. else
  146. days = 0;
  147. return days;
  148. }
  149. QString DialogSelectSegment::getIsDown()
  150. {
  151. QString isdown;
  152. if(ui->radioButtonAll->isChecked())
  153. isdown = "0";
  154. else if(ui->radioButtonDown->isChecked())
  155. isdown = "1";
  156. else if(ui->radioButtonNoDown->isChecked())
  157. isdown = "2";
  158. else
  159. isdown = "0";
  160. return isdown;
  161. }
  162. void DialogSelectSegment::queryPackRpnum()
  163. {
  164. showQueryAnimation();
  165. QueryPackRealPnum *query = new QueryPackRealPnum();
  166. connect(query,SIGNAL(queryFinished()),this,SLOT(onSegmentUpdateFinished()));
  167. query->setAccountInfo(m_account);
  168. query->setAreaInfo(currentProvince,currentCity);
  169. query->start();
  170. ui->treeView->setEnabled(false);
  171. }
  172. void DialogSelectSegment::delayLoadLabel(int value)
  173. {
  174. for(int row = qMax(0,value - 1);row < qMin(value + 7,ui->tableWidget->rowCount());row++)
  175. {
  176. for(int col =0;col < 4;col++)
  177. {
  178. if(!ui->tableWidget->cellWidget(row,col))
  179. {
  180. QTableWidgetItem *item = this->ui->tableWidget->item(row,col);
  181. if(item)
  182. {
  183. QStringList list = item->data(Qt::UserRole).toString().split(":");
  184. QWidget *widget = new QWidget();
  185. QHBoxLayout *layout = new QHBoxLayout();
  186. widget->setLayout(layout);
  187. QLabel *label1 = new QLabel();
  188. //QLabel *label2 = new QLabel();
  189. XLabel *label2 = new XLabel();
  190. label2->setFixedSize(35,35);
  191. layout->addWidget(label2);
  192. layout->addWidget(label1);
  193. layout->addStretch(1);
  194. if(list.size()==4)
  195. {
  196. QString packno = list.at(0);
  197. int days = packno.right(9).left(4).toInt();
  198. QDateTime dt;
  199. dt.setDate(QDate(2014,1,1));
  200. dt = dt.addDays(days);
  201. QString date = dt.toString("yyyy-MM-dd");
  202. label1->setText(QString("%1[<font color =red>%2</font>]")\
  203. .arg(date)\
  204. .arg(list.at(1)));
  205. label1->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
  206. label1->setFixedSize(100,30);
  207. int dlcount= list.at(3).toInt();
  208. QString isselect;
  209. if(ZxshDB::validatePacknoSelected(list.at(0),m_account.value("usercode")))
  210. {
  211. isselect = "1";
  212. }
  213. else
  214. {
  215. isselect = "0";
  216. }
  217. //isp10:yd.png isp11:yd2.png ......
  218. QString pixmap = QString(":/ispimage/isp%1%2").arg(list.at(2)).arg(isselect);
  219. label2->setPixmap(QPixmap(pixmap));
  220. //modify by xxw on 2016-5-24
  221. //用户不登录就看不到其他用户下载的数字
  222. if(!this->m_account.value("usercode").isEmpty())
  223. {
  224. if(dlcount>0)
  225. {
  226. //dlcount = qMin(dlcount,99);
  227. label2->setValue(dlcount);
  228. }
  229. else
  230. {
  231. if(isselect=="1")
  232. label2->setValue(1);
  233. }
  234. }
  235. }
  236. //delete item;
  237. ui->tableWidget->setCellWidget(row,col,widget);
  238. }
  239. }
  240. }
  241. }
  242. }
  243. void DialogSelectSegment::showQueryAnimation()
  244. {
  245. ui->tableWidget->setRowCount(0);
  246. ui->tableWidget->setRowCount(4);
  247. QLabel *lbl = new QLabel();
  248. QTableWidgetItem *item = new QTableWidgetItem("正在读取...");
  249. lbl->setMovie(m_movie);
  250. lbl->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
  251. item->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
  252. ui->tableWidget->setItem(2,2,item);
  253. ui->tableWidget->setCellWidget(2,1,lbl);
  254. }
  255. void DialogSelectSegment::onSegmentUpdateFinished()
  256. {
  257. ui->treeView->setEnabled(true);
  258. fetchSegmentData();
  259. getUserServiceInfo(getUpday());
  260. }
  261. void DialogSelectSegment::onSlideValueChanged(int value)
  262. {
  263. delayLoadLabel(value);
  264. }
  265. void DialogSelectSegment::onTimeOut()
  266. {
  267. getUserServiceInfo(getUpday());
  268. }
  269. DialogSelectSegment::~DialogSelectSegment()
  270. {
  271. m_cube->abort();
  272. delete m_cube;
  273. delete m_movie;
  274. delete m_model;
  275. delete segmentModel;
  276. delete ui;
  277. }
  278. void DialogSelectSegment::loadCity()
  279. {
  280. segmentModel = new QStandardItemModel();
  281. segmentModel->setHorizontalHeaderItem(0,new QStandardItem("号码地区"));
  282. QString current;
  283. QStandardItem *parentItem = new QStandardItem();
  284. QList<QStringList> maps= SNCDataBase::getRegionInfo();
  285. if(maps.size()!=2)
  286. return ;
  287. ui->treeView->header()->setStyleSheet("font:12px");
  288. for(int i=0;i<maps.at(0).size();i++)
  289. {
  290. QString province = maps.at(1).at(i);
  291. QString city = maps.at(0).at(i);
  292. QStandardItem *provinceItem;
  293. QStandardItem *cityItem;
  294. if(current!=province)
  295. {
  296. provinceItem= new QStandardItem(province);
  297. cityItem= new QStandardItem(city);
  298. parentItem = provinceItem;
  299. current = province;
  300. segmentModel->appendRow(provinceItem);
  301. parentItem->appendRow(cityItem);
  302. }
  303. else
  304. {
  305. cityItem= new QStandardItem(city);
  306. parentItem->appendRow(cityItem);
  307. }
  308. }
  309. ui->treeView->setModel(segmentModel);
  310. }
  311. void DialogSelectSegment::on_treeView_clicked(const QModelIndex &index)
  312. {
  313. if(index.parent().isValid())
  314. {
  315. this->currentProvince = index.parent().data().toString();
  316. this->currentCity = index.data().toString();
  317. queryPackRpnum();
  318. }
  319. }
  320. void DialogSelectSegment::fetchSegmentData()
  321. {
  322. if(this->currentCity.isEmpty())
  323. return ;
  324. QStringList list,segs;
  325. QString corp,isdown;
  326. int days,count,index;
  327. corp = getIsp();
  328. days = getUpday();
  329. isdown = getIsDown();
  330. setCursor(Qt::WaitCursor);
  331. list = ZxshDB::getShkjZxshPackRealPnum(days,corp,this->currentCity,\
  332. this->m_account.value("usercode"),isdown);
  333. setCursor(Qt::ArrowCursor);
  334. count = 0;
  335. index = 0;
  336. if(days<=7)
  337. index = days;
  338. else if(days==30)
  339. index = 8;
  340. else if(days==90)
  341. index = 9;
  342. else if(days==180)
  343. index = 10;
  344. ui->tableWidget->setRowCount(0);
  345. ui->tableWidget->clear();
  346. ui->tableWidget->setRowCount(list.size()/ui->tableWidget->columnCount()+1);
  347. for(int row=0;row<ui->tableWidget->rowCount();row++)
  348. {
  349. for(int col = 0;col<ui->tableWidget->columnCount();col++)
  350. {
  351. int idx = row * ui->tableWidget->columnCount()+col;
  352. if(idx<list.size())
  353. {
  354. QString seg = list.at(idx).split(",").at(0);
  355. QString num = list.at(idx).split(",").at(1);
  356. QString isp = list.at(idx).split(",").at(2);
  357. QString dlcount = list.at(idx).split(",").at(4);
  358. if(dlcount.isEmpty())
  359. dlcount="0";
  360. else if(dlcount=="9+")
  361. dlcount = 10;
  362. count+=list.at(idx).split(",").at(1).toInt();
  363. segs<<seg+num;
  364. QTableWidgetItem *item = new QTableWidgetItem();
  365. item->setData(Qt::UserRole,QString("%1:%2:%3:%4").arg(seg).arg(num).arg(isp).arg(dlcount));
  366. //item->setTextAlignment(Qt::AlignRight);
  367. ui->tableWidget->setItem(row,col,item);
  368. }
  369. }
  370. }
  371. delayLoadLabel(ui->tableWidget->verticalScrollBar()->value());
  372. ui->labelRealCount->setText(QString("共<font color=red>%1</font>个实号包<font color=red>%2</font>个实号").\
  373. arg(segs.count()).arg(count));
  374. }
  375. void DialogSelectSegment::on_allRB_clicked()
  376. {
  377. fetchSegmentData();
  378. }
  379. void DialogSelectSegment::on_cmccRB_clicked()
  380. {
  381. fetchSegmentData();
  382. }
  383. void DialogSelectSegment::on_cutcRB_clicked()
  384. {
  385. fetchSegmentData();
  386. }
  387. void DialogSelectSegment::on_ctccRB_clicked()
  388. {
  389. fetchSegmentData();
  390. }
  391. QList<QStringList> DialogSelectSegment::getSelectedSegmentsInfo()
  392. {
  393. }
  394. QMap<QString,QString> DialogSelectSegment::getSaveFileName()
  395. {
  396. return m_filename;
  397. }
  398. bool DialogSelectSegment::isReserve()
  399. {
  400. return m_isRerve;
  401. }
  402. void DialogSelectSegment::setAccountInfo(QMap<QString, QString> info)
  403. {
  404. m_account = info;
  405. QString ssoHash = info.value("ssohash");
  406. if(!ssoHash.isEmpty())
  407. {
  408. m_state = LoginOk;
  409. m_timer->start();
  410. }
  411. else
  412. {
  413. m_state = NotLogin;
  414. }
  415. }
  416. void DialogSelectSegment::setAreaInfo(QString province, QString city)
  417. {
  418. int rows = ui->treeView->model()->rowCount();
  419. int cols = ui->treeView->model()->columnCount();
  420. for(int row=0;row<rows;row++)
  421. {
  422. QModelIndex index = ui->treeView->model()->index(row,0);
  423. if(index.data().toString()==province)
  424. {
  425. ui->treeView->expand(index);
  426. int i=0;
  427. while(true)
  428. {
  429. QModelIndex index2 = ui->treeView->model()->index(i,0,index);
  430. if(index2.isValid())
  431. {
  432. if(index2.data().toString()==city)
  433. {
  434. ui->treeView->setCurrentIndex(index2);
  435. currentCity = city;
  436. currentProvince = province;
  437. queryPackRpnum();
  438. }
  439. }
  440. else
  441. {
  442. break;
  443. }
  444. i++;
  445. }
  446. }
  447. }
  448. }
  449. void DialogSelectSegment::setCustomInfo(QMap<QString, QString> info)
  450. {
  451. QString isp = info.value("isp");
  452. QString updatedays = info.value("updatedays");
  453. if(updatedays=="1")
  454. ui->radioButton1->setChecked(true);
  455. else if(updatedays=="2")
  456. ui->radioButton2->setChecked(true);
  457. else if(updatedays=="3")
  458. ui->radioButton3->setChecked(true);
  459. else if(updatedays=="4")
  460. ui->radioButton4->setChecked(true);
  461. else if(updatedays=="5")
  462. ui->radioButton5->setChecked(true);
  463. else if(updatedays=="6")
  464. ui->radioButton6->setChecked(true);
  465. else if(updatedays=="7")
  466. ui->radioButton7->setChecked(true);
  467. else if(updatedays=="30")
  468. ui->radioButton30->setChecked(true);
  469. else if(updatedays=="90")
  470. ui->radioButton90->setChecked(true);
  471. else if(updatedays=="180")
  472. ui->radioButton180->setChecked(true);
  473. if(isp=="0")
  474. ui->allRB->setChecked(true);
  475. else if(isp=="1")
  476. ui->cmccRB->setChecked(true);
  477. else if(isp=="2")
  478. ui->cutcRB->setChecked(true);
  479. else if(isp=="3")
  480. ui->ctccRB->setChecked(true);
  481. }
  482. void DialogSelectSegment::on_pushButtonClose_clicked()
  483. {
  484. this->reject();
  485. }
  486. void DialogSelectSegment::onUpdateMessage(QString msg, int rtCode)
  487. {
  488. if(rtCode==-3)
  489. QMessageBox::critical(this,"系统通知",msg,QMessageBox::Ok);
  490. }
  491. void DialogSelectSegment::on_pushButtonToDown_clicked()
  492. {
  493. if(!chkAccountState(m_state))
  494. return;
  495. int updatedays,neednum,realnum;
  496. QString ssid,usercode,inserttime,finishtime,isp,segdata,slttype,packnos,province,city,userhash;
  497. slttype = "1";
  498. segdata = "";
  499. packnos = getSelectPackNoList();
  500. qDebug()<<packnos;
  501. updatedays = getUpday();
  502. isp = getIsp();
  503. segdata = "";
  504. province = this->currentProvince;
  505. city = this->currentCity;
  506. neednum = getSelectPackNums();
  507. realnum = 0;
  508. inserttime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
  509. usercode = m_account.value("usercode");
  510. userhash = m_account.value("ssohash");
  511. if(checkSelectPackno())
  512. {
  513. return ;
  514. }
  515. if(province.isEmpty()||city.isEmpty()||isp.isEmpty()||updatedays<=0)
  516. {
  517. QMessageBox::critical(this,"系统通知","您选择的数据不完整!",QMessageBox::Ok);
  518. return ;
  519. }
  520. QMap<QString,QString> srvparas = SNCDataBase::getSrvParam("cube2");
  521. int ZxshPnumMaxSize = srvparas.value("ZxshPnumMaxSize").toInt();
  522. if(neednum>ZxshPnumMaxSize)
  523. {
  524. QMessageBox::critical(this,"提示",QString("一次选择实号数量的最大值为[%1],请重新选择").arg(ZxshPnumMaxSize),QMessageBox::Ok);
  525. return ;
  526. }
  527. if(QMessageBox::Yes!=QMessageBox::question(NULL,
  528. "确认",
  529. QString("此次下载需要扣除下载量,是否继续?")
  530. ,QMessageBox::Yes,QMessageBox::No))
  531. {
  532. return ;
  533. }
  534. QString ssoHash = m_account.value("ssohash");
  535. this->setCursor(Qt::WaitCursor);
  536. QString json = m_cube->getUserZXSHServiceInfo(ssoHash);
  537. this->setCursor(Qt::ArrowCursor);
  538. RespGetUserZXSHServiceInfo resp0(json);
  539. if(resp0.getRtnCode()<=0)
  540. {
  541. QMessageBox::critical(this,"提示",resp0.getRtnMemo(),QMessageBox::Ok);
  542. return ;
  543. }
  544. int monthDownShzs = resp0.getMonthDownShzs().toInt();
  545. int monthMaxDownShzs = resp0.getMonthMaxDownShzs().toInt();
  546. neednum = qMin(neednum,monthMaxDownShzs-monthDownShzs);
  547. if(neednum<=0)
  548. {
  549. QMessageBox::critical(this,"提示",QString("您的余额已不足,已经下载%1条实号").arg(monthDownShzs),QMessageBox::Ok);
  550. return ;
  551. }
  552. this->setCursor(Qt::WaitCursor);
  553. json = m_cube->userServiceVerify("SubmitZxshTask",QString("%1,%2").arg(neednum).arg(updatedays),ssoHash);
  554. this->setCursor(Qt::ArrowCursor);
  555. RespUserServiceVerify response1(json);
  556. if(response1.getRtnCode()<=0)
  557. {
  558. QMessageBox::critical(this,"提示",response1.getRtnMemo(),QMessageBox::Ok);
  559. return ;
  560. }
  561. this->setCursor(Qt::WaitCursor);
  562. ui->pushButtonToDown->setEnabled(false);
  563. json = m_cube->submitZxshTask(province,city,QString::number(updatedays),\
  564. isp,slttype,packnos,segdata,QString::number(neednum),userhash);
  565. this->setCursor(Qt::ArrowCursor);
  566. RespSubmitZxshTask resp(json);
  567. if(resp.getRtnCode()==1)
  568. {
  569. ssid = resp.getSSID();
  570. ZxshDB::addShkjZxshTask(ssid,usercode,province,city,inserttime,finishtime,\
  571. updatedays,isp,slttype,packnos,segdata,neednum,realnum);
  572. QMessageBox::information(this,"系统通知",QString("您选择的%1%2的号码已经添加下载列表!").arg(province).arg(city),QMessageBox::Ok);
  573. m_isRerve = false;
  574. //this->accept();
  575. }
  576. else
  577. {
  578. QMessageBox::critical(this,"系统通知",resp.getRtnMemo(),QMessageBox::Ok);
  579. }
  580. refreshUserInfo();
  581. emit zxshDownDataUpdated();
  582. ui->pushButtonToDown->setEnabled(true);
  583. }
  584. void DialogSelectSegment::on_pushButtonOrder_clicked()
  585. {
  586. if(!chkAccountState(m_state))
  587. return;
  588. QString province,city,isp,userHash;
  589. province = this->currentProvince;
  590. city = this->currentCity;
  591. isp = getIsp();
  592. userHash = m_account.value("ssohash");
  593. if(province.isEmpty()||city.isEmpty()||isp.isEmpty())
  594. {
  595. QMessageBox::critical(this,"系统通知","您选择的数据不完整!",QMessageBox::Ok);
  596. return;
  597. }
  598. if(QMessageBox::Yes!=QMessageBox::question(NULL,
  599. "确认",
  600. QString("您需要预约[%1][%2]地区吗?").arg(province).arg(city)
  601. ,QMessageBox::Yes,QMessageBox::No))
  602. {
  603. return ;
  604. }
  605. this->setCursor(Qt::WaitCursor);
  606. QString json = m_cube->submitHmyy(province,city,isp,userHash);
  607. this->setCursor(Qt::ArrowCursor);
  608. RespSubmitHmyy resp(json);
  609. if(resp.getRtnCode()==1)
  610. {
  611. QMessageBox::information(this,"系统通知",QString("您预约的%1%2的号码成功!").arg(province).arg(city),QMessageBox::Ok);
  612. m_isRerve = true;
  613. emit zxshReserveDataUpdated();
  614. this->accept();
  615. }
  616. else
  617. {
  618. QMessageBox::critical(this,"系统通知",resp.getRtnMemo(),QMessageBox::Ok);
  619. }
  620. }
  621. void DialogSelectSegment::on_radioButton1_clicked()
  622. {
  623. fetchSegmentData();
  624. }
  625. void DialogSelectSegment::on_radioButton2_clicked()
  626. {
  627. fetchSegmentData();
  628. }
  629. void DialogSelectSegment::on_radioButton3_clicked()
  630. {
  631. fetchSegmentData();
  632. }
  633. void DialogSelectSegment::on_radioButton4_clicked()
  634. {
  635. fetchSegmentData();
  636. }
  637. void DialogSelectSegment::on_radioButton5_clicked()
  638. {
  639. fetchSegmentData();
  640. }
  641. void DialogSelectSegment::on_radioButton6_clicked()
  642. {
  643. fetchSegmentData();
  644. }
  645. void DialogSelectSegment::on_radioButton7_clicked()
  646. {
  647. fetchSegmentData();
  648. getUserServiceInfo(7);
  649. }
  650. void DialogSelectSegment::on_radioButton30_clicked()
  651. {
  652. fetchSegmentData();
  653. getUserServiceInfo(30);
  654. }
  655. void DialogSelectSegment::on_radioButton90_clicked()
  656. {
  657. fetchSegmentData();
  658. getUserServiceInfo(90);
  659. }
  660. void DialogSelectSegment::on_radioButton180_clicked()
  661. {
  662. fetchSegmentData();
  663. getUserServiceInfo(180);
  664. }
  665. QString DialogSelectSegment::getSelectPackNoList()
  666. {
  667. QString infos;
  668. QString select;
  669. for(int row=0;row<ui->tableWidget->rowCount();row++)
  670. {
  671. for(int col=0;col<4;col++)
  672. {
  673. QTableWidgetItem *item;
  674. item = ui->tableWidget->item(row,col);
  675. if(item)
  676. {
  677. if(item->isSelected())
  678. {
  679. QString data = item->data(Qt::UserRole).toString();
  680. QString packno;
  681. if(data.split(":").size()>0)
  682. {
  683. packno = data.split(":").at(0);
  684. if(ZxshDB::validatePacknoSelected(packno,m_account.value("usercode")))
  685. select+=packno+"\r\n";
  686. infos +=packno+",";
  687. }
  688. }
  689. }
  690. }
  691. }
  692. if(!infos.isEmpty())
  693. {
  694. infos+="end";
  695. }
  696. return infos;
  697. }
  698. bool DialogSelectSegment::checkSelectPackno()
  699. {
  700. QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
  701. int count = 0;
  702. for(int i=0;i<items.size();i++)
  703. {
  704. QTableWidgetItem *item = items.at(i);
  705. QString data = item->data(Qt::UserRole).toString();
  706. QString packno;
  707. if(data.split(":").size()>0)
  708. {
  709. packno = data.split(":").at(0);
  710. if(ZxshDB::validatePacknoSelected(packno,m_account.value("usercode")))
  711. {
  712. count++;
  713. }
  714. }
  715. }
  716. if(items.size()==0)
  717. {
  718. QMessageBox::critical(this,"提示","你至少要选择一个实号包!",QMessageBox::Ok);
  719. return true;
  720. }
  721. if(count>0)
  722. {
  723. if(QMessageBox::Yes==QMessageBox::question(NULL,
  724. "确认",
  725. QString("您选择的实号包中,其中%1个已经下载过,是否重复下载?").arg(count)
  726. ,QMessageBox::Yes,QMessageBox::No))
  727. {
  728. return false;
  729. }
  730. else
  731. {
  732. return true;
  733. }
  734. }
  735. else
  736. {
  737. return false;
  738. }
  739. }
  740. bool DialogSelectSegment::chkAccountState(AccountLoginState state)
  741. {
  742. bool ret = false;
  743. switch(state)
  744. {
  745. case NotLogin:
  746. QMessageBox::critical(this,"提示","您现在还没有登录系统,请登录后再操作!",QMessageBox::Ok);
  747. break;
  748. case NotBind:
  749. QMessageBox::critical(this,"提示","此项服务尚未开通,请开通后再操作!",QMessageBox::Ok);
  750. break;
  751. case LoginError:
  752. QMessageBox::critical(this,"提示","此项服务暂时无法连接,请稍候重试!",QMessageBox::Ok);
  753. break;
  754. default:
  755. ret = true;
  756. }
  757. return ret;
  758. }
  759. void DialogSelectSegment::getUserServiceInfo(int day)
  760. {
  761. //同步查询用户端服务器信息
  762. if(m_account.value("ssohash").isEmpty())
  763. {
  764. ui->labelTip->setText(QString("<font color=red>您需要登录后才能获得资费信息</font>"));
  765. return ;
  766. }
  767. WSCube2 cube;
  768. setCursor(Qt::WaitCursor);
  769. QString json = cube.getUserZXSHServiceInfo(m_account.value("ssohash"));
  770. setCursor(Qt::ArrowCursor);
  771. RespGetUserZXSHServiceInfo resp(json);
  772. if(resp.getRtnCode()==1)
  773. {
  774. int total = resp.getMonthMaxDownShzs().toInt();
  775. int already = resp.getMonthDownShzs().toInt();
  776. int total2 = resp.getZxshMonthMaxDownShzs().toInt();
  777. int already2 = resp.getZxshMonthDownShzs().toInt();
  778. int day7inmax = resp.getZxshMonthMaxDownIn7dayShzs().toInt();
  779. int day7insubmit = resp.getZxshMonthDownIn7dayShzs().toInt();
  780. int day30inmax = resp.getZxshMonthMaxDownIn1MonthShzs().toInt();
  781. int day30insubmit = resp.getZxshMonthDownIn1MonthShzs().toInt();
  782. int day90inmax = resp.getZxshMonthMaxDownIn3MonthShzs().toInt();
  783. int day90insubmit = resp.getZxshMonthDownIn3MonthShzs().toInt();
  784. int day7 = qMin(qMin(total-already,day7inmax-day7insubmit),total2-already2);
  785. int day30= qMin(qMin(total-already,day30inmax-day30insubmit),total2-already2);
  786. int day90= qMin(qMin(total-already,day90inmax-day90insubmit),total2-already2);
  787. if(day<=7)
  788. ui->labelTip->setText(QString("[7天内实号数]已下载<font size=5 color=red><strong>%1</strong></font>个,还可下载<font size=5 color=red><strong>%2</strong></font>个").\
  789. arg(day7insubmit).arg(day7));
  790. else if(day==30)
  791. ui->labelTip->setText(QString("[1月内实号数]已下载<font size=5 color=red><strong>%1</strong></font>个,还可下载<font size=5 color=red><strong>%2</strong></font>个").\
  792. arg(day30insubmit).arg(day30));
  793. else if(day==90)
  794. ui->labelTip->setText(QString("[3月内实号数]已下载<font size=5 color=red><strong>%1</strong></font>个,还可下载<font size=5 color=red><strong>%2</strong></font>个").\
  795. arg(day90insubmit).arg(day90));
  796. else
  797. ui->labelTip->setText(QString("<font color=red>未知信息</font>"));
  798. }
  799. else
  800. {
  801. ui->labelTip->setText(QString("<font color=red>无法获取资费信息,错误原因:%1</font>").arg(resp.getRtnMemo()));
  802. }
  803. m_timer->stop();
  804. }
  805. int DialogSelectSegment::getSelectPackNums()
  806. {
  807. QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
  808. int count=0;
  809. int nums = 0;
  810. for(int i=0;i<items.size();i++)
  811. {
  812. QTableWidgetItem *item = items.at(i);
  813. count++;
  814. QString data = item->data(Qt::UserRole).toString();
  815. if(data.split(":").size()>2)
  816. {
  817. nums += data.split(":").at(1).toInt();
  818. }
  819. }
  820. return nums;
  821. }
  822. void DialogSelectSegment::refreshUserInfo()
  823. {
  824. if(ui->radioButton7->isChecked())
  825. {
  826. on_radioButton7_clicked();
  827. }
  828. else if(ui->radioButton30->isChecked())
  829. {
  830. on_radioButton30_clicked();
  831. }
  832. else if(ui->radioButton90->isChecked())
  833. {
  834. on_radioButton90_clicked();
  835. }
  836. }
  837. void DialogSelectSegment::on_tableWidget_itemSelectionChanged()
  838. {
  839. QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
  840. int count=0;
  841. int nums = 0;
  842. for(int i=0;i<items.size();i++)
  843. {
  844. QTableWidgetItem *item = items.at(i);
  845. count++;
  846. QString data = item->data(Qt::UserRole).toString();
  847. if(data.split(":").size()>2)
  848. {
  849. nums += data.split(":").at(1).toInt();
  850. }
  851. }
  852. ui->labelSelect->setText(QString("已选择<font size=5 color =red><strong>%1</strong></font>个实号包\
  853. <font size=5 color=red><strong>%2</strong></font>个实号").arg(count).arg(nums));
  854. }
  855. void DialogSelectSegment::on_pushButtonClearSelect_clicked()
  856. {
  857. QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
  858. if(items.size()==0)
  859. return ;
  860. for(int i=0;i<items.size();i++)
  861. {
  862. QTableWidgetItem *item = items.at(i);
  863. item->setSelected(false);
  864. }
  865. ui->labelSelect->setText(QString("已选择<font size=5 color =red><strong>%1</strong></font>个实号包\
  866. <font size=5 color=red><strong>%2</strong></font>个实号").arg(0).arg(0));
  867. }
  868. void DialogSelectSegment::on_xnRB_clicked()
  869. {
  870. fetchSegmentData();
  871. }
  872. void DialogSelectSegment::on_radioButtonAll_clicked()
  873. {
  874. fetchSegmentData();
  875. }
  876. void DialogSelectSegment::on_radioButtonDown_clicked()
  877. {
  878. fetchSegmentData();
  879. }
  880. void DialogSelectSegment::on_radioButtonNoDown_clicked()
  881. {
  882. fetchSegmentData();
  883. }
  884. void DialogSelectSegment::on_tableWidget_cellClicked(int row, int column)
  885. {
  886. // QList<QTableWidgetItem *> items = ui->tableWidget->selectedItems();
  887. // QTableWidgetItem *item = items.at(items.size()-2);
  888. // if(!item)
  889. // {
  890. // return ;
  891. // }
  892. // int startrow = item->row();
  893. // int startcol = item->column();
  894. }
  895. void DialogSelectSegment::on_pushButtonDetail_clicked()
  896. {
  897. QString ssoHash = m_account.value("ssohash");
  898. if(ssoHash.isEmpty())
  899. {
  900. QMessageBox::critical(this,"提示","您现在还没有登录系统,请登录后再操作!",QMessageBox::Ok);
  901. return;
  902. }
  903. WSSSO sso;
  904. QString json = sso.encrypt(ssoHash);
  905. RespEncrypt resp1(json);
  906. QString data = resp1.getEncryptData();
  907. json = sso.getServerTime();
  908. RespGetServerTime resp2(json);
  909. QString authCode;
  910. QByteArray ba;
  911. QString str = SNCDataBase::getAuthCodeUrl().arg(resp2.getServerTime().mid(0,16));
  912. ba = QCryptographicHash::hash ( str.toAscii(), QCryptographicHash::Md5 );
  913. authCode.append(ba.toHex());
  914. QString url = SNCDataBase::getSSOPayUrl() + "?s=mf&r="+authCode+"&u="+data+"&p=xq_zxsh";
  915. QDesktopServices::openUrl(QUrl(url));
  916. }
  917. bool DialogSelectSegment::eventFilter(QObject *object, QEvent *event)
  918. {
  919. if( event->type() == QEvent::KeyPress)
  920. {
  921. // if yes, we need to cast the event into a QMouseEvent type
  922. QKeyEvent * pKeyEvent = static_cast<QKeyEvent *>(event);
  923. // check whether it's mid button pressed
  924. if (pKeyEvent->key() == Qt::Key_Control||pKeyEvent->key() == Qt::Key_Shift)
  925. {
  926. //do the processing and return true
  927. //textBrowserErrorInfo->setText(tr("clicked"));
  928. ui->tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
  929. return true; //一定要返回true,如果你不想别的object也能接收到这个event
  930. }
  931. }
  932. else if( event->type() == QEvent::KeyRelease)
  933. {
  934. QKeyEvent * pKeyEvent = static_cast<QKeyEvent *>(event);
  935. // check whether it's mid button pressed
  936. if (pKeyEvent->key() == Qt::Key_Control||pKeyEvent->key() == Qt::Key_Shift)
  937. {
  938. //do the processing and return true
  939. //textBrowserErrorInfo->setText(tr("clicked"));
  940. ui->tableWidget->setSelectionMode(QAbstractItemView::MultiSelection);
  941. return true; //一定要返回true,如果你不想别的object也能接收到这个event
  942. }
  943. }
  944. return QWidget::eventFilter(object, event);
  945. }/**/
  946. void DialogSelectSegment::on_pushButtonSync_clicked()
  947. {
  948. ui->pushButtonSync->setEnabled(false);
  949. onTimeOut();
  950. ui->pushButtonSync->setEnabled(true);
  951. }