Commit 6222412f by gujin.wang

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

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