Commit ee12dfc5 by Carwyn

Merge branch 'release/1.0.1'

parents 3d462c58 9f2329d1
...@@ -70,5 +70,7 @@ Thumbs.db ...@@ -70,5 +70,7 @@ Thumbs.db
# -------- # --------
*.exe *.exe
/bin/* /bin/*
!/bin/release/fmclient.cfg
!/bin/release/fmcrypt.dll
!/bin/*.txt !/bin/*.txt
...@@ -26,12 +26,16 @@ CONFIG(debug, debug|release){ ...@@ -26,12 +26,16 @@ CONFIG(debug, debug|release){
SOURCES += main.cpp\ SOURCES += main.cpp\
widget.cpp \ widget.cpp \
qfmclient.cpp qfmclient.cpp \
scanner.cpp
HEADERS += widget.h \ HEADERS += widget.h \
fmcrypt.h \ fmcrypt.h \
qfmclient.h \ qfmclient.h \
app_single.h \ app_single.h \
log.h log.h \
utility.h \
scanner.h
FORMS += widget.ui FORMS += widget.ui \
scanner.ui
2.0
1
115.159.63.201
34952
26666
30
30
1
E:\NewPos61\out\receipt.txt
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "app_single.h" #include "app_single.h"
#include "log.h" #include "log.h"
#include "scanner.h"
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
...@@ -15,9 +17,12 @@ int main(int argc, char *argv[]) ...@@ -15,9 +17,12 @@ int main(int argc, char *argv[])
InitLogger(); InitLogger();
QLOG_INFO()<<"start FmclientUi..."; QLOG_INFO()<<"start FmclientUi...";
Widget w; Widget w;
scanner s;
QFmClient client; QFmClient client;
QObject::connect(&client,&QFmClient::HideUi, &w, &Widget::hide,Qt::QueuedConnection); QObject::connect(&client,&QFmClient::HideUi, &w, &Widget::hide,Qt::QueuedConnection);
QObject::connect(&client,&QFmClient::ShowUi, &w, &Widget::showTop,Qt::QueuedConnection); QObject::connect(&client,&QFmClient::ShowUi, &w, &Widget::showRequesting,Qt::QueuedConnection);
QObject::connect(&client, &QFmClient::ShowRefundUi, &s, &scanner::showRefund);
QObject::connect(&s, SIGNAL(fetched(QString)), &client, SLOT(SetTransactionId(QString)));
QObject::connect(&client,&QFmClient::finished, &a, &a.quit); QObject::connect(&client,&QFmClient::finished, &a, &a.quit);
client.start(); client.start();
return a.exec(); return a.exec();
......
...@@ -10,7 +10,11 @@ ...@@ -10,7 +10,11 @@
#include <QApplication> #include <QApplication>
#include <QWidget> #include <QWidget>
#include <QDir> #include <QDir>
#include <QTimer>
#include "QsLog/QsLog.h" #include "QsLog/QsLog.h"
#include "utility.h"
#include "scanner.h"
#ifdef WIN32 #ifdef WIN32
#include <direct.h> #include <direct.h>
...@@ -778,6 +782,15 @@ void QFmClient::BackupPosReq(char * req) ...@@ -778,6 +782,15 @@ void QFmClient::BackupPosReq(char * req)
} }
} }
void QFmClient::SetTransactionId(QString fmId)
{
_refundTransId.clear();
_refundTransId = fmId;
emit ContinueRefund();
}
void QFmClient::run() void QFmClient::run()
{ {
if(!Init("115.159.63.201", 29534, 34952, 30, 5)) if(!Init("115.159.63.201", 29534, 34952, 30, 5))
...@@ -823,7 +836,6 @@ void QFmClient::run() ...@@ -823,7 +836,6 @@ void QFmClient::run()
CloseSocket(&_acceptedSock); CloseSocket(&_acceptedSock);
continue; continue;
} }
emit ShowUi();
QJsonObject object; QJsonObject object;
char temp_recv[MAX_BUF_LEN] = {0}; char temp_recv[MAX_BUF_LEN] = {0};
strcpy(temp_recv, _recvbuf); strcpy(temp_recv, _recvbuf);
...@@ -832,23 +844,50 @@ void QFmClient::run() ...@@ -832,23 +844,50 @@ void QFmClient::run()
if (0 > needBackup) if (0 > needBackup)
{ {
CloseSocket(&_acceptedSock); CloseSocket(&_acceptedSock);
emit HideUi();
continue; continue;
} }
int reqtype = object.value("reqtype").toInt(72);
if(reqtype == 72 || reqtype == 101)
{
emit ShowUi();
}
if (reqtype == 52 && (!object.contains("fmId") || object["fmId"].isNull())) {
emit ShowRefundUi();
QEventLoop evt;
QTimer t(this);
connect(&t, SIGNAL(timeout()), &evt, SLOT(quit()));
t.start(30000);
connect(this, SIGNAL(ContinueRefund()), &evt, SLOT(quit()));
evt.exec();
object["fmId"] = _refundTransId;
if (!object.contains("station_id")) {
//! 给到客户的文档中, 缺少 station_id 字段
object["station_id"] = "1";
}
QLOG_ERROR() << "refund fmId: " << _refundTransId;
}
if (0 != Try2ConnectZhProxy()) if (0 != Try2ConnectZhProxy())
{ {
qDebug() << "connect to proxy failed"; qDebug() << "connect to proxy failed";
QLOG_ERROR() << "connect to proxy failed"; QLOG_ERROR() << "connect to proxy failed";
CloseSocket(&_acceptedSock); CloseSocket(&_acceptedSock);
if(reqtype == 72 || reqtype == 101)
{
emit HideUi(); emit HideUi();
}
continue; continue;
} }
if (0 != SendCtrlInfo2Proxy()) if (0 != SendCtrlInfo2Proxy())
{ {
CloseSocket(&_acceptedSock); CloseSocket(&_acceptedSock);
if(reqtype == 72 || reqtype == 101)
{
emit HideUi(); emit HideUi();
}
continue; continue;
} }
...@@ -860,7 +899,10 @@ void QFmClient::run() ...@@ -860,7 +899,10 @@ void QFmClient::run()
rlt = SendData2ZhProxyAndWaitRspData(); rlt = SendData2ZhProxyAndWaitRspData();
if(reqtype == 72 || reqtype == 101)
{
emit HideUi(); emit HideUi();
}
OutputDebugString(L"hide Ui"); OutputDebugString(L"hide Ui");
if (0 == rlt) if (0 == rlt)
{ {
......
...@@ -21,11 +21,13 @@ public: ...@@ -21,11 +21,13 @@ public:
void quit(); void quit();
bool Init(QString proxy_IP, unsigned short proxy_port, unsigned short listen_prot, unsigned short long_timeout, unsigned short short_timeout); bool Init(QString proxy_IP, unsigned short proxy_port, unsigned short listen_prot, unsigned short long_timeout, unsigned short short_timeout);
signals:
signals:
void Error(QString error); void Error(QString error);
void HideUi(); void HideUi();
void ShowUi(); void ShowUi();
void ShowRefundUi();
void ContinueRefund();
private: private:
void CloseSocket(int *sock); void CloseSocket(int *sock);
void GetKey(); void GetKey();
...@@ -51,6 +53,10 @@ private: ...@@ -51,6 +53,10 @@ private:
int ProcessZhProxyRspDataAndSend2Pos(); int ProcessZhProxyRspDataAndSend2Pos();
int CheckRecvedData(); int CheckRecvedData();
void BackupPosReq(char *req); void BackupPosReq(char *req);
public slots:
void SetTransactionId(QString fmId); //退款流程1, 从输入获取长码
private: private:
bool _endflag; bool _endflag;
...@@ -96,7 +102,7 @@ private: ...@@ -96,7 +102,7 @@ private:
char _reserved; char _reserved;
QString _refundTransId;
static unsigned int s_reqCount; static unsigned int s_reqCount;
}; };
......
#include "scanner.h"
#include "ui_scanner.h"
#include <QPainter>
#include <Windows.h>
#include <QDebug>
scanner::scanner(QWidget *parent) :
QDialog(parent),
ui(new Ui::scanner)
{
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_QuitOnClose, false);
connect(ui->fmIdEdit, SIGNAL(editingFinished()), SLOT(OnEditFinished()));
}
scanner::~scanner()
{
delete ui;
}
void scanner::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void scanner::OnEditFinished()
{
emit fetched(ui->fmIdEdit->text());
QDialog::accept();
}
void scanner::showRefund()
{
ui->fmIdEdit->clear();
showNormal();
HWND hForeWnd = ::GetForegroundWindow();
DWORD dwForeID = ::GetWindowThreadProcessId(hForeWnd,NULL);
DWORD dwCurID = ::GetCurrentThreadId();
::AttachThreadInput(dwCurID,dwForeID,TRUE);
::SetForegroundWindow((HWND)effectiveWinId());
::SetWindowPos( (HWND)effectiveWinId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
showNormal();
::SetForegroundWindow((HWND)effectiveWinId());
::AttachThreadInput(dwCurID,dwForeID,FALSE);
QDialog::exec();
}
#ifndef SCANNER_H
#define SCANNER_H
#include <QDialog>
namespace Ui {
class scanner;
}
class scanner : public QDialog
{
Q_OBJECT
public:
explicit scanner(QWidget *parent = 0);
~scanner();
void paintEvent(QPaintEvent *);
signals:
void fetched(QString);
public slots:
void OnEditFinished();
void showRefund();
private:
Ui::scanner *ui;
};
#endif // SCANNER_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>scanner</class>
<widget class="QDialog" name="scanner">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>310</width>
<height>310</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="windowTitle">
<string>请扫描付款凭证</string>
</property>
<property name="styleSheet">
<string notr="true">QLabel
{
font: 75 25px &quot;Microsoft YaHei Light&quot;;
}
#scanner
{
border: 0 solid gray;
border-radius:15px;
font: 9pt &quot;Agency FB&quot;;
background-color: rgb(225, 225, 225);
}
#fmIdEdit
{
border: 0 solid white;
background: transparent;
color: orange;
font: 400 25px &quot;Microsoft YaHei&quot;;
}
</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_wait_title">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">#label_wait_title
{
font: 75 25px &quot;Microsoft YaHei UI Light&quot;;
}</string>
</property>
<property name="text">
<string>请扫描付款凭证</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fmIdEdit">
<property name="cursor">
<cursorShape>BlankCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
#ifndef UTILITY
#define UTILITY
#endif // UTILITY
...@@ -56,7 +56,7 @@ void Widget::move() ...@@ -56,7 +56,7 @@ void Widget::move()
// //show(); // //show();
//} //}
void Widget::showTop() void Widget::showRequesting()
{ {
showNormal(); showNormal();
HWND hForeWnd = ::GetForegroundWindow(); HWND hForeWnd = ::GetForegroundWindow();
......
...@@ -15,7 +15,7 @@ class Widget : public QWidget ...@@ -15,7 +15,7 @@ class Widget : public QWidget
public: public:
explicit Widget(QWidget *parent = 0); explicit Widget(QWidget *parent = 0);
~Widget(); ~Widget();
void showTop(); void showRequesting();
protected slots: protected slots:
void move(); void move();
......
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