Commit 3d636b36 by gujin.wang

新建鲜芋仙分支

parent 780286d3
......@@ -9,6 +9,15 @@ TEMPLATE = app
INCLUDEPATH += $$PWD/../include/ctk \
$$PWD/../include/interface \
LIBS += -L$$PWD/../lib
CONFIG(debug, debug|release) {
#Linking library
LIBS += -lCTKCored -lCTKPluginFrameworkd
} else {
LIBS += -lCTKCore -lCTKPluginFramework
}
CONFIG(debug, debug|release) {
DESTDIR = $$PWD/../debug/bins
}
......
......@@ -15,8 +15,10 @@ Level=4
[Home]
Server=http://115.159.226.87:20001/api/user/login
PartnerId=1371
StoreId=fm99999
;PartnerId=1371
;StoreId=fm99999
PartnerId=1670
StoreId=99999
PosId=01
Position=1479, 521
CashierId=001
......
#include "fmp_logger_p.h"
#include "fmp_logger_p.h"
#include <fmp_settings_i.h>
#include <QDateTime>
#include <QDir>
......@@ -64,19 +64,19 @@ void FMPLoggerPrivate::Log(short level, const QString &msg, const char* file, co
LoggerPtr logger = Logger::getLogger(q->currentModule.toUtf8().data());
switch(level)
{
case FMPLogStream::ERROR:
case FMPLogStream::LOG_ERROR:
if (logger->isErrorEnabled()) {
::log4cxx::helpers::MessageBuffer oss_;
logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << msg.toUtf8().data()), LocationInfo(file, func, line));
}
break;
case FMPLogStream::WARNING:
case FMPLogStream::LOG_WARNING:
if (logger->isWarnEnabled()) {
::log4cxx::helpers::MessageBuffer oss_;
logger->forcedLog(::log4cxx::Level::getWarn(), oss_.str(oss_ << msg.toUtf8().data()), LocationInfo(file, func, line));
}
break;
case FMPLogStream::DEBUG:
case FMPLogStream::LOG_DEBUG:
if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {
::log4cxx::helpers::MessageBuffer oss_;
logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ << msg.toUtf8().data()), LocationInfo(file, func, line));
......
#ifndef FMP_LOGGERSTREAM_H
 #ifndef FMP_LOGGERSTREAM_H
