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
xiaojing.zhang
fmp_vip
Commits
6be36ff2
Commit
6be36ff2
authored
Jul 28, 2017
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
插件更新
parent
88afe087
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
53 additions
and
81 deletions
+53
-81
fmnetwork.cpp
+1
-0
fmp_ve_handlers.cpp
+3
-4
fmp_ve_handlers.h
+1
-4
fmp_vip.cpp
+4
-6
fmp_vip.h
+5
-2
fmp_vip_i.h
+2
-2
fmp_vip_p.cpp
+4
-5
fmp_vip_p.h
+2
-2
fmp_vip_server.cpp
+2
-5
fmp_vip_server.h
+0
-2
fmp_vip_settings.cpp
+6
-6
fmp_vip_settings.h
+2
-2
fmvipdispatcher.cpp
+21
-38
fmvipdispatcher.h
+0
-3
No files found.
fmnetwork.cpp
View file @
6be36ff2
...
...
@@ -54,6 +54,7 @@ int FMNetwork::send(const QString &url, const QByteArray &reqData, QByteArray &r
rspData
=
reply
->
readAll
();
}
else
{
int
err
=
reply
->
error
();
rspData
=
reply
->
readAll
();
error
=
FM_API_NETWORERROR
;
errorMsg
=
netErrInfo
(
err
);
}
...
...
fmp_ve_handlers.cpp
View file @
6be36ff2
...
...
@@ -2,14 +2,13 @@
#include "fmp_ve_handlers.h"
#include "fmp_vip.h"
FMPStartEventHandler
::
FMPStartEventHandler
(
ctkPluginContext
*
ctx
,
FMPVip
*
vip
)
FMPStartEventHandler
::
FMPStartEventHandler
(
FMPVip
*
vip
)
:
FMPVipEventHandler
(
FMP_TOPICS_SERVICES
FMPE_SERVICE_ACK_START
"/"
+
QString
::
number
(
ctx
->
getPlugin
()
->
getPluginId
()),
vip
),
_ctx
(
ctx
)
+
QString
::
number
(
vip
->
GetPluginId
()),
vip
)
{
FMPProps
props
;
props
[
ctkEventConstants
::
EVENT_TOPIC
]
=
_topic
;
_ctx
->
r
egisterService
<
ctkEventHandler
>
(
this
,
props
);
FMP
::
R
egisterService
<
ctkEventHandler
>
(
this
,
props
);
}
...
...
fmp_ve_handlers.h
View file @
6be36ff2
...
...
@@ -27,11 +27,8 @@ class FMPStartEventHandler : public QObject, public FMPVipEventHandler
Q_OBJECT
Q_INTERFACES
(
ctkEventHandler
)
public
:
explicit
FMPStartEventHandler
(
ctkPluginContext
*
ctx
,
FMPVip
*
vip
);
explicit
FMPStartEventHandler
(
FMPVip
*
vip
);
void
handleEvent
(
const
ctkEvent
&
event
);
private
:
ctkPluginContext
*
_ctx
;
};
#endif // FMP_MANAGER_EVENT_HANDLERS_H
fmp_vip.cpp
View file @
6be36ff2
#
include
"fmp_vip_p.h"
#include "fmp_ve_handlers.h"
class
ctkPluginContext
;
FMPVip
::
FMPVip
(
ctkPluginContext
*
context
)
:
FMPVipInterface
(
context
),
FMPVip
::
FMPVip
(
const
FMPContext
ctx
)
:
FMPVipInterface
(),
context
(
ctx
),
_inited
(
false
),
d_ptr
(
new
FMPVipPrivate
(
this
))
{
FMPStartEventHandler
*
handler
=
new
FMPStartEventHandler
(
_ctx
,
this
);
FMPLoggerInterface
::
InitContext
(
context
);
FMPStartEventHandler
*
handler
=
new
FMPStartEventHandler
(
this
);
}
FMPVip
::~
FMPVip
()
...
...
fmp_vip.h
View file @
6be36ff2
...
...
@@ -14,15 +14,18 @@ class FMPVip : public FMPVipInterface
Q_DECLARE_PRIVATE
(
FMPVip
)
public
:
explicit
FMPVip
(
c
tkPluginContext
*
context
);
explicit
FMPVip
(
c
onst
FMPContext
ctx
);
virtual
~
FMPVip
();
protected
:
const
FMPContext
GetContext
()
const
{
return
context
;
}
protected
:
void
InitService
();
void
UninitService
();
private
:
bool
_inited
;
FMPVipPrivate
*
d_ptr
;
FMPVipPrivate
*
d_ptr
;
const
FMPContext
context
;
};
#endif // FMP_VIP_H
fmp_vip_i.h
View file @
6be36ff2
...
...
@@ -13,7 +13,7 @@ class FMPVipInterface : public QObject, public FMPluginInterface
Q_INTERFACES
(
FMPBaseInterface
)
Q_INTERFACES
(
FMPluginInterface
)
public
:
explicit
FMPVipInterface
(
ctkPluginContext
*
ctx
)
:
FMPluginInterface
(
ctx
)
explicit
FMPVipInterface
(
)
:
FMPluginInterface
(
)
{
connect
(
this
,
&
FMPVipInterface
::
TriggerInit
,
this
,
&
FMPVipInterface
::
OnTriggerInit
);
connect
(
this
,
&
FMPVipInterface
::
TriggerUninit
,
this
,
&
FMPVipInterface
::
OnTriggerUninit
);
...
...
@@ -28,7 +28,7 @@ protected slots:
void
OnTriggerUninit
()
{
FMPluginInterface
::
OnTriggerUninit
();
}
};
Q_DECLARE_INTERFACE
(
FMPVipInterface
,
"
com.
fmp.vip"
)
Q_DECLARE_INTERFACE
(
FMPVipInterface
,
"fmp.vip"
)
#endif // FMP_LOGGER_I_H
fmp_vip_p.cpp
View file @
6be36ff2
...
...
@@ -3,7 +3,6 @@
#include <fmp_home_i.h>
#include <QCoreApplication>
#include <QDateTime>
#include <ctkPluginContext.h>
#include <ctkServiceReference.h>
#include "fmp_vip_server.h"
#include "fmp_vip_settings.h"
...
...
@@ -19,16 +18,16 @@ FMPVipPrivate::FMPVipPrivate(FMPVip *vip):
int
FMPVipPrivate
::
Init
()
{
Q_Q
(
FMPVip
);
FMPHomeInterface
*
home
=
q
->
GetService
<
FMPHomeInterface
>
(
q
->
_ctx
);
FMPHomeInterface
*
home
=
FMP
::
GetService
<
FMPHomeInterface
>
(
);
if
(
q
->
_inited
)
{
home
->
notification
(
QString
::
fromLocal8Bit
(
"[非码POS插件]已在运行!"
));
}
else
{
_settings
=
q
->
GetService
<
FMPSettingsInterface
>
(
q
->
_ctx
);
FMPVipSettings
::
instance
()
->
init
(
_
settings
);
settings
=
FMP
::
GetService
<
FMPSettingsInterface
>
(
);
FMPVipSettings
::
instance
()
->
init
(
settings
);
auto
resend
=
new
ReSend
();
resend
->
start
();
FMPVipServer
::
instance
()
->
SetPluginContext
(
q
->
_ctx
)
;
FMPVipServer
::
instance
();
q
->
_inited
=
true
;
...
...
fmp_vip_p.h
View file @
6be36ff2
...
...
@@ -17,9 +17,9 @@ public:
int
Uninit
();
public
:
FMPVip
*
q_ptr
;
FMPVip
*
q_ptr
;
private
:
FMPSettingsInterface
*
_
settings
;
FMPSettingsInterface
*
settings
;
};
#endif // FMP_VIP_P_H
fmp_vip_server.cpp
View file @
6be36ff2
...
...
@@ -33,11 +33,6 @@ void FMPVipServer::Write(const QByteArray &data)
}
}
void
FMPVipServer
::
SetPluginContext
(
ctkPluginContext
*
ctx
)
{
dispatcher
->
setPluginContext
(
ctx
);
}
void
FMPVipServer
::
onNewConnection
()
{
socket
=
nextPendingConnection
();
...
...
@@ -78,6 +73,7 @@ void FMPVipServer::SendToMonitor(const QByteArray &data)
{
QTcpSocket
client
;
FMP_INFO
()
<<
"SendToMonitor to pos: "
<<
data
;
int
jsonLength
=
data
.
length
();
char
*
m_pFmPackage
=
new
char
[
jsonLength
+
sizeof
(
FMSOCKEHEADER
)];
FMSOCKEHEADER
header
=
{
0
,
0
,
0
};
...
...
@@ -109,4 +105,5 @@ void FMPVipServer::SendToMonitor(const QByteArray &data)
FMP_DEBUG
()
<<
"socket 连接失败!"
;
}
client
.
close
();
delete
[]
m_pFmPackage
;
}
fmp_vip_server.h
View file @
6be36ff2
...
...
@@ -6,7 +6,6 @@
#define FMSOCKFLAG 0x4d46
class
FMVipDispatcher
;
class
ctkPluginContext
;
typedef
struct
{
int
flag
;
...
...
@@ -22,7 +21,6 @@ public:
void
Listen
(
quint16
port
);
void
Write
(
const
QByteArray
&
data
);
void
SetPluginContext
(
ctkPluginContext
*
ctx
);
//signals:
private
slots
:
void
onNewConnection
();
...
...
fmp_vip_settings.cpp
View file @
6be36ff2
...
...
@@ -12,9 +12,9 @@ FMPVipSettings *FMPVipSettings::instance()
return
&
vipSettings
;
}
void
FMPVipSettings
::
init
(
FMPSettingsInterface
*
settings
)
void
FMPVipSettings
::
init
(
FMPSettingsInterface
*
svc
)
{
this
->
_settings
=
settings
;
this
->
settings
=
svc
;
}
QString
FMPVipSettings
::
getServerUrl
()
...
...
@@ -24,8 +24,8 @@ QString FMPVipSettings::getServerUrl()
QVariant
FMPVipSettings
::
_GetValue
(
const
QString
&
key
,
QVariant
defaultValue
)
{
if
(
_
settings
)
{
return
_
settings
->
GetValue
(
key
);
if
(
settings
)
{
return
settings
->
GetValue
(
key
);
}
else
{
FMP_WARN
()
<<
"Settings service not available"
;
...
...
@@ -36,8 +36,8 @@ QVariant FMPVipSettings::_GetValue(const QString &key, QVariant defaultValue)
bool
FMPVipSettings
::
_SetValue
(
const
QString
&
key
,
QVariant
value
)
{
if
(
_
settings
)
{
_
settings
->
SetValue
(
key
,
value
);
if
(
settings
)
{
settings
->
SetValue
(
key
,
value
);
return
true
;
}
else
{
...
...
fmp_vip_settings.h
View file @
6be36ff2
...
...
@@ -12,7 +12,7 @@ class FMPVipSettings : public QObject
Q_OBJECT
public
:
static
FMPVipSettings
*
instance
();
void
init
(
FMPSettingsInterface
*
s
ettings
);
void
init
(
FMPSettingsInterface
*
s
vc
);
QString
getServerUrl
();
...
...
@@ -23,7 +23,7 @@ private:
bool
_SetValue
(
const
QString
&
key
,
QVariant
value
);
private
:
FMPSettingsInterface
*
_
settings
;
FMPSettingsInterface
*
settings
;
};
#endif // FMP_VIP_SETTINGS_H
fmvipdispatcher.cpp
View file @
6be36ff2
...
...
@@ -10,16 +10,15 @@
#include "fmp_vip_server.h"
#include "tasklogin.h"
#include "taskpay.h"
#include "taskothers.h"
#include "taskfinal.h"
#include <ctkPluginContext.h>
#undef StartService
#include <fmp_epay_i.h>
FMVipDispatcher
::
FMVipDispatcher
(
QObject
*
parent
)
:
QObject
(
parent
),
fmTask
(
nullptr
),
_ctx
(
nullptr
)
fmTask
(
nullptr
)
{
}
...
...
@@ -49,32 +48,29 @@ void FMVipDispatcher::doTask(const QByteArray &reqData, QByteArray &rspData)
rspData
=
taskPay
.
doTask
();
break
;
}
case
FM_QR_Pay
:
{
if
(
_ctx
)
{
ctkServiceReference
ref
=
_ctx
->
getServiceReference
<
FMPePayInterface
>
();
FMPePayInterface
*
epay
=
_ctx
->
getService
<
FMPePayInterface
>
(
ref
);
epay
->
DockPayRequest
(
reqData
);
epay
->
StartService
();
rspData
=
epay
->
DockPayRespond
();
epay
->
StopService
();
}
else
{
rspData
=
QString
::
fromLocal8Bit
(
"{
\"
msg:
\"
:
\"
支付服务不可用
\"
}"
).
toUtf8
();
}
FMPePayInterface
*
epay
=
FMP
::
GetService
<
FMPePayInterface
>
();
epay
->
DockPayRequest
(
reqData
);
epay
->
StartService
();
rspData
=
epay
->
DockPayRespond
();
break
;
}
case
FM_Order_Refund
:
{
// TaskRefundOrder taskRefundOrder(jsonObj);
// rspData = taskRefundOrder.doTask();
break
;
}
case
FM_Order_Revoke
:
{
// TaskRefundPay taskRefundPay(jsonObj);
// rspData = taskRefundPay.doTask();
break
;
}
case
FM_QR_Refund
:
{
if
(
_ctx
)
{
ctkServiceReference
ref
=
_ctx
->
getServiceReference
<
FMPePayInterface
>
();
FMPePayInterface
*
epay
=
_ctx
->
getService
<
FMPePayInterface
>
(
ref
);
epay
->
DockRefundRequest
(
reqData
);
epay
->
StartService
();
rspData
=
epay
->
DockRefundRespond
();
epay
->
StopService
();
}
else
{
rspData
=
QString
::
fromLocal8Bit
(
"{
\"
msg:
\"
:
\"
退款服务不可用
\"
}"
).
toUtf8
();
}
FMPePayInterface
*
epay
=
FMP
::
GetService
<
FMPePayInterface
>
();
epay
->
DockRefundRequest
(
reqData
);
epay
->
StartService
();
rspData
=
epay
->
DockRefundRespond
();
break
;
}
case
FM_Final
:
{
...
...
@@ -90,16 +86,3 @@ void FMVipDispatcher::doTask(const QByteArray &reqData, QByteArray &rspData)
FMP_INFO
()
<<
"Send to pos: "
<<
rspData
;
}
void
FMVipDispatcher
::
setPluginContext
(
ctkPluginContext
*
ctx
)
{
if
(
ctx
&&
_ctx
!=
ctx
)
{
try
{
//! Verify pointer
ctx
->
getPlugin
();
_ctx
=
ctx
;
}
catch
(
const
ctkException
&
)
{
FMP_ERROR
()
<<
"Invalid context:"
<<
ctx
;
}
}
}
fmvipdispatcher.h
View file @
6be36ff2
...
...
@@ -8,7 +8,6 @@
class
FMTask
;
class
FMPVipServer
;
class
ctkPluginContext
;
class
FMVipDispatcher
:
public
QObject
/*, public FMApiRelay*/
{
...
...
@@ -19,11 +18,9 @@ public:
void
doTask
(
const
QByteArray
&
reqData
,
QByteArray
&
rspData
);
void
setPluginContext
(
ctkPluginContext
*
ctx
);
private
:
FMTask
*
fmTask
;
ctkPluginContext
*
_ctx
;
};
#endif // FMVIPDISPATCHER_H
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