Commit 1cfe7b2d by gujin.wang

对悬浮窗进行相应调整;在核销插件上显示版本号

parent 972932d0
......@@ -64,6 +64,19 @@ private:
int main(int argc, char** argv)
{
HANDLE m_hMutex = CreateMutex(NULL, FALSE, L"Global\\fmTakeaway" );
if(m_hMutex != NULL)
{
if (GetLastError() == ERROR_ALREADY_EXISTS||GetLastError() == ERROR_ACCESS_DENIED) {
CloseHandle(m_hMutex);
m_hMutex = NULL;
return 0;
}
}
else{
return 0;
}
QString app_path = QString::fromLocal8Bit(argv[0]);
app_path.replace("\\", "/");
QString app_dir = app_path.section("/", 0, -2);
......
[General]
ShowStoreInfo=0
[Service]
Name=FMPService
Desc=\xe9\x9d\x9e\xe7\xa0\x81 POS \xe6\x8f\x92\xe4\xbb\xb6\xe6\x9c\x8d\xe5\x8a\xa1
......@@ -16,10 +19,12 @@ Level=4
[Home]
Server=http://115.159.226.87:20001/api/user/login
PartnerId=1371
StoreId=fm99999
PosId=01
Position=1479, 521
StoreId=aaa
PosId=bbb
Position=2561, 423
CashierId=001
OperatorId=01
ShowStoreInfo=0
[Pay]
Server=https://115.159.18.100/api
......@@ -28,6 +33,9 @@ Timeout=60
[Vip]
Server=http://member.freemudorder.com/member_today/service/restful/pos
[Coupon]
Server=http://115.159.142.32/api
[Syncer]
Interval=3
TaskUrl=http://192.168.110.150:8080/api/fork/checkupdate
......
......@@ -61,8 +61,8 @@
}
#labCodeName{
font: 72 25pt "微软雅黑";
color: rgb(146, 53, 50);
font: 65 15pt "微软雅黑";
color: rgb(255, 255, 0);
border:none;
}
......@@ -86,7 +86,8 @@
/**/
#btnConsumption{
border:none;
background-image: url(:/img/btn_consumption.png);
border-image: url(:/img/btn_consumption.png);
background-repeat:no-repeat;
}
#btnConsumNull{
border:none;
......
......@@ -92,12 +92,13 @@
/**/
#btnConsumption{
border:none;
background-image: url(:/img/btn_consumption.png);
border-image: url(:/img/btn_consumption.png);
background-repeat:no-repeat;
}
#btnConsumNull{
border:none;
background-image: url(:/img/btn_consumption_invalid.png);
border-image: url(:/img/btn_consumption_invalid.png);
background-repeat:no-repeat;
}
/**/</string>
</property>
......
......@@ -22,10 +22,14 @@
#include <QResource>
#include <QSettings>
#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
FMPRedeem::FMPRedeem(const FMPContext context)
:FMPRedeemInterface(),
_context(context),
_isRedeeming(false),
_inited(false),
_clientReqCount(0),
_ste_handler(new FMPStartEventHandler(this))
......@@ -57,6 +61,11 @@ void FMPRedeem::UninitService()
_inited = false;
}
bool FMPRedeem::IsRedeeming()const
{
return _isRedeeming;
}
QJsonValue FMPRedeem::SearchJsonObject(QJsonObject& searchJson, QString searchKey)
{
QJsonValue value;
......@@ -116,7 +125,8 @@ QJsonObject FMPRedeem::Reverse(QJsonObject request)
}
QJsonObject FMPRedeem::Redeem(const QJsonArray& productsInfo)
{
{
_isRedeeming = true;
FMP_DEBUG() << "Recv redeem data: " << QJsonDocument(productsInfo).toJson(QJsonDocument::Compact);
_products_info = productsInfo;
//读取门店信息
......@@ -144,6 +154,7 @@ QJsonObject FMPRedeem::Redeem(const QJsonArray& productsInfo)
ret["statusCode"] = FM_API_WINDOWCLOSE;
ret["msg"] = QString::fromLocal8Bit("窗口关闭");
FMP_DEBUG() << QJsonDocument(ret).toJson(QJsonDocument::Compact);
_isRedeeming = false;
return ret;
}
}
......@@ -156,6 +167,7 @@ QJsonObject FMPRedeem::Redeem(const QJsonArray& productsInfo)
ret["statusCode"] = FM_API_WINDOWCLOSE;
ret["msg"] = QString::fromLocal8Bit("窗口关闭");
FMP_DEBUG() << QJsonDocument(ret).toJson(QJsonDocument::Compact);
_isRedeeming = false;
return ret;
}
_coupon = scanningDialog.code;
......@@ -177,16 +189,23 @@ QJsonObject FMPRedeem::Redeem(const QJsonArray& productsInfo)
switch (statusCode)
{
case 100: //成功
return ShowForUnConsum(retJson);
retJson = ShowForUnConsum(retJson);
break;
case 11: //无效码
return ShowForInvalid(retJson);
retJson = ShowForInvalid(retJson);
break;
case 12: //过期码
return ShowForExpird(retJson);
retJson = ShowForExpird(retJson);
break;
case 14: //已核销
return ShowForHasConsum(retJson);
retJson = ShowForHasConsum(retJson);
break;
default: //出错
return ShowForErr(retJson);
retJson = ShowForErr(retJson);
break;
}
_isRedeeming = false;
return retJson;
}
QJsonObject FMPRedeem::SendRequest(const QByteArray &reqData)
......@@ -253,14 +272,19 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
{
QJsonObject codeInfo = json["codeInfo"].toObject();
QString act_name = codeInfo["act_name"].toString();
QString code_name = codeInfo["act_id"].toString();
QString act_id = codeInfo["act_id"].toString();
QString vdata = codeInfo["vdata"].toString();
QString coupon = codeInfo["code"].toString();
QString ebcode = codeInfo["ebcode"].toString();
QString ebname = codeInfo["ebname"].toString();
QString time_name = QString::fromLocal8Bit("有效期至: ").append(vdata);
int couponType = json["couponType"].toInt();
if( ConsumptionDialog::ShowForUnConsum(act_name, code_name,time_name,coupon))
double amount = codeInfo["amount"].toInt()/100.0;
QString info = QString::fromLocal8Bit("面值:%1元 实收:%2元 渠道:%3")
.arg(amount)
.arg(amount)
.arg(ebname);
if( ConsumptionDialog::ShowForUnConsum(act_name, info,time_name,coupon))
{
_redeem_json = QJsonObject();
_redeem_json["ver"] = 2;
......@@ -323,14 +347,12 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
QJsonObject redeemResult;
QJsonObject retJson = SendRequest(reqData);
int statusCode = retJson["statusCode"].toInt();
QString msg = retJson["msg"].toString();
switch(statusCode)
{
case 100:
{
QString _time = QDateTime::currentDateTime().toString("yyyy-MM-dd");
QString _time_name;
_time_name.append(_store_id).append("(").append(_station_id).append( ")").append(" ").append(_time);
ConsumOkDialog::showConsumOk( act_name, code_name, _time_name, coupon);
ConsumOkDialog::showConsumOk( act_name, "", time_name, coupon);
if(couponType == 0) //商品券
{
......@@ -346,10 +368,13 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
redeemResult["couponDesc"] = act_name;
redeemResult["code"] = coupon;
redeemResult["redeem_json"] = _redeem_json;
//save redeem result
SaveRedeemResult(coupon, act_name, ebname, amount);
}
break;
default:
ErrCodeDialog::showForErr(coupon, QString("error:").append(QString::number(statusCode)));
ErrCodeDialog::showForErr(coupon, msg);
break;
}
redeemResult["statusCode"] = retJson["statusCode"];
......@@ -367,8 +392,7 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
QJsonObject FMPRedeem::ShowForHasConsum(QJsonObject json)
{
QString storeInfo = QString("%1(%2)").arg(_store_id).arg(_station_id);
ConsumptionDialog::ShowForHasConsum(json["msg"].toString(), "", storeInfo, _coupon);
ConsumptionDialog::ShowForHasConsum(json["msg"].toString(), "", "", _coupon);
return json;
}
......@@ -386,8 +410,8 @@ QJsonObject FMPRedeem::ShowForExpird(QJsonObject json)
QJsonObject FMPRedeem::ShowForErr(QJsonObject json)
{
int statusCode = json["statusCode"].toInt();
ErrCodeDialog::showForErr(_coupon, QString("error: ").append(QString::number(statusCode)));
QString msg = json["msg"].toString();
ErrCodeDialog::showForErr(_coupon, msg);
return json;
}
......@@ -461,4 +485,36 @@ QByteArray FMPRedeem::CheckSendArray(QByteArray &jsonArray)
QByteArray array(tmpBuf);
return array;
}
\ No newline at end of file
}
void FMPRedeem::SaveRedeemResult(QString code, QString code_name, QString ebname, double amount)
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
QString path = QApplication::applicationDirPath();
db.setDatabaseName(path + "/redeem.db");
if(!db.open())
{
FMP_DEBUG() << "open redeem.db failed: " << db.lastError().driverText();
return ;
}
QSqlQuery query(db);
QString sql = "create table if not exists redeem(code varchar(20), code_name varchar(20), ebname varchar(20), amount double)";
if(!query.exec(sql))
{
FMP_DEBUG() << "create redeem table failed: " << query.lastError().driverText();
db.close();
return;
}
sql = "insert into redeem values(?,?,?,?)";
query.prepare(sql);
query.addBindValue(code);
query.addBindValue(code_name);
query.addBindValue(ebname);
query.addBindValue(amount);
if(!query.exec())
{
FMP_DEBUG() << "insert into redeem failed: " << query.lastError().driverText() << " code=" << code;
return;
}
FMP_DEBUG() << "insert into redeem success: code=" << code;
}
......@@ -32,6 +32,7 @@ public:
QJsonObject Redeem(const QJsonArray& productsInfo); //券码核销
QJsonObject Reverse(QJsonObject request);
QJsonObject GetRedeemJson()const;
virtual bool IsRedeeming() const;
protected:
const FMPContext GetContext() const { return _context; }
......@@ -52,7 +53,10 @@ private:
QByteArray CheckSendArray( QByteArray & jsonArray);
QJsonValue SearchJsonObject(QJsonObject& searchJson, QString searchKey);
QJsonValue SearchJsonArray(QJsonArray& searchJson, QString searchKey);
void SaveRedeemResult(QString code, QString code_name, QString ebname, double amount);
private:
bool _isRedeeming;
bool _inited;
QString _store_id;
QString _station_id;
......
......@@ -5,7 +5,7 @@
#-------------------------------------------------
TEMPLATE = lib
QT += core gui network winextras
QT += core gui network winextras sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
......
......@@ -23,6 +23,7 @@ public:
virtual QJsonObject Redeem(const QJsonArray& productsInfo) = 0; //券码核销
virtual QJsonObject Reverse(QJsonObject request) = 0; //卡券冲正
virtual QJsonObject GetRedeemJson()const = 0;
virtual bool IsRedeeming()const = 0;
signals:
void TriggerInit();
......
fmp_redeem/res/img/bg_be_invalid.png