#define FMP_LOGGERSTREAM_H
#include <QObject>
#include <QDebug>
......@@ -8,9 +8,7 @@
class FMPLogStream
{
public:
enum {
ERROR = 1, WARNING, INFO, DEBUG
};
enum {LOG_ERROR = 1, LOG_WARNING, LOG_INFO, LOG_DEBUG};
explicit FMPLogStream(short level, const char* file, const char* func, int line)
: _level(level),
_file(file),
......
......@@ -113,11 +113,10 @@ QJsonObject FMPRedeem::Reverse(QJsonObject request)
return retJson;
}
QJsonObject FMPRedeem::Redeem(const double needPay, const QJsonArray& productsInfo)
QJsonObject FMPRedeem::Redeem(const QJsonArray& productsInfo)
{
FMP_DEBUG() << "Recv redeem data: " << QJsonDocument(productsInfo).toJson(QJsonDocument::Compact);
_products_info = productsInfo;
_needPay = needPay;
//读取门店信息
QString apppath = QCoreApplication::applicationDirPath();
QSettings settings(QString("%1/FreemudPOS.ini").arg(apppath), QSettings::IniFormat);
......@@ -253,14 +252,6 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
_redeem_json["business_date"] = QDate::currentDate().toString("yyyyMMdd");
if( couponType == 0){ //商品券
if(!IsContinue(SearchJsonObject(json, "paid").toInt()))
{
QJsonObject result;
result["statusCode"] = FM_API_WINDOWCLOSE;
result["msg"] = QString::fromLocal8Bit("窗口关闭");
return result;
}
QJsonObject transaction;
QJsonArray transactions;
transaction["code"] = coupon;
......@@ -295,14 +286,6 @@ QJsonObject FMPRedeem::ShowForUnConsum(QJsonObject json)
_redeem_json["transactions"] = transactions;
}
if( couponType == 1){ //代金券
if(!IsContinue(SearchJsonObject(json, "amount").toInt()))
{
QJsonObject result;
result["statusCode"] = FM_API_WINDOWCLOSE;
result["msg"] = QString::fromLocal8Bit("窗口关闭");
return result;
}
QJsonObject transaction;
transaction["code"] = coupon;
transaction["ebcode"] = ebcode;
......@@ -400,28 +383,6 @@ QJsonObject FMPRedeem::GetRedeemJson() const
return _redeem_json;
}
bool FMPRedeem::IsContinue(int couponAmount)
{
if(_needPay < couponAmount/100.0)
{
//如果卡券抵扣额已大于待付金额,则给出警告提示
QMessageBox msg;
msg.setWindowTitle(QString::fromLocal8Bit("警告"));
msg.setText(QString::fromLocal8Bit("卡券总额已超出应付金额!是否继续?"));
msg.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);
msg.setIcon(QMessageBox::Warning);
//msg.setWindowModality(Qt::ApplicationModal);
msg.setWindowFlags(msg.windowFlags() | Qt::WindowStaysOnTopHint);
msg.setAttribute(Qt::WA_QuitOnClose, false);
int choice = msg.exec();
if(choice != QMessageBox::Yes)
{
return false;
}
}
return true;
}
int FMPRedeem::ZH_caclChkValue(char *pJsonData, int startPos, int endPos)
{
/* startPos <= && < endPos */
......
......@@ -29,7 +29,7 @@ public:
explicit FMPRedeem(const FMPContext context);
virtual ~FMPRedeem();
QJsonObject Redeem(const double needPay, const QJsonArray& productsInfo); //券码核销
QJsonObject Redeem(const QJsonArray& productsInfo); //券码核销
QJsonObject Reverse(QJsonObject request);
QJsonObject GetRedeemJson()const;
......@@ -50,12 +50,10 @@ private:
QJsonObject ShowForMismatch(QJsonObject json);
int ZH_caclChkValue(char * pJsonData, int startPos, int endPos);
QByteArray CheckSendArray( QByteArray & jsonArray);
bool IsContinue(int couponAmount);
QJsonValue SearchJsonObject(QJsonObject& searchJson, QString searchKey);
QJsonValue SearchJsonArray(QJsonArray& searchJson, QString searchKey);
private:
bool _inited;
double _needPay;
QString _store_id;
QString _station_id;
QString _operator_id;
......
......@@ -20,7 +20,7 @@ public:
connect(this, &FMPRedeemInterface::TriggerUninit, this, &FMPRedeemInterface::OnTriggerUninit);
}
virtual QJsonObject Redeem(const double needPay, const QJsonArray& productsInfo) = 0; //券码核销
virtual QJsonObject Redeem(const QJsonArray& productsInfo) = 0; //券码核销
virtual QJsonObject Reverse(QJsonObject request) = 0; //卡券冲正
virtual QJsonObject GetRedeemJson()const = 0;
......
......@@ -6,7 +6,8 @@
#include <QLocalSocket>
#include <QLocalServer>
#include <QApplication>
#include <QJsonArray>
#include "fmp_redeem_i.h"
class FMSingleApplication : public QApplication
{
......@@ -82,6 +83,21 @@ private:
widget->activateWindow();
}
//程序已启动,则直接显示核销界面
FMPRedeemInterface* svcRedeem = FMP::GetService<FMPRedeemInterface>();
if(svcRedeem)
{
svcRedeem->StartService();
QJsonArray products;
QJsonObject product;
product["consume_num"] = 1;
product["pid"] = "1607271";
product["price"] = 500;
products.append(product);
QJsonObject result = svcRedeem->Redeem(products);
FMP_DEBUG() << result;
}
return;
}
......
......@@ -15,8 +15,8 @@ Level=0
[Home]
Server=http://115.159.226.87:20001/api/user/login
PartnerId=1521
StoreId=9999
PartnerId=1670
StoreId=99999
PosId=01
Position=1382, 776
CashierId=001
......
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