Commit f614c7cd by xiaoqing.gu

1.6.0第三方配送对接

parent c768bf9d
......@@ -494,7 +494,7 @@ bool NewPrintLib::PrintLabel(const QString &config, OrderObject *order)
while(num > 0)
{
QByteArray data = config.toUtf8();
QByteArray data = config.toLocal8Bit();
char *tmpconfig = NULL;
......
#include "driverinfogetwork.h"
#include "event/fmapplication.h"
#include "event/posevent.h"
#include "QsLog.h"
#include <QJsonArray>
DriverInfoGetWork::DriverInfoGetWork(WorkObject *parent) : WorkObject(parent)
{
_isgetorder = false;
FMApplication::subscibeEvent(this, PosEvent::s_get_order_status);
FMApplication::subscibeEvent(this, PosEvent::s_token_change);
FMApplication::subscibeEvent(this, PosEvent::s_login_storeinfo);
FMApplication::subscibeEvent(this, PosEvent::s_need_get_driver_info);
}
DriverInfoGetWork::~DriverInfoGetWork()
{
qDebug() << "";
while(!_stoped)
{
_stopflag = true;
emit quit();
EVENTWAIT(10);
}
}
bool DriverInfoGetWork::event(QEvent *e)
{
if(e->type() == PosEvent::s_get_order_status)
{
bool isgetorder = false;
GETEVENTINFO(isgetorder, e, bool);
QLOG_DEBUG() << "DriverInfoGetWork::event::PosEvent::s_get_order_status:" << isgetorder;
_isgetorder = isgetorder;
return true;
}
if(e->type() == PosEvent::s_token_change)
{
QString token;
GETEVENTINFO(token, e, QString);
QLOG_DEBUG() << "DriverInfoGetWork::event::PosEvent::s_token_chang:" << token;
_token = token;
emit quit();
return true;
}
if(e->type() == PosEvent::s_login_storeinfo)
{
QVariantMap storeinfo;
GETEVENTINFO(storeinfo,e,QVariantMap);
QLOG_DEBUG() << "StallsGetWork::event::PosEvent::s_login_storeinfo:" << storeinfo;
_storeinfo = storeinfo;
return true;
}
if(e->type() == PosEvent::s_need_get_driver_info)
{
QLOG_INFO() << QThread::currentThreadId() << "OrderGetWork PosEvent::s_need_get_order";
emit quitwork();
return true;
}
return WorkObject::event(e);
}
void DriverInfoGetWork::setUrl(const QString &url)
{
_url = url;
}
void DriverInfoGetWork::workstart()
{
if(_token.isEmpty())
{
QEventLoop loop;
connect(this, &DriverInfoGetWork::quit, &loop, &QEventLoop::quit);
loop.exec();
}
if(_isgetorder)
{
QEventLoop loop;
connect(this, &DriverInfoGetWork::quit, &loop, &QEventLoop::quit);
loop.exec();
}
QLOG_DEBUG() << "DriverInfoGetWork::workstart loop start";
while(!_stopflag)
{
if(!getDriverInfo())
{
QLOG_WARN() << "DriverInfoGetWork::getDriverInfo failed wait " << DEFAULT_STALLS_TIMEOUT;
QTimer timer;
QEventLoop loop;
connect(this, &DriverInfoGetWork::quit, &loop, &QEventLoop::quit);
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
timer.start(DEFAULT_STALLS_TIMEOUT);
loop.exec();
continue;
}
//获取档口信息完成后检擦是否退出表示
if(_stopflag)
break;
QEventLoop loop;
connect(this, &DriverInfoGetWork::quit, &loop, &QEventLoop::quit);
connect(this, &DriverInfoGetWork::quitwork, &loop, &QEventLoop::quit);
loop.exec();
}
_stoped = true;
}
bool DriverInfoGetWork::getDriverInfo()
{
QJsonObject json, recvjson;
QString realurl;
QString error;
if(!GetDriverInfoDataProcess::getDriverInfoRequest(json, _storeinfo))
{
QLOG_ERROR() << "getDriverInfoRequest failed";
return false;
}
QLOG_INFO() << "getDriverInfoRequest request json : " << json;
if(!GetDriverInfoDataProcess::getRealUrl(ADVANCEORDER, json, _url, realurl))
{
QLOG_ERROR() << "GetDriverInfoDataProcess getRealUrl failed";
return false;
}
QLOG_INFO() << "GetDriverInfoDataProcess request url :" << realurl;
if(!this->S_Request(json, recvjson, realurl, error))
{
QLOG_ERROR() << "getDriverInfo failed : " << error;
return false;
}
QLOG_INFO() << "getDriverInfo return json : " << recvjson;
return praseRecvJson(recvjson);
}
bool DriverInfoGetWork::praseRecvJson(QJsonObject &json)
{
if(!json.contains(JSON_KEY_CODE) || QString("ok").compare(json[JSON_KEY_CODE].toString(), Qt::CaseInsensitive) != 0)
{
QLOG_ERROR() << "DriverInfoGetWork::praseRecvJson failed";
return false;
}
if(!json.contains(JSON_KEY_RESULT))
{
QLOG_ERROR() << "DriverInfoGetWork::praseRecvJson failed";
return false;
}
QJsonArray result = json[JSON_KEY_RESULT].toArray();
QLOG_DEBUG() << "QJsonArray result:" << result.size();
for(int i = 0;i < result.size(); i++)
{
QJsonObject driverInfo = result.at(i).toObject();
QLOG_DEBUG() << "driverinfo input:" << driverInfo;
QVariantMap map;
map.insert(JSON_ORDERID, driverInfo["order_id"].toString());
map.insert("rider_name", driverInfo["rider_name"].toString());
map.insert("rider_phone", driverInfo["rider_phone"].toString());
POSTEVENTTYPE(PosEvent::s_get_driver_info,map,QVariantMap);
}
return true;
}
#ifndef DRIVERINFOGETWORK_H
#define DRIVERINFOGETWORK_H
#include <QEvent>
#include <QString>
#include <QJsonObject>
#include <QTimer>
#include <QEventLoop>
#include "workobject.h"
#include "preDefine.h"
#include "base/Arithmetic/cretopt.h"
#define ADVANCEORDER 0
class DriverInfoGetWork : public WorkObject
{
Q_OBJECT
public:
explicit DriverInfoGetWork(WorkObject *parent = 0);
~DriverInfoGetWork();
bool event(QEvent *e);
void setUrl(const QString &url);
signals:
void quitwork();
public slots:
void workstart();
private:
bool getDriverInfo();
bool praseRecvJson(QJsonObject &json);
private:
QVariantMap _storeinfo;
QString _token;
QString _url;
bool _isgetorder;
};
class GetDriverInfoDataProcess
{
public:
friend class DriverInfoGetWork;
private:
static bool getAction(int REQ, QString &action)
{
#ifndef USE_QAACTION
switch (REQ)
{
case ADVANCEORDER:
action = QString("saas.order.deliveryInfo");
return true;
default:
return false;
}
#else
switch (REQ)
{
case ADVANCEORDER:
action = QString("qasaas.order.deliveryInfo");
return true;
default:
return false;
}
#endif
}
static bool getAccess_Token(QString &access_toekn)
{
access_toekn = DEFAULT_ACCESS_TOKEN;
return true;
}
static bool getVer(QString &ver)
{
ver = "1";
return true;
}
static bool getRealUrl(int reqtype, const QJsonObject &json, const QString &url, QString &realurl)
{
QString action, access_token, ver, sign;
if(!GetDriverInfoDataProcess::requestGetRSASign(reqtype, json, sign, action, access_token, ver))
return false;
QString tmpurl = url;
realurl = tmpurl.arg(action, access_token, ver, sign);
return true;
}
static bool requestGetRSASign(int reqtype, const QJsonObject &json, QString &sign, QString &action, QString &access_token, QString &ver)
{
QJsonObject tmpjson;
if(!GetDriverInfoDataProcess::getAction(reqtype, action) ||
!GetDriverInfoDataProcess::getAccess_Token(access_token) ||
!GetDriverInfoDataProcess::getVer(ver))
return false;
GetDriverInfoDataProcess::getComplateJson(action, access_token, ver, json, tmpjson);
return CretOperate::GetSign(tmpjson, sign);
}
static void getComplateJson(QString action, QString access_token, QString ver, const QJsonObject &json, QJsonObject &complatejson)
{
complatejson = json;
complatejson.insert(JSON_KEY_ACTION, action);
complatejson.insert(JSON_KEY_ACCESS_TOKEN, access_token);
complatejson.insert(JSON_KEY_VER, ver);
}
static bool getDriverInfoRequest(QJsonObject &data, QVariantMap &map)
{
if(!map.contains(JSON_STOREID)) {
return false;
}
data.insert(JSON_KEY_PARTNERID, map[JSON_KEY_PARTNERID].toString());
data.insert(JSON_STOREID, map[JSON_STOREID].toString());
return true;
}
};
#endif // DRIVERINFOGETWORK_H
......@@ -335,6 +335,12 @@ bool OrderGetWork::PullOrder(unsigned int timeout, QString &error)
OrderGetDataProcess::getTimestamp(recvjson, _timestamp);
QVariantMap map;
map.insert(EVENT_KEY_STATUS, true);
map.insert(EVENT_KEY_MSG, error);
POSTEVENTTYPE(PosEvent::s_get_order_status,map,QVariantMap);
return true;
}
......
......@@ -387,6 +387,47 @@ void OrderPushWork::heartBeatTcpService()
continue;
}
else if(cmd == COMMAND_LOGIN_REQ)
{
quint32 reallen = 0;
QByteArray tmplen = _socket->read(4);
OrderPushDataProcess::getRealLen(tmplen, reallen);
QByteArray msgdata = _socket->read(reallen);
needPostDriverEvent(msgdata);
QByteArray data;
OrderPushDataProcess::getMSGResponseData(data, tmplenandsynSeq);
QLOG_INFO() << "tcp response data : " << data.toHex();
_socket->write(data);
//_socket->waitForBytesWritten();
_istimeout = true;
{
QEventLoop loop;
QTimer timer;
connect(this, &OrderPushWork::quit, &loop, &QEventLoop::quit);
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
connect(this, &OrderPushWork::writeready, &loop, &QEventLoop::quit);
timer.start(30*1000);
loop.exec();
}
continue;
}
QLOG_ERROR() << "not support cmdtype";
_socket->readAll();
break;
......@@ -403,6 +444,14 @@ bool OrderPushWork::checkMsgData(const QByteArray &msgdata)
return false;
}
bool OrderPushWork::needPostDriverEvent(const QByteArray &msgdata)
{
QLOG_INFO() << "recv driver_get_work info : " << msgdata;
DEFAULTPOSTEVENT(PosEvent::s_need_get_driver_info, QString::fromUtf8(msgdata));
return false;
}
bool OrderPushWork::GetServiceList()
{
if(_serurl.isEmpty())
......
......@@ -138,6 +138,8 @@ public:
bool getHost(QString &ip, qint16 &port);
//检查是否有效的MSG
bool checkMsgData(const QByteArray &msgdata);
//收到骑手接单消息后推送需要拉取骑手信息的事件
bool needPostDriverEvent(const QByteArray &msgdata);
private:
bool GetServiceList();
......
......@@ -30,6 +30,9 @@ QEvent::Type PosEvent::s_change_stalls = static_cast<QEvent::Type>(QEvent::regis
QEvent::Type PosEvent::s_show_stalls = static_cast<QEvent::Type>(QEvent::registerEventType());
QEvent::Type PosEvent::s_get_prtmodel = static_cast<QEvent::Type>(QEvent::registerEventType());
QEvent::Type PosEvent::s_driver_order_status = static_cast<QEvent::Type>(QEvent::registerEventType());
QEvent::Type PosEvent::s_get_driver_info = static_cast<QEvent::Type>(QEvent::registerEventType());
QEvent::Type PosEvent::s_need_get_driver_info = static_cast<QEvent::Type>(QEvent::registerEventType());
PosEvent::PosEvent(Type e):QEvent(e)
{
......
......@@ -116,6 +116,11 @@ public:
//---------------------打印模板-----------------------
static Type s_get_prtmodel;
//---------------------第三方配送---------------------
static Type s_driver_order_status; //拉取到骑手信息并缓存后,推送事件,展示界面响应事件,展示图标
static Type s_get_driver_info; //登陆拉取骑手信息后,推送事件,posorderpool响应事件,将骑手信息缓存
static Type s_need_get_driver_info; //收到消息中心推送的cmd=5的消息的时候,推送的事件
private:
//事件携带的信息,该内存你应当在堆中分配
void *_info;
......
......@@ -16,6 +16,7 @@
#include "control/prtmodelgetwork.h"
#include "control/stallsgetwork.h"
#include "control/networkcheckwork.h"
#include "control/driverinfogetwork.h"
#include "base/Dump/dump.h"
#include "base/DB/fm_database.h"
//#include "view/loginform.h"
......@@ -161,6 +162,8 @@ int main(int argc, char *argv[])
QThread stallsThread;
//获取打印模板线程
QThread prtModelThread;
//获取骑手信息线程
QThread driverInfoThread;
QLOG_INFO() << "Thread List :" << &thread << &threadt << QThread::currentThread();
//初始化打印文件
InitPtr();
......@@ -190,11 +193,13 @@ int main(int argc, char *argv[])
StallsGetWork stallsgetwork;
//获取打印模板
prtModelGetWork prtmodelgetwork;
//拉取骑手信息
DriverInfoGetWork driverinfogetwork;
//网络超时工作
NetworkCheckWork networkcheckwork;
driverinfogetwork.setUrl(geturl);
prtmodelgetwork.setUrl(geturl);
stallsgetwork.setUrl(geturl);
pickuporderwork.setUrl(geturl);
......@@ -214,6 +219,7 @@ int main(int argc, char *argv[])
stallsgetwork.moveToThread(&stallsThread, true);
prtmodelgetwork.moveToThread(&prtModelThread, true);
driverinfogetwork.moveToThread(&driverInfoThread, true);
//启动tcp长链接和拉单工作流
thread.start();
threadt.start();
......@@ -223,6 +229,7 @@ int main(int argc, char *argv[])
checkipthread.start();
stallsThread.start();
prtModelThread.start();
driverInfoThread.start();
//界面类定义及初始化
#ifndef FM_NEW_UI
MainForm mainform;
......
......@@ -47,6 +47,7 @@ PosOrderPool::PosOrderPool(QObject *parent) : QObject(parent)
FMApplication::subscibeEvent(this, PosEvent::s_change_orderpool);
FMApplication::subscibeEvent(this, PosEvent::s_location_orderpool);
FMApplication::subscibeEvent(this, PosEvent::s_pickuporder_remind);
FMApplication::subscibeEvent(this, PosEvent::s_get_driver_info);
loadOrders();
......@@ -424,6 +425,36 @@ bool PosOrderPool::GetOrderStatusAndOrderType(QString key, int &status, int &ref
return true;
}
bool PosOrderPool::GetDriverInfo(QString key, QString &rider_name, QString &rider_phone)
{
QMutexLocker loker(&s_mutex);
if(!s_order_pool.contains(key))
return false;
Order_Info info = s_order_pool[key];
rider_name = info.rider_name;
rider_phone = info.rider_phone;
return true;
}
bool PosOrderPool::GetDriverStatus(QString key, int &status)
{
QMutexLocker loker(&s_mutex);
if(!s_order_pool.contains(key))
return false;
Order_Info info = s_order_pool[key];
status = info.driver_order_status;
return true;
}
bool PosOrderPool::TryChangeOrderPrintStatus(QString key, int order_print_status)
{
QMutexLocker loker(&s_mutex);
......@@ -462,6 +493,37 @@ bool PosOrderPool::TryChangeOrderRemindStatus(QString key, int order_remind_stat
return true;
}
bool PosOrderPool::TryChangeDriverInfo(QString key, QVariantMap &map)
{
QMutexLocker loker(&s_mutex);
if(!s_order_pool.contains(key))
return false;
Order_Info info = s_order_pool[key];
QLOG_DEBUG() << "TryChangeDriverInfo:" << info.driver_order_status;
if(info.driver_order_status != 1)
{
info.driver_order_status = 1;
info.rider_name = map["rider_name"].toString();
info.rider_phone = map["rider_phone"].toString();
s_order_pool.insert(key, info);
// DEFAULTPOSTEVENT(PosEvent::s_driver_order_status, key);
QVariantMap map;
map.insert(EVENT_KEY_ORDERID, info.order_id);
map.insert(EVENT_KEY_DRIVER_STATUS, 1);
POSTEVENTTYPE(PosEvent::s_driver_order_status, map, QVariantMap);
}
return true;
}
bool PosOrderPool::GetOrderBaseInfo(QString key, QVariantHash &hash)
{
QMutexLocker loker(&s_mutex);
......@@ -705,6 +767,20 @@ bool PosOrderPool::event(QEvent *e)
return true;
}
if(e->type() == PosEvent::s_get_driver_info)
{
QLOG_INFO() << "PosEvent::s_get_driver_info : " << QThread::currentThreadId();
QVariantMap map;
GETEVENTINFO(map,e,QVariantMap);
TryChangeDriverInfo(map[JSON_ORDERID].toString(), map);
return true;
}
return QObject::event(e);
}
......
......@@ -53,6 +53,9 @@
info.order_refund_status = 0; \
info.order_print_status = 0; \
info.order_change_time = QDateTime::currentDateTime().toTime_t(); \
info.driver_order_status = 0; \
info.rider_name = ""; \
info.rider_phone = ""; \
} while (0)
#define INCTAKEOUT(tmpstatus, tk_new, tk_make, tk_send, tk_refund) do { \
......@@ -180,6 +183,12 @@ typedef struct
QString reserved4;
//保留字段5
QString reserved5;
//骑手接单的状态
int driver_order_status;
//骑手姓名
QString rider_name;
//骑手电话
QString rider_phone;
} Order_Info;
......@@ -210,6 +219,10 @@ public:
static bool GetOrderStatusAndOrderType(QString key, int &status, int &refund_status, int &order_type, bool &oldorder);
static bool GetDriverInfo(QString key, QString &rider_name, QString &rider_phone);
static bool GetDriverStatus(QString key, int &status);
template <typename T>
static bool GetOrderIndex(T &t, std::function<bool (OrderObject &order, T &)> fun)
{
......@@ -242,6 +255,9 @@ private:
static bool TryChangeOrderRemindStatus(QString key, int order_remind_status);
//修改骑手接单状态
static bool TryChangeDriverInfo(QString key, QVariantMap &map);
static void removeOrderInfo(QString key);
static void GetOrderStatus(const OrderObject *order, int &status);
......
......@@ -204,6 +204,7 @@
#define JSON_KEY_REFUNDSTATUS "refund_status"
#define EVENT_KEY_STATUS "status"
#define EVENT_KEY_DRIVER_STATUS "driver_status"
#define EVENT_KEY_MSG "msg"
#define EVENT_KEY_ORDERID "order_id"
......
......@@ -21,7 +21,7 @@ LIBS += -L$$PWD/lib -llibeay32 -lssleay32 -lwinspool
LIBS += -lWs2_32
LIBS += -lDbghelp
DEFINES += USE_QAACTION
#DEFINES += USE_QAACTION
DEFINES += FM_NEW_UI
#DEFINES += FM_TEST
......@@ -83,7 +83,8 @@ SOURCES += main.cpp \
control/prtmodelgetwork.cpp \
model/prtmodelpool.cpp \
view/newchangeshiftsform.cpp \
base/Arithmetic/cretopt.cpp
base/Arithmetic/cretopt.cpp \
control/driverinfogetwork.cpp
HEADERS += \
event/fmapplication.h \
......@@ -141,7 +142,8 @@ HEADERS += \
base/System/downloader.h \
control/prtmodelgetwork.h \
model/prtmodelpool.h \
view/newchangeshiftsform.h
view/newchangeshiftsform.h \
control/driverinfogetwork.h
DISTFILES += takeout.rc
......
......@@ -8,6 +8,7 @@
#include "event/fmapplication.h"
#include "event/posevent.h"
#include "model/posorderpool.h"
#include "model/posorderpool.h"
#include "QsLog.h"
NewDetailForm::NewDetailForm(QWidget *parent) :
......@@ -35,6 +36,12 @@ void NewDetailForm::InitData(OrderObject *orderObject, bool flag)
ui->dishTableWidget->setRowCount(0);
ui->detailBtn2->show();
ui->detailBtn3->show();
QString rider_name = "";
QString rider_phone = "";
PosOrderPool::GetDriverInfo(_orderid, rider_name, rider_phone);
QLOG_DEBUG() << "driverinfo" << rider_name << rider_phone;
//ui->detailBtn1->hide();
//"<h2><i>Hello</i><font color=red>Qt!</font></h2>"
......@@ -106,6 +113,17 @@ void NewDetailForm::InitData(OrderObject *orderObject, bool flag)
}
//ui->deliveryInfoLb_dec->setText(QString::fromLocal8Bit("【%1】【%2】").arg(orderObject->delivery_party,timeStr));
if(!rider_name.isEmpty() || !rider_phone.isEmpty())
{
ui->deliverydriverLb_dec->setText(QString::fromLocal8Bit("【%1】【%2】").arg(rider_name, rider_phone));
ui->deliverydriverLb_dec->setWordWrap(true);
}
else
{
ui->deliverydriverLb_dec->clear();
}
QList<DiscountObject *> list = orderObject->disList;
QString disStr;
for(int i = 0; i < list.size(); i++) {
......
......@@ -40,7 +40,7 @@
font: 75 14pt &quot;微软雅黑&quot;;
}
#orderInfoLb,#orderMemoLb,#customerInfoLb,#addressLb,#deliveryInfoLb,#promotionInfoLb,#checkInfoLb
#orderInfoLb,#orderMemoLb,#customerInfoLb,#addressLb,#deliveryInfoLb,#promotionInfoLb,#checkInfoLb,#deliverydriverLb
{
font: 11pt &quot;微软雅黑&quot;;
......@@ -83,7 +83,7 @@
}
#orderInfoLb_dec, #orderMemoLb_dec, #customerInfoLb_dec, #addressLb_dec, #deliveryInfoLb_dec, #promotionInfoLb_dec, #checkInfoLb_dec
#orderInfoLb_dec, #orderMemoLb_dec, #customerInfoLb_dec, #addressLb_dec, #deliveryInfoLb_dec, #promotionInfoLb_dec, #checkInfoLb_dec,#deliverydriverLb_dec
{
font: 11pt &quot;微软雅黑&quot;;
background-color:rgb(250, 249, 249);
......@@ -842,6 +842,51 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="deliverydriverLb">
<property name="minimumSize">
<size>
<width>75</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>骑手信息</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="deliverydriverLb_dec">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
<number>0</number>
......@@ -953,7 +998,7 @@
<number>20</number>
</property>
<property name="topMargin">
<number>40</number>
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
......
......@@ -49,6 +49,7 @@ NewMainForm::NewMainForm(QWidget *parent) :
FMApplication::subscibeEvent(this, PosEvent::s_show_mainform);
FMApplication::subscibeEvent(this, PosEvent::s_network_outtime);
FMApplication::subscibeEvent(this, PosEvent::s_show_stalls);
FMApplication::subscibeEvent(this,PosEvent::s_driver_order_status);
//this->show();
this->showFullScreen();
......@@ -604,6 +605,34 @@ bool NewMainForm::event(QEvent *e)
return true;
}
if(e->type() == PosEvent::s_driver_order_status)
{
QVariantMap map;
GETEVENTINFO(map, e, QVariantMap);
QLOG_DEBUG() << "PosEvent::s_driver_order_status:" << map;
QString orderid = map[JSON_ORDERID].toString();
OrderObject order;
if(!PosOrderPool::GetOrderObject(orderid, order))
return true;
Order_Index tmp = {order.status, order.refund_status};
if(_order_indexs.contains(order.order_id))
{
_order_indexs.insert(order.order_id, tmp);
UpdateTableWidget(order);
}
else
{
_order_indexs.insert(order.order_id, tmp);
InsertTableWidget(order);
}
return true;
}
if(e->type() == PosEvent::s_login_storeinfo)
{
QVariantMap map;
......@@ -790,11 +819,17 @@ void NewMainForm::UpdateTableWidget(OrderObject &orderObject)
for(int i=0; i<table->rowCount(); i++)
{
OrderTypeForm *pwd = (OrderTypeForm *)table->cellWidget(i, 1);
OrderTypeForm *cwd = (OrderTypeForm *)table->cellWidget(i, 2);
OrderOptForm *opt = (OrderOptForm *)table->cellWidget(i, 6);
if(orderObject.order_id.compare(pwd->order_id()) == 0)
{
int driver_status;
PosOrderPool::GetDriverStatus(orderObject.order_id, driver_status);
QString channelName;
getOrderChannelName(&orderObject,channelName);
pwd->InitShow(orderObject.order_id, orderObject.status, orderObject.refund_status, orderObject.order_type);
cwd->InitChannelShow(orderObject.order_id, orderObject.status, orderObject.refund_status, orderObject.order_type,channelName,driver_status);
opt->InitShow(orderObject.order_id, orderObject.status, orderObject.refund_status, orderObject.order_type);
break;
}
......@@ -890,9 +925,18 @@ void NewMainForm::InsertTableWidget(OrderObject &orderObject)
getOrderChannelName(&orderObject,channelName);
QTableWidgetItem *item0 = new QTableWidgetItem(QString(channelName));
item0->setTextAlignment(Qt::AlignCenter);
table->setItem(0, 2, item0); // 渠道
//渠道使用ordertypeform进行插入和订单状态一样的操作
int driver_status = 0;
PosOrderPool::GetDriverStatus(orderObject.order_id, driver_status);
OrderTypeForm *cWdg = new OrderTypeForm(table);
cWdg->InitChannelShow(orderObject.order_id, orderObject.status, orderObject.refund_status, orderObject.order_type,channelName,driver_status);
connect(cWdg, &OrderTypeForm::showOrderInfo, this, &NewMainForm::onPickUpGetOrder);
table->setCellWidget(0, 2, cWdg); // 渠道
// QTableWidgetItem *item0 = new QTableWidgetItem(QString(channelName));
// item0->setTextAlignment(Qt::AlignCenter);
// table->setItem(0, 2, item0); // 渠道
// QTableWidgetItem *item1 = new QTableWidgetItem(orderObject.order_id);
// item1->setTextAlignment(Qt::AlignCenter);
// table->setItem(0, 3, item1); // 订单ID
......
......@@ -4,6 +4,9 @@
#include <QMouseEvent>
#include "QsLog.h"
#include "event/fmapplication.h"
#include "event/posevent.h"
#include "preDefine.h"
OrderTypeForm::OrderTypeForm(QWidget *parent) :
......@@ -15,6 +18,7 @@ OrderTypeForm::OrderTypeForm(QWidget *parent) :
_order_status = DefaultOrder;
_refund_status = DefaultOrder;
_order_type = DefaultOrderType;
_drive_status = 0;
}
OrderTypeForm::~OrderTypeForm()
......@@ -22,6 +26,7 @@ OrderTypeForm::~OrderTypeForm()
delete ui;
}
void OrderTypeForm::mousePressEvent(QMouseEvent *e)
{
if(e->buttons()&Qt::LeftButton)
......@@ -50,6 +55,32 @@ void OrderTypeForm::InitShow(QString order_id, int order_status, int refund_stat
}
void OrderTypeForm::InitChannelShow(QString order_id, int order_status, int refund_status, int order_type, QString channel, int driver_status)
{
_order_id = order_id;
_order_status = order_status;
_refund_status = refund_status;
_order_type = order_type;
_drive_status = driver_status;
// if(_order_type == AppointmentTakeout || _order_type == AppointmentDining || _order_type == AppointmentInvite)
// {
// ui->ordertypelabel_type->setStyleSheet("#ordertypelabel_type{ border-image: url(:yy.png)}");
// }
if(!(_order_status == CancelOrder || _order_status == ServiceOrder || _order_status == RefusedOrder ||
_order_status == CompleteRefundOrder || _order_status == CompleteOrder))
{
if(_drive_status == 1)
{
ui->ordertypelabel_type->setStyleSheet("#ordertypelabel_type{ border-image: url(:yy.png)}");
}
}
ui->ordertypelabel_name->setText(channel);
ui->ordertypelabel_name->adjustSize();
}
void OrderTypeForm::SetNameStyle(int status)
{
switch (status) {
......
#ifndef ORDERTYPEFORM_H
#define ORDERTYPEFORM_H
......@@ -22,6 +23,8 @@ public:
void InitShow(QString order_id, int order_status, int refund_status, int order_type);
void InitChannelShow(QString order_id, int order_status, int refund_status, int order_type, QString channel, int driver_status);
QString order_id() const;
int order_status() const;
......@@ -42,6 +45,7 @@ private:
int _order_status;
int _refund_status;
int _order_type;
int _drive_status;
};
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>74</width>
<width>86</width>
<height>28</height>
</rect>
</property>
......@@ -64,13 +64,13 @@
<widget class="QLabel" name="ordertypelabel_name">
<property name="minimumSize">
<size>
<width>48</width>
<width>70</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>48</width>
<width>70</width>
<height>20</height>
</size>
</property>
......
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