Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FMVip_LXJ
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_LXJ
Commits
6c703210
Commit
6c703210
authored
Jun 19, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 增加"确认充值信息"接口,充值后30秒POS未确认自动冲正。
parent
f3e0e6c9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
125 additions
and
7 deletions
+125
-7
FMVip_LXJ/FMVip_LXJ.pro
+4
-2
FMVip_LXJ/fmvipdispatcher.cpp
+69
-0
FMVip_LXJ/fmvipdispatcher.h
+5
-0
FMVip_LXJ/global.h
+4
-0
FMVip_LXJ/task/fmtask.h
+2
-1
FMVip_LXJ/task/taskconfirmrecharge.cpp
+15
-0
FMVip_LXJ/task/taskconfirmrecharge.h
+16
-0
FMVip_LXJ/task/taskfactory.cpp
+6
-1
FMVip_LXJ/task/taskfund.cpp
+4
-3
No files found.
FMVip_LXJ/FMVip_LXJ.pro
View file @
6c703210
...
...
@@ -41,7 +41,8 @@ SOURCES += main.cpp\
windows
/
itemdelegate
.
cpp
\
fmprinter
.
cpp
\
fmsetting
.
cpp
\
windows
/
fmvipsetting
.
cpp
windows
/
fmvipsetting
.
cpp
\
task
/
taskconfirmrecharge
.
cpp
HEADERS
+=
\
task
/
fmtask
.
h
\
...
...
@@ -74,7 +75,8 @@ HEADERS += \
windows
/
itemdelegate
.
h
\
fmprinter
.
h
\
fmsetting
.
h
\
windows
/
fmvipsetting
.
h
windows
/
fmvipsetting
.
h
\
task
/
taskconfirmrecharge
.
h
FORMS
+=
\
windows
/
forms
/
fmloading
.
ui
\
...
...
FMVip_LXJ/fmvipdispatcher.cpp
View file @
6c703210
#
include
<
QMenu
>
#include <QAction>
#include <QTimer>
#include <QJsonDocument>
#include <winsock2.h>
#include "fmvipdispatcher.h"
#include "fmtask.h"
#include "taskfactory.h"
#include "fmvipsetting.h"
#include "taskothers.h"
#include "fmprinter.h"
FMVipDispatcher
::
FMVipDispatcher
(
QObject
*
parent
)
:
QObject
(
parent
),
FMApiRelay
(),
_posSocketTimer
(
new
QTimer
(
this
)),
_confirmRechageTimer
(
new
QTimer
(
this
)),
fmTask
(
nullptr
)
{
connect
(
this
,
SIGNAL
(
doTask
()),
this
,
SLOT
(
onDoTask
()));
...
...
@@ -19,11 +23,15 @@ FMVipDispatcher::FMVipDispatcher(QObject *parent) :
connect
(
_posSocketTimer
,
SIGNAL
(
timeout
()),
SLOT
(
onCheckSocket
()));
connect
(
this
,
SIGNAL
(
startSocketTimer
()),
_posSocketTimer
,
SLOT
(
start
()));
connect
(
this
,
SIGNAL
(
stopSocketTimer
()),
_posSocketTimer
,
SLOT
(
stop
()));
connect
(
_confirmRechageTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
onConfirmRechageTimeOut
()));
_confirmRechageTimer
->
setSingleShot
(
true
);
}
FMVipDispatcher
::~
FMVipDispatcher
()
{
del_p
(
_posSocketTimer
);
del_p
(
_confirmRechageTimer
);
}
BOOL
FMVipDispatcher
::
Transfer
(
LPSTR
data
,
LPSTR
&
rsp
,
UINT
&
rsp_len
)
...
...
@@ -55,8 +63,56 @@ void FMVipDispatcher::onDoTask()
if
(
fmTask
==
nullptr
)
{
rspData
=
"{
\"
msg:
\"
:
\"
未知的请求类型
\"
}"
;
}
else
if
(
fmTask
->
FM_Type
()
==
FM_Confirm_Recharge
){
QJsonObject
rspObj
;
if
(
backupReqObj
.
empty
()
||
backupReqObj
[
PosProps
.
Fm_id
]
!=
fmTask
->
getPosJsonValue
(
PosProps
.
Fm_id
))
{
QString
msg
=
"未备份该充值订单或非码订单号不一致."
;
qDebug
()
<<
msg
;
rspObj
[
PosProps
.
RechargeStatus
]
=
FM_API_ERROR
;
rspObj
[
PosProps
.
Msg
]
=
msg
;
}
else
{
if
(
fmTask
->
getPosJsonValue
(
PosProps
.
RechargeStatus
).
toInt
()
==
FM_API_SUCCESS
)
{
QString
print
=
backupReqObj
[
PosProps
.
Print
].
toString
();
if
(
FMPrinter
::
Print
(
print
))
{
rspObj
[
PosProps
.
RechargeStatus
]
=
FM_API_SUCCESS
;
}
else
{
qDebug
()
<<
"打印小票失败."
;
rspObj
[
PosProps
.
RechargeStatus
]
=
FM_API_ERROR
;
rspObj
[
PosProps
.
Msg
]
=
"打印小票失败"
;
}
_confirmRechageTimer
->
stop
();
// 停止计时
}
else
{
qDebug
()
<<
"POS回执不正确,自动冲正上一笔充值."
;
rspObj
[
PosProps
.
RechargeStatus
]
=
fmTask
->
getPosJsonValue
(
PosProps
.
RechargeStatus
).
toInt
();
onConfirmRechageTimeOut
();
_confirmRechageTimer
->
stop
();
// 停止计时
}
}
rspObj
[
PosProps
.
StatusCode
]
=
FM_API_SUCCESS
;
rspObj
[
PosProps
.
Prompt
]
=
0
;
rspObj
[
PosProps
.
Fm_id
]
=
fmTask
->
getPosJsonValue
(
PosProps
.
Fm_id
).
toString
();
QJsonDocument
doc
(
rspObj
);
rspData
=
doc
.
toJson
(
QJsonDocument
::
Compact
);
backupReqObj
=
QJsonObject
();
}
else
{
rspData
=
fmTask
->
doTask
();
if
(
fmTask
->
FM_Type
()
==
FM_Manage
)
{
QJsonObject
posRspJsonObj
=
*
(
fmTask
->
getPosRspJsonObj
());
if
(
!
posRspJsonObj
.
empty
()
&&
posRspJsonObj
.
contains
(
PosProps
.
FundInfo
))
{
backupReqObj
=
*
(
fmTask
->
getPosReqJsonObj
());
backupReqObj
[
PosProps
.
TransId
]
=
fmTask
->
session
()
->
data
(
PosProps
.
TransId
).
toString
();
backupReqObj
[
PosProps
.
Fm_id
]
=
fmTask
->
session
()
->
data
(
PosProps
.
Fm_id
).
toString
();
backupReqObj
[
PosProps
.
Print
]
=
fmTask
->
session
()
->
data
(
PosProps
.
Print
).
toString
();
// 启动定时器,30秒后对该充值订单进行冲正
if
(
_confirmRechageTimer
->
isActive
())
{
onConfirmRechageTimeOut
();
_confirmRechageTimer
->
stop
();
}
_confirmRechageTimer
->
start
(
30000
);
}
}
}
qDebug
()
<<
"Send to pos: "
<<
QString
::
fromUtf8
(
rspData
);
qDebug
()
<<
"==============="
;
...
...
@@ -136,3 +192,16 @@ void FMVipDispatcher::onSetting()
FMVipSetting
settingWnd
;
settingWnd
.
exec
();
}
void
FMVipDispatcher
::
onConfirmRechageTimeOut
()
{
if
(
!
backupReqObj
.
empty
())
{
qDebug
()
<<
"冲正备份的请求:"
<<
backupReqObj
;
FMTask
*
reversalTask
=
new
TaskRefundOrder
(
backupReqObj
,
this
);
reversalTask
->
doTask
();
reversalTask
->
deleteLater
();
backupReqObj
=
QJsonObject
();
}
else
{
qDebug
()
<<
"备份的请求为空,未执行冲正."
;
}
}
FMVip_LXJ/fmvipdispatcher.h
View file @
6c703210
...
...
@@ -5,6 +5,7 @@
#include <QMutex>
#include <QWaitCondition>
#include <QSystemTrayIcon>
#include <QJsonObject>
#include "fmapirelay.h"
class
FMTask
;
...
...
@@ -27,8 +28,10 @@ private:
QSystemTrayIcon
_sysIcon
;
QTimer
*
_posSocketTimer
;
QTimer
*
_confirmRechageTimer
;
FMTask
*
fmTask
;
QJsonObject
backupReqObj
;
protected
:
BOOL
Transfer
(
LPSTR
data
,
LPSTR
&
rsp
,
UINT
&
rsp_len
);
...
...
@@ -44,6 +47,8 @@ public slots:
void
onCheckSocket
();
void
onDisconnected
();
void
onConfirmRechageTimeOut
();
};
#endif // FMVIPDISPATCHER_H
FMVip_LXJ/global.h
View file @
6c703210
...
...
@@ -15,6 +15,7 @@
// 请求类型链表
const
static
QStringList
FM_Type_List
=
QString
(
"member_manage_request,"
"confirm_recharge_request,"
"member_check_request,"
"order_request,"
"integral_request,"
...
...
@@ -22,6 +23,7 @@ const static QStringList FM_Type_List = QString(
// 服务端请求类型
const
static
QStringList
FM_Server_Type
=
QString
(
"member_manage_request,"
"order_rechargeprint_request,"
"member_check_request,"
"order_request,"
"integral_request,"
...
...
@@ -35,6 +37,7 @@ const static QStringList FM_Server_Type = QString(
// 请求类型的枚举值
enum
FM_TYPE
{
FM_Manage
,
FM_Confirm_Recharge
,
// 确认充值结果,获取打印信息
FM_Login
,
FM_Pay
,
FM_Final
,
...
...
@@ -158,6 +161,7 @@ struct{
const
QString
AfterValue
=
"after_value"
;
const
QString
FundInfo
=
"fund_info"
;
const
QString
Discount
=
"discount"
;
const
QString
RechargeStatus
=
"recharge_status"
;
// 卡激活锁定
const
QString
CardUUID
=
"CardUUID"
;
...
...
FMVip_LXJ/task/fmtask.h
View file @
6c703210
#ifndef FMTASK_H
#
ifndef
FMTASK_H
#define FMTASK_H
#include "fmvipwnd.h"
#include "fmmsgwnd.h"
...
...
@@ -30,6 +30,7 @@ public:
QJsonValue
getPosJsonValue
(
const
QString
prop
);
QString
createTransId
();
QJsonObject
*
getPosReqJsonObj
()
{
return
&
posReqJsonObj
;}
QJsonObject
*
getPosRspJsonObj
()
{
return
&
posRspJsonObj
;}
protected
:
...
...
FMVip_LXJ/task/taskconfirmrecharge.cpp
0 → 100644
View file @
6c703210
#
include
"taskconfirmrecharge.h"
TaskConfirmRecharge
::
TaskConfirmRecharge
(
QJsonObject
&
jsonObj
,
QObject
*
parent
)
:
FMTaskNoWnd
(
jsonObj
,
FM_Confirm_Recharge
,
0
,
parent
)
{
}
void
TaskConfirmRecharge
::
packageServerReq
()
{
}
void
TaskConfirmRecharge
::
packagePOSRsp
()
{
}
FMVip_LXJ/task/taskconfirmrecharge.h
0 → 100644
View file @
6c703210
#
ifndef
TASKCONFIRMRECHARGE_H
#define TASKCONFIRMRECHARGE_H
#include "fmtasknownd.h"
// 整单退款
class
TaskConfirmRecharge
:
public
FMTaskNoWnd
{
Q_OBJECT
public
:
explicit
TaskConfirmRecharge
(
QJsonObject
&
jsonObj
,
QObject
*
parent
=
0
);
void
packageServerReq
();
void
packagePOSRsp
();
};
#endif // TASKCONFIRMRECHARGE_H
FMVip_LXJ/task/taskfactory.cpp
View file @
6c703210
#include "taskfactory.h"
#
include
"taskfactory.h"
#include "tasklogin.h"
#include "taskpay.h"
#include "taskmanage.h"
#include "taskfinal.h"
#include "taskothers.h"
#include "taskconfirmrecharge.h"
#include "global.h"
#include "fmmsgwnd.h"
#include <QJsonDocument>
...
...
@@ -51,6 +52,10 @@ FMTask* TaskFactory::Task(QByteArray data)
task
=
new
TaskRefundOrder
(
jsonObj
);
break
;
}
case
FM_Confirm_Recharge
:
{
task
=
new
TaskConfirmRecharge
(
jsonObj
);
break
;
}
default
:
break
;
}
...
...
FMVip_LXJ/task/taskfund.cpp
View file @
6c703210
...
...
@@ -2,7 +2,6 @@
#include "fmvipfund.h"
#include "tasklogin.h"
#include "taskothers.h"
#include "fmprinter.h"
#include <QDateTime>
TaskFund
::
TaskFund
(
QJsonObject
&
jsonObj
,
Session
*
session
,
QObject
*
parent
)
...
...
@@ -65,6 +64,7 @@ void TaskFund::onFund()
posReqJsonObj
[
PosProps
.
TransId
]
=
serverReqJsonObj
[
ServerProps
(
PosProps
.
TransId
)];
FMTask
*
reversalTask
=
new
TaskRefundOrder
(
posReqJsonObj
,
this
);
reversalTask
->
doTask
();
reversalTask
->
deleteLater
();
}
QString
msg
=
"充值失败:
\n
"
+
errorString
();
FMMsgWnd
::
FailureWnd
(
msg
);
...
...
@@ -72,8 +72,9 @@ void TaskFund::onFund()
QString
msg
=
"充值失败:
\n
"
+
getServerJsonValue
(
PosProps
.
Msg
).
toString
();
FMMsgWnd
::
FailureWnd
(
msg
);
}
else
{
QString
print
=
getServerJsonValue
(
PosProps
.
Print
).
toString
();
FMPrinter
::
Print
(
print
);
session
()
->
addData
(
PosProps
.
Fm_id
,
getServerJsonValue
(
PosProps
.
Fm_id
));
session
()
->
addData
(
PosProps
.
Print
,
getServerJsonValue
(
PosProps
.
Print
));
session
()
->
addData
(
PosProps
.
TransId
,
getServerJsonValue
(
PosProps
.
TransId
));
int
before_value
=
getServerJsonValue
(
PosProps
.
BeforeValue
).
toInt
();
int
after_value
=
getServerJsonValue
(
PosProps
.
AfterValue
).
toInt
();
QString
before_value_str
=
DOUBLE_STR
(
before_value
/
100.0
);
...
...
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