3.87 KB | W: | H:

fmp_redeem/res/img/bg_be_invalid.png

7.29 KB | W: | H:

fmp_redeem/res/img/bg_be_invalid.png
fmp_redeem/res/img/bg_be_invalid.png
fmp_redeem/res/img/bg_be_invalid.png
fmp_redeem/res/img/bg_be_invalid.png
  • 2-up
  • Swipe
  • Onion skin
fmp_redeem/res/img/bg_exchange.png

8.44 KB | W: | H:

fmp_redeem/res/img/bg_exchange.png

13.6 KB | W: | H:

fmp_redeem/res/img/bg_exchange.png
fmp_redeem/res/img/bg_exchange.png
fmp_redeem/res/img/bg_exchange.png
fmp_redeem/res/img/bg_exchange.png
  • 2-up
  • Swipe
  • Onion skin
fmp_redeem/res/img/bg_invalid_code.png

10.8 KB | W: | H:

fmp_redeem/res/img/bg_invalid_code.png

11.4 KB | W: | H:

fmp_redeem/res/img/bg_invalid_code.png
fmp_redeem/res/img/bg_invalid_code.png
fmp_redeem/res/img/bg_invalid_code.png
fmp_redeem/res/img/bg_invalid_code.png
  • 2-up
  • Swipe
  • Onion skin
