Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FMVip_Today
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
zhenfei.zhang
FMVip_Today
Commits
25a8e50e
Commit
25a8e50e
authored
Nov 05, 2016
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 新增网络不通畅时返回一个虚拟fm_id。 2. 修复_needBackupData没有及时清空导致下次请求出错问题。
parent
056628f6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
21 deletions
+51
-21
FMVip/backup/fmbackup.cpp
+30
-4
FMVip/backup/fmbackup.h
+3
-1
FMVip/backup/resend.cpp
+2
-1
FMVip/fmvipdispatcher.cpp
+0
-4
FMVip/fmvipforward.cpp
+15
-5
FMVip/fmvipforward.h
+1
-1
FMVip/fmviplogin.cpp
+0
-1
FMVip/fmvipwnd.cpp
+0
-2
FMVip/main.cpp
+0
-2
No files found.
FMVip/backup/fmbackup.cpp
View file @
25a8e50e
...
@@ -55,7 +55,7 @@ bool FMBackup::createTable(const QString &dbname)
...
@@ -55,7 +55,7 @@ bool FMBackup::createTable(const QString &dbname)
_db
.
open
();
_db
.
open
();
QSqlQuery
query
(
_db
);
QSqlQuery
query
(
_db
);
// 创建表
// 创建表
bool
isOk
=
query
.
exec
(
"create table tbl_req(id integer
primary key, url varchar(1
00), req text)"
);
bool
isOk
=
query
.
exec
(
"create table tbl_req(id integer
PRIMARY KEY autoincrement, url varchar(2
00), req text)"
);
qDebug
()
<<
"创建数据库:"
<<
dbname
;
qDebug
()
<<
"创建数据库:"
<<
dbname
;
if
(
!
isOk
)
{
if
(
!
isOk
)
{
...
@@ -64,15 +64,33 @@ bool FMBackup::createTable(const QString &dbname)
...
@@ -64,15 +64,33 @@ bool FMBackup::createTable(const QString &dbname)
return
isOk
;
return
isOk
;
}
}
bool
FMBackup
::
insertReqData
(
const
QString
url
,
const
QString
&
reqData
)
int
FMBackup
::
insertNewRow
(
)
{
{
if
(
!
_db
.
isOpen
())
{
if
(
!
_db
.
isOpen
())
{
connect
();
connect
();
}
}
QSqlQuery
query
(
_db
);
QSqlQuery
query
(
_db
);
bool
isOk
=
query
.
exec
(
QString
(
"insert into tbl_req('url','req') values('%1','%2')"
)
bool
isOk
=
query
.
exec
(
QString
(
"insert into tbl_req('url','req') values('','');"
));
isOk
&=
query
.
exec
(
"select last_insert_rowid();"
);
int
id
=
-
1
;
if
(
isOk
&&
query
.
next
())
{
id
=
query
.
record
().
value
(
0
).
toInt
();
}
return
id
;
}
bool
FMBackup
::
updateReqData
(
const
int
id
,
const
QString
url
,
const
QString
&
reqData
)
{
if
(
!
_db
.
isOpen
())
{
connect
();
}
QSqlQuery
query
(
_db
);
bool
isOk
=
query
.
exec
(
QString
(
"update tbl_req set url = '%1', req='%2' where id=%3"
)
.
arg
(
url
)
.
arg
(
url
)
.
arg
(
reqData
));
.
arg
(
reqData
)
.
arg
(
id
));
qDebug
()
<<
"备份数据:"
<<
reqData
;
qDebug
()
<<
"备份数据:"
<<
reqData
;
if
(
!
isOk
)
{
if
(
!
isOk
)
{
...
@@ -100,3 +118,11 @@ QSqlQuery FMBackup::reqDataQuery() const
...
@@ -100,3 +118,11 @@ QSqlQuery FMBackup::reqDataQuery() const
}
}
return
query
;
return
query
;
}
}
bool
FMBackup
::
reset
()
{
QSqlQuery
query
(
_db
);
bool
isOk
=
query
.
exec
(
"VACUUM"
);
qDebug
()
<<
"数据库重置: "
<<
isOk
;
return
isOk
;
}
FMVip/backup/fmbackup.h
View file @
25a8e50e
...
@@ -7,9 +7,11 @@ class FMBackup
...
@@ -7,9 +7,11 @@ class FMBackup
{
{
public
:
public
:
static
FMBackup
*
instance
();
static
FMBackup
*
instance
();
bool
insertReqData
(
const
QString
url
,
const
QString
&
reqData
);
bool
updateReqData
(
const
int
id
,
const
QString
url
,
const
QString
&
reqData
);
bool
removeReqData
(
const
int
&
id
);
bool
removeReqData
(
const
int
&
id
);
int
insertNewRow
();
QSqlQuery
reqDataQuery
()
const
;
QSqlQuery
reqDataQuery
()
const
;
bool
reset
();
private
:
private
:
FMBackup
();
FMBackup
();
static
FMBackup
*
_instance
;
static
FMBackup
*
_instance
;
...
...
FMVip/backup/resend.cpp
View file @
25a8e50e
...
@@ -43,8 +43,9 @@ void ReSend::trySend()
...
@@ -43,8 +43,9 @@ void ReSend::trySend()
// 如果发送失败则不再继续发送
// 如果发送失败则不再继续发送
if
(
!
isSuccess
)
{
if
(
!
isSuccess
)
{
break
;
break
;
}
else
{
FMBackup
::
instance
()
->
removeReqData
(
id
);
}
}
FMBackup
::
instance
()
->
removeReqData
(
id
);
}
}
}
}
...
...
FMVip/fmvipdispatcher.cpp
View file @
25a8e50e
...
@@ -88,8 +88,6 @@ INT FMVipDispatcher::_ParseRequest(LPSTR data)
...
@@ -88,8 +88,6 @@ INT FMVipDispatcher::_ParseRequest(LPSTR data)
BOOL
FMVipDispatcher
::
_GetResponse
(
LPSTR
&
rsp
,
UINT
&
len
)
BOOL
FMVipDispatcher
::
_GetResponse
(
LPSTR
&
rsp
,
UINT
&
len
)
{
{
qDebug
()
<<
__FUNCTION__
;
mutex
.
lock
();
mutex
.
lock
();
if
(
_serverRspData
.
isEmpty
())
if
(
_serverRspData
.
isEmpty
())
{
{
...
@@ -177,8 +175,6 @@ void FMVipDispatcher::onResponse(const QByteArray &rsp)
...
@@ -177,8 +175,6 @@ void FMVipDispatcher::onResponse(const QByteArray &rsp)
void
FMVipDispatcher
::
onFinished
()
void
FMVipDispatcher
::
onFinished
()
{
{
qDebug
()
<<
__FUNCTION__
;
if
(
_windowReturn
==
-
1
){
if
(
_windowReturn
==
-
1
){
_serverRspData
=
Err_WindowClose
;
_serverRspData
=
Err_WindowClose
;
serverIsBusy
.
wakeAll
();
serverIsBusy
.
wakeAll
();
...
...
FMVip/fmvipforward.cpp
View file @
25a8e50e
...
@@ -96,7 +96,7 @@ void FMVipForward::request(const QJsonObject &reqJob)
...
@@ -96,7 +96,7 @@ void FMVipForward::request(const QJsonObject &reqJob)
if
(
trans
[
"codeAmount"
].
toInt
()
==
0
&&
if
(
trans
[
"codeAmount"
].
toInt
()
==
0
&&
trans
[
"scoreAmount"
].
toInt
()
==
0
&&
trans
[
"scoreAmount"
].
toInt
()
==
0
&&
trans
[
"coupons"
].
toArray
().
isEmpty
()
)
{
trans
[
"coupons"
].
toArray
().
isEmpty
()
)
{
_needBackup
Data
=
reqData
;
_needBackup
ReqJob
=
reqJob
;
}
}
}
}
...
@@ -135,11 +135,21 @@ void FMVipForward::onServerFinished(QNetworkReply *reply, bool isTimeOut)
...
@@ -135,11 +135,21 @@ void FMVipForward::onServerFinished(QNetworkReply *reply, bool isTimeOut)
if
(
reply
->
error
()
!=
QNetworkReply
::
NoError
||
isTimeOut
==
true
)
{
if
(
reply
->
error
()
!=
QNetworkReply
::
NoError
||
isTimeOut
==
true
)
{
// 如果有需要备份的请求数据,则直接返回成功
// 如果有需要备份的请求数据,则直接返回成功
if
(
!
_needBackupData
.
isEmpty
())
{
if
(
!
_needBackupReqJob
.
isEmpty
())
{
FMBackup
::
instance
()
->
insertReqData
(
_req
.
url
().
toString
(),
_needBackupData
);
_needBackupData
.
clear
();
int
newId
=
FMBackup
::
instance
()
->
insertNewRow
();
QString
uuid
=
QString
(
"E%1%2%3%4"
)
.
arg
(
_needBackupReqJob
[
"storeId"
].
toString
())
.
arg
(
_needBackupReqJob
[
"stationId"
].
toString
().
toInt
(),
2
,
10
,
QChar
(
'0'
))
.
arg
(
QDateTime
::
currentDateTime
().
toString
(
"yyMMdd"
))
.
arg
(
newId
,
5
,
10
,
QChar
(
'0'
));
_needBackupReqJob
[
"memberTransId"
]
=
uuid
;
QJsonDocument
jdoc
(
_needBackupReqJob
);
FMBackup
::
instance
()
->
updateReqData
(
newId
,
_req
.
url
().
toString
(),
jdoc
.
toJson
(
QJsonDocument
::
Compact
));
posObj
[
"statusCode"
]
=
100
;
posObj
[
"statusCode"
]
=
100
;
posObj
[
"msg"
]
=
"结算成功"
;
posObj
[
"msg"
]
=
"结算成功"
;
posObj
[
"fm_id"
]
=
uuid
;
posObj
[
"prompt"
]
=
1
;
posObj
[
"prompt"
]
=
1
;
posObj
[
"print1"
]
=
""
;
posObj
[
"print1"
]
=
""
;
posObj
[
"print2"
]
=
""
;
posObj
[
"print2"
]
=
""
;
...
@@ -212,7 +222,7 @@ void FMVipForward::onServerFinished(QNetworkReply *reply, bool isTimeOut)
...
@@ -212,7 +222,7 @@ void FMVipForward::onServerFinished(QNetworkReply *reply, bool isTimeOut)
}
}
}
}
}
}
_needBackupReqJob
=
QJsonObject
();
emit
serverResponsed
(
posObj
);
emit
serverResponsed
(
posObj
);
}
}
...
...
FMVip/fmvipforward.h
View file @
25a8e50e
...
@@ -105,7 +105,7 @@ private:
...
@@ -105,7 +105,7 @@ private:
QMap
<
QString
,
QVariant
>
_sessionDataMap
;
QMap
<
QString
,
QVariant
>
_sessionDataMap
;
QStringList
_sessionDataList
;
QStringList
_sessionDataList
;
Q
String
_needBackupData
;
Q
JsonObject
_needBackupReqJob
;
signals
:
signals
:
void
serverResponsed
(
const
QJsonObject
&
rspData
);
void
serverResponsed
(
const
QJsonObject
&
rspData
);
private
slots
:
private
slots
:
...
...
FMVip/fmviplogin.cpp
View file @
25a8e50e
...
@@ -32,7 +32,6 @@ FMVipLogin::FMVipLogin(bool isMustPayCode, QDialog *parent) :
...
@@ -32,7 +32,6 @@ FMVipLogin::FMVipLogin(bool isMustPayCode, QDialog *parent) :
FMVipLogin
::~
FMVipLogin
()
FMVipLogin
::~
FMVipLogin
()
{
{
qDebug
()
<<
__FUNCTION__
;
delete
ui
;
delete
ui
;
}
}
...
...
FMVip/fmvipwnd.cpp
View file @
25a8e50e
...
@@ -85,8 +85,6 @@ int FMVipWnd::exec()
...
@@ -85,8 +85,6 @@ int FMVipWnd::exec()
QRect
rc
=
w
.
availableGeometry
();
QRect
rc
=
w
.
availableGeometry
();
setGeometry
((
rc
.
width
()
-
width
())
/
2
,
(
rc
.
height
()
-
height
())
/
2
,
width
(),
height
());
setGeometry
((
rc
.
width
()
-
width
())
/
2
,
(
rc
.
height
()
-
height
())
/
2
,
width
(),
height
());
qDebug
()
<<
QString
(
"rc(%1, %2), w(%3, %4)"
).
arg
(
rc
.
width
()).
arg
(
rc
.
height
()).
arg
(
w
.
width
()).
arg
(
w
.
height
());
return
QDialog
::
exec
();
return
QDialog
::
exec
();
}
}
...
...
FMVip/main.cpp
View file @
25a8e50e
...
@@ -85,7 +85,5 @@ int main(int argc, char *argv[])
...
@@ -85,7 +85,5 @@ int main(int argc, char *argv[])
w
.
show
();
w
.
show
();
w
.
hide
();
w
.
hide
();
qDebug
()
<<
"v1.17 (2016-10-28 14:40)"
;
return
a
.
exec
();
return
a
.
exec
();
}
}
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