Commit 0f065311 by yunpeng.song

增加销售单结果记录sqlite,增加补录功能

parent d97925b3
......@@ -22,6 +22,7 @@
#include <QSqlError>
#include <QDateTime>
#include <QSqlRecord>
#include <Tool/orderstatus.h>
flowControll::flowControll(QObject *parent) : QObject(parent),m_loginSocket(0),
......@@ -957,6 +958,43 @@ QString flowControll::getHostMacAddress()
return result;
}
bool flowControll::_EntryOrder(OrderObject *orderObject)
{
int result;
if((orderObject->status!=100&&orderObject->status!=3)&&!Orderstatus::getInstance().isentry(orderObject->order_id))
{
if(!DoSalesSlip(orderObject,0))
{
QLOG_INFO() << QString("entry order %1 failed[%2]").arg(orderObject->order_id).arg(error);
result= 0;
}
else
{
Orderstatus::getInstance().entryupdate(orderObject->order_id,1);
QLOG_INFO() << QString("[entry order %1 success].").arg(orderObject->order_id);
result= 1;
}
}
if((orderObject->status==100||orderObject->status==3)&&!Orderstatus::getInstance().isrefund(orderObject->order_id)
&&Orderstatus::getInstance().isentry(orderObject->order_id))
{
QString tmpstr="";
if(!RefuseSalesSlip(orderObject))
{
tmpstr = QString("\r\n[撤回销售单失败]");
QLOG_INFO() << QString("entry order %1 failed[%2]").arg(orderObject->order_id).arg(error);
return false;
}else
{
Orderstatus::getInstance().refundupdate(orderObject->order_id,1);
tmpstr = QString("\r\n[撤回销售单成功]");
return true;
}
}
}
// 撤单的id 记录
QByteArray flowControll::_GetRefundOrderData(const QString &orderId)
{
......@@ -1170,8 +1208,34 @@ bool flowControll::_RefundOrder(const QString& orderId, QString reason)//退单
emit showOrderDetails(m_ordersMap.value(orderId));
}
void flowControll::onReEntryOrder(const QString &orderId)
void flowControll::onReEntryOrder(OrderObject* orderObject,int operation)
{
if(operation==OPERATIONMAME_ENTRY)
{
if(!DoSalesSlip(orderObject,0))
{
QLOG_INFO() << QString("entry order %1 failed[%2]").arg(orderObject->order_id).arg(error);
}
else
{
Orderstatus::getInstance().entryupdate(orderObject->order_id,1);
QLOG_INFO() << QString("[entry order %1 success].").arg(orderObject->order_id);
}
}
else
{
QString tmpstr="";
if(!RefuseSalesSlip(orderObject))
{
tmpstr = QString("\r\n[撤回销售单失败]");
QLOG_INFO() << QString("entry order %1 failed[%2]").arg(orderObject->order_id).arg(error);
}else
{
Orderstatus::getInstance().refundupdate(orderObject->order_id,1);
tmpstr = QString("\r\n[撤回销售单成功]");
}
}
}
void flowControll::onNetReEntryOrder(const QString &orderId)
......
......@@ -118,11 +118,14 @@ public slots:
void onUpdateCashier(const CashierObject& cashier);//更新收银员信息
void onGetOnDutyCashiers();//获取在班收银员信息
void onGetOrderDetails(const QString& orderId);//获取订单详情
void onReEntryOrder(const QString &orderId);//本地接受销售单
void onReEntryOrder(OrderObject *orderObject, int operation);//本地接受销售单
void onNetReEntryOrder(const QString &orderId);//发送数据到服务端
void onProcessRejectOrder(const QString& orderId, const int& reason, const int &reasontype);
bool _RefundOrder(const QString& orderId, QString reason);//退单
void onStopTimer();
private slots:
bool _EntryOrder(OrderObject *orderObject);
};
......
#include "orderstatus.h"
#include "QsLog/QsLog.h"
#include <QCoreApplication>
Orderstatus::Orderstatus()
{
QString dbpath=QCoreApplication::applicationDirPath()+QString("/orderstatus.db");
//db.addDatabase("QSQLITE");
QSqlDatabase db=QSqlDatabase::addDatabase("QSQLITE");
//db.setDatabaseName("orderstatus.db");
db.setDatabaseName(dbpath);
if(!db.open())
{
QString error=db.lastError().text();
QLOG_ERROR()<<QString("Qsqlite database open filed,%1").arg(error);
}
else{
QLOG_INFO()<<QString("Qsqlite database open successed");
}
QSqlQuery query;
int isTableExist;
query.exec(QString("select count(*) from sqlite_master where type='table' and name='%1'").arg("status"));
while(query.next())
{
isTableExist = query.value(0).toInt();
}
if(!isTableExist){
QLOG_INFO() << "table status does not exist";
query.exec(QString("create table status (orderId varchar(20) primary key, isentry int(1),isrefund int(1))"));
} else{
QLOG_INFO() << "table status exists";
}
//qDebug()<<query.lastError().text()<<"create table error";
}
Orderstatus &Orderstatus::getInstance()
{
static Orderstatus order;
return order;
}
bool Orderstatus::statusinsert(const QString &orderId, const int &entrystatus,const int &refundstatus)
{
QSqlQuery query;
query.prepare(QString("insert into status values('%1',%2,%3)").arg(orderId).arg(QString::number(entrystatus)).arg(QString::number(refundstatus)));
if(!query.exec())
{
QLOG_ERROR()<<query.lastError().text()<<QString::number(query.lastError().type())<<"statusinsert";
return false;
}
else{
QLOG_INFO()<<QString("insert orderId %1 into status success").arg(orderId);
return true;
}
}
bool Orderstatus::entryupdate(const QString &orderId, const int &entrystatus)
{
QSqlQuery query;
query.prepare(QString("update status set isentry=%1 where orderId='%2'").arg(QString::number(entrystatus)).arg(orderId));
if(!query.exec())
{
QLOG_ERROR()<<query.lastError().text()<<"entryupdate";
return false;
}
else{
QLOG_INFO()<<QString("update orderId %1 entrystatus success").arg(orderId);
return true;
}
}
bool Orderstatus::isentry(const QString &orderId)
{
QSqlQuery query;
query.prepare(QString("select isentry from status where orderId='%1'").arg(orderId));
if(!query.exec())
{
QLOG_ERROR()<<query.lastError().text()<<"isentry";
return false;
}
while(query.next())
{
return query.value(0).toBool();
}
}
bool Orderstatus::refundupdate(const QString &orderId, const int &refundstatus)
{
QSqlQuery query;
query.prepare(QString("update status set isrefund=%1 where orderId='%2'").arg(QString::number(refundstatus)).arg(orderId));
if(!query.exec())
{
QLOG_ERROR()<<query.lastError().text()<<"refundupdate";
return false;
}
else{
QLOG_INFO()<<QString("update orderId %1 status success").arg(orderId);
return true;
}
}
bool Orderstatus::isrefund(const QString &orderId)
{
QSqlQuery query;
query.prepare(QString("select isrefund from status where orderId='%1'").arg(orderId));
if(!query.exec())
{
QLOG_ERROR()<<query.lastError().text()<<"isrefund";
return false;
}
while(query.next())
{
return query.value(0).toBool();
}
}
bool Orderstatus::isorderexit(const QString &orderId)
{
QSqlQuery query;
query.prepare(QString("select orderId from status where orderId='%1'").arg(orderId));
if(!query.exec())
{
QLOG_ERROR()<<query.lastError().text()<<"isorderexit";
return false;
}
if(query.first())
{
return true;
}
else{
return false;
}
}
#ifndef ORDERSTATUS_H
#define ORDERSTATUS_H
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlError>
#include <QObject>
class Orderstatus : public QObject
{
Q_OBJECT
public:
// explicit Orderstatus(QObject *parent = 0);
static Orderstatus& getInstance();
bool statusinsert(const QString& orderId, const int &entrystatus, const int &refundstatus);
bool entryupdate(const QString& orderId, const int &entrystatus);
//bool statusdelete(const QString&);
bool isentry(const QString& orderId);
bool refundupdate(const QString& orderId, const int &refundstatus);
//bool statusdelete(const QString&);
bool isrefund(const QString& orderId);
bool isorderexit(const QString& orderId);
private:
Orderstatus();
Orderstatus(Orderstatus const&);
Orderstatus& operator=(Orderstatus const&);
signals:
public slots:
};
#endif // ORDERSTATUS_H
......@@ -17,6 +17,7 @@
#include "Ui/MateChooser.h"
#include <QHeaderView>
#include <QFileInfo>
#include "Tool/orderstatus.h"
DetailForm::DetailForm(QWidget *parent) :
QWidget(parent),
......@@ -38,7 +39,7 @@ DetailForm::DetailForm(QWidget *parent) :
connect(ui->refuseorder,SIGNAL(clicked(bool)),this,SLOT(onOthersOperate()));
connect(ui->detailnull,SIGNAL(clicked(bool)),this,SLOT(onOthersOperate()));
connect(ui->detailBtnClose,SIGNAL(clicked(bool)),this,SLOT(onhideUi()));
// connect(this,&DetailForm::reEntryOrder,&flowControll::GetInstance(),&flowControll::onReEntryOrder);
connect(this,&DetailForm::reEntryOrder,&flowControll::GetInstance(),&flowControll::onReEntryOrder);
connect(this,&DetailForm::NetreEntryOrder,&flowControll::GetInstance(),&flowControll::onNetReEntryOrder);
connect(this,&DetailForm::processOrder,&flowControll::GetInstance(),&flowControll::onProcessOrder);
connect(this, &DetailForm::processRejectOrder, &flowControll::GetInstance(), &flowControll::onProcessRejectOrder);
......@@ -120,11 +121,27 @@ void DetailForm::showUi(OrderObject *orderObject)
}
ui->HandleRecord->setText(records);
QFile orderFlag(QString("%1/orders/%2").arg(QApplication::applicationDirPath(), orderObject->order_id));
qDebug()<<"qfile is "<<QString("%1/orders/%2").arg(QApplication::applicationDirPath(), orderObject->order_id);
if(!orderFlag.exists())
// QFile orderFlag(QString("%1/orders/%2").arg(QApplication::applicationDirPath(), orderObject->order_id));
// qDebug()<<"qfile is "<<QString("%1/orders/%2").arg(QApplication::applicationDirPath(), orderObject->order_id);
// if(!orderFlag.exists())
// {
// ui->againWrite->hide();
// }
if(orderObject->status==3||orderObject->status==100)
{
if(!Orderstatus::getInstance().isrefund(orderObject->order_id))
{
ui->againWrite->hide();
ui->againWrite->show();
ui->againWrite->setProperty("operation",OPERATIONMAME_REFUDN);
}
}
else
{
if(!Orderstatus::getInstance().isentry(orderObject->order_id))
{
ui->againWrite->show();
ui->againWrite->setProperty("operation",OPERATIONMAME_ENTRY);
}
}
ui->refuseorder->setProperty("operation", OPERATION_REFUSE);
......@@ -152,6 +169,7 @@ void DetailForm::showUi(OrderObject *orderObject)
{
ui->detailnull->hide();
}
if(m_rejectForm==NULL)
m_rejectForm = new RejectForm(this);
bool assigned = _ReadBilledMates();
......@@ -178,12 +196,13 @@ void DetailForm::showUi(OrderObject *orderObject)
void DetailForm::WriteData(/*char data[]*/)
{
QPushButton* btn=(QPushButton*)sender();
//补录要用到接口
if(0== m_orderObject)
{
return;
}
emit reEntryOrder(m_orderObject->order_id);
emit reEntryOrder(m_orderObject,btn->property("opertion").toInt());
hide();
}
......
......@@ -64,7 +64,7 @@ private:
public:
Ui::DetailForm *ui;
Q_SIGNAL void reEntryOrder(const QString& orderId); //补录订单
Q_SIGNAL void reEntryOrder(OrderObject* order,int opertion); //补录订单
Q_SIGNAL void NetreEntryOrder(const QString& orderId);//上传补录
Q_SIGNAL void processOrder(const QString& operation, const QString& orderId, const DeliverObject& deliverObj); // 处理订单1pra操作动作名2pra订单编号3pra配送员信息
Q_SIGNAL void processRejectOrder(const QString& orderId,const int& reason,const int& reasontype);
......
......@@ -47,7 +47,8 @@ SOURCES +=fmp_takeout.cpp \
Ui/RejectForm.cpp \
Tool/HttpSocket.cpp\
Ui/DrinkItem.cpp \
Ui/MateChooser.cpp
Ui/MateChooser.cpp \
Tool/orderstatus.cpp
HEADERS +=fmp_takeout_i.h \
fmp_takeout.h \
......@@ -94,7 +95,8 @@ HEADERS +=fmp_takeout_i.h \
Tool/HttpSocket.h \
fmp_takeout_def.h \
Ui/DrinkItem.h \
Ui/MateChooser.h
Ui/MateChooser.h \
Tool/orderstatus.h
FORMS += \
Ui/mainwindow.ui \
......
......@@ -82,7 +82,7 @@ void FMPTakeoutPrivate::sltStopBlink(int type)
void FMPTakeoutPrivate::sltPrint(QString data,QString label)
{
if (_Printer) {
emit sgnReceiveStatus(_Printer->DoPrint(data,label));
//emit sgnReceiveStatus(_Printer->DoPrint(data,label));
}
}
......
No preview for this file type
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