fmp_redeem/res/img/bg_no_exchange.png

8.37 KB | W: | H:

fmp_redeem/res/img/bg_no_exchange.png

13.7 KB | W: | H:

fmp_redeem/res/img/bg_no_exchange.png
fmp_redeem/res/img/bg_no_exchange.png
fmp_redeem/res/img/bg_no_exchange.png
fmp_redeem/res/img/bg_no_exchange.png
  • 2-up
  • Swipe
  • Onion skin
fmp_redeem/res/img/bg_sanning.png

51 KB | W: | H:

fmp_redeem/res/img/bg_sanning.png

36.9 KB | W: | H:

fmp_redeem/res/img/bg_sanning.png
fmp_redeem/res/img/bg_sanning.png
fmp_redeem/res/img/bg_sanning.png
fmp_redeem/res/img/bg_sanning.png
  • 2-up
  • Swipe
  • Onion skin
fmp_redeem/res/img/bg_working.png

26.3 KB | W: | H:

fmp_redeem/res/img/bg_working.png

32.2 KB | W: | H:

fmp_redeem/res/img/bg_working.png
fmp_redeem/res/img/bg_working.png
fmp_redeem/res/img/bg_working.png
fmp_redeem/res/img/bg_working.png
  • 2-up
  • Swipe
  • Onion skin
