Commit cd71b166 by yunpeng.song

更改图标样式,增加多用户互斥,修改posSalesId写入db错误的问题,给一些资源增加互斥锁,登录改为同步的。

parent 716544c1
......@@ -87,17 +87,19 @@ private:
QMap<QString, QMultiMap<QString, dishesObject> >m_dishesMap;
// 已接单的订单
QMap<QString, OrderProperpy> m_ordersMapXbk;
QMap<QString, OrderProperpy> m_ordersEntryMap;
//订单号与pos短号映射
QMap<QString,QString> m_orderIdToPosSalesIdMap;
//记录当前订单操作
QMap<QString, int> m_orderOperatePair;
QMutex m_mutex;
//订单拉取记录
QList<PullOrderInfo> m_orderPullList;
//订单操作互斥信号
QSemaphore semaphore;
//订单操作状态
OrderOperation orderOperation;
QMutex m_OrderEntryMutex;
signals:
// 发送信号给自己 做登陆
void doLogin();
......@@ -252,6 +254,7 @@ private slots:
bool _Get01ReplyJson(const QJsonObject &content, QJsonObject &data,QString &error);
bool _Get02ReplyJson(const QJsonObject &content, QJsonObject &data,QString &error);
bool _Get03ReplyJson(const QJsonObject &content, QJsonObject &data,QString &error);
bool _Get04ReplyJson(const QJsonObject &content, QJsonObject &data,QString &error);
bool _Get11ReplyJson(const QJsonObject &content, QJsonObject &data,QString &error);
bool _Get12ReplyJson(const QJsonObject &content, QJsonObject &data,QString &error);
bool _GetLoginReplyJson(const QJsonObject &content, QString &error);
......
#include "orderstatus.h"
#include "orderstatus.h"
#include "QsLog.h"
#include <QCoreApplication>
......@@ -25,8 +25,7 @@ Orderstatus::Orderstatus()
}
if(!isTableExist){
QLOG_INFO() << "table status does not exist";
query.prepare(QString("create table status (orderId varchar(20) primary key, "
"isput int(1),isrefund int(1),isreport int(1),isbackreport int(1),creatTime varchar(20))"));
query.prepare(QString("create table status (orderId varchar(20) primary key,isput int(1),isrefund int(1),isreport int(1),isbackreport int(1),posSalesId varchar(20),creatTime varchar(20))"));
if(!query.exec())
{
QLOG_ERROR()<<query.lastError().text()<<QString::number(query.lastError().type())<<"create table";
......@@ -55,7 +54,7 @@ bool Orderstatus::statusinsert(const QString &orderId,const QString& creatTime)
}
bool result;
QSqlQuery query(db);
query.prepare(QString("insert into status values('%1',0,0,0,0,'%6')").arg(orderId).arg(creatTime));
query.prepare(QString("insert into status values('%1',0,0,0,0,NUll,'%6')").arg(orderId).arg(creatTime));
qDebug()<<creatTime;
if(!query.exec())
{
......@@ -302,6 +301,56 @@ bool Orderstatus::isorderexit(const QString &orderId)
return result;
}
bool Orderstatus::PosSalesIdupdate(const QString &orderId, const QString &posSalesId)
{
m_mutex.lock();
if(!db.open())
{
QLOG_ERROR()<<"sqlite open failed"<<db.lastError().text();
return false;
}
bool result;
QSqlQuery query(db);
query.prepare(QString("update status set posSalesId='%1' where orderId='%2'")
.arg(posSalesId).arg(orderId));
if(!query.exec())
{
QLOG_ERROR()<<query.lastError().text()<<__FUNCTION__;
result= false;
}
else{
QLOG_INFO()<<QString("update orderId %1 posSalesId success").arg(orderId);
result = true;
}
db.close();
m_mutex.unlock();
return result;
}
QString Orderstatus::getPosSalesId(const QString &orderId)
{
m_mutex.lock();
QString result;
if(!db.open())
{
QLOG_ERROR()<<"sqlite open failed"<<db.lastError().text();
return result;
}
QSqlQuery query(db);
query.prepare(QString("select posSalesId from status where orderId='%1'").arg(orderId));
if(!query.exec())
{
QLOG_ERROR()<<query.lastError().text()<<orderId<<__FUNCTION__;
}
while(query.next())
{
result= query.value(0).toString();
}
db.close();
m_mutex.unlock();
return result;
}
bool Orderstatus::deleteRecord(QString creatTime)
{
m_mutex.lock();
......
/******************
/******************
*进行sqlite操作
******************/
#ifndef ORDERSTATUS_H
......@@ -76,6 +76,9 @@ public:
*返回:true是,false否
**/
bool isorderexit(const QString& orderId);
bool PosSalesIdupdate(const QString& orderId, const QString &posSalesId);
QString getPosSalesId(const QString& orderId);
bool deleteRecord(QString creatTime);
private:
QMutex m_mutex;
......
#include "SysTray.h"
#include "SysTray.h"
#include <QApplication>
#include <QThread>
extern QThread tcpThread;
......@@ -9,7 +9,7 @@ SysTray::SysTray(QObject *parent) :
{
_CreatMenu();
setIcon(QIcon(":fm.ico"));
setIcon(QIcon(":fm.png"));
}
void SysTray::_CreatMenu()
......
#ifndef ORDEROBJECT_H
#ifndef ORDEROBJECT_H
#define ORDEROBJECT_H
#include "Model/baseObject.h"
......@@ -148,6 +148,7 @@ public:
Q_PROPERTY (int delivery_time READ getdelivery_time WRITE setdelivery_time)
Q_PROPERTY (int delivery_status READ getdelivery_status WRITE setdelivery_status)
Q_PROPERTY (QString fm_id READ getfm_id WRITE setfm_id)
Q_PROPERTY (QString possale_id READ getpossale_id WRITE setpossale_id)
Q_PROPERTY (QStringList records READ getrecords WRITE setrecords)
Q_PROPERTY (int service_fee READ getservice_fee WRITE setservice_fee)
Q_PROPERTY (int dis_platform_fee READ getdis_platform_fee WRITE setdis_platform_fee)
......@@ -155,11 +156,13 @@ public:
Q_PROPERTY (int package_fee READ getpackage_fee WRITE setpackage_fee)
Q_PROPERTY (int product_fee READ getproduct_fee WRITE setproduct_fee)
Q_PROPERTY (int order_type READ getorder_type WRITE setorder_type)
Q_PROPERTY (int update_time READ getupdate_time WRITE setupdate_time)
int service_fee; //平台佣金
int dis_platform_fee; //平台承担的优惠金额
int dis_shop_fee; //商户承担的优惠金额
int package_fee; //打包费
QString possale_id; //pos短号
QString address; //地址
QString channel; //渠道
......@@ -201,8 +204,14 @@ public:
int product_fee; // 商户商品金额=商品金额+打包费
int order_type; //订单类型
int update_time; //期望送达时间
protected:
inline int getupdate_time() const{return update_time;}
inline void setupdate_time(const int &v){update_time = v;}
inline int getproduct_fee() const{return product_fee;}
inline void setproduct_fee(const int &v){product_fee = v;}
......@@ -239,6 +248,10 @@ protected:
inline void setchannelName(const QString &v){channel_name = v;}
inline void setpossale_id(const QString &v){possale_id = v;}
inline QString getpossale_id() const{return possale_id;}
inline QString getphone() const{return phone;}
inline void setphone(const QString& v){phone = v;}
......
#include "floatForm.h"
#include "floatForm.h"
#include "ui_floatForm.h"
#include <QPixmap>
#include "DTools/configManger.h"
......@@ -18,9 +18,9 @@ FloatForm::FloatForm(QWidget *parent) :
m_bReminding = false;
QPixmap imgNormal(":float_normal.jpg");
QPixmap imgNormal(":float_normal.png");
m_imgNormalSize = imgNormal.size();
QPixmap imgRemind(":float_remind.jpg");
QPixmap imgRemind(":float_remind.png");
m_imgRemindSize = imgRemind.size();
m_animation.setTargetObject(this);
......@@ -93,7 +93,7 @@ void FloatForm::_Init()
setAttribute(Qt::WA_TranslucentBackground);
setFixedSize(m_imgNormalSize);
setStyleSheet("#floatWdg{ border-image: url(:float_normal.jpg); }");
setStyleSheet("#floatWdg{ border-image: url(:float_normal.png); }");
//setStyleSheet("#floatWdg{ border-image: url(:logo.svg); }");
//setStyleSheet("#floatWdg{ border-image: url(:float_normal.png); }");
......@@ -109,7 +109,7 @@ void FloatForm::_Blink()
m_animation.start();
loop.exec();
this->setFixedSize(m_imgRemindSize);
ui->floatWdg->setStyleSheet("#floatWdg{ border-image: url(:float_remind.jpg);}");
ui->floatWdg->setStyleSheet("#floatWdg{ border-image: url(:float_remind.png);}");
//ui->floatWdg->setStyleSheet("#floatWdg{ border-image: url(:float_remind.png);}");
m_animation.setStartValue(0);
m_animation.setEndValue(1);
......@@ -121,7 +121,7 @@ void FloatForm::_Blink()
loop.exec();
this->setFixedSize(m_imgNormalSize);
//ui->floatWdg->setStyleSheet("#floatWdg{ border-image: url(:float_normal.png)}");
ui->floatWdg->setStyleSheet("#floatWdg{ border-image: url(:float_normal.jpg);}");
ui->floatWdg->setStyleSheet("#floatWdg{ border-image: url(:float_normal.png);}");
m_animation.setStartValue(0);
m_animation.setEndValue(1);
m_animation.start();
......
......@@ -14,7 +14,7 @@
<string>Dialog</string>
</property>
<property name="windowOpacity">
<double>0.500000000000000</double>
<double>0.800000000000000</double>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
......
......@@ -4,7 +4,7 @@
#
#-------------------------------------------------
QT += core gui network printsupport multimedia concurrent sql
QT += core gui network multimedia concurrent sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
......
IDI_ICON1 ICON DISCARDABLE"fm.ico"
\ No newline at end of file
IDI_ICON1 ICON DISCARDABLE "logo.ico"
\ No newline at end of file
#include "mainForm.h"
#include "mainForm.h"
#include <QApplication>
#include <QDir>
#include <QResource>
......@@ -53,12 +53,17 @@ void LoadTheme(const QString& theme)
int main(int argc, char *argv[])
{
HANDLE m_hMutex = CreateMutex(NULL, FALSE, L"fmTakeaway" );
HANDLE m_hMutex = CreateMutex(NULL, FALSE, L"Global\\fmTakeaway" );
if (GetLastError() == ERROR_ALREADY_EXISTS) {
CloseHandle(m_hMutex);
m_hMutex = NULL;
return -1;
if(NULL!=m_hMutex){
if (GetLastError() == ERROR_ALREADY_EXISTS) {
CloseHandle(m_hMutex);
m_hMutex = NULL;
return -1;
}
}
else{
return -1;
}
QApplication a(argc, argv);
......
#include "settingForm.h"
#include "settingForm.h"
#include "ui_settingForm.h"
#include "preDefine.h"
#include "DTools/configManger.h"
#include <QPrinterInfo>
#include <QSound>
SettingForm::SettingForm(QWidget *parent) :
......@@ -12,17 +11,17 @@ SettingForm::SettingForm(QWidget *parent) :
ui->setupUi(this);
// 初始化打印机选项
QString printer = ConfigManger::GetInstance().GetPrinterName();
QStringList printerList = QPrinterInfo::availablePrinterNames();
for(int i=0; i<printerList.count(); i++)
{
QString name = printerList[i];
ui->settingCbxPrinter->addItem(name);
if(!name.compare(printer))
{
ui->settingCbxPrinter->setCurrentIndex(i);
}
}
// QString printer = ConfigManger::GetInstance().GetPrinterName();
// QStringList printerList = QPrinterInfo::availablePrinterNames();
// for(int i=0; i<printerList.count(); i++)
// {
// QString name = printerList[i];
// ui->settingCbxPrinter->addItem(name);
// if(!name.compare(printer))
// {
// ui->settingCbxPrinter->setCurrentIndex(i);
// }
// }
_Init();
}
......
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