Commit 9a455eae by 戴尚尚

增加小票支持子商品打印

parent ba8a41f6
......@@ -68,14 +68,31 @@ QString FmPrinter::_GetPrintData(OrderObject *pData)
{
foreach(ProductObject* pObj, map.values(key))
{
QString name, price;
name = pObj->name;
price = QString("%1 x%2 %3").arg(_Penny2Dollar(pObj->price)).arg(pObj->productAmount)
.arg(_Penny2Dollar(pObj->price*pObj->productAmount));
if( !pObj->sub_products.isEmpty() )
{
str_comd_list.append(QString(pObj->name+"#"));
foreach(ProductObject *sun_pObj, pObj->sub_products)
{
QString name, price;
name = sun_pObj->name;
price = QString("%1 x%2 %3").arg(_Penny2Dollar(sun_pObj->price)).arg(sun_pObj->productAmount)
.arg(_Penny2Dollar(sun_pObj->price*sun_pObj->productAmount));
str_comd_list.append(QString(name+"#"+price+"#"));
productCount += sun_pObj->productAmount ;
}
}else
{
QString name, price;
name = pObj->name;
price = QString("%1 x%2 %3").arg(_Penny2Dollar(pObj->price)).arg(pObj->productAmount)
.arg(_Penny2Dollar(pObj->price*pObj->productAmount));
str_comd_list.append(QString(name+"#"+price+"#"));
productCount += pObj->productAmount ;
str_comd_list.append(QString(name+"#"+price+"#"));
productCount += pObj->productAmount ;
}
}
index++;
if(index!=count)
......@@ -86,7 +103,7 @@ QString FmPrinter::_GetPrintData(OrderObject *pData)
result_str.append("#"+QString::number(pData->order_index));
result_str.append("|");
result_str.append(pData->channelName);
result_str.append(!pData->channelName.compare("非码微店") ? "官网" : pData->channelName);
result_str.append("|");
result_str.append(storename);
result_str.append("|");
......@@ -98,7 +115,7 @@ QString FmPrinter::_GetPrintData(OrderObject *pData)
result_str.append("|");
result_str.append(pData->delivery_time>0?QDateTime::fromTime_t(pData->delivery_time).toString("yy-MM-dd hh:mm"):"立即送达");
result_str.append("|");
result_str.append(pData->remark.isEmpty()?"null":pData->remark);
result_str.append(pData->remark.isEmpty()?"null":pData->remark.replace("\r\n", ""));
result_str.append("|");
result_str.append(pData->has_invoiced?"是": "null");
......@@ -131,7 +148,12 @@ QString FmPrinter::_GetPrintData(OrderObject *pData)
result_str.append("|");
result_str.append(_Penny2Dollar(pData->total_fee)); // 订单总金额
result_str.append("|");
result_str.append(_Penny2Dollar(pData->product_fee - pData->dis_shop_fee));// 商品金额
// 减去商家优惠金额
//result_str.append(_Penny2Dollar(pData->product_fee - pData->dis_shop_fee));// 商品金额
// 不减商家优惠金额
result_str.append(_Penny2Dollar(pData->product_fee));// 商品金额
result_str.append("|");
result_str.append(pData->address);
result_str.append("|");
......
......@@ -27,6 +27,7 @@ FlowControl::FlowControl()
m_pullOrderSocket = NULL;
m_procOrderSocket = NULL;
m_pullDishesSocket = NULL;
m_yzDishesSocket = NULL;
netErrorIndex = 0;
//QTimer::singleShot(10000,this, &FlowControl::_PostBill);
......@@ -870,8 +871,10 @@ void FlowControl::onFlowStart()
m_pullOrderSocket = new BillSocket(this);
m_procOrderSocket = new BillSocket(this);
m_syncStockSocket = new BillSocket(this);
m_yzDishesSocket = new BillSocket(this);
m_pullDishesSocket = new BillSocket(this);
m_yzDishesSocket->SetUrl("http://www.wdmcake.cn/api/freemud/api.php");
if(_GetStoreInfo())
{
_Login();
......@@ -1027,16 +1030,29 @@ void FlowControl::onPullDishes()
{
// 分别获取每个平台的菜品信息
QJsonArray jaChannels = recvJson[JSON_SHOPSTATUS].toArray();
//QJsonArray jaChannels;
QJsonObject tmpObj;
tmpObj.insert("code", "mall");
tmpObj.insert("name", "官网");
jaChannels.append(tmpObj);
foreach(QJsonValue v, jaChannels)
{
QJsonObject channel = v.toObject();
QString channelName = channel["name"].toString();
QString channelCode = channel["code"].toString();
sendJson = DataManger::GetInstance().GetPullDishesData(channelCode);
sendJson = DataManger::GetInstance().GetPullDishesData(channelCode, m_storeId);
emit showAlert(AlertForm::LOADING, QString("正在获取[%1]菜品信息......").arg(channelName));
QLOG_INFO() << QString("[---pullDishes %1---]. [requestData:%2]").arg(channelName, _GetJsonStr(sendJson));
result = m_pullDishesSocket->Request(sendJson, recvJson, error);
if(!channelCode.compare("mall"))
{
QLOG_INFO() << "有赞商城获取菜单";
result = m_yzDishesSocket->Request(sendJson, recvJson, error);
}else
{
result = m_pullDishesSocket->Request(sendJson, recvJson, error);
}
QLOG_INFO() << QString("pullDishes finsh. [result:%1][msg:%2][recvData:%3]")
.arg(result).arg(error, _GetJsonStr(recvJson));
if(!result)
......@@ -1115,10 +1131,17 @@ void FlowControl::onUpdDishes(QStringList channelCode, QString disheId, int stat
emit showAlert(AlertForm::LOADING, "正在同步菜品销售状态......");
foreach (QString channel, channelCode) {
sendJson = DataManger::GetInstance().GetUpdDishesData(channel.split(":").at(1), channel.split(":").at(2), status);
sendJson = DataManger::GetInstance().GetUpdDishesData(channel.split(":").at(1), channel.split(":").at(2), status, m_storeId);
QLOG_INFO() << QString("[---update dishes---]. [requestData:%1]").arg(_GetJsonStr(sendJson));
result = m_pullDishesSocket->Request(sendJson, recvJson, error);
if(!channel.split(":").at(1).compare("mall"))
{
result = m_yzDishesSocket->Request(sendJson, recvJson, error);
}else
{
result = m_pullDishesSocket->Request(sendJson, recvJson, error);
}
QLOG_INFO() << QString("update dishes finsh. [result:%1][msg:%2][recvData:%3]")
.arg(result).arg(error, _GetJsonStr(recvJson));
if(!result)
......
......@@ -68,6 +68,7 @@ private:
BillSocket *m_procOrderSocket;
BillSocket *m_syncStockSocket;
BillSocket *m_pullDishesSocket;
BillSocket *m_yzDishesSocket;
// 拉取订单的时间戳
QString m_timestamp;
// 订单容器
......
......@@ -95,6 +95,11 @@ QString ConfigManger::GetPrefix()
return m_config->value("Client/prefix").toString();
}
QSize ConfigManger::GetFormSize()
{
return m_userConfig->value("Client/size").toSize();
}
QString ConfigManger::getproxyIp()
{
return m_userConfig->value("Proxy/Ip").toString();
......
......@@ -88,6 +88,12 @@ public:
* */
QString GetPrefix();
/* 功能:获取界面大小
* 参数:NULL
* 返回:NULL
* */
QSize GetFormSize();
QString getproxyIp();
int getproxyProt();
void setPrinterMode(const QString &mode);
......
......@@ -192,16 +192,23 @@ QJsonObject DataManger::GetReportOERData(const QString &orderId, int status, con
return rObj;
}
QJsonObject DataManger::GetPullDishesData(const QString& channelCode)
QJsonObject DataManger::GetPullDishesData(const QString& channelCode, QString storeId)
{
QJsonObject rObj;
rObj.insert(JSON_REQTYPE, PULL_DISHES);
rObj.insert(JSON_CHANNEL, channelCode);
rObj.insert(JSON_TOKEN, m_token);
if(!channelCode.compare("mall"))
{
rObj.insert("shopId", storeId);
}else
{
rObj.insert(JSON_TOKEN, m_token);
}
return rObj;
}
QJsonObject DataManger::GetUpdDishesData(QString channelCode, QString disheId, int status)
QJsonObject DataManger::GetUpdDishesData(QString channelCode, QString disheId, int status, QString storeId)
{
QJsonObject rObj;
QJsonArray dishes;
......@@ -213,7 +220,14 @@ QJsonObject DataManger::GetUpdDishesData(QString channelCode, QString disheId, i
rObj.insert(JSON_REQTYPE, UPD_DISHES_STATUS);
rObj.insert(JSON_CHANNEL, channelCode);
rObj.insert("dishes", dishes);
rObj.insert(JSON_TOKEN, m_token);
if(!channelCode.compare("mall"))
{
rObj.insert("shopId", storeId);
}else
{
rObj.insert(JSON_TOKEN, m_token);
}
return rObj;
}
......
......@@ -92,12 +92,12 @@ public:
* 参数:[1]时间戳
* 返回:登录数据
* */
QJsonObject GetPullDishesData(const QString &channelCode);
QJsonObject GetPullDishesData(const QString &channelCode, QString storeId="");
/* 功能:获取更新菜品信息数据
* 参数:[1]时间戳
* 返回:登录数据
* */
QJsonObject GetUpdDishesData(QString channelCode, QString disheId, int status);
QJsonObject GetUpdDishesData(QString channelCode, QString disheId, int status, QString storeId="");
QJsonObject GetUpdDishesForRefData(QString channelCode, QMap<QString, int> dishesMap);
......
......@@ -13,7 +13,7 @@ void OrderObject::FromJson(const QJsonObject &json)
{
QJsonObject proJson = product.toObject();
ProductObject *proObject = new ProductObject(this);
proObject->FetchDataFromJson(proJson);
proObject->FromJson(proJson);
proList.append(proObject);
}
......
......@@ -34,6 +34,11 @@ BillSocket::~BillSocket()
}
void BillSocket::SetUrl(const QString &url)
{
m_networkRequest.setUrl(QUrl(url));
}
bool BillSocket::Request(const QJsonObject &requestJson, QJsonObject &recvJson, QString &error)
{
if(QNetworkAccessManager::Accessible != m_networkManger.networkAccessible())
......
......@@ -13,6 +13,7 @@ public:
explicit BillSocket(QObject *parent=0);
~BillSocket();
void SetUrl(const QString& url);
bool Request(const QJsonObject& requestJson, QJsonObject& recvJson, QString& error);
private:
......
......@@ -26,7 +26,7 @@ void BStatusItem::InitData(QString str)
m_channelName = list.at(1);
m_channelStatus = QString(list.at(2)).toInt();
ui->btsItemLab->setText(m_channelName);
ui->btsItemLab->setText(!m_channelName.compare("非码微店") ? "官网" : m_channelName);
if(m_channelStatus == 0)
{
......
......@@ -63,10 +63,13 @@ void DailyForm::onShowDailyForm(QList<DailyStatement> infos)
QTableWidgetItem *num0 = new QTableWidgetItem(QString::number(info.total_number));
num0->setTextAlignment(Qt::AlignCenter);
ui->daily_table0->setItem(0, 1, num0);
QTableWidgetItem *fee0 = new QTableWidgetItem(QString::number((float)(info.product_fee_zps+info.product_fee-info.discount_shop_fee-info.discount_shop_fee_zps)/100, 'f' , 1));
// 减去优惠金额
//QTableWidgetItem *fee0 = new QTableWidgetItem(QString::number((float)(info.product_fee_zps+info.product_fee-info.discount_shop_fee-info.discount_shop_fee_zps)/100, 'f' , 1));
// 不减优惠金额
QTableWidgetItem *fee0 = new QTableWidgetItem(QString::number((float)(info.product_fee_zps+info.product_fee)/100, 'f' , 1));
fee0->setTextAlignment(Qt::AlignCenter);
ui->daily_table0->setItem(0, 2, fee0);
tmp_printDate0.append(QString("%1*X%2*%3").arg(m_map.value(info.channel)).arg(info.total_number).arg(QString::number((float)(info.product_fee_zps+info.product_fee-info.discount_shop_fee-info.discount_shop_fee_zps)/100, 'f' , 1)));
tmp_printDate0.append(QString("%1*X%2*%3").arg(m_map.value(info.channel)).arg(info.total_number).arg(QString::number((float)(info.product_fee_zps+info.product_fee)/100, 'f' , 1)));
tmp_printDate0.append("$");
ui->daily_table1->insertRow(0);
......@@ -95,7 +98,10 @@ void DailyForm::onShowDailyForm(QList<DailyStatement> infos)
tmp_printDate1.append(QString("%1*平台配送*%3").arg(m_map.value(info.channel)).arg(QString::number((float)info.send_fee/100, 'f' , 1)));
tmp_printDate1.append("$");
shop_total_fee += info.product_fee_zps+info.product_fee-info.discount_shop_fee-info.discount_shop_fee_zps;
// 减去商家优惠
//shop_total_fee += info.product_fee_zps+info.product_fee-info.discount_shop_fee-info.discount_shop_fee_zps;
// 不减商家优惠
shop_total_fee += info.product_fee_zps+info.product_fee;
}
......
......@@ -42,7 +42,7 @@ void DetailForm::InitData(OrderObject *orderObject)
ui->detailLabNotice->setText("");
// 初始化界面
ui->detailLab0->setText(QString("[%1][%2][%3]").arg(orderObject->channelName,
ui->detailLab0->setText(QString("[%1][%2][%3]").arg(!orderObject->channelName.compare("非码微店") ? "官网" : orderObject->channelName,
orderObject->status_desc,
orderObject->order_id));
ui->detailLab1->setText(QString("[%1]%2").arg(orderObject->pay_type,
......@@ -61,26 +61,34 @@ void DetailForm::InitData(OrderObject *orderObject)
ui->detailLab9->setPixmap(Code39().getCode39Map(orderObject->order_id)); // 条码
ui->detailLab10->setText(QString("-")+Penny2Dollar(orderObject->service_fee));
ui->detailLab11->setText(QString("-")+Penny2Dollar(orderObject->dis_shop_fee+orderObject->service_fee));
int pricecount=0;
for(int i=0; i<orderObject->proList.count(); i++)
{
ui->detailTable0->insertRow(i);
ui->detailTable0->setItem(i, 0, new QTableWidgetItem(orderObject->proList.at(i)->name)); // 商品名
ui->detailTable0->item(i, 0)->setTextAlignment(Qt::AlignCenter);
ui->detailTable0->setItem(i, 1, new QTableWidgetItem(Penny2Dollar(orderObject->proList.at(i)->price))); // 价格
ui->detailTable0->item(i, 1)->setTextAlignment(Qt::AlignCenter);
ui->detailTable0->setItem(i, 2, new QTableWidgetItem(QString::number(orderObject->proList.at(i)->productAmount))); // 数量
ui->detailTable0->item(i, 2)->setTextAlignment(Qt::AlignCenter);
pricecount=pricecount+orderObject->proList.at(i)->price*orderObject->proList.at(i)->productAmount;
int row = ui->detailTable0->rowCount();
ui->detailTable0->insertRow(row);
ui->detailTable0->setItem(row, 0, new QTableWidgetItem(orderObject->proList.at(i)->name)); // 商品名
ui->detailTable0->item(row, 0)->setTextAlignment(Qt::AlignCenter);
ui->detailTable0->setItem(row, 1, new QTableWidgetItem(Penny2Dollar(orderObject->proList.at(i)->price))); // 价格
ui->detailTable0->item(row, 1)->setTextAlignment(Qt::AlignCenter);
ui->detailTable0->setItem(row, 2, new QTableWidgetItem(QString::number(orderObject->proList.at(i)->productAmount))); // 数量
ui->detailTable0->item(row, 2)->setTextAlignment(Qt::AlignCenter);
if(!orderObject->proList.at(i)->sub_products.isEmpty())
{
foreach(ProductObject* pObj, orderObject->proList.at(i)->sub_products)
{
row = ui->detailTable0->rowCount();
ui->detailTable0->insertRow(row);
ui->detailTable0->setItem(row, 0, new QTableWidgetItem(pObj->name)); // 商品名
ui->detailTable0->item(row, 0)->setTextAlignment(Qt::AlignCenter);
ui->detailTable0->setItem(row, 1, new QTableWidgetItem(Penny2Dollar(pObj->price))); // 价格
ui->detailTable0->item(row, 1)->setTextAlignment(Qt::AlignCenter);
ui->detailTable0->setItem(row, 2, new QTableWidgetItem(QString::number(pObj->productAmount))); // 数量
ui->detailTable0->item(row, 2)->setTextAlignment(Qt::AlignCenter);
}
}
}
int count=orderObject->proList.count();
ui->detailTable0->insertRow(count);
ui->detailTable0->setItem(count,0,new QTableWidgetItem(QString("商品合计")));
ui->detailTable0->item(count, 0)->setTextAlignment(Qt::AlignCenter);
ui->detailTable0->setItem(count, 1, new QTableWidgetItem(Penny2Dollar(pricecount))); // 商品总价
ui->detailTable0->item(count, 1)->setTextAlignment(Qt::AlignCenter);
ui->detailTable0->setItem(count, 2, new QTableWidgetItem(QString::number(orderObject->total_amount))); // 总数量
ui->detailTable0->item(count, 2)->setTextAlignment(Qt::AlignCenter);
......
......@@ -10,6 +10,7 @@
#include "fmPrinter.h"
#include <QDebug>
#include <QThread>
#include <QDesktopWidget>
MainForm::MainForm(QWidget *parent) :
QWidget(parent),
......@@ -116,6 +117,13 @@ void MainForm::MyShow()
void MainForm::_Init()
{
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
// this->show();
// this->resize(ConfigManger::GetInstance().GetFormSize());
// QSize desktopSize = QApplication::desktop()->screenGeometry().size();
// this->move((desktopSize.width()-ConfigManger::GetInstance().GetFormSize().width())/2, (desktopSize.height()-ConfigManger::GetInstance().GetFormSize().height())/2);
this->showFullScreen();
// 显示托盘
m_tray.show();
......@@ -125,7 +133,7 @@ void MainForm::_Init()
// 初始化文字
ui->mainLabStoreid->setText(UI_STOREID);
ui->mainLabVersion->setText("1.1.8");
ui->mainLabVersion->setText("1.1.9");
ui->mainLabCashier->setText(UI_CASHIER);
// 初始化表
......@@ -383,7 +391,8 @@ void MainForm::onChangeOrderStatus(OrderObject *orderObject, int oldStatus)
table = findChild<QTableWidget*>(tabBtn->property("tableName").toString());
table->insertRow(0);
QTableWidgetItem *item0 = new QTableWidgetItem("#"+QString::number(orderObject->order_index)+orderObject->channelName);
QString tmpChannelName = !orderObject->channelName.compare("非码微店") ? "官网" : orderObject->channelName;
QTableWidgetItem *item0 = new QTableWidgetItem("#"+QString::number(orderObject->order_index)+tmpChannelName);
item0->setTextAlignment(Qt::AlignCenter);
table->setItem(0, 0, item0); // 渠道
QTableWidgetItem *item1 = new QTableWidgetItem(orderObject->order_view_id.isEmpty()?orderObject->order_id:orderObject->order_view_id);
......@@ -442,6 +451,9 @@ void MainForm::onChangeOrderStatus(OrderObject *orderObject, int oldStatus)
}else if(!ConfigManger::GetInstance().GetOutConfirm().compare("1") && ui->mainTableMake->rowCount() > 0)
{
emit startRemind(0);
}else if(orderObject->order_type ==2 && orderObject->status ==2)
{
emit startRemind(0);
}else if(ui->mainTableRefund->rowCount() > 0)
{
emit startRemind(1);
......
......@@ -24,13 +24,13 @@
<number>0</number>
</property>
<property name="leftMargin">
<number>15</number>
<number>5</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>15</number>
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
......@@ -43,11 +43,17 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11" stretch="0,0,0,0,0,0,0">
<property name="spacing">
<number>20</number>
<number>5</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="mainFrmHead">
<property name="minimumSize">
......
No preview for this file type
run/skin/float_normal.png

2.41 KB | W: | H:

run/skin/float_normal.png

8.17 KB | W: | H:

run/skin/float_normal.png
run/skin/float_normal.png
run/skin/float_normal.png
run/skin/float_normal.png
  • 2-up
  • Swipe
  • Onion skin
run/skin/float_remind.png

3.15 KB | W: | H:

run/skin/float_remind.png

9.32 KB | W: | H:

run/skin/float_remind.png
run/skin/float_remind.png
run/skin/float_remind.png
run/skin/float_remind.png
  • 2-up
  • Swipe
  • Onion skin
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