Commit 9b836681 by guanghui.cui

收银信息展示

parent 6456ea36
#include "cquerythread.h"
CQueryThread::CQueryThread(FMPePayPrivate *fmPay)
:_fmPay(fmPay)
,_iReqCount(0)
,_run(false)
{
}
void CQueryThread::run()
{
while (_run) {
QThread::sleep(5);
trySend();
}
}
void CQueryThread::trySend()
{
QString errors;
QJsonObject outjson;
_query_request["clientReqCount"]=_iReqCount+1;
_fmPay->HttpPost(outjson, _query_request ,errors);
if(outjson[FMP_RPAY_PAY_RETURN_STATUSCODE].toInt() != 102){
_run=false;
//write sqlite
outjson[FMP_EPAY_TRANSID]=_reqJson[FMP_EPAY_TRANSID];
_fmPay->updateSqlite(outjson);
}
}
bool CQueryThread::isRunning()
{
return _run;
}
void CQueryThread::setReqJson(QJsonObject reqJson)
{
_reqJson=reqJson;
_query_request.insert("clientReqCount",++_iReqCount);
_query_request.insert("trans_id",_reqJson[FMP_EPAY_TRANSID]);
_query_request.insert("station_id",_reqJson[FMP_EPAY_STATIONID]);
_query_request.insert("partnerId",_reqJson[FMP_EPAY_PARTNERID]);
_query_request.insert("reqtype",52);
_query_request.insert("store_id",_reqJson[FMP_EPAY_STOREID]);
_query_request.insert("operator_id",_reqJson[FMP_EPAY_OPERATORID]);
_query_request.insert("ver",_reqJson[FMP_EPAY_VER]);
_query_request.insert("fmid","");
_run=true;
}
#ifndef CQUERYTHREAD_H
#define CQUERYTHREAD_H
#include <QThread>
#include <QJsonObject>
#include "fmp_epay_p.h"
class FMPePayPrivate;
class CQueryThread:public QThread
{
public:
CQueryThread(FMPePayPrivate *fmPay);
void run();
void trySend();
void setReqJson(QJsonObject reqJson);
bool isRunning();
private:
FMPePayPrivate *_fmPay;
QJsonObject _reqJson;
QJsonObject _query_request;
int _iReqCount;
bool _run;
};
#endif // CQUERYTHREAD_H
......@@ -140,6 +140,28 @@ bool FMPDataBase::find(QString table, QSqlQuery &query, QStringList keylist, QSt
return flag;
}
bool FMPDataBase::isRecordExist(QString table, QString condition)
{
if(!_isopen)
return false;
QSqlQuery tmpquery(_db);
QString sql = QString("select * from %1 where trans_id = '%2'").arg(table, condition);
//QString sql = QString("select * from %1 where trans_id = '%2'").arg(table, "70102003004005");
FMP_INFO() << "find sql : " << sql;
bool flag = tmpquery.exec(sql);
if(!flag)
FMP_WARN() << tmpquery.lastError();
tmpquery.last();
int total=tmpquery.at()+1;
if(total>0)
return true;
return false;
}
bool FMPDataBase::getSql(QString table, QVariantHash data, QStringList& columnnamelist, QStringList& columnvaluelist)
{
QSqlQuery query(_db);
......
......@@ -29,6 +29,8 @@ public:
QSqlDatabase getDb() const;
bool isRecordExist(QString table, QString condition);
private:
bool exist(QString table);
......
......@@ -22,7 +22,8 @@ SOURCES += \
fmnumpad.cpp \
fmp_cashconfirm_dialog.cpp \
fmp_forceclose_dialog.cpp \
fmp_payfailed_dialog.cpp
fmp_payfailed_dialog.cpp \
cquerythread.cpp
HEADERS +=\
fmp_epay.h \
......@@ -39,7 +40,8 @@ HEADERS +=\
fmnumpad.h \
fmp_cashconfirm_dialog.h \
fmp_forceclose_dialog.h \
fmp_payfailed_dialog.h
fmp_payfailed_dialog.h \
cquerythread.h
unix {
target.path = /usr/lib
......
......@@ -29,6 +29,24 @@ public:
return QString::fromLocal8Bit("未退款");
}
}
if ((idx.column() == 14) && role == Qt::DisplayRole) {
QVariant d = QSqlTableModel::data(idx,role);
if (d.toInt()==100) {
return QString::fromLocal8Bit("成功");
}
else if(d.toInt()==102)
{
return QString::fromLocal8Bit("超时");
}
else if(d.toInt()==105||d.toInt()==106)
{
return QString::fromLocal8Bit("待支付");
}
else if(d.toInt()==108)
{
return QString::fromLocal8Bit("关闭");
}
}
return QSqlTableModel::data(idx, role);
}
......
......@@ -2,6 +2,7 @@
#define FMP_EPAY_P_H
#include "fmp_epay.h"
#include "cquerythread.h"
#include <QObject>
#include <QFuture>
#include <QJsonObject>
......@@ -12,6 +13,13 @@ class FMPLoggerInterface;
class FMPNetworkInterface;
class FMPDataBase;
class QSqlTableModel;
class CQueryThread;
typedef struct {
int flag;
int ver;
int len;
}FMSOCKEHEADER;
class FMPePayPrivate : public QObject
{
......@@ -33,6 +41,8 @@ public:
void GetMode();
void GetApiReqMode(int type);
void ClosePayWindow(int type);
QSqlTableModel *model() const;
......@@ -42,6 +52,14 @@ public:
void DockRefundRequest(const QByteArray &json);
QByteArray DockRefundRespond();
void writeOrderToSqlite();
void updateSqlite(const QJsonObject &json);
void setPosTransId(QString orderId);
bool HttpPost(QJsonObject& outjson, QJsonObject json, QString &error, int timeout = 60);
private:
void ControlReverseJson();
......@@ -49,15 +67,15 @@ private:
void GetReverseJson();
bool GetPayJson(const QString &sum, const QString &code);
bool HttpPost(QJsonObject& outjson, QJsonObject json, QString &error, int timeout = 60);
bool GetPayJson(const QString &sum, const QString &code);
bool CheckReturnJson(QByteArray data, QJsonObject &returnjson);
void SetBasicInfo(QVariantHash hash);
void clearorder();
void SendToMonitor(const QByteArray &data);
signals:
void apiError();
void apiFinish();
......@@ -76,14 +94,15 @@ public:
FMPSettingsInterface *_setting;
FMPNetworkInterface *_network;
bool _is_api;
CQueryThread *_queryThread;
private:
QJsonObject _origin_request;
QJsonObject _docked_request;
QJsonObject _origin_response;
QJsonObject _docked_response;
bool _is_api;
bool _reverse_flag;
static unsigned int s_ClientReqCount;
......
......@@ -18,6 +18,11 @@
#define DIALOG_FORCE_CLOSE 1 //窗口强制关闭
#define DIALOG_CASH_CLOSE 2 //转现金支付
#define ORDER_NEED_PAY 1 //待支付订单
#define ORDER_HAS_ERROR 2 //支付失败订单
#define ORDER_PAY_SUCCESS 3 //支付成功订单
#define ORDER_DONE 4 //已关闭订单
class FMPePayPrivate;
class FMPLoggerInterface;
......@@ -51,6 +56,8 @@ public slots:
void onSelectionChanged(QModelIndex idx);
void onWaitPaySelectionChanged(QModelIndex idx);
void setBasicInfo(QVariantHash basicinfo);
void on_cash_pay();
......@@ -89,11 +96,17 @@ private slots:
void on_lineEdit_textChanged(const QString &arg1);
void on_btn_waitPay_pay_clicked();
void on_btn_waitPay_close_clicked();
public:
void setPayView();
void setRefundView();
void setShowFunc();
private:
void setCheckView();
......@@ -111,6 +124,12 @@ private:
void closeEvent(QCloseEvent * event);
void setTableHeader();
void setSuccessView();
void setErrorOrderView();
void setWaitPayView();
void setDoneView();
private:
Ui::FMPPayDialog *ui;
......
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 13
#define VER_BUILD 14
//! Convert version numbers to string
#define _STR(S) #S
......
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