Commit 9f2329d1 by Carwyn

1. 添加McD 扫码退款功能

parent 7a2db306
......@@ -2,7 +2,7 @@
1
115.159.63.201
34952
29535
26666
30
30
1
......
......@@ -4,6 +4,8 @@
#include "app_single.h"
#include "log.h"
#include "scanner.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
......@@ -15,9 +17,12 @@ int main(int argc, char *argv[])
InitLogger();
QLOG_INFO()<<"start FmclientUi...";
Widget w;
scanner s;
QFmClient client;
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);
client.start();
return a.exec();
......
......@@ -10,9 +10,12 @@
#include <QApplication>
#include <QWidget>
#include <QDir>
#include <QTimer>
#include "QsLog/QsLog.h"
#include "utility.h"
#include "scanner.h"
#ifdef WIN32
#include <direct.h>
#include <windows.h>
......@@ -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()
......@@ -846,6 +853,22 @@ void QFmClient::run()
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())
{
qDebug() << "connect to proxy failed";
......
......@@ -21,11 +21,13 @@ public:
void quit();
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 HideUi();
void ShowUi();
void ShowRefundUi();
void ContinueRefund();
private:
void CloseSocket(int *sock);
void GetKey();
......@@ -51,7 +53,9 @@ private:
int ProcessZhProxyRspDataAndSend2Pos();
int CheckRecvedData();
void BackupPosReq(char *req);
QString GetInputfmId(); //退款流程1, 从输入获取长码
public slots:
void SetTransactionId(QString fmId); //退款流程1, 从输入获取长码
private:
......@@ -98,7 +102,7 @@ private:
char _reserved;
QString _refundTransId;
static unsigned int s_reqCount;
};
......
#include "scanner.h"
#include "ui_scanner.h"
#include <QPainter>
#include <Windows.h>
#include <QDebug>
scanner::scanner(QWidget *parent) :
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()
......@@ -13,18 +20,32 @@ scanner::~scanner()
delete ui;
}
bool scanner::eventFilter(QObject *obj, QEvent *event)
void scanner::paintEvent(QPaintEvent *)
{
if (obj == fmId_edit) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
qDebug() << "key press" << keyEvent->key();
return true;
} else {
return false;
}
} else {
// pass the event on to the parent class
return QWidget::eventFilter(obj, event);
}
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 <QWidget>
#include <QDialog>
namespace Ui {
class scanner;
}
class scanner : public QWidget
class scanner : public QDialog
{
Q_OBJECT
......@@ -15,6 +15,15 @@ public:
explicit scanner(QWidget *parent = 0);
~scanner();
void paintEvent(QPaintEvent *);
signals:
void fetched(QString);
public slots:
void OnEditFinished();
void showRefund();
private:
Ui::scanner *ui;
};
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>scanner</class>
<widget class="QWidget" name="scanner">
<widget class="QDialog" name="scanner">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>240</height>
<width>310</width>
<height>310</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="windowTitle">
<string>退款条码输入</string>
<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>
<widget class="QLineEdit" name="fmId_edit">
<property name="geometry">
<rect>
<x>62</x>
<y>149</y>
<width>241</width>
<height>41</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="fmId">
<property name="geometry">
<rect>
<x>10</x>
<y>160</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>fmId</string>
</property>
</widget>
<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>
......@@ -56,7 +56,7 @@ void Widget::move()
// //show();
//}
void Widget::showTop()
void Widget::showRequesting()
{
showNormal();
HWND hForeWnd = ::GetForegroundWindow();
......
......@@ -15,7 +15,7 @@ class Widget : public QWidget
public:
explicit Widget(QWidget *parent = 0);
~Widget();
void showTop();
void showRequesting();
protected slots:
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