Commit 9f2329d1 by Carwyn

1. 添加McD 扫码退款功能

parent 7a2db306
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
1 1
115.159.63.201 115.159.63.201
34952 34952
29535 26666
30 30
30 30
1 1
......
...@@ -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,9 +10,12 @@ ...@@ -10,9 +10,12 @@
#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 "utility.h"
#include "scanner.h"
#ifdef WIN32 #ifdef WIN32
#include <direct.h> #include <direct.h>
#include <windows.h> #include <windows.h>
...@@ -779,9 +782,13 @@ void QFmClient::BackupPosReq(char * req) ...@@ -779,9 +782,13 @@ void QFmClient::BackupPosReq(char * req)
} }
} }
QString QFmClient::GetInputfmId() void QFmClient::SetTransactionId(QString fmId)
{ {
_refundTransId.clear();
_refundTransId = fmId;
emit ContinueRefund();
} }
void QFmClient::run() void QFmClient::run()
...@@ -846,6 +853,22 @@ void QFmClient::run() ...@@ -846,6 +853,22 @@ void QFmClient::run()
emit ShowUi(); 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";
......
...@@ -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,7 +53,9 @@ private: ...@@ -51,7 +53,9 @@ private:
int ProcessZhProxyRspDataAndSend2Pos(); int ProcessZhProxyRspDataAndSend2Pos();
int CheckRecvedData(); int CheckRecvedData();
void BackupPosReq(char *req); void BackupPosReq(char *req);
QString GetInputfmId(); //退款流程1, 从输入获取长码
public slots:
void SetTransactionId(QString fmId); //退款流程1, 从输入获取长码
private: private:
...@@ -98,7 +102,7 @@ private: ...@@ -98,7 +102,7 @@ private:
char _reserved; char _reserved;
QString _refundTransId;
static unsigned int s_reqCount; static unsigned int s_reqCount;
}; };
......
#include "scanner.h" #include "scanner.h"
#include "ui_scanner.h" #include "ui_scanner.h"
#include <QPainter>
#include <Windows.h>
#include <QDebug>
scanner::scanner(QWidget *parent) : scanner::scanner(QWidget *parent) :
QWidget(parent), QDialog(parent),
ui(new Ui::scanner) ui(new Ui::scanner)
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_QuitOnClose, false);
connect(ui->fmIdEdit, SIGNAL(editingFinished()), SLOT(OnEditFinished()));
} }
scanner::~scanner() scanner::~scanner()
...@@ -13,18 +20,32 @@ scanner::~scanner() ...@@ -13,18 +20,32 @@ scanner::~scanner()
delete ui; delete ui;
} }
bool scanner::eventFilter(QObject *obj, QEvent *event) void scanner::paintEvent(QPaintEvent *)
{ {
if (obj == fmId_edit) { QStyleOption opt;
if (event->type() == QEvent::KeyPress) { opt.init(this);
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); QPainter p(this);
qDebug() << "key press" << keyEvent->key(); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
return true; }
} else {
return false; void scanner::OnEditFinished()
} {
} else { emit fetched(ui->fmIdEdit->text());
// pass the event on to the parent class QDialog::accept();
return QWidget::eventFilter(obj, event); }
}
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 #ifndef SCANNER_H
#define SCANNER_H #define SCANNER_H
#include <QWidget> #include <QDialog>
namespace Ui { namespace Ui {
class scanner; class scanner;
} }
class scanner : public QWidget class scanner : public QDialog
{ {
Q_OBJECT Q_OBJECT
...@@ -15,6 +15,15 @@ public: ...@@ -15,6 +15,15 @@ public:
explicit scanner(QWidget *parent = 0); explicit scanner(QWidget *parent = 0);
~scanner(); ~scanner();
void paintEvent(QPaintEvent *);
signals:
void fetched(QString);
public slots:
void OnEditFinished();
void showRefund();
private: private:
Ui::scanner *ui; Ui::scanner *ui;
}; };
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>scanner</class> <class>scanner</class>
<widget class="QWidget" name="scanner"> <widget class="QDialog" name="scanner">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>320</width> <width>310</width>
<height>240</height> <height>310</height>
</rect> </rect>
</property> </property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>退款条码输入</string> <string>请扫描付款凭证</string>
</property> </property>
<widget class="QLineEdit" name="fmId_edit"> <property name="styleSheet">
<property name="geometry"> <string notr="true">QLabel
<rect> {
<x>62</x> font: 75 25px &quot;Microsoft YaHei Light&quot;;
<y>149</y> }
<width>241</width> #scanner
<height>41</height> {
</rect> 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> </property>
</widget> </widget>
<widget class="QLabel" name="fmId"> </item>
<property name="geometry"> <item>
<rect> <widget class="QLineEdit" name="fmIdEdit">
<x>10</x> <property name="cursor">
<y>160</y> <cursorShape>BlankCursor</cursorShape>
<width>54</width> </property>
<height>12</height> <property name="focusPolicy">
</rect> <enum>Qt::StrongFocus</enum>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>fmId</string> <string/>
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </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> </widget>
<layoutdefault spacing="6" margin="11"/>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>
...@@ -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