Commit 61b27a22 by ss.dai

鲜丰自动入账完成

parent 55171f32
......@@ -145,7 +145,6 @@ bool FmPlugin::GetOnDutyCashiers(QList<CashierObject> &cashiersList, QString &er
bool FmPlugin::DoOrderEntry(const OrderObject *orderObject, const QString &cashierId, const QString &cashierName, const QString &shiftId, const QString &shiftName, QString &error)
{
return true;
QString apppath=QCoreApplication::applicationDirPath();
// 检查这单之前是否写过
QString remark_file_path = QString("%1/orders/%2/%3_%4").arg(apppath, QDateTime::fromTime_t(orderObject->create_time).toString("yyyy-MM-dd"), orderObject->channel ,orderObject->order_id);
......@@ -287,7 +286,7 @@ bool FmPlugin::_InsertInto_d_t_food_fmbill0(const QString& cashierId, const QStr
query.bindValue(13, QString("\351\200\201\351\244\220\345\215\225"));// 送餐单
query.bindValue(14, m_orderObject->order_id);
query.bindValue(15, m_orderObject->channelName);
query.bindValue(16, m_orderObject->pay_type.compare("在线支付") ? "0" : _Penny2Dollar(m_orderObject->send_fee));
//query.bindValue(16, m_orderObject->pay_type.compare("在线支付") ? "0" : _Penny2Dollar(m_orderObject->send_fee));
query.bindValue(17, custid);
if(!query.exec())
{
......@@ -380,19 +379,21 @@ bool FmPlugin::_Exec_pr_fmwm()
return true;
}
QString FmPlugin::_Penny2Dollar(int penny)
double FmPlugin::_Penny2Dollar(int penny)
{
double dollar = (double)penny/100;
return QString::number(dollar,'f',2);
return dollar;
}
QByteArray FmPlugin::_GetOrderEntryData(const OrderObject *orderObject)
{
QJsonObject rObj;
rObj.insert("uuid", orderObject->order_id);
rObj.insert("senderCode", m_storeId);
rObj.insert("sendWrh", "-");
rObj.insert("receiverCode", "95560000001");
// rObj.insert("senderCode", "31310033");
rObj.insert("senderWrh", "-");
rObj.insert("receiverCode", m_recCodeMap.value(orderObject->channel));
rObj.insert("contactor", orderObject->customer);
rObj.insert("phoneNumber", orderObject->phone);
rObj.insert("deliverAddress", orderObject->address);
......@@ -400,17 +401,65 @@ QByteArray FmPlugin::_GetOrderEntryData(const OrderObject *orderObject)
rObj.insert("ocrDate", QDateTime::fromTime_t(orderObject->create_time).toString("yyyy-MM-ddThh:mm:ss.zzz+0800"));
rObj.insert("filler", "*");
rObj.insert("seller", "*");
rObj.insert("souceOrderCls", "");
rObj.insert("negInvFlag", 0);
QJsonArray products;
for(int i=0; i < orderObject->proList.count(); i++)
{
QJsonObject cObj;
cObj.insert("skuId", "01001");
cObj.insert("qty", orderObject->proList.at(i)->productAmount);
cObj.insert("price", orderObject->proList.at(i)->price);
products.insert(i, cObj);
ProductObject *pObj = orderObject->proList.at(i);
if(!pObj->sub_products.isEmpty())
{
foreach(ProductObject *cpObj, pObj->sub_products)
{
float ratio = (float)cpObj->unit_ratio/100;
QJsonObject cObj;
cObj.insert("skuId", cpObj->pid);
cObj.insert("qty", cpObj->productAmount*ratio);
cObj.insert("price", _Penny2Dollar(cpObj->price));
cObj.insert("total", "");
cObj.insert("freight", "");
cObj.insert("payAmount", "");
cObj.insert("unitPrice", "");
cObj.insert("priceAmount", "");
cObj.insert("buyAmount", "");
cObj.insert("businessDiscount", "");
cObj.insert("platformDiscount", "");
cObj.insert("businessDiscountInfo", "");
cObj.insert("platformDiscountInfo", "");
cObj.insert("note", QString::number(_Penny2Dollar(pObj->productAmount*ratio*pObj->cost),'f',2));
products.insert(i, cObj);
}
}else
{
float ratio = (float)pObj->unit_ratio/100;
QJsonObject cObj;
cObj.insert("skuId", pObj->pid);
cObj.insert("qty", pObj->productAmount*ratio);
cObj.insert("price", _Penny2Dollar(pObj->price));
cObj.insert("total", "");
cObj.insert("freight", "");
cObj.insert("payAmount", "");
cObj.insert("unitPrice", "");
cObj.insert("priceAmount", "");
cObj.insert("buyAmount", "");
cObj.insert("businessDiscount", "");
cObj.insert("platformDiscount", "");
cObj.insert("businessDiscountInfo", "");
cObj.insert("platformDiscountInfo", "");
cObj.insert("note", QString::number(_Penny2Dollar(pObj->productAmount*ratio*pObj->cost),'f',2));
products.insert(i, cObj);
}
}
QJsonArray pays;
QJsonObject payObj;
payObj.insert("total", _Penny2Dollar(orderObject->total_fee-orderObject->send_fee-orderObject->service_fee-orderObject->dis_shop_fee));
payObj.insert("payName", "非码外卖");
pays.insert(0, payObj);
rObj.insert("products", products);
rObj.insert("pays", pays);
qDebug() << rObj;
return QJsonDocument(rObj).toJson(QJsonDocument::Compact);
}
......@@ -45,7 +45,13 @@ public:
bool GetStockInfo(QList<StockObject>& stockList, QString& error);
private:
FmPlugin(){}
FmPlugin()
{
m_recCodeMap.insert("mtwm", "9556000001");
m_recCodeMap.insert("eleme", "9556000002");
m_recCodeMap.insert("bdwm", "9556000003");
m_recCodeMap.insert("jdwm", "9556000004");
}
FmPlugin(FmPlugin const&);
FmPlugin& operator=(FmPlugin const&);
......@@ -58,6 +64,9 @@ private:
// 错误信息
QString m_lastError;
// 各平台对应的receiverCode
QMap<QString, QString> m_recCodeMap;
/* 功能:写入表p_t_fmwm_custinfo(顾客信息表)
* 参数:[1]_out信息ID
* 返回:true成功false失败
......@@ -88,7 +97,7 @@ private:
* 参数:[1]分
* 返回:元
* */
QString _Penny2Dollar(int penny);
double _Penny2Dollar(int penny);
/* 功能:获取写销售单的数据
* 参数:[1]订单对象
* 返回:销售单数据
......
......@@ -26,3 +26,5 @@ unix {
target.path = /usr/lib
INSTALLS += target
}
DESTDIR += ../XianFeng
......@@ -26,3 +26,5 @@ unix {
}
LIBS += -lWinspool
DESTDIR += ../XianFeng
......@@ -205,17 +205,17 @@ bool FlowControl::_PullOrder()
emit changeOrderStatus(orderObject, oldStatus);
}
}
// if(orderObject->status != 1 && orderObject->status != 2)
// {
// QString error;
// if(FmPlugin::GetInstance().DoOrderEntry(orderObject,"","","","",error))
// {
// QLOG_INFO() << QString("_PullOrder DoOrderEntry successful") << error;
// }else
// {
// QLOG_INFO() << QString("_PullOrder DoOrderEntry failed %1").arg(error);
// }
// }
if(orderObject->status != 1 && orderObject->status != 2 && orderObject->delivery_status==3)
{
QString error;
if(FmPlugin::GetInstance().DoOrderEntry(orderObject,"","","","",error))
{
QLOG_INFO() << QString("_PullOrder DoOrderEntry successful") << error;
}else
{
QLOG_INFO() << QString("_PullOrder DoOrderEntry failed %1").arg(error);
}
}
m_timestamp = orderObject->timestamp;
}
syncTime = recvJson[JSON_SYNCTIME].toInt()*1000;
......
......@@ -12,7 +12,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);
}
......
#include "productObject.h"
#include <QJsonArray>
void ProductObject::FromJson(const QJsonObject &json)
{
qDeleteAll(sub_products);
sub_products.clear();
FetchDataFromJson(json);
QJsonArray products = json["sub_products"].toArray();
foreach(QJsonValue product, products)
{
QJsonObject proJson = product.toObject();
ProductObject *proObject = new ProductObject(this);
proObject->FetchDataFromJson(proJson);
sub_products.append(proObject);
}
return;
}
int ProductObject::getcost() const
{
return cost;
}
void ProductObject::setcost(const int &v)
{
cost = v;
}
int ProductObject::getunit_ratio() const
{
return unit_ratio;
}
void ProductObject::setunit_ratio(const int &v)
{
unit_ratio = v;
}
QString ProductObject::getPid() const
{
......
......@@ -10,11 +10,19 @@ public:
ProductObject(QObject *parent=0)
:BaseObject(parent){}
/* 功能:从Json对象初获取数据
* 参数:[1]JSon对象
* 返回:NULL
* */
void FromJson(const QJsonObject& json);
Q_PROPERTY (QString pid READ getPid WRITE setPid)
Q_PROPERTY (QString name READ getName WRITE setName)
Q_PROPERTY (QString upc READ getupc WRITE setupc)
Q_PROPERTY (int price READ getprice WRITE setprice)
Q_PROPERTY (int productAmount READ getProductAmount WRITE setProductAmount)
Q_PROPERTY (int cost READ getcost WRITE setcost)
Q_PROPERTY (int unit_ratio READ getunit_ratio WRITE setunit_ratio)
QString pid;
QString name;
......@@ -22,7 +30,18 @@ public:
int price;
int productAmount;
int cost; // 成本价
int unit_ratio; // 商品系数
QList<ProductObject *> sub_products; // 子商品
protected:
int getcost() const;
void setcost(const int& v);
int getunit_ratio() const;
void setunit_ratio(const int& v);
QString getPid() const ;
void setPid(const QString& v);
......
......@@ -81,10 +81,13 @@ FORMS += mainForm.ui \
RC_FILE += fmTakeaway.rc
DESTDIR += ../XianFeng
CONFIG(release, debug|release) {
LIBS += -L../fmPlugin/release -lfmPlugin
LIBS += -L../fmPrinter/release -lfmPrinter
LIBS += -L$$DESTDIR -lfmPlugin
LIBS += -L$$DESTDIR -lfmPrinter
} else {
LIBS += -L../fmPlugin/debug -lfmPlugin
LIBS += -L../fmPrinter/debug -lfmPrinter
LIBS += -L$$DESTDIR -lfmPlugin
LIBS += -L$$DESTDIR -lfmPrinter
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.1.0, 2017-03-08T17:25:57. -->
<!-- Written by QtCreator 4.0.0, 2017-03-09T19:38:29. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{4b727d6b-8adb-4560-aded-4083fff25375}</value>
<value type="QByteArray">{042357ee-9101-48ac-bf1d-2c241fdf6544}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
......@@ -59,68 +59,14 @@
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{71d2a3a8-fb84-4f0f-89e6-23308737ddf5}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{6c6796ef-4feb-46bd-be7b-581170645c49}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/daima/xfsg/build-takeaway-unknown-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/daima/xfsg/build-takeaway-unknown-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Alan/Work/Build/takeaway-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
......@@ -173,7 +119,7 @@
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
......@@ -191,7 +137,7 @@
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">0</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
......@@ -232,14 +178,13 @@
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fmTakeaway</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/daima/xfsg/takeaway/fmTakeaway/fmTakeaway.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Alan/Work/takeaway/fmTakeaway/fmTakeaway.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fmTakeaway/fmTakeaway.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">D:/daima/xfsg/build-takeaway-unknown-Release/fmTakeaway</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">C:/Users/Alan/Work/Build/takeaway-Release/XianFeng</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
......
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