Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bft_takeout
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
guanghui.cui
bft_takeout
Commits
4bb20744
Commit
4bb20744
authored
Oct 30, 2017
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接单后直接打印
parent
5b64e84b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
41 deletions
+47
-41
fmTakeaway/Util/wbillcontrol.cpp
+47
-41
No files found.
fmTakeaway/Util/wbillcontrol.cpp
View file @
4bb20744
...
...
@@ -40,39 +40,39 @@ WBillControl::WBillControl()
g_thread
.
start
();
GetPosMenu
();
//test print
OrderObject
obj
;
obj
.
channelName
=
"美团外卖"
;
obj
.
order_id
=
"3014384743591261407"
;
obj
.
address
=
"上海金巢铂瑞阁公寓合宝路18号金巢大厦金巢铂瑞阁公寓1116室"
;
obj
.
customer
=
"钱多多"
;
obj
.
phone
=
"15600833522"
;
obj
.
order_index
=
1
;
obj
.
package_fee
=
600
;
obj
.
send_fee
=
500
;
obj
.
discount_fee
=
1300
;
obj
.
user_fee
=
14701
;
obj
.
channel
=
"mtwm"
;
obj
.
pay_type
=
"在线支付"
;
obj
.
product_fee
=
10000
;
obj
.
service_fee
=
1000
;
obj
.
dis_shop_fee
=
1300
;
obj
.
create_time
=
1508640524
;
obj
.
remark
=
"4套餐具"
;
ComdObject
comd1
;
comd1
.
pid
=
"001101"
;
comd1
.
productAmount
=
4
;
comd1
.
price
=
123
;
obj
.
proList
.
push_back
(
&
comd1
);
ComdObject
comd2
;
comd2
.
pid
=
"006114"
;
comd2
.
productAmount
=
1
;
comd2
.
price
=
45678
;
obj
.
proList
.
push_back
(
&
comd2
);
ComdObject
comd3
;
comd3
.
pid
=
"009091"
;
comd3
.
productAmount
=
1
;
comd3
.
price
=
789
;
obj
.
proList
.
push_back
(
&
comd3
);
//
OrderObject obj;
//
obj.channelName="美团外卖";
//
obj.order_id="3014384743591261407";
//
obj.address="上海金巢铂瑞阁公寓合宝路18号金巢大厦金巢铂瑞阁公寓1116室";
//
obj.customer="钱多多";
//
obj.phone="15600833522";
//
obj.order_index=1;
//
obj.package_fee=600;
//
obj.send_fee=500;
//
obj.discount_fee=1300;
//
obj.user_fee=14701;
//
obj.channel="mtwm";
//
obj.pay_type="在线支付";
//
obj.product_fee=10000;
//
obj.service_fee=1000;
//
obj.dis_shop_fee=1300;
//
obj.create_time=1508640524;
//
obj.remark="4套餐具";
//
ComdObject comd1;
//
comd1.pid="001101";
//
comd1.productAmount=4;
//
comd1.price=123;
//
obj.proList.push_back(&comd1);
//
ComdObject comd2;
//
comd2.pid="006114";
//
comd2.productAmount=1;
//
comd2.price=45678;
//
obj.proList.push_back(&comd2);
//
ComdObject comd3;
//
comd3.pid="009091";
//
comd3.productAmount=1;
//
comd3.price=789;
//
obj.proList.push_back(&comd3);
//PrintLable(&obj);
//printMenu(&obj);
...
...
@@ -105,8 +105,7 @@ void WBillControl::SetStoreInfo(const QString &partner_id, const QString &storeI
void
WBillControl
::
DoOrderEntry
(
const
OrderObject
*
orderObject
)
{
//打印小票
//PrintLable(orderObject);
int
iPosOrderStatus
=
0
;
QTcpSocket
*
socket
=
new
QTcpSocket
(
this
);
// 连接
QByteArray
byteSlip
=
GetOrderEntryData
(
orderObject
,
false
);
...
...
@@ -122,7 +121,8 @@ void WBillControl::DoOrderEntry(const OrderObject *orderObject)
QJsonObject
recvJson
=
QJsonDocument
::
fromJson
(
socket
->
readAll
()).
object
();
QLOG_INFO
()
<<
"write order back:"
<<
recvJson
;
bool
res
=
1
;
if
(
recvJson
[
"statusCode"
].
toInt
()
!=
100
)
iPosOrderStatus
=
recvJson
[
"statusCode"
].
toInt
();
if
(
101
==
iPosOrderStatus
)
{
res
=
0
;
QLOG_INFO
()
<<
"write order failed:"
<<
recvJson
[
"msg"
].
toString
();
...
...
@@ -138,6 +138,12 @@ void WBillControl::DoOrderEntry(const OrderObject *orderObject)
}
}
socket
->
close
();
//102 订单已存在
if
(
102
!=
iPosOrderStatus
){
QLOG_INFO
()
<<
"开始打印小票"
;
//打印小票
PrintLable
(
orderObject
);
}
}
void
WBillControl
::
RefundOrder
(
const
QString
&
fmId
)
...
...
@@ -158,7 +164,7 @@ void WBillControl::RefundOrder(const QString &fmId)
QJsonObject
recvJson
=
QJsonDocument
::
fromJson
(
socket
->
readAll
()).
object
();
QLOG_INFO
()
<<
"refund order back:"
<<
recvJson
;
bool
res
=
1
;
if
(
recvJson
[
"statusCode"
].
toInt
()
!=
100
)
if
(
recvJson
[
"statusCode"
].
toInt
()
==
101
)
{
res
=
0
;
QLOG_INFO
()
<<
"write order failed:"
<<
recvJson
[
"msg"
].
toString
();
...
...
@@ -588,7 +594,7 @@ void WBillControl::printTakeout(const OrderObject *obj)
//set_port(fd,19200);
fd
=
open_port
(
IniDataManger
::
Instance
().
GetPOSLocalPrinterPort
().
toStdString
().
data
());
if
(
-
1
==
fd
){
QLOG_ERROR
()
<<
"printTakeout failed"
;
QLOG_ERROR
()
<<
"printTakeout
open_port
failed"
;
return
;
}
if
(
!
set_port
(
IniDataManger
::
Instance
().
GetPOSLocalPrinterBaud
())){
...
...
@@ -615,7 +621,7 @@ void WBillControl::printTakeout(const OrderObject *obj)
print
(
""
,
1
);
print
(
"-----------------------------------------------"
,
1
);
QString
strOrderTime
=
QDateTime
::
fromTime_t
(
1508640524
).
toString
(
"下单时间:MM-dd hh:mm"
);
QString
strOrderTime
=
QDateTime
::
fromTime_t
(
obj
->
create_time
).
toString
(
"下单时间:MM-dd hh:mm"
);
std
::
string
stdOrderTime
=
strOrderTime
.
toStdString
();
print
(
charset_u2g
(
stdOrderTime
).
data
(),
3
);
print
(
"-----------------------------------------------"
,
1
);
...
...
@@ -706,7 +712,7 @@ void WBillControl::printMenu(const OrderObject *obj)
if
(
0
==
i
){
fd
=
open_port
(
IniDataManger
::
Instance
().
GetPOSLocalPrinterPort
().
toStdString
().
data
());
if
(
-
1
==
fd
){
QLOG_ERROR
()
<<
"printMenu failed"
;
QLOG_ERROR
()
<<
"printMenu
open_port
failed"
;
return
;
}
if
(
!
set_port
(
IniDataManger
::
Instance
().
GetPOSLocalPrinterBaud
())){
...
...
@@ -795,7 +801,7 @@ void WBillControl::printBill(const OrderObject *obj)
if
(
0
==
i
){
fd
=
open_port
(
IniDataManger
::
Instance
().
GetPOSLocalPrinterPort
().
toStdString
().
data
());
if
(
-
1
==
fd
){
QLOG_ERROR
()
<<
"printBill failed"
;
QLOG_ERROR
()
<<
"printBill
open_port
failed"
;
return
;
}
if
(
!
set_port
(
IniDataManger
::
Instance
().
GetPOSLocalPrinterBaud
())){
...
...
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