fmp_redeem/res/img/btn_consumption.png

4.98 KB | W: | H:

fmp_redeem/res/img/btn_consumption.png

19.5 KB | W: | H:

fmp_redeem/res/img/btn_consumption.png
fmp_redeem/res/img/btn_consumption.png
fmp_redeem/res/img/btn_consumption.png
fmp_redeem/res/img/btn_consumption.png
  • 2-up
  • Swipe
  • Onion skin
fmp_redeem/res/img/consumption_ok.png

5.79 KB | W: | H:

fmp_redeem/res/img/consumption_ok.png

20.6 KB | W: | H:

fmp_redeem/res/img/consumption_ok.png
fmp_redeem/res/img/consumption_ok.png
fmp_redeem/res/img/consumption_ok.png
fmp_redeem/res/img/consumption_ok.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -14,8 +14,6 @@ ScanningDialog::ScanningDialog(QWidget * parent, Qt::WindowFlags f) :
//setGeometry(0, 0, 350, 470);
setWindowTitle(QString::fromLocal8Bit("非码卡券"));
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
//setWindowFlags(Qt::FramelessWindowHint);
//setAutoFillBackground(false); //这个不设置的话就背景变黑
setAttribute(Qt::WA_TranslucentBackground,true);
setAttribute(Qt::WA_QuitOnClose, false);
......@@ -24,7 +22,6 @@ ScanningDialog::ScanningDialog(QWidget * parent, Qt::WindowFlags f) :
connect( scanningBar, &QPropertyAnimation::finished, this, &ScanningDialog::animationEnd);
animationUp = true;
animationEnd();
ui->labScaningBar->setFocus();
//关闭按钮
connect(ui->btnClose, &QPushButton::clicked, this, &ScanningDialog::onClose);
......@@ -71,6 +68,30 @@ void ScanningDialog::keyPressEvent(QKeyEvent *e)
code.append( e->text());
}
void ScanningDialog::focusInEvent(QFocusEvent *e)
{
ui->widget->setStyleSheet("#widget{\
border:3px solid yellow;\
background-color:transparent;\
border-radius:12px;\
background-image:url(:/img/bg_sanning.png);\
background-repeat:no-repeat;\
}");
QDialog::focusInEvent(e);
}
void ScanningDialog::focusOutEvent(QFocusEvent *e)
{
ui->widget->setStyleSheet("#widget{\
border:none;\
background-color:transparent;\
border-radius:12px;\
background-image:url(:/img/bg_sanning.png);\
background-repeat:no-repeat;\
}");
QDialog::focusOutEvent(e);
}
void ScanningDialog::onClose()
{
scanningBar->stop();
......@@ -93,9 +114,6 @@ void ScanningDialog::timeOut()
::SetForegroundWindow((HWND)this->effectiveWinId());
::AttachThreadInput(dwCurID,dwForeID,FALSE);
this->setFocus();
ui->labScaningBar->setFocus();
}
ScanningDialog::~ScanningDialog()
......
#ifndef SCANNINGDIALOG_H
#ifndef SCANNINGDIALOG_H
#define SCANNINGDIALOG_H
#include <QDialog>
......@@ -21,6 +21,8 @@ public:
protected:
void keyPressEvent(QKeyEvent* e);
void focusInEvent(QFocusEvent* e);
void focusOutEvent(QFocusEvent* e);
private slots:
void animationEnd();
......
......@@ -10,6 +10,9 @@
<height>502</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="windowTitle">
<string>ScanningDialog</string>
</property>
......@@ -55,13 +58,16 @@
<height>451</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<widget class="QPushButton" name="btnClose">
<property name="geometry">
<rect>
<x>261</x>
<y>2</y>
<width>75</width>
<height>61</height>
<x>246</x>
<y>3</y>
<width>82</width>
<height>82</height>
</rect>
</property>
<property name="text">
......@@ -77,6 +83,9 @@
<height>31</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="text">
<string/>
</property>
......
......@@ -15,11 +15,12 @@ Level=0
[Home]
Server=http://115.159.226.87:20001/api/user/login
PartnerId=1371
StoreId=fm99999
PartnerId=1739
StoreId=WH026
PosId=01
Position=1382, 776
Position=1591, 268
CashierId=001
ShowStoreInfo=1
[Pay]
Server=https://115.159.18.100/api
......
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