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
61dc935d
Commit
61dc935d
authored
Oct 25, 2017
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
外卖小票打印
parent
92146f81
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
186 additions
and
12 deletions
+186
-12
build-Debug/fmTakeout/Config.ini
+3
-2
fmTakeaway/Util/IniDataManger.cpp
+7
-0
fmTakeaway/Util/IniDataManger.h
+1
-0
fmTakeaway/Util/wbillcontrol.cpp
+167
-7
fmTakeaway/Util/wbillcontrol.h
+4
-1
fmTakeaway/pos_print.h
+4
-2
No files found.
build-Debug/fmTakeout/Config.ini
View file @
61dc935d
...
...
@@ -52,4 +52,5 @@ storeId=pos_bft_SH002
operatorId
=
001
[POSServer]
serverIp
=
192.168.0.102
\ No newline at end of file
serverIp
=
192.168.0.102
storeName
=
避风塘(金玉兰店)
\ No newline at end of file
fmTakeaway/Util/IniDataManger.cpp
View file @
61dc935d
...
...
@@ -11,6 +11,7 @@
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonParseError>
#include <QTextCodec>
#include <QDebug>
IniDataManger
&
IniDataManger
::
Instance
()
...
...
@@ -252,6 +253,7 @@ IniDataManger::IniDataManger()
QLOG_WARN
()
<<
QString
(
"can't find ini file![%1]"
).
arg
(
iniPath
);
}
m_set
=
new
QSettings
(
iniPath
,
QSettings
::
IniFormat
);
m_set
->
setIniCodec
(
QTextCodec
::
codecForName
(
"UTF-8"
));
iniPath
=
QString
(
"%1/%2"
).
arg
(
QApplication
::
applicationDirPath
()).
arg
(
USERINI_FILE_NAME
);
if
(
!
QFile
(
iniPath
).
exists
())
...
...
@@ -298,3 +300,8 @@ QString IniDataManger::GetPOSServerIP()
{
return
m_set
->
value
(
"POSServer/serverIp"
,
""
).
toString
();
}
QString
IniDataManger
::
GetPOSStoreName
()
{
return
m_set
->
value
(
"POSServer/storeName"
,
""
).
toString
();
}
fmTakeaway/Util/IniDataManger.h
View file @
61dc935d
...
...
@@ -71,6 +71,7 @@ public:
QJsonObject
GetStoreJson
();
QString
GetTillFile
();
QString
GetPOSServerIP
();
QString
GetPOSStoreName
();
bool
GetShowCancel
();
QString
GetStoreIdPrefix
();
...
...
fmTakeaway/Util/wbillcontrol.cpp
View file @
61dc935d
...
...
@@ -39,24 +39,39 @@ WBillControl::WBillControl()
g_thread
.
start
();
GetPosMenu
();
//test print
//QString strTitle=IniDataManger::Instance().GetPOSStoreName();
OrderObject
obj
;
obj
.
channelName
=
"美团外卖"
;
obj
.
order_id
=
"3014384743591261407"
;
obj
.
order_index
=
56
;
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
.
create_time
=
1508640524
;
ComdObject
comd1
;
comd1
.
pid
=
"061301"
;
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
);
//printMenu(&obj);
printTakeout
(
&
obj
);
// printCook(&obj,"061301",4);
// printCook(&obj,"006114",2);
// printCook(&obj,"002561",4);
...
...
@@ -373,7 +388,7 @@ void WBillControl::printCook(const OrderObject *obj,const QString& menuId,int nu
strDesk
+=
obj
->
channelName
;
strDesk
+=
QString
::
number
(
obj
->
order_index
);
std
::
string
stdDesk
=
strDesk
.
toStdString
();
print
(
charset_u2g
(
stdDesk
).
data
(),
6
);
print
(
charset_u2g
(
stdDesk
).
data
(),
8
);
QString
order
=
"单据:"
;
order
+=
obj
->
order_id
;
...
...
@@ -403,15 +418,112 @@ void WBillControl::printCook(const OrderObject *obj,const QString& menuId,int nu
}
//外卖单打印
void
WBillControl
::
printTakeout
()
void
WBillControl
::
printTakeout
(
const
OrderObject
*
obj
)
{
#ifdef Q_OS_LINUX
int
fd
=-
1
;
for
(
int
i
=
0
;
i
<
obj
->
proList
.
size
();
i
++
)
{
QString
pid
=
obj
->
proList
.
at
(
i
)
->
pid
;
int
num
=
obj
->
proList
.
at
(
i
)
->
productAmount
;
int
price
=
obj
->
proList
.
at
(
i
)
->
price
;
for
(
PrinterMenu
menu
:
vecMenu
){
if
(
menu
.
strMenuId
==
pid
){
//订单头 打印
if
(
0
==
i
){
fd
=
open_port
(
"/dev/ttyS1"
);
set_port
(
fd
,
19200
);
QString
str
=
getPrintTitle
(
obj
->
channel
,
obj
->
order_index
);
std
::
string
title
=
str
.
toStdString
();
print
(
charset_u2g
(
title
).
data
(),
3
);
//QString strTitle=" 避风塘(金玉兰店)";
QString
strTitle
=
" "
;
strTitle
+=
IniDataManger
::
Instance
().
GetPOSStoreName
();
std
::
string
stdTitle
=
strTitle
.
toStdString
();
print
(
charset_u2g
(
stdTitle
).
data
(),
3
);
print
(
""
,
1
);
QString
strPayType
=
" —"
;
strPayType
+=
obj
->
pay_type
;
strPayType
+=
"—"
;
std
::
string
stdPaytype
=
strPayType
.
toStdString
();
print
(
charset_u2g
(
stdPaytype
).
data
(),
3
);
print
(
""
,
1
);
print
(
"-----------------------------------------------"
,
1
);
QString
strOrderTime
=
QDateTime
::
fromTime_t
(
1508640524
).
toString
(
"下单时间:MM-dd hh:mm"
);
std
::
string
stdOrderTime
=
strOrderTime
.
toStdString
();
print
(
charset_u2g
(
stdOrderTime
).
data
(),
3
);
print
(
"-----------------------------------------------"
,
1
);
}
QByteArray
menuName
=
QString
(
"%1"
).
arg
(
menu
.
strMenuName
,
-
36
).
toLatin1
();
menuName
.
append
(
"x"
);
menuName
.
append
(
QString
::
number
(
num
).
toLatin1
());
menuName
.
append
(
" "
);
menuName
.
append
(
QString
(
"%1"
).
arg
(
QString
::
number
(
price
/
100.00
,
'f'
,
2
),
6
).
toLatin1
());
print
(
menuName
.
data
(),
5
);
break
;
}
}
}
if
(
-
1
!=
fd
){
print
(
"-----------------------------------------------"
,
1
);
QString
strPakage
=
"餐盒 x1 "
;
strPakage
+=
QString
(
"%1"
).
arg
(
QString
::
number
(
obj
->
package_fee
/
100.00
,
'f'
,
2
),
6
);
std
::
string
stdPakage
=
strPakage
.
toStdString
();
print
(
charset_u2g
(
stdPakage
).
data
(),
3
);
print
(
"-----------------------------------------------"
,
1
);
QString
strDiscount
=
"优惠 "
;
strDiscount
+=
QString
(
"%1"
).
arg
(
QString
::
number
(
obj
->
discount_fee
/
100.00
,
'f'
,
2
),
6
);
std
::
string
stdDiscount
=
strDiscount
.
toStdString
();
print
(
charset_u2g
(
stdDiscount
).
data
(),
3
);
QString
strSend
=
"配送费 "
;
strSend
+=
QString
(
"%1"
).
arg
(
QString
::
number
(
obj
->
send_fee
/
100.00
,
'f'
,
2
),
6
);
std
::
string
stdSend
=
strSend
.
toStdString
();
print
(
charset_u2g
(
stdSend
).
data
(),
3
);
print
(
"-----------------------------------------------"
,
1
);
QString
strUser
=
"已付 "
;
strUser
+=
QString
(
"%1"
).
arg
(
QString
::
number
(
obj
->
user_fee
/
100.00
,
'f'
,
2
),
6
);
std
::
string
stdUser
=
strUser
.
toStdString
();
print
(
charset_u2g
(
stdUser
).
data
(),
3
);
print
(
"-----------------------------------------------"
,
1
);
std
::
string
stdAddress
=
obj
->
address
.
toStdString
();
print
(
charset_u2g
(
stdAddress
).
data
(),
3
);
std
::
string
stdName
=
obj
->
customer
.
toStdString
();
print
(
charset_u2g
(
stdName
).
data
(),
3
);
std
::
string
stdPhone
=
obj
->
phone
.
toStdString
();
print
(
charset_u2g
(
stdPhone
).
data
(),
3
);
QString
strId
=
"订单号:"
;
strId
+=
obj
->
order_id
;
std
::
string
stdId
=
strId
.
toStdString
();
print
(
charset_u2g
(
stdId
).
data
(),
3
);
//为空时换行
print
(
""
,
1
);
QString
end
=
"*********"
;
end
+=
QString
(
"%1"
).
arg
(
"#"
+
QString
::
number
(
obj
->
order_index
),
4
);
end
+=
"完"
;
end
+=
"********"
;
std
::
string
strEnd
=
end
.
toStdString
();
print
(
charset_u2g
(
strEnd
).
data
(),
3
);
cut_paper
();
}
#endif
}
//上菜单打印
void
WBillControl
::
printMenu
(
const
OrderObject
*
obj
)
{
//
#ifdef Q_OS_LINUX
#ifdef Q_OS_LINUX
int
fd
=-
1
;
for
(
int
i
=
0
;
i
<
obj
->
proList
.
size
();
i
++
)
{
...
...
@@ -427,7 +539,7 @@ void WBillControl::printMenu(const OrderObject *obj)
print
(
menu
.
strOrderTitle
.
toLatin1
().
data
(),
3
);
QString
strDesk
=
" 台号:"
;
QString
strDesk
=
"
台号:"
;
strDesk
+=
obj
->
channelName
;
strDesk
+=
QString
::
number
(
obj
->
order_index
);
std
::
string
stdDesk
=
strDesk
.
toStdString
();
...
...
@@ -460,9 +572,57 @@ void WBillControl::printMenu(const OrderObject *obj)
cut_paper
();
}
//
#endif
#endif
}
QString
WBillControl
::
getPrintTitle
(
const
QString
&
channel
,
int
index
)
{
QString
title
;
if
(
"eleme"
==
channel
){
title
=
"****"
;
title
+=
QString
(
"%1"
).
arg
(
"#"
+
QString
::
number
(
index
),
4
);
title
+=
"饿了么外卖单"
;
title
+=
"****"
;
}
else
if
(
"mtwm"
==
channel
){
title
=
"*****"
;
title
+=
QString
(
"%1"
).
arg
(
"#"
+
QString
::
number
(
index
),
4
);
title
+=
"美团外卖单"
;
title
+=
"*****"
;
}
else
if
(
"bdwm"
==
channel
){
title
=
"*****"
;
title
+=
QString
(
"%1"
).
arg
(
"#"
+
QString
::
number
(
index
),
4
);
title
+=
"百度外卖单"
;
title
+=
"*****"
;
}
else
if
(
"jdwm"
==
channel
){
title
=
"******"
;
title
+=
QString
(
"%1"
).
arg
(
"#"
+
QString
::
number
(
index
),
4
);
title
+=
"京东到家"
;
title
+=
"******"
;
}
else
if
(
"sdg"
==
channel
){
title
=
"*******"
;
title
+=
QString
(
"%1"
).
arg
(
"#"
+
QString
::
number
(
index
),
4
);
title
+=
"闪电购"
;
title
+=
"*******"
;
}
else
if
(
"fmwd"
==
channel
){
title
=
"******"
;
title
+=
QString
(
"%1"
).
arg
(
"#"
+
QString
::
number
(
index
),
4
);
title
+=
"非码微店"
;
title
+=
"******"
;
}
else
if
(
"mall"
==
channel
){
title
=
"******"
;
title
+=
QString
(
"%1"
).
arg
(
"#"
+
QString
::
number
(
index
),
4
);
title
+=
"非码Mall"
;
title
+=
"******"
;
}
return
title
;
}
int
WBillControl
::
charset_convert
(
const
char
*
charset_from
,
const
char
*
charset_to
,
const
std
::
string
&
string_from
,
std
::
string
&
string_to
)
...
...
fmTakeaway/Util/wbillcontrol.h
View file @
61dc935d
...
...
@@ -106,11 +106,14 @@ private:
void
printCook
(
const
OrderObject
*
obj
,
const
QString
&
menuId
,
int
num
);
//外卖单打印
void
printTakeout
();
void
printTakeout
(
const
OrderObject
*
obj
);
//上菜单打印
void
printMenu
(
const
OrderObject
*
obj
);
//上菜单打印
QString
getPrintTitle
(
const
QString
&
channel
,
int
index
);
public
:
QVector
<
PrinterMenu
>
vecMenu
;
QMap
<
QString
,
QVector
<
SetMenuItem
>>
mapSetMenu
;
...
...
fmTakeaway/pos_print.h
View file @
61dc935d
...
...
@@ -13,8 +13,10 @@ void cut_paper();
// 2、标准加粗
// 3、两倍宽高
// 4、两倍宽高,加粗
// 5、三倍宽高
// 6、三倍宽高,加粗,红色
// 5、两倍高
// 6、两倍高,加粗
// 7、三倍宽高
// 8、三倍宽高,加粗,红色
//---------------------------------------------
void
print
(
const
char
*
data
,
int
type
);
#endif
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