Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FmTakeaway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shangshang.dai
FmTakeaway
Commits
01b524b2
Commit
01b524b2
authored
Jun 02, 2017
by
ss.dai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 1:新增【配送费&&服务费】写入
parent
19e6d9c7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
39 deletions
+108
-39
fmPlugin/fmPlugin.cpp
+97
-39
fmPlugin/fmPlugin.h
+9
-0
fmPlugin/fmPlugin.pro
+2
-0
No files found.
fmPlugin/fmPlugin.cpp
View file @
01b524b2
...
...
@@ -13,6 +13,7 @@
#include <QJsonDocument>
#include <QDir>
#include <QJsonArray>
#include <QNetworkReply>
#include "DTools/configManger.h"
// HTTP
...
...
@@ -62,14 +63,14 @@ bool HTTP::post(const QNetworkRequest &request, const QByteArray &appendData, QB
target
=
data
;
eventLoop
.
exit
(
true
);
},
[
&
eventLoop
](
const
QNetworkReply
::
NetworkError
&
error
)
[
&
eventLoop
,
this
](
const
QNetworkReply
::
NetworkError
&
error
)
{
error_
=
error
.
errorString
(
);
this
->
error_
=
QString
::
number
(
error
);
eventLoop
.
exit
(
false
);
},
[
&
failFlag
,
&
eventLoop
]()
[
&
failFlag
,
&
eventLoop
,
this
]()
{
error
=
"timeout"
;
this
->
error_
=
"timeout"
;
failFlag
=
true
;
eventLoop
.
exit
(
false
);
}
...
...
@@ -229,9 +230,9 @@ bool FmPlugin::DoOrderEntry(const OrderObject *orderObject, const QString &cashi
QString
inipath
=
apppath
+
QString
(
"/config.ini"
);
QSettings
set
(
inipath
,
QSettings
::
IniFormat
);
QUrl
url
;
QUrl
url
,
url_fee
;
url
=
set
.
value
(
"HdServer/url"
).
toUrl
();
url_fee
=
set
.
value
(
"HdServer/url1"
).
toUrl
();
HTTP
http
;
QByteArray
recvArray
;
...
...
@@ -244,37 +245,45 @@ bool FmPlugin::DoOrderEntry(const OrderObject *orderObject, const QString &cashi
if
(
http
.
post
(
qRequset
,
_GetOrderEntryData
(
orderObject
),
recvArray
,
15000
))
{
QJsonObject
recvJson
;
recvJson
=
QJsonDocument
::
fromJson
(
recvArray
).
object
();
}
else
{
}
qDebug
()
<<
"写销售单获取到的返回数据"
<<
recvJson
;
QString
uuid
=
recvJson
[
"uuid"
].
toString
();
if
(
uuid
.
isEmpty
())
{
error
.
append
(
recvJson
[
"echoMessage"
].
toString
());
return
false
;
}
recvArray
.
clear
();
QNetworkRequest
qRequset1
;
qRequset1
.
setUrl
(
url_fee
);
qRequset1
.
setRawHeader
(
"Content-Type"
,
"application/json;charset=utf-8"
);
qRequset1
.
setRawHeader
(
"Accept"
,
"application/json;charset=utf-8"
);
error
.
append
(
"配送费:"
+
_GetFeeData
(
orderObject
,
uuid
));
if
(
http
.
post
(
qRequset1
,
_GetFeeData
(
orderObject
,
uuid
),
recvArray
,
15000
))
{
QJsonObject
recvJson
;
recvJson
=
QJsonDocument
::
fromJson
(
recvArray
).
object
();
qDebug
()
<<
"记配送费获取到的返回数据"
<<
recvJson
;
if
(
recvJson
[
"echoCode"
].
toString
()
!=
"0"
)
{
error
=
recvJson
[
"echoMessage"
].
toString
();
return
false
;
}
}
if
(
reply
->
error
()
!=
QNetworkReply
::
NoError
)
{
error
=
reply
->
errorString
();
return
false
;
}
QByteArray
recvArray
=
reply
->
readAll
();
error
=
QString
(
recvArray
);
if
(
recvArray
.
size
()
==
0
)
{
error
=
"nothing recved"
;
return
false
;
}
QJsonObject
recvJson
;
recvJson
=
QJsonDocument
::
fromJson
(
recvArray
).
object
();
qDebug
()
<<
recvJson
;
if
(
recvJson
[
"echoCode"
].
toString
()
!=
"0"
)
{
error
=
recvJson
[
"echoMessage"
].
toString
();
return
false
;
QDir
().
mkpath
(
remark_file_path
.
mid
(
0
,
remark_file_path
.
lastIndexOf
(
"/"
)));
file
.
open
(
QFile
::
WriteOnly
);
file
.
close
();
return
true
;
}
QDir
().
mkpath
(
remark_file_path
.
mid
(
0
,
remark_file_path
.
lastIndexOf
(
"/"
)));
file
.
open
(
QFile
::
WriteOnly
);
file
.
close
();
return
true
;
error
=
http
.
error
();
return
false
;
}
bool
FmPlugin
::
GetStockInfo
(
QList
<
StockObject
>
&
stockList
,
QString
&
error
)
...
...
@@ -504,9 +513,6 @@ QByteArray FmPlugin::_GetOrderEntryData(const OrderObject *orderObject)
// 该商品实际收到的钱
float
ss_fee
=
ys_fee
*
(
1
-
(
float
)
orderObject
->
dis_shop_fee
/
orderObject
->
product_fee
);
qDebug
()
<<
"ys_fee"
<<
ys_fee
<<
"ss_fee"
<<
ss_fee
;
QJsonObject
cObj
;
cObj
.
insert
(
"skuId"
,
cpObj
->
pid
);
cObj
.
insert
(
"qty"
,
cpObj
->
productAmount
*
ratio
);
...
...
@@ -535,8 +541,6 @@ QByteArray FmPlugin::_GetOrderEntryData(const OrderObject *orderObject)
// 该商品实际收到的钱
float
ss_fee
=
ys_fee
*
(
1
-
(
float
)
orderObject
->
dis_shop_fee
/
orderObject
->
product_fee
);
qDebug
()
<<
"ys_fee"
<<
ys_fee
<<
"ss_fee"
<<
ss_fee
;
cObj
.
insert
(
"skuId"
,
pObj
->
pid
);
cObj
.
insert
(
"qty"
,
pObj
->
productAmount
*
ratio
);
cObj
.
insert
(
"price"
,
ss_fee
/
(
pObj
->
productAmount
*
ratio
));
...
...
@@ -567,6 +571,60 @@ QByteArray FmPlugin::_GetOrderEntryData(const OrderObject *orderObject)
rObj
.
insert
(
"products"
,
products
);
rObj
.
insert
(
"pays"
,
pays
);
qDebug
()
<<
"销售单数据: "
<<
rObj
;
return
QJsonDocument
(
rObj
).
toJson
(
QJsonDocument
::
Compact
);
}
QByteArray
FmPlugin
::
_GetFeeData
(
const
OrderObject
*
orderObject
,
QString
uuid
)
{
double
serviceFee
;
if
(
orderObject
->
channel
==
"jdwm"
)
{
serviceFee
=
_Penny2Dollar
((
orderObject
->
product_fee
-
orderObject
->
dis_shop_fee
)
*
0.08
);
}
else
{
serviceFee
=
_Penny2Dollar
(
orderObject
->
service_fee
);
}
double
sendFee
;
sendFee
=
_Penny2Dollar
(
orderObject
->
send_fee
);
QJsonObject
rObj
;
rObj
.
insert
(
"num"
,
orderObject
->
order_view_id
);
rObj
.
insert
(
"cls"
,
"外卖费用"
);
rObj
.
insert
(
"busType"
,
"美团外卖"
);
rObj
.
insert
(
"platform"
,
"美团外卖"
);
rObj
.
insert
(
"filDate"
,
QDateTime
::
fromTime_t
(
orderObject
->
create_time
).
toString
(
"yyyy-MM-ddThh:mm:ss.zzz+0800"
));
rObj
.
insert
(
"filler"
,
"非码外卖"
);
rObj
.
insert
(
"note"
,
""
);
rObj
.
insert
(
"total"
,
serviceFee
+
sendFee
);
rObj
.
insert
(
"customFieldS1"
,
m_storeId
);
rObj
.
insert
(
"customFieldS2"
,
uuid
);
rObj
.
insert
(
"customFieldN1"
,
0
);
rObj
.
insert
(
"customFieldN2"
,
0
);
QJsonArray
array
;
QJsonObject
cObj0
,
cObj1
;
cObj0
.
insert
(
"line"
,
1
);
cObj0
.
insert
(
"itemName"
,
"服务费"
);
cObj0
.
insert
(
"total"
,
serviceFee
);
cObj0
.
insert
(
"customFieldS1"
,
""
);
cObj0
.
insert
(
"customFieldS2"
,
""
);
cObj0
.
insert
(
"customFieldN1"
,
0
);
cObj0
.
insert
(
"customFieldN2"
,
0
);
cObj0
.
insert
(
"note"
,
""
);
array
.
insert
(
0
,
cObj0
);
cObj1
.
insert
(
"line"
,
2
);
cObj1
.
insert
(
"itemName"
,
"配送费"
);
cObj1
.
insert
(
"total"
,
sendFee
);
cObj1
.
insert
(
"customFieldS1"
,
""
);
cObj1
.
insert
(
"customFieldS2"
,
""
);
cObj1
.
insert
(
"customFieldN1"
,
0
);
cObj1
.
insert
(
"customFieldN2"
,
0
);
cObj1
.
insert
(
"note"
,
""
);
array
.
insert
(
1
,
cObj1
);
rObj
.
insert
(
"details"
,
array
);
return
QJsonDocument
(
rObj
).
toJson
(
QJsonDocument
::
Compact
);
}
fmPlugin/fmPlugin.h
View file @
01b524b2
...
...
@@ -8,6 +8,10 @@
#include <QtSql/QSqlDatabase>
#include <QDateTime>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <functional>
#include <QObject>
class
HTTP
{
...
...
@@ -119,6 +123,11 @@ private:
* 返回:销售单数据
* */
QByteArray
_GetOrderEntryData
(
const
OrderObject
*
);
/* 功能:获取写配送费的数据
* 参数:[1]订单对象
* 返回:销售单数据
* */
QByteArray
_GetFeeData
(
const
OrderObject
*
,
QString
uuid
);
};
#endif // FMPLUGIN_H
fmPlugin/fmPlugin.pro
View file @
01b524b2
...
...
@@ -8,6 +8,8 @@ QT -= gui
QT
+=
sql
network
CONFIG
*=
c
++
11
TARGET
=
fmPlugin
TEMPLATE
=
lib
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment