Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
takeout_sbk
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
yunpeng.song
takeout_sbk
Commits
29098ac4
Commit
29098ac4
authored
Jul 01, 2018
by
wuyang.zou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug: 新增 sql server 数据库功能:想 POS本地数据库添加 打印汇总的数据信息
parent
cf8250b2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
327 additions
and
13 deletions
+327
-13
fmTakeout/Control/flowControl.cpp
+13
-2
fmTakeout/Control/flowControl.h
+6
-0
fmTakeout/DTools/printSumBillPosDB.cpp
+223
-0
fmTakeout/DTools/printSumBillPosDB.h
+73
-0
fmTakeout/Model/orderObject.h
+4
-4
fmTakeout/fmTakeout.pro
+4
-2
fmTakeout/mainForm.cpp
+0
-1
fmTakeout/preDefine.h
+4
-4
No files found.
fmTakeout/Control/flowControl.cpp
View file @
29098ac4
...
...
@@ -17,6 +17,7 @@
#include <QMap>
#include <QFile>
#include <DTools/simProcOrderDB.h>
#include <DTools/PrintSumBillPosDB.h>
#include <QHostInfo>
...
...
@@ -119,6 +120,11 @@ FlowControl::FlowControl()
/***打开Sqlite数据库并登陆外卖插件***/
SimProcOrderDB
::
getInstance
();
/***打开SqlServer POS打印汇总信息本地数据库***/
PrintSumBillPosDB
::
getInstance
();
if
(
!
PrintSumBillPosDB
::
getInstance
().
initPrintSumBillPosDB
()
){
emit
showAlert
(
AlertForm
::
MSGERROR
,
QString
::
fromLocal8Bit
(
"尝试打开POS本地数据库失败"
));
}
_ClickOMSAssignArea
();
m_loginTimer
->
start
(
20
*
1000
);
}
...
...
@@ -322,6 +328,11 @@ bool FlowControl::_GetStoreInfo()
return
result
;
}
QString
FlowControl
::
_GetCashierId
()
{
return
m_cashierId
;
}
bool
FlowControl
::
_Login
()
{
QString
error
;
...
...
@@ -1329,8 +1340,8 @@ bool FlowControl::_ResponseSimphony05Request(const QJsonObject &content, QJsonOb
}
****/
/***** 更新 POS本地数据库的打印信息是否成功;begin:*********/
//
int retSyncOrderPrintInfo = 1;
int
retSyncOrderPrintInfo
=
0
;
int
retSyncOrderPrintInfo
=
1
;
//
int retSyncOrderPrintInfo = 0;
/***** 更新 POS本地数据库的打印信息是否成功;end:********/
/***** 解析 同步更新POS本地数据库是否成功:retSyncOrderPrintInfo:1->成功********/
if
(
retSyncOrderPrintInfo
){
...
...
fmTakeout/Control/flowControl.h
View file @
29098ac4
...
...
@@ -25,6 +25,12 @@ class FlowControl : public QObject
public
:
static
FlowControl
&
GetInstance
();
/* 功能:获取收银员ID
* 参数:NULL
* 返回:是否成功
* */
QString
_GetCashierId
();
private
:
FlowControl
();
FlowControl
(
FlowControl
const
&
);
...
...
fmTakeout/DTools/printSumBillPosDB.cpp
0 → 100644
View file @
29098ac4
#include "printSumBillPosDB.h"
#include "QsLog.h"
#include "alertForm.h"
#include <QDateTime>
#include "Control/flowControl.h"
PrintSumBillPosDB
::
PrintSumBillPosDB
()
{
QLOG_INFO
()
<<
"[<<<<---Try Open Pos SqlServer DataBase--->>>>]"
;
}
bool
PrintSumBillPosDB
::
initPrintSumBillPosDB
(){
//QString dbPath = QString(ConfigManage::Instance().databasePath());
m_sqlDb
=
QSqlDatabase
::
addDatabase
(
"QODBC"
);
//数据库驱动类型为SQL Server
if
(
m_sqlDb
.
isValid
()){
QLOG_INFO
()
<<
"[<<<<---SqlServer ODBC driver is valid--->>>>]"
;
QString
dsn
=
"DRIVER={SQL SERVER};SERVER=127.0.0.1
\\
sqlexpress;DATABASE=MMXBenefits"
;
//数据源名称 QT_FmConnectPosDb
m_sqlDb
.
setDatabaseName
(
dsn
);
//设置数据源名称
m_sqlDb
.
setUserName
(
"sa"
);
//登录用户
m_sqlDb
.
setPassword
(
"SIM29@123"
);
if
(
!
m_sqlDb
.
open
())
//打开数据库
{
QLOG_ERROR
()
<<
"[<<<<---SqlServer Open Database error:--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
}
else
{
QLOG_INFO
()
<<
"[<<<<---SqlServer Test Open database success!:--->>>>]"
;
m_sqlDb
.
close
();
return
true
;
}
}
else
{
QLOG_ERROR
()
<<
"[<<<<---SqlServer ODBC driver no valid--->>>>]"
;
}
return
false
;
}
PrintSumBillPosDB
&
PrintSumBillPosDB
::
getInstance
()
{
static
PrintSumBillPosDB
printSumBillPosDB
;
return
printSumBillPosDB
;
}
bool
PrintSumBillPosDB
::
insertOrderSumBill
(
OrderObject
*
orderObj
,
const
QString
&
posCheckNo
){
m_mutex
.
lock
();
if
(
!
m_sqlDb
.
open
())
{
QLOG_ERROR
()
<<
"[<<<<---SqlServer Database:Open Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
return
false
;
}
bool
result
;
QSqlQuery
query
(
m_sqlDb
);
query
.
prepare
(
"INSERT INTO tb_msr_customer_info(chk_num, last_name, full_name, gender, "
"is_birthday, create_datetime, created_by, modify_datetime, modified_by, accept_name, accept_address, accept_phone, order_id, "
"waybill_id, take_no, deliver_phone, deliver_name) "
"VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
query
.
addBindValue
(
posCheckNo
);
// --小票号
query
.
addBindValue
(
orderObj
->
lastName
);
// --顾客-姓
query
.
addBindValue
(
QString
(
orderObj
->
firstName
));
// --顾客-名
query
.
addBindValue
(
orderObj
->
customerSex
);
// --顾客-性别
query
.
addBindValue
(
false
);
// --顾客-生日
QDateTime
qdaTi
=
QDateTime
::
currentDateTimeUtc
();
query
.
addBindValue
(
qdaTi
.
addSecs
(
1000
*
60
*
60
*
8
).
toString
(
"yyyy-MM-dd hh:mm:ss"
));
// --POS出小票时间
query
.
addBindValue
(
FlowControl
::
GetInstance
().
_GetCashierId
());
// --订单处理者
query
.
addBindValue
(
""
);
// --变更订单时间 //??????????????????????????????????????????
query
.
addBindValue
(
""
);
// --变更订单作者 //??????????????????????????????????????????
query
.
addBindValue
(
orderObj
->
customerName
);
// --收货者-名 //??????????????????????????????????????????
query
.
addBindValue
(
orderObj
->
addressDetail
);
// --收货者-地址 //??????????????????????????????????????????
query
.
addBindValue
(
orderObj
->
phone
);
// --收货者-电话 //??????????????????????????????????????????
query
.
addBindValue
(
orderObj
->
id
);
// --订单编号
query
.
addBindValue
(
orderObj
->
waybillId
);
// --物流编号
query
.
addBindValue
(
0
);
// --取票号 //??????????????????????????????????????????
query
.
addBindValue
(
orderObj
->
riderPhone
);
// --配送者电话
query
.
addBindValue
(
orderObj
->
riderName
);
// -配送者名称
if
(
!
query
.
exec
())
{
QLOG_ERROR
()
<<
"[<<<<---SqlServer Database:customer_info Error--->>>>]"
<<
query
.
lastError
().
text
()
<<
QString
::
number
(
query
.
lastError
().
type
());
result
=
false
;
}
else
{
QLOG_INFO
()
<<
QString
(
"[<<<<---SqlServer Database:Insert OrderId %1 Into customer_info Success--->>>>]"
).
arg
(
orderObj
->
id
);
result
=
true
;
}
m_sqlDb
.
close
();
m_mutex
.
unlock
();
return
result
;
}
bool
PrintSumBillPosDB
::
updateOrderSumBillStatus
(
OrderObject
*
orderObj
,
const
int
&
OrderStatus
){
m_mutex
.
lock
();
if
(
!
m_sqlDb
.
open
())
{
QLOG_ERROR
()
<<
"[<<<<---SqlServer Database:Open Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
return
false
;
}
bool
result
;
QSqlQuery
query
(
m_sqlDb
);
query
.
prepare
(
QString
(
"update tb_msr_customer_info set OrderStatus=%1 where order_id='%2'"
)
.
arg
(
QString
::
number
(
OrderStatus
)).
arg
(
orderObj
->
id
));
if
(
!
query
.
exec
())
{
QLOG_ERROR
()
<<
query
.
lastError
().
text
()
<<
"[<<<<---SqlServer Database:update Order Status Failed--->>>>]"
;
result
=
false
;
}
else
{
QLOG_INFO
()
<<
QString
(
"[<<<<---SqlServer Database:Update OrderId %1 OrderStatus success--->>>>]"
).
arg
(
orderObj
->
id
);
result
=
true
;
}
m_sqlDb
.
close
();
m_mutex
.
unlock
();
return
result
;
}
bool
PrintSumBillPosDB
::
isOrderAndCknoSumBillExit
(
const
QString
&
orderId
,
const
QString
&
posCheckNo
){
m_mutex
.
lock
();
if
(
!
m_sqlDb
.
open
())
{
QLOG_ERROR
()
<<
"[<<<<---SqlServer Database:Open Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
return
false
;
}
bool
result
;
QSqlQuery
query
(
m_sqlDb
);
query
.
prepare
(
QString
(
"select order_id from tb_msr_customer_info where order_id='%1' and chk_num='%2'"
).
arg
(
orderId
).
arg
(
posCheckNo
));
if
(
!
query
.
exec
())
{
QLOG_ERROR
()
<<
"[<<<<---SqlServer Database:isOrderAndCknoSumBillExit--->>>>]"
<<
orderId
<<
query
.
lastError
().
text
();
result
=
false
;
}
if
(
query
.
first
())
{
result
=
true
;
}
else
{
result
=
false
;
}
m_sqlDb
.
close
();
m_mutex
.
unlock
();
return
result
;
}
bool
PrintSumBillPosDB
::
isOrderSumBillExit
(
const
QString
&
orderId
){
m_mutex
.
lock
();
if
(
!
m_sqlDb
.
open
())
{
QLOG_ERROR
()
<<
"[<<<<---SqlServer Database:Open Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
return
false
;
}
bool
result
;
QSqlQuery
query
(
m_sqlDb
);
query
.
prepare
(
QString
(
"select order_id from tb_msr_customer_info where order_id='%1'"
).
arg
(
orderId
));
if
(
!
query
.
exec
())
{
QLOG_ERROR
()
<<
"[<<<<---SqlServer Database:isOrderSumBillExit--->>>>]"
<<
orderId
<<
query
.
lastError
().
text
();
result
=
false
;
}
if
(
query
.
first
())
{
result
=
true
;
}
else
{
result
=
false
;
}
m_sqlDb
.
close
();
m_mutex
.
unlock
();
return
result
;
}
bool
PrintSumBillPosDB
::
queryValue
(
const
QString
&
orderId
,
const
QString
&
key
,
QString
&
error
,
QVariant
&
value
){
QMutexLocker
mutex
(
&
m_mutex
);
if
(
!
m_sqlDb
.
open
())
{
error
.
append
(
QString
(
"SqlServer Database:Open Failed"
).
append
(
m_sqlDb
.
lastError
().
text
()));
return
false
;
}
QSqlQuery
query
(
m_sqlDb
);
query
.
prepare
(
QString
(
"select %1 from tb_msr_customer_info where order_id='%1'"
).
arg
(
key
).
arg
(
orderId
));
if
(
!
query
.
exec
())
{
error
.
append
(
query
.
lastError
().
text
());
m_sqlDb
.
close
();
return
false
;
}
else
{
while
(
query
.
next
())
{
value
=
query
.
value
(
0
);
}
}
m_sqlDb
.
close
();
return
true
;
}
bool
PrintSumBillPosDB
::
queryIsNull
(
const
QString
&
orderId
,
const
QString
&
key
,
QString
&
error
,
bool
&
result
){
QMutexLocker
mutex
(
&
m_mutex
);
if
(
!
m_sqlDb
.
open
())
{
error
.
append
(
QString
(
"SqlServer Database:Open Failed"
).
append
(
m_sqlDb
.
lastError
().
text
()));
return
false
;
}
QSqlQuery
query
(
m_sqlDb
);
query
.
prepare
(
QString
(
"select %1 from tb_msr_customer_info where order_id=%2 and %3 is null"
).
arg
(
orderId
,
orderId
,
key
));
if
(
!
query
.
exec
())
{
error
.
append
(
query
.
lastError
().
text
());
m_sqlDb
.
close
();
return
false
;
}
else
{
if
(
query
.
first
())
{
result
=
true
;
}
else
{
result
=
false
;
}
}
m_sqlDb
.
close
();
return
true
;
}
fmTakeout/DTools/printSumBillPosDB.h
0 → 100644
View file @
29098ac4
/******************
*进行sql server操作
******************/
#ifndef PRINTSUMBILLPOSDB_H
#define PRINTSUMBILLPOSDB_H
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlError>
#include <QObject>
#include <QMutex>
#include <Model/orderObject.h>
class
PrintSumBillPosDB
:
public
QObject
{
Q_OBJECT
public
:
// explicit PrintSumBillPosDB(QObject *parent = 0);
static
PrintSumBillPosDB
&
getInstance
();
/**
*功能:初始化pos本地数据库;方便后期判断 打开pos本地数据库是否成功;
*参数:[无]
*返回:true:能够成功打开POS本地数据库,false:不能够成功打开POS本地数据库
**/
bool
initPrintSumBillPosDB
();
/**
*功能:插入一条汇总单信息到pos本地数据库中;
*参数:[1]订单号 [2]小票号
*返回:true操作成功,false失败
**/
bool
insertOrderSumBill
(
OrderObject
*
orderObj
,
const
QString
&
posCheckNo
);
/**
*功能: 根据订单ID 更新 pos本地数据库中汇总单状态信息;
*参数:[1]订单号[2] [3] [4] [5] [6]
*返回:true操作成功,false失败
**/
bool
updateOrderSumBillStatus
(
OrderObject
*
orderObj
,
const
int
&
OrderStatus
);
/**
*功能:查询 订单号和小票号 的汇总账单是否存在本地的POS系统中;
*参数:[1]订单号 [2]小票号
*返回:true是,false否
**/
bool
isOrderAndCknoSumBillExit
(
const
QString
&
orderId
,
const
QString
&
posCheckNo
);
/**
*功能:查询订单的汇总账单是否存在本地的POS系统中;
*参数:[1]订单号
*返回:true是,false否
**/
bool
isOrderSumBillExit
(
const
QString
&
orderId
);
bool
queryValue
(
const
QString
&
orderId
,
const
QString
&
key
,
QString
&
error
,
QVariant
&
value
);
bool
queryIsNull
(
const
QString
&
orderId
,
const
QString
&
key
,
QString
&
error
,
bool
&
result
);
private
:
QMutex
m_mutex
;
PrintSumBillPosDB
();
PrintSumBillPosDB
(
PrintSumBillPosDB
const
&
);
PrintSumBillPosDB
&
operator
=
(
PrintSumBillPosDB
const
&
);
QSqlDatabase
m_sqlDb
;
signals
:
public
slots
:
};
#endif // PRINTSUMBILLPOSDB_H
fmTakeout/Model/orderObject.h
View file @
29098ac4
...
...
@@ -54,7 +54,7 @@ class OrderObject : public QObject
Q_PROPERTY
(
int
payStatus
READ
getPayStatus
WRITE
setPayStatus
)
Q_PROPERTY
(
int
refundStatus
READ
getRefundStatus
WRITE
setRefundStatus
)
Q_PROPERTY
(
int
deliveryChannel
READ
getDeliveryChannel
WRITE
setDeliveryChannel
)
Q_PROPERTY
(
int
customerSex
READ
getCustomerSex
WRITE
setCustomerSex
)
Q_PROPERTY
(
QString
customerSex
READ
getCustomerSex
WRITE
setCustomerSex
)
Q_PROPERTY
(
int
orderIndex
READ
getOrderIndex
WRITE
setOrderIndex
)
public
:
OrderObject
(
QObject
*
parent
=
0
)
...
...
@@ -115,7 +115,7 @@ public:
QString
addressDetail
;
int
orderIndex
;
int
updateTime
;
int
customerSex
;
//用户性别 1- 男2- 女
QString
customerSex
;
//用户性别 1- 男2- 女
int
needInvoice
;
int
deliveryPrice
;
int
productPrice
;
...
...
@@ -265,8 +265,8 @@ public:
inline
int
getRefundStatus
()
const
{
return
refundStatus
;}
inline
void
setRefundStatus
(
const
int
&
v
){
refundStatus
=
v
;}
inline
int
getCustomerSex
()
const
{
return
customerSex
;}
inline
void
setCustomerSex
(
const
int
&
v
){
customerSex
=
v
;}
inline
QString
getCustomerSex
()
const
{
return
customerSex
;}
inline
void
setCustomerSex
(
const
QString
&
v
){
customerSex
=
v
;}
};
...
...
fmTakeout/fmTakeout.pro
View file @
29098ac4
...
...
@@ -53,7 +53,8 @@ SOURCES += main.cpp\
refuseForm
.
cpp
\
dailyreportForm
.
cpp
\
Model
/
dailyObject
.
cpp
\
DTools
/
simProcOrderDB
.
cpp
DTools
/
simProcOrderDB
.
cpp
\
DTools
/
printSumBillPosDB
.
cpp
HEADERS
+=
\
mainForm
.
h
\
...
...
@@ -85,7 +86,8 @@ HEADERS += \
dailyreportForm
.
h
\
Model
/
dailyObject
.
h
\
DTools
/
dump
.
h
\
DTools
/
simProcOrderDB
.
h
DTools
/
simProcOrderDB
.
h
\
DTools
/
printSumBillPosDB
.
h
FORMS
+=
mainForm
.
ui
\
alertForm
.
ui
\
...
...
fmTakeout/mainForm.cpp
View file @
29098ac4
...
...
@@ -392,7 +392,6 @@ void MainForm::onChangeOrderStatus(OrderObject *orderObject, int oldStatus)
QTableWidgetItem
*
item4
=
new
QTableWidgetItem
(
orderObject
->
phone
);
item4
->
setTextAlignment
(
Qt
::
AlignCenter
);
table
->
setItem
(
0
,
4
,
item4
);
// 联系方式
//QTableWidgetItem *item5 = new QTableWidgetItem(QDateTime::fromTime_t(orderObject->createTime).toString("MM-dd hh:mm"));
QTableWidgetItem
*
item5
=
new
QTableWidgetItem
(
orderObject
->
createTime
);
item5
->
setTextAlignment
(
Qt
::
AlignCenter
);
table
->
setItem
(
0
,
5
,
item5
);
// 下单时间
...
...
fmTakeout/preDefine.h
View file @
29098ac4
...
...
@@ -43,7 +43,7 @@
#define JSON_REQTYPE "reqtype"
#define JSON_CURRENTUSER "current
_u
ser"
#define JSON_CURRENTUSER "current
U
ser"
#define JSON_STOREID "storeId"
#define JSON_PASSWORD "password"
#define JSON_IPADDRESS "iPAddress"
...
...
@@ -76,13 +76,13 @@
#define JSON_BUSINESSID "businessId"
#define JSON_REASON "reason"
#define JSON_REASONCODE "reason_code"
#define JSON_SYNCTIME "sync
_t
ime"
#define JSON_SYNCTIME "sync
T
ime"
#define JSON_SHOPCODE "storeId"
#define JSON_CHANNEL "channel"
#define JSON_BUSINESSSTATUS "business_status"
#define JSON_CODE "code"
#define JSON_PAGENUMBER "page
_n
o"
#define JSON_PAGESIZE "page
_s
ize"
#define JSON_PAGENUMBER "page
N
o"
#define JSON_PAGESIZE "page
S
ize"
#define JSON_DELIVERS "deliverymans"
#define JSON_DELIVERYID "deliveryman_id"
#define JSON_DELIVERYNAME "deliveryman_name"
...
...
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