Commit 6222412f by gujin.wang

1,为卡券核销添加等待画面 2,添加对折扣券的支持

parent 2461d574
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
border-top-left-radius:12px; border-top-left-radius:12px;
border-top-right-radius:12px; border-top-right-radius:12px;
} }
/**/
#topNoConsumeWidget{ #topNoConsumeWidget{
background-image: url(:/img/bg_no_exchange.png); background-image: url(:/img/bg_no_exchange.png);
border:none; border:none;
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
border-top-left-radius:12px; border-top-left-radius:12px;
border-top-right-radius:12px; border-top-right-radius:12px;
} }
/**/
#labActName{ #labActName{
font-size:30px; font-size:30px;
font-family:"微软雅黑"; font-family:"微软雅黑";
...@@ -77,15 +77,13 @@ ...@@ -77,15 +77,13 @@
#btnCannel{ #btnCannel{
border:none; border:none;
background-image: url(:/img/btn_canel.png); border-image: url(:/img/btn_canel.png);
} }
/**/
#btnConsumOk{ #btnConsumOk{
border:none; border:none;
background-image: url(:/img/consumption_ok.png); border-image: url(:/img/consumption_ok.png);
} }
/**/
</string> </string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
......
#include "consumptiondialog.h" #include "consumptiondialog.h"
#include "ui_consumptiondialog.h" #include "ui_consumptiondialog.h"
#include <QTimer>
ConsumptionDialog::ConsumptionDialog(QWidget * parent, Qt::WindowFlags f) : ConsumptionDialog::ConsumptionDialog(QWidget * parent, Qt::WindowFlags f) :
QDialog(parent, f), QDialog(parent, f),
ui(new Ui::ConsumptionDialog) ui(new Ui::ConsumptionDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
timer = Q_NULLPTR;
setWindowTitle(QString::fromLocal8Bit("非码卡券")); setWindowTitle(QString::fromLocal8Bit("非码卡券"));
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
setAutoFillBackground(false); //这个不设置的话就背景变黑 setAutoFillBackground(false); //这个不设置的话就背景变黑
...@@ -18,6 +20,10 @@ ConsumptionDialog::ConsumptionDialog(QWidget * parent, Qt::WindowFlags f) : ...@@ -18,6 +20,10 @@ ConsumptionDialog::ConsumptionDialog(QWidget * parent, Qt::WindowFlags f) :
ConsumptionDialog::~ConsumptionDialog() ConsumptionDialog::~ConsumptionDialog()
{ {
if(timer->isActive())
timer->stop();
timer->deleteLater();
timer = Q_NULLPTR;
delete ui; delete ui;
} }
...@@ -61,6 +67,38 @@ bool ConsumptionDialog::ShowForHasConsum(const QString& act_name, const QString& ...@@ -61,6 +67,38 @@ bool ConsumptionDialog::ShowForHasConsum(const QString& act_name, const QString&
return false; return false;
} }
void ConsumptionDialog::ShowForWaiting(const QString &act_name, const QString &code_name, const QString &time_name, const QString &coupon, QWidget *parent)
{
ui->topNoConsumeWidget->setObjectName( "topNoConsumeWidget");
ui->topNoConsumeWidget->setStyleSheet( ui->topNoConsumeWidget->styleSheet());
ui->btnConsumption->setObjectName( "btnConsumNull");
ui->btnConsumption->setStyleSheet( ui->btnConsumption->styleSheet());
ui->btnConsumption->setEnabled( false);
setData( act_name,code_name ,time_name,coupon );
show();
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(OnTimeout()));
timer->start(1000);
}
void ConsumptionDialog::OnTimeout()
{
static int i = 0;
i++;
if(i > 3)
{
ui->labActName->setText(QString::fromLocal8Bit("请稍后"));
i = 0;
}
else
{
QString txt = ui->labActName->text();
txt.append(".");
ui->labActName->setText(txt);
}
}
void ConsumptionDialog::setData(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon) void ConsumptionDialog::setData(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon)
{ {
ui->labCode->setText( coupon); ui->labCode->setText( coupon);
......
#ifndef CONSUMPTIONDIALOG_H #ifndef CONSUMPTIONDIALOG_H
#define CONSUMPTIONDIALOG_H #define CONSUMPTIONDIALOG_H
#include <QDialog> #include <QDialog>
#include <QTimer>
class WorkObject; class WorkObject;
namespace Ui { namespace Ui {
...@@ -21,6 +21,10 @@ public: ...@@ -21,6 +21,10 @@ public:
void setData(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon); void setData(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon);
static bool ShowForUnConsum(const QString &act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0); static bool ShowForUnConsum(const QString &act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0);
static bool ShowForHasConsum(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0); static bool ShowForHasConsum(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0);
void ShowForWaiting(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0);
private slots:
void OnTimeout();
signals: signals:
void sgBtnOk(); void sgBtnOk();
...@@ -28,6 +32,7 @@ signals: ...@@ -28,6 +32,7 @@ signals:
private: private:
Ui::ConsumptionDialog *ui; Ui::ConsumptionDialog *ui;
QTimer* timer;
}; };
#endif // CONSUMPTIONDIALOG_H #endif // CONSUMPTIONDIALOG_H
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
border-top-left-radius:12px; border-top-left-radius:12px;
border-top-right-radius:12px; border-top-right-radius:12px;
} }
/**/ /**/
#labActName{ #labActName{
/*font: 30 bold &quot;微软雅黑&quot;;*/ /*font: 30 bold &quot;微软雅黑&quot;;*/
...@@ -81,18 +82,17 @@ ...@@ -81,18 +82,17 @@
#btnCannel{ #btnCannel{
border:none; border:none;
background-image: url(:/img/btn_canel.png); border-image: url(:/img/btn_canel.png);
} }
/**/
#btnConsumption{ #btnConsumption{
border:none; border:none;
background-image: url(:/img/btn_consumption.png); border-image: url(:/img/btn_consumption.png);
} }
#btnConsumNull{ #btnConsumNull{
border:none; border:none;
background-image: url(:/img/btn_consumption_invalid.png); border-image: url(:/img/btn_consumption_invalid.png);
} }</string>
/**/</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing"> <property name="spacing">
......
...@@ -87,17 +87,16 @@ ...@@ -87,17 +87,16 @@
/*label*/ /*label*/
#btnCannel{ #btnCannel{
border:none; border:none;
background-image: url(:/img/btn_canel.png); border-image: url(:/img/btn_canel.png);
} }
/**/ /**/
#btnConsumption{ #btnConsumption{
border:none; border:none;
background-image: url(:/img/btn_consumption.png); border-image: url(:/img/btn_consumption.png);
} }
#btnConsumNull{ #btnConsumNull{
border:none; border:none;
border-image: url(:/img/btn_consumption_invalid.png);
background-image: url(:/img/btn_consumption_invalid.png);
} }
/**/</string> /**/</string>
</property> </property>
......
...@@ -135,8 +135,10 @@ QJsonObject FMPRedeem::Redeem(const QJsonArray& productsInfo) ...@@ -135,8 +135,10 @@ QJsonObject FMPRedeem::Redeem(const QJsonArray& productsInfo)
{ {
_store_id = storeDialog.storeId; _store_id = storeDialog.storeId;
_station_id = storeDialog.posId; _station_id = storeDialog.posId;
_partner_id = storeDialog.partnerId.toInt();
settings.setValue(FMP_INIKEY_LOGINSTOREID, _store_id); settings.setValue(FMP_INIKEY_LOGINSTOREID, _store_id);
settings.setValue(FMP_INIKEY_LOGINPOSID, _station_id); settings.setValue(FMP_INIKEY_LOGINPOSID, _station_id);
settings.setValue(FMP_INIKEY_LOGINPARTNERID, _partner_id);
} }
else else
{ {
...@@ -219,8 +221,12 @@ QJsonObject FMPRedeem::SendRequest(const QByteArray &reqData) ...@@ -219,8 +221,12 @@ QJsonObject FMPRedeem::SendRequest(const QByteArray &reqData)
timer.setSingleShot(true); timer.setSingleShot(true);
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
timer.start(1000 * 30); timer.start(1000 * 30);
ConsumptionDialog cd;
connect(&cd, SIGNAL(rejected()), &loop, SLOT(quit()));
connect(&timer, SIGNAL(timeout()), &cd, SLOT(reject()));
cd.ShowForWaiting(QString::fromLocal8Bit("请稍后"), "", "", "");
loop.exec(); loop.exec();
if(timer.isActive()) if(timer.isActive())
{ {
timer.stop(); timer.stop();
...@@ -246,6 +252,7 @@ QJsonObject FMPRedeem::SendRequest(const QByteArray &reqData) ...@@ -246,6 +252,7 @@ QJsonObject FMPRedeem::SendRequest(const QByteArray &reqData)
} }
reply->deleteLater(); reply->deleteLater();
FMP_DEBUG() << "Server response: " << QJsonDocument(retJson).toJson(QJsonDocument::Compact); FMP_DEBUG() << "Server response: " << QJsonDocument(retJson).toJson(QJsonDocument::Compact);
return retJson; return retJson;
} }
...@@ -279,30 +286,16 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json) ...@@ -279,30 +286,16 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
transaction["code"] = coupon; transaction["code"] = coupon;
transaction["ebcode"] = ebcode; transaction["ebcode"] = ebcode;
//得到该券所对应商品id,目前一张券只对应一种商品 QJsonArray products;
QString canUsedProduct = SearchJsonObject(json, "pid").toString(); for(int i = 0; i < _products_info.size(); i++)
//遍历传入的商品信息,查找是否有相同的商品id,
//若有则进行核销,否则,直接返回失败
int i;
for(i = 0; i < _products_info.size(); i++){
QJsonObject obj = _products_info[i].toObject();
if(obj["pid"].toString() == canUsedProduct)
break;
}
if(i >= _products_info.size())
{ {
//不存在对应商品 QJsonObject product;
return ShowForMismatch(json); product.insert("seq", 1);
product.insert("pid", _products_info[i].toObject()["pid"]);
product.insert("consume_num", _products_info[i].toObject()["consume_num"]);
products.append(product);
} }
QJsonArray products;
QJsonObject product;
product.insert("seq", 1);
product.insert("pid", _products_info[i].toObject()["pid"]);
product.insert("consume_num", _products_info[i].toObject()["consume_num"]);
products.append(product);
transaction["products"] = products; transaction["products"] = products;
transactions.append(transaction); transactions.append(transaction);
_redeem_json["transactions"] = transactions; _redeem_json["transactions"] = transactions;
...@@ -317,6 +310,14 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json) ...@@ -317,6 +310,14 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
_redeem_json["transactions"] = transactions; _redeem_json["transactions"] = transactions;
} }
if(couponType == 3){ //折扣券
QJsonObject transaction;
transaction["code"] = coupon;
transaction["ebcode"] = ebcode;
QJsonArray transactions;
transactions.append(transaction);
_redeem_json["transactions"] = transactions;
}
QByteArray reqData = QJsonDocument(_redeem_json).toJson(); QByteArray reqData = QJsonDocument(_redeem_json).toJson();
reqData = CheckSendArray(reqData); reqData = CheckSendArray(reqData);
...@@ -391,15 +392,6 @@ QJsonObject FMPRedeem::ShowForErr(QJsonObject json) ...@@ -391,15 +392,6 @@ QJsonObject FMPRedeem::ShowForErr(QJsonObject json)
return json; return json;
} }
QJsonObject FMPRedeem::ShowForMismatch(QJsonObject json)
{
ErrCodeDialog::showForMismatch(_coupon, QString::fromLocal8Bit("券和商品不匹配"));
QJsonObject mismatch;
mismatch["statusCode"] = 31;
mismatch["msg"] = QString::fromLocal8Bit("券和商品不匹配");
return mismatch;
}
QJsonObject FMPRedeem::GetRedeemJson() const QJsonObject FMPRedeem::GetRedeemJson() const
{ {
return _redeem_json; return _redeem_json;
......
...@@ -47,7 +47,6 @@ private: ...@@ -47,7 +47,6 @@ private:
QJsonObject ShowForInvalid(QJsonObject json); QJsonObject ShowForInvalid(QJsonObject json);
QJsonObject ShowForExpird(QJsonObject json); QJsonObject ShowForExpird(QJsonObject json);
QJsonObject ShowForErr(QJsonObject json); QJsonObject ShowForErr(QJsonObject json);
QJsonObject ShowForMismatch(QJsonObject json);
int ZH_caclChkValue(char * pJsonData, int startPos, int endPos); int ZH_caclChkValue(char * pJsonData, int startPos, int endPos);
QByteArray CheckSendArray( QByteArray & jsonArray); QByteArray CheckSendArray( QByteArray & jsonArray);
QJsonValue SearchJsonObject(QJsonObject& searchJson, QString searchKey); QJsonValue SearchJsonObject(QJsonObject& searchJson, QString searchKey);
......
...@@ -21,6 +21,8 @@ StoreDialog::StoreDialog(QWidget *parent) : ...@@ -21,6 +21,8 @@ StoreDialog::StoreDialog(QWidget *parent) :
ui->storeIdEdit->installEventFilter(this); ui->storeIdEdit->installEventFilter(this);
ui->posIdEdit->installEventFilter(this); ui->posIdEdit->installEventFilter(this);
ui->partnerEdit->installEventFilter(this);
ui->partnerEdit->setFocus();
QTimer::singleShot(1000, this, &StoreDialog::timeOut); QTimer::singleShot(1000, this, &StoreDialog::timeOut);
} }
...@@ -52,8 +54,9 @@ void StoreDialog::ShowKeyBoard() ...@@ -52,8 +54,9 @@ void StoreDialog::ShowKeyBoard()
void StoreDialog::GetId() void StoreDialog::GetId()
{ {
storeId = ui->storeIdEdit->text(); storeId = ui->storeIdEdit->text().trimmed();
posId = ui->posIdEdit->text(); posId = ui->posIdEdit->text().trimmed();
partnerId = ui->partnerEdit->text().trimmed();
FMPKeyBoardInterface* keyboard = FMP::GetService<FMPKeyBoardInterface>(); FMPKeyBoardInterface* keyboard = FMP::GetService<FMPKeyBoardInterface>();
keyboard->StartService(); keyboard->StartService();
keyboard->HideKeyBoard(); keyboard->HideKeyBoard();
...@@ -63,7 +66,7 @@ void StoreDialog::GetId() ...@@ -63,7 +66,7 @@ void StoreDialog::GetId()
void StoreDialog::textChanged(const QString &text) void StoreDialog::textChanged(const QString &text)
{ {
Q_UNUSED(text); Q_UNUSED(text);
if(ui->storeIdEdit->text().isEmpty() || ui->posIdEdit->text().isEmpty()) if(ui->storeIdEdit->text().trimmed().isEmpty() || ui->posIdEdit->text().trimmed().isEmpty() || ui->partnerEdit->text().trimmed().isEmpty())
{ {
ui->okBtn->setEnabled(false); ui->okBtn->setEnabled(false);
} }
...@@ -89,7 +92,7 @@ void StoreDialog::timeOut() ...@@ -89,7 +92,7 @@ void StoreDialog::timeOut()
::AttachThreadInput(dwCurID,dwForeID,FALSE); ::AttachThreadInput(dwCurID,dwForeID,FALSE);
setFocus(); setFocus();
ui->storeIdEdit->setFocus(); ui->partnerEdit->setFocus();
} }
bool StoreDialog::eventFilter(QObject *obj, QEvent *event) bool StoreDialog::eventFilter(QObject *obj, QEvent *event)
...@@ -112,9 +115,17 @@ bool StoreDialog::eventFilter(QObject *obj, QEvent *event) ...@@ -112,9 +115,17 @@ bool StoreDialog::eventFilter(QObject *obj, QEvent *event)
} }
return false; return false;
} }
else { else if(obj == ui->partnerEdit)
return QDialog::eventFilter(obj, event); {
if(event->type() == QEvent::FocusIn)
{
FMPKeyBoardInterface* keyboard = FMP::GetService<FMPKeyBoardInterface>();
keyboard->StartService();
keyboard->setLineEdit(ui->partnerEdit);
}
return false;
} }
return QDialog::eventFilter(obj, event);
} }
void StoreDialog::CloseKeyBoard() void StoreDialog::CloseKeyBoard()
......
...@@ -28,6 +28,7 @@ private slots: ...@@ -28,6 +28,7 @@ private slots:
public: public:
QString storeId; QString storeId;
QString posId; QString posId;
QString partnerId;
private: private:
Ui::StoreDialog *ui; Ui::StoreDialog *ui;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>367</width> <width>367</width>
<height>202</height> <height>244</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
background: rgb(231,68,59); background: rgb(231,68,59);
} }
#storeIdLabel,#posIdLabel #storeIdLabel,#posIdLabel,#partnerLabel
{ {
font: 75 15pt &quot;微软雅黑&quot;; font: 75 15pt &quot;微软雅黑&quot;;
color: rgb(57, 57, 57); color: rgb(57, 57, 57);
...@@ -70,7 +70,7 @@ QPushButton:!enabled { ...@@ -70,7 +70,7 @@ QPushButton:!enabled {
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>请输入门店号和POS编号</string> <string>请输入门店信息</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
...@@ -80,7 +80,7 @@ QPushButton:!enabled { ...@@ -80,7 +80,7 @@ QPushButton:!enabled {
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>5</x> <x>5</x>
<y>48</y> <y>98</y>
<width>101</width> <width>101</width>
<height>31</height> <height>31</height>
</rect> </rect>
...@@ -93,7 +93,7 @@ QPushButton:!enabled { ...@@ -93,7 +93,7 @@ QPushButton:!enabled {
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>120</x> <x>120</x>
<y>48</y> <y>98</y>
<width>161</width> <width>161</width>
<height>32</height> <height>32</height>
</rect> </rect>
...@@ -103,7 +103,7 @@ QPushButton:!enabled { ...@@ -103,7 +103,7 @@ QPushButton:!enabled {
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>5</x> <x>5</x>
<y>97</y> <y>145</y>
<width>101</width> <width>101</width>
<height>31</height> <height>31</height>
</rect> </rect>
...@@ -116,7 +116,7 @@ QPushButton:!enabled { ...@@ -116,7 +116,7 @@ QPushButton:!enabled {
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>120</x> <x>120</x>
<y>98</y> <y>146</y>
<width>161</width> <width>161</width>
<height>32</height> <height>32</height>
</rect> </rect>
...@@ -126,7 +126,7 @@ QPushButton:!enabled { ...@@ -126,7 +126,7 @@ QPushButton:!enabled {
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>290</x> <x>290</x>
<y>42</y> <y>50</y>
<width>72</width> <width>72</width>
<height>52</height> <height>52</height>
</rect> </rect>
...@@ -139,7 +139,7 @@ QPushButton:!enabled { ...@@ -139,7 +139,7 @@ QPushButton:!enabled {
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>124</x> <x>124</x>
<y>140</y> <y>190</y>
<width>72</width> <width>72</width>
<height>52</height> <height>52</height>
</rect> </rect>
...@@ -152,7 +152,7 @@ QPushButton:!enabled { ...@@ -152,7 +152,7 @@ QPushButton:!enabled {
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>210</x> <x>210</x>
<y>140</y> <y>190</y>
<width>72</width> <width>72</width>
<height>52</height> <height>52</height>
</rect> </rect>
...@@ -161,7 +161,38 @@ QPushButton:!enabled { ...@@ -161,7 +161,38 @@ QPushButton:!enabled {
<string>取消</string> <string>取消</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="partnerLabel">
<property name="geometry">
<rect>
<x>6</x>
<y>49</y>
<width>101</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>商户号</string>
</property>
</widget>
<widget class="QLineEdit" name="partnerEdit">
<property name="geometry">
<rect>
<x>120</x>
<y>49</y>
<width>161</width>
<height>32</height>
</rect>
</property>
</widget>
</widget> </widget>
<tabstops>
<tabstop>partnerEdit</tabstop>
<tabstop>storeIdEdit</tabstop>
<tabstop>posIdEdit</tabstop>
<tabstop>okBtn</tabstop>
<tabstop>cancelBtn</tabstop>
<tabstop>keyBtn</tabstop>
</tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>
This source diff could not be displayed because it is too large. You can view the blob instead.
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