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
576ec1d1
Commit
576ec1d1
authored
Jan 27, 2021
by
wuyang.zou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix Use Transcation When insert table Products + promotions
parent
39cee4f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
fmTakeout/DTools/PrintOrderPromotionDB.cpp
+3
-3
fmTakeout/DTools/printCupStickPosDB.cpp
+3
-3
No files found.
fmTakeout/DTools/PrintOrderPromotionDB.cpp
View file @
576ec1d1
...
@@ -117,7 +117,7 @@ bool PrintOrderPromotionDB::insertOrderPromotion(OrderObject* orderObj){
...
@@ -117,7 +117,7 @@ bool PrintOrderPromotionDB::insertOrderPromotion(OrderObject* orderObj){
// 开启数据库事务实现原子操作: 保证 tb_order_promotions: 订单促销优惠列表 同时插入成功;
// 开启数据库事务实现原子操作: 保证 tb_order_promotions: 订单促销优惠列表 同时插入成功;
// m_sqlDb.transaction(); 驱动不支持;
// m_sqlDb.transaction(); 驱动不支持;
QSqlQuery
query
(
m_sqlDb
);
QSqlQuery
query
(
m_sqlDb
);
if
(
!
query
.
exec
(
"
START TRANSACTION
"
)
)
{
if
(
!
query
.
exec
(
"
begin tran
"
)
)
{
QLOG_ERROR
()
<<
"[<<<<---PrintCupStickPosDB::insertOrderPromotion: Begin transaction Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
QLOG_ERROR
()
<<
"[<<<<---PrintCupStickPosDB::insertOrderPromotion: Begin transaction Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
}
}
...
@@ -134,9 +134,9 @@ bool PrintOrderPromotionDB::insertOrderPromotion(OrderObject* orderObj){
...
@@ -134,9 +134,9 @@ bool PrintOrderPromotionDB::insertOrderPromotion(OrderObject* orderObj){
// Sleep(10*1000); // test sqldb transaction
// Sleep(10*1000); // test sqldb transaction
// m_sqlDb.commit() and m_sqlDb.rollback() 都是不支持的;
// m_sqlDb.commit() and m_sqlDb.rollback() 都是不支持的;
if
(
retInsCoupProm
||
retInsNorProm
)
{
if
(
retInsCoupProm
||
retInsNorProm
)
{
if
(
!
query
.
exec
(
"
COMMIT
"
)
)
{
if
(
!
query
.
exec
(
"
commit
"
)
)
{
QLOG_ERROR
()
<<
"[<<<<---insertOrderProduct::insertOrderPromotion: Begin Commit Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
QLOG_ERROR
()
<<
"[<<<<---insertOrderProduct::insertOrderPromotion: Begin Commit Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
if
(
!
query
.
exec
(
"
ROLLBACK
"
)
)
{
if
(
!
query
.
exec
(
"
rollback
"
)
)
{
QLOG_ERROR
()
<<
"[<<<<---insertOrderProduct::insertOrderPromotion: Begin Rollback Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
QLOG_ERROR
()
<<
"[<<<<---insertOrderProduct::insertOrderPromotion: Begin Rollback Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
}
}
}
}
...
...
fmTakeout/DTools/printCupStickPosDB.cpp
View file @
576ec1d1
...
@@ -130,7 +130,7 @@ bool PrintCupStickPosDB::insertOrderProduct(OrderObject* orderObj,const QString&
...
@@ -130,7 +130,7 @@ bool PrintCupStickPosDB::insertOrderProduct(OrderObject* orderObj,const QString&
// 开启数据库事务实现原子操作: 保证 tb_main_prod_refinfo:父商品与子商品 同时插入成功;
// 开启数据库事务实现原子操作: 保证 tb_main_prod_refinfo:父商品与子商品 同时插入成功;
// m_sqlDb.transaction(); 驱动不支持;
// m_sqlDb.transaction(); 驱动不支持;
QSqlQuery
query
(
m_sqlDb
);
QSqlQuery
query
(
m_sqlDb
);
if
(
!
query
.
exec
(
"
START TRANSACTION
"
)
)
{
if
(
!
query
.
exec
(
"
begin tran
"
)
)
{
QLOG_ERROR
()
<<
"[<<<<---PrintCupStickPosDB::insertOrderProduct: Begin transaction Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
QLOG_ERROR
()
<<
"[<<<<---PrintCupStickPosDB::insertOrderProduct: Begin transaction Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
}
}
...
@@ -147,9 +147,9 @@ bool PrintCupStickPosDB::insertOrderProduct(OrderObject* orderObj,const QString&
...
@@ -147,9 +147,9 @@ bool PrintCupStickPosDB::insertOrderProduct(OrderObject* orderObj,const QString&
// Sleep(10*1000); // test sqldb transaction
// Sleep(10*1000); // test sqldb transaction
// m_sqlDb.commit() and m_sqlDb.rollback() 都是不支持的;
// m_sqlDb.commit() and m_sqlDb.rollback() 都是不支持的;
if
(
retInsCoupProd
||
retInsNorProd
)
{
if
(
retInsCoupProd
||
retInsNorProd
)
{
if
(
!
query
.
exec
(
"
COMMIT
"
)
)
{
if
(
!
query
.
exec
(
"
commit
"
)
)
{
QLOG_ERROR
()
<<
"[<<<<---insertOrderProduct::insertOrderProduct: Begin Commit Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
QLOG_ERROR
()
<<
"[<<<<---insertOrderProduct::insertOrderProduct: Begin Commit Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
if
(
!
query
.
exec
(
"
ROLLBACK
"
)
)
{
if
(
!
query
.
exec
(
"
rollback
"
)
)
{
QLOG_ERROR
()
<<
"[<<<<---insertOrderProduct::insertOrderProduct: Begin Rollback Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
QLOG_ERROR
()
<<
"[<<<<---insertOrderProduct::insertOrderProduct: Begin Rollback Failed--->>>>]"
<<
m_sqlDb
.
lastError
().
text
();
}
}
}
}
...
...
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