Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmp_vip
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
fmp_vip
Commits
4df412ec
Commit
4df412ec
authored
Aug 21, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.实现没有用会员支付的订单,遇到网络错误或超时时,返回POS成功,备份并重发请求。
parent
8f5aa9cb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
25 deletions
+41
-25
backup/fmbackup.cpp
+2
-2
backup/resend.cpp
+8
-3
fmnetwork.cpp
+4
-2
fmp_vip.pro
+2
-0
task/taskfinal.cpp
+22
-18
task/taskfinal.h
+1
-0
task/tasklogin.cpp
+2
-0
No files found.
backup/fmbackup.cpp
View file @
4df412ec
...
...
@@ -36,7 +36,7 @@ bool FMBackup::connect()
if
(
!
QFile
::
exists
(
dbname
))
{
isOk
=
createTable
(
dbname
);
}
else
{
_db
=
QSqlDatabase
::
addDatabase
(
"QSQLITE"
);
_db
=
QSqlDatabase
::
addDatabase
(
"QSQLITE"
,
"fmvipbackupdb"
);
_db
.
setDatabaseName
(
dbname
);
isOk
=
_db
.
open
();
}
...
...
@@ -51,7 +51,7 @@ bool FMBackup::connect()
bool
FMBackup
::
createTable
(
const
QString
&
dbname
)
{
_db
=
QSqlDatabase
::
addDatabase
(
"QSQLITE"
);
_db
=
QSqlDatabase
::
addDatabase
(
"QSQLITE"
,
"fmvipbackupdb"
);
_db
.
setDatabaseName
(
dbname
);
_db
.
open
();
QSqlQuery
query
(
_db
);
...
...
backup/resend.cpp
View file @
4df412ec
...
...
@@ -6,6 +6,7 @@
#include <QSqlRecord>
#include <QNetworkReply>
#include <QDebug>
#include "global.h"
ReSend
::
ReSend
()
{
...
...
@@ -31,7 +32,7 @@ void ReSend::trySend()
net
.
send
(
url
,
data
,
rspData
);
// 如果发送失败则不再继续发送
if
(
net
.
error
!=
1
)
{
if
(
net
.
error
!=
FM_API_SUCCESS
)
{
break
;
}
else
{
FMBackup
::
instance
()
->
removeReqData
(
id
);
...
...
@@ -42,9 +43,13 @@ void ReSend::trySend()
void
ReSend
::
run
()
{
int
waitTime
=
0
;
while
(
true
)
{
trySend
();
QThread
::
sleep
(
5
);
if
(
++
waitTime
>
30
)
{
trySend
();
waitTime
=
0
;
}
QThread
::
sleep
(
1
);
}
}
fmnetwork.cpp
View file @
4df412ec
...
...
@@ -44,7 +44,7 @@ int FMNetwork::send(const QString &url, const QByteArray &reqData, QByteArray &r
QTimer
timer
;
timer
.
setSingleShot
(
true
);
connect
(
&
timer
,
SIGNAL
(
timeout
()),
&
loop
,
SLOT
(
quit
()));
timer
.
start
(
1000
*
60
*
60
);
timer
.
start
(
1000
*
60
);
loop
.
exec
();
if
(
timer
.
isActive
())
...
...
@@ -56,10 +56,12 @@ int FMNetwork::send(const QString &url, const QByteArray &reqData, QByteArray &r
int
err
=
reply
->
error
();
rspData
=
reply
->
readAll
();
error
=
FM_API_NETWORERROR
;
errorMsg
=
QString
::
fromLocal8Bit
(
"NetworkError(%1):%2"
).
arg
(
err
).
arg
(
QString
(
rspData
));
errorMsg
=
QString
::
fromLocal8Bit
(
"NetworkError(%1):%2"
).
arg
(
err
).
arg
(
QString
(
reply
->
errorString
()));
FMP_ERROR
()
<<
errorMsg
;
}
}
else
{
error
=
FM_API_TIMEOUT
;
FMP_ERROR
()
<<
"Request timeout."
;
}
return
error
;
}
...
...
fmp_vip.pro
View file @
4df412ec
...
...
@@ -11,6 +11,8 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG
+=
c
++
11
#DEFINES += TEST
SOURCES
+=
\
fmp_vip
.
cpp
\
fmp_vip_p
.
cpp
\
...
...
task/taskfinal.cpp
View file @
4df412ec
...
...
@@ -16,6 +16,7 @@ TaskFinal::TaskFinal(QJsonObject &jsonObj, Session *session, QObject *parent)
void
TaskFinal
::
packageServerReq
()
{
isUseVipPay
=
false
;
QJsonObject
transData
;
std
::
vector
<
QString
>
p
;
p
.
push_back
(
PosProps
.
BussinessDate
);
...
...
@@ -63,6 +64,10 @@ void TaskFinal::packageServerReq()
}
else
{
pay
[
"typeModeFlag"
]
=
typeModeFlag
;
}
if
(
typeModeFlag
.
compare
(
"20001"
)
==
0
||
typeModeFlag
.
compare
(
"20002"
)
==
0
||
typeModeFlag
.
compare
(
"20003"
)
==
0
)
{
isUseVipPay
=
true
;
}
payList
.
append
(
pay
);
}
...
...
@@ -76,22 +81,20 @@ bool TaskFinal::sendToServer(bool isShowMsg)
FMTask
::
sendToServer
(
false
);
// 备份
// if(error() == FM_API_NETWORERROR) {
// if(searchJsonValue(serverReqJsonObj,ServerProps(PosProps.CodeAmount)).toInt() == 0 &&
// searchJsonValue(serverReqJsonObj,ServerProps(PosProps.ScoreAmount)).toInt() == 0 &&
// searchJsonValue(serverReqJsonObj,ServerProps(PosProps.Coupons)).toArray().isEmpty()) {
// QString fm_id = backup();
// if(!fm_id.isEmpty()){
// setError(FM_API_SUCCESS);
// serverRspJsonObj[ServerProps(PosProps.StatusCode)] = FM_API_SUCCESS;
// serverRspJsonObj[ServerProps(PosProps.Msg)] = QString::fromLocal8Bit("结算成功");
// serverRspJsonObj[ServerProps(PosProps.Fm_id)] = fm_id;
// serverRspJsonObj[ServerProps(PosProps.Prompt)] = 1;
// serverRspJsonObj[ServerProps(PosProps.Print1)] = "";
// serverRspJsonObj[ServerProps(PosProps.Print2)] = "";
// }
// }
// }
if
(
error
()
==
FM_API_NETWORERROR
||
error
()
==
FM_API_TIMEOUT
)
{
if
(
!
isUseVipPay
)
{
QString
fm_id
=
backup
();
if
(
!
fm_id
.
isEmpty
()){
setError
(
FM_API_SUCCESS
);
serverRspJsonObj
[
ServerProps
(
PosProps
.
StatusCode
)]
=
FM_API_SUCCESS
;
serverRspJsonObj
[
ServerProps
(
PosProps
.
Msg
)]
=
QString
::
fromLocal8Bit
(
"结算成功"
);
serverRspJsonObj
[
ServerProps
(
PosProps
.
Fm_id
)]
=
fm_id
;
serverRspJsonObj
[
ServerProps
(
PosProps
.
Prompt
)]
=
1
;
serverRspJsonObj
[
ServerProps
(
PosProps
.
Print1
)]
=
""
;
serverRspJsonObj
[
ServerProps
(
PosProps
.
Print2
)]
=
""
;
}
}
}
bool
isOk
=
(
error
()
==
FM_API_SUCCESS
);
if
(
!
isOk
)
{
...
...
@@ -104,6 +107,7 @@ void TaskFinal::packagePOSRsp()
{
posRspJsonObj
[
PosProps
.
StatusCode
]
=
getServerJsonValue
(
PosProps
.
StatusCode
);
posRspJsonObj
[
PosProps
.
Msg
]
=
getServerJsonValue
(
PosProps
.
Msg
);
posRspJsonObj
[
PosProps
.
Fm_id
]
=
getServerJsonValue
(
PosProps
.
Fm_id
);
posRspJsonObj
[
PosProps
.
Prompt
]
=
1
;
}
...
...
@@ -113,11 +117,11 @@ QString TaskFinal::backup()
QString
uuid
=
QString
(
"E%1%2%3%4"
)
.
arg
(
getPosJsonValue
(
PosProps
.
StoreId
).
toString
())
.
arg
(
getPosJsonValue
(
PosProps
.
PosId
).
toString
().
toInt
(),
2
,
10
,
QChar
(
'0'
))
.
arg
(
QDateTime
::
currentDateTime
().
toString
(
"yyMMdd"
))
.
arg
(
QDateTime
::
currentDateTime
().
toString
(
"yyMMdd
hhmmsszzz
"
))
.
arg
(
newId
,
5
,
10
,
QChar
(
'0'
));
QJsonDocument
json
(
serverReqJsonObj
);
bool
isOk
=
FMBackup
::
instance
()
->
updateReqData
(
newId
,
this
->
url
,
json
.
toJson
(
QJsonDocument
::
Compact
));
if
(
isOk
&&
uuid
.
length
()
==
20
)
{
if
(
isOk
)
{
return
uuid
;
}
return
""
;
...
...
task/taskfinal.h
View file @
4df412ec
...
...
@@ -14,6 +14,7 @@ public:
private
:
QString
backup
();
bool
isUseVipPay
;
};
#endif // TASKFINAL_H
task/tasklogin.cpp
View file @
4df412ec
...
...
@@ -75,7 +75,9 @@ void TaskLogin::onLogin()
QString
name
=
getServerJsonValue
(
PosProps
.
Name
).
toString
();
bool
canPay
=
(
getServerJsonValue
(
PosProps
.
CanPay
).
toInt
()
==
1
);
#ifdef TEST
canPay
=
true
;
#endif
if
(
!
canPay
)
{
if
(
getPosJsonValue
(
PosProps
.
Fm_cmd
).
toInt
()
!=
FM_Pay
)
{
FMMsgWnd
::
LoginSuccess
(
account
,
name
,
birthday
,
_window
);
...
...
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