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
ed18036b
Commit
ed18036b
authored
Sep 20, 2017
by
gujin.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初步完成大鼓米线会员支付功能
parent
3193ea90
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
263 additions
and
119 deletions
+263
-119
fmp_vip.pro
+0
-0
fmp_vip_server.cpp
+40
-9
fmp_vip_server.h
+1
-2
global.h
+9
-6
task/fmtask.cpp
+33
-15
task/fmtask.h
+3
-2
task/taskfinal.cpp
+15
-36
task/taskfinal.h
+2
-2
task/tasklogin.cpp
+6
-1
task/taskothers.cpp
+23
-18
task/taskpay.cpp
+113
-23
task/taskpay.h
+1
-0
windows/forms/fmviporder.ui
+17
-5
No files found.
fmp_vip.pro
View file @
ed18036b
fmp_vip_server.cpp
View file @
ed18036b
...
@@ -29,9 +29,43 @@ void FMPVipServer::Listen(quint16 port)
...
@@ -29,9 +29,43 @@ void FMPVipServer::Listen(quint16 port)
void
FMPVipServer
::
Write
(
const
QByteArray
&
data
)
void
FMPVipServer
::
Write
(
const
QByteArray
&
data
)
{
{
if
(
!
socket
||
socket
->
write
(
data
)
==
-
1
)
{
qDebug
()
<<
data
;
FMP_ERROR
()
<<
"Write error: "
<<
(
socket
?
socket
->
errorString
()
:
"connection closed."
);
QTcpSocket
client
;
//client.connectToHost("172.16.13.191", 23771);
client
.
connectToHost
(
"127.0.0.1"
,
23771
);
if
(
!
client
.
waitForConnected
())
{
FMP_ERROR
()
<<
"Connect monitor failed. "
<<
client
.
errorString
();
return
;
}
//添加消息头
FMSOCKEHEADER
header
=
{
0
,
0
,
0
};
header
.
flag
=
FMSOCKFLAG
;
header
.
ver
=
0x2
;
header
.
len
=
data
.
length
();
int
len
=
sizeof
(
FMSOCKEHEADER
)
+
data
.
length
();
char
*
reply
=
new
char
[
len
];
memset
(
reply
,
0
,
len
);
memcpy
(
reply
,
&
header
,
sizeof
(
header
));
memcpy
(
reply
+
sizeof
(
header
),
data
.
data
(),
data
.
length
());
if
(
client
.
write
(
reply
,
len
)
==
-
1
)
{
FMP_ERROR
()
<<
"Write error: "
<<
client
.
errorString
();
return
;
}
}
if
(
!
client
.
waitForBytesWritten
())
{
FMP_ERROR
()
<<
"Write failed: "
<<
client
.
errorString
();
}
client
.
disconnectFromHost
();
if
(
client
.
state
()
==
QAbstractSocket
::
ConnectedState
)
client
.
waitForDisconnected
();
client
.
close
();
delete
[]
reply
;
reply
=
nullptr
;
}
}
void
FMPVipServer
::
SetPluginContext
(
ctkPluginContext
*
ctx
)
void
FMPVipServer
::
SetPluginContext
(
ctkPluginContext
*
ctx
)
...
@@ -50,15 +84,17 @@ void FMPVipServer::onNewConnection()
...
@@ -50,15 +84,17 @@ void FMPVipServer::onNewConnection()
void
FMPVipServer
::
onDisconnected
()
void
FMPVipServer
::
onDisconnected
()
{
{
FMP_DEBUG
()
<<
"Socket disconnected."
;
FMP_DEBUG
()
<<
"Socket disconnected."
;
socket
->
close
();
}
}
void
FMPVipServer
::
onReadyRead
()
void
FMPVipServer
::
onReadyRead
()
{
{
QByteArray
recvData
=
socket
->
readAll
();
QByteArray
recvData
=
socket
->
readAll
();
socket
->
close
();
socket
->
deleteLater
();
socket
=
nullptr
;
if
(
isNeedSocketHeader
)
{
if
(
isNeedSocketHeader
)
{
FMSOCKEHEADER
header
=
{
0
};
FMSOCKEHEADER
header
=
{
0
,
0
,
0
};
memcpy
(
&
header
,
recvData
.
data
(),
sizeof
(
FMSOCKEHEADER
));
memcpy
(
&
header
,
recvData
.
data
(),
sizeof
(
FMSOCKEHEADER
));
if
(
header
.
flag
!=
FMSOCKFLAG
)
{
if
(
header
.
flag
!=
FMSOCKFLAG
)
{
FMP_WARN
()
<<
"Incompatible protocol."
;
FMP_WARN
()
<<
"Incompatible protocol."
;
...
@@ -71,9 +107,4 @@ void FMPVipServer::onReadyRead()
...
@@ -71,9 +107,4 @@ void FMPVipServer::onReadyRead()
dispatcher
->
doTask
(
recvData
,
rspData
);
dispatcher
->
doTask
(
recvData
,
rspData
);
Write
(
rspData
);
Write
(
rspData
);
socket
->
waitForBytesWritten
();
socket
->
close
();
socket
->
deleteLater
();
socket
=
nullptr
;
}
}
fmp_vip_server.h
View file @
ed18036b
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
#define FMP_VIP_SERVER_H
#define FMP_VIP_SERVER_H
#include <QTcpServer>
#include <QTcpServer>
#define FMSOCKFLAG 0x4d46
#define FMSOCKFLAG 0x4d46
class
FMVipDispatcher
;
class
FMVipDispatcher
;
...
@@ -23,7 +22,7 @@ public:
...
@@ -23,7 +22,7 @@ public:
void
Write
(
const
QByteArray
&
data
);
void
Write
(
const
QByteArray
&
data
);
void
SetPluginContext
(
ctkPluginContext
*
ctx
);
void
SetPluginContext
(
ctkPluginContext
*
ctx
);
//signals:
private
slots
:
private
slots
:
void
onNewConnection
();
void
onNewConnection
();
void
onDisconnected
();
void
onDisconnected
();
...
...
global.h
View file @
ed18036b
...
@@ -11,12 +11,15 @@
...
@@ -11,12 +11,15 @@
//#define KEY_CODE "a35e33c8-e6f2-4107-8670-a69a85adf85b"
//#define KEY_CODE "a35e33c8-e6f2-4107-8670-a69a85adf85b"
//#define PARTNER_ID "f92b8997-40c7-4622-af3b-512fd49d6113"
//#define PARTNER_ID "f92b8997-40c7-4622-af3b-512fd49d6113"
////! 一茶一座
//! 一茶一座
#define APP_ID "T014"
//#define APP_ID "T014"
#define KEY_CODE "a440d553-87d3-4fcd-b59a-5ec9ce7c4157"
//#define KEY_CODE "a440d553-87d3-4fcd-b59a-5ec9ce7c4157"
#define PARTNER_ID "df2f90b0-eece-402c-820d-ba8ac56c4687"
//#define PARTNER_ID "df2f90b0-eece-402c-820d-ba8ac56c4687"
//! 大鼓米线
#define APP_ID "T017"
#define KEY_CODE "838cd505-1a97-43b3-b521-3b37caa0ab1a"
#define PARTNER_ID "fcce79cf-ba55-4ff8-bde4-684ca26c0ff0"
// 请求类型的枚举值
// 请求类型的枚举值
enum
FM_TYPE
{
enum
FM_TYPE
{
...
...
task/fmtask.cpp
View file @
ed18036b
...
@@ -106,20 +106,16 @@ bool FMTask::sendToServer(bool isShowMsg)
...
@@ -106,20 +106,16 @@ bool FMTask::sendToServer(bool isShowMsg)
serverReqJsonObj
[
PosProps
.
AppId
]
=
APP_ID
;
serverReqJsonObj
[
PosProps
.
AppId
]
=
APP_ID
;
serverReqJsonObj
[
PosProps
.
PartnerId
]
=
PARTNER_ID
;
serverReqJsonObj
[
PosProps
.
PartnerId
]
=
PARTNER_ID
;
serverReqJsonObj
[
PosProps
.
T
]
=
QString
::
number
(
QDateTime
::
currentMSecsSinceEpoch
());
serverReqJsonObj
[
PosProps
.
T
]
=
QString
::
number
(
QDateTime
::
currentMSecsSinceEpoch
());
serverReqJsonObj
[
ServerProps
(
PosProps
.
Fm_cmd
)]
=
QString
::
number
(
FM_Type
());
serverReqJsonObj
[
ServerProps
(
PosProps
.
Fm_cmd
)]
=
QString
::
number
(
FM_Type
());
serverReqJsonObj
[
PosProps
.
Sign
]
=
sign
();
packageServerReq
();
packageServerReq
();
serverReqJsonObj
[
PosProps
.
Sign
]
=
sign
();
QJsonDocument
json
(
serverReqJsonObj
);
QJsonDocument
json
(
serverReqJsonObj
);
QByteArray
data
=
json
.
toJson
(
QJsonDocument
::
Compact
);
QByteArray
data
=
json
.
toJson
(
QJsonDocument
::
Compact
);
url
=
FMPVipSettings
::
instance
()
->
getServerUrl
()
+
"/"
+
ReqUrl
.
at
(
FM_Type
());
url
=
FMPVipSettings
::
instance
()
->
getServerUrl
()
+
"/"
+
ReqUrl
.
at
(
FM_Type
());
// if(FM_Type() == FM_Coupon) {
// url = "http://172.16.16.42:8732/pos/member/ordercoupon";
// }
QByteArray
rspData
;
QByteArray
rspData
;
FMNetwork
net
;
FMNetwork
net
;
net
.
send
(
url
,
data
,
rspData
);
net
.
send
(
url
,
data
,
rspData
);
...
@@ -150,7 +146,7 @@ bool FMTask::sendToServer(bool isShowMsg)
...
@@ -150,7 +146,7 @@ bool FMTask::sendToServer(bool isShowMsg)
}
}
bool
isOk
=
(
error
()
==
FM_API_SUCCESS
);
bool
isOk
=
(
error
()
==
FM_API_SUCCESS
);
if
(
!
isOk
&&
isShowMsg
)
if
(
!
isOk
&&
isShowMsg
&&
FM_Type
()
!=
FM_Coupon
)
{
{
FMMsgWnd
::
FailureWnd
(
errorString
(),
_window
);
FMMsgWnd
::
FailureWnd
(
errorString
(),
_window
);
}
}
...
@@ -158,32 +154,54 @@ bool FMTask::sendToServer(bool isShowMsg)
...
@@ -158,32 +154,54 @@ bool FMTask::sendToServer(bool isShowMsg)
return
isOk
;
return
isOk
;
}
}
QJsonValue
FMTask
::
searchJson
Value
(
QJsonObject
&
searchJson
,
QString
searchKey
)
QJsonValue
FMTask
::
searchJson
Object
(
QJsonObject
&
searchJson
,
QString
searchKey
)
{
{
QJsonValue
value
;
if
(
searchJson
.
contains
(
searchKey
))
{
if
(
searchJson
.
contains
(
searchKey
))
{
return
searchJson
[
searchKey
];
value
=
searchJson
[
searchKey
];
}
else
{
}
else
{
foreach
(
QString
key
,
searchJson
.
keys
())
{
foreach
(
QString
key
,
searchJson
.
keys
())
{
if
(
searchJson
[
key
].
isObject
())
{
if
(
searchJson
[
key
].
isObject
())
{
QJsonObject
ob
=
searchJson
[
key
].
toObject
();
QJsonObject
ob
=
searchJson
[
key
].
toObject
();
QJsonValue
value
=
searchJsonValue
(
ob
,
searchKey
);
value
=
searchJsonObject
(
ob
,
searchKey
);
if
(
!
value
.
isNull
()){
}
return
value
;
else
if
(
searchJson
[
key
].
isArray
())
{
QJsonArray
arr
=
searchJson
[
key
].
toArray
();
value
=
searchJsonArray
(
arr
,
searchKey
);
}
}
}
}
}
return
value
;
}
QJsonValue
FMTask
::
searchJsonArray
(
QJsonArray
&
searchJson
,
QString
searchKey
)
{
QJsonValue
value
;
for
(
int
i
=
0
;
i
<
searchJson
.
size
();
i
++
)
{
if
(
searchJson
[
i
].
isObject
())
{
QJsonObject
ob
=
searchJson
[
i
].
toObject
();
value
=
searchJsonObject
(
ob
,
searchKey
);
}
else
if
(
searchJson
[
i
].
isArray
())
{
QJsonArray
arr
=
searchJson
[
i
].
toArray
();
value
=
searchJsonArray
(
arr
,
searchKey
);
}
}
}
}
return
QJsonValue
()
;
return
value
;
}
}
QJsonValue
FMTask
::
getServerJsonValue
(
const
QString
prop
)
QJsonValue
FMTask
::
getServerJsonValue
(
const
QString
prop
)
{
{
return
searchJson
Value
(
serverRspJsonObj
,
ServerProps
(
prop
));
return
searchJson
Object
(
serverRspJsonObj
,
ServerProps
(
prop
));
}
}
QJsonValue
FMTask
::
getPosJsonValue
(
const
QString
prop
)
QJsonValue
FMTask
::
getPosJsonValue
(
const
QString
prop
)
{
{
return
searchJson
Value
(
posReqJsonObj
,
prop
);
return
searchJson
Object
(
posReqJsonObj
,
prop
);
}
}
QString
FMTask
::
sign
()
const
QString
FMTask
::
sign
()
const
...
...
task/fmtask.h
View file @
ed18036b
...
@@ -23,7 +23,8 @@ public:
...
@@ -23,7 +23,8 @@ public:
Session
*
session
()
const
{
return
_session
;}
Session
*
session
()
const
{
return
_session
;}
QJsonValue
searchJsonValue
(
QJsonObject
&
searchJson
,
QString
searchKey
);
QJsonValue
searchJsonObject
(
QJsonObject
&
searchJson
,
QString
searchKey
);
QJsonValue
searchJsonArray
(
QJsonArray
&
searchJson
,
QString
searchKey
);
QJsonValue
getServerJsonValue
(
const
QString
prop
);
QJsonValue
getServerJsonValue
(
const
QString
prop
);
QJsonValue
getPosJsonValue
(
const
QString
prop
);
QJsonValue
getPosJsonValue
(
const
QString
prop
);
...
@@ -50,7 +51,7 @@ protected:
...
@@ -50,7 +51,7 @@ protected:
FMTask
*
preTask
;
FMTask
*
preTask
;
pr
ivate
:
pr
otected
:
QString
sign
()
const
;
QString
sign
()
const
;
/**
/**
...
...
task/taskfinal.cpp
View file @
ed18036b
...
@@ -14,6 +14,15 @@ TaskFinal::TaskFinal(QJsonObject &jsonObj, Session *session, QObject *parent)
...
@@ -14,6 +14,15 @@ TaskFinal::TaskFinal(QJsonObject &jsonObj, Session *session, QObject *parent)
{
{
}
}
QByteArray
TaskFinal
::
doTask
()
{
serverReqJsonObj
=
posReqJsonObj
;
sendToServer
(
false
);
packagePOSRsp
();
QJsonDocument
json
(
posRspJsonObj
);
return
json
.
toJson
(
QJsonDocument
::
Compact
);
}
void
TaskFinal
::
packageServerReq
()
void
TaskFinal
::
packageServerReq
()
{
{
isUseVipPay
=
false
;
isUseVipPay
=
false
;
...
@@ -36,33 +45,14 @@ void TaskFinal::packageServerReq()
...
@@ -36,33 +45,14 @@ void TaskFinal::packageServerReq()
int
price
=
p
.
toObject
()[
"price"
].
toInt
();
int
price
=
p
.
toObject
()[
"price"
].
toInt
();
product
[
"price"
]
=
price
;
product
[
"price"
]
=
price
;
product
[
"productId"
]
=
p
.
toObject
()[
"pid"
];
product
[
"productId"
]
=
p
.
toObject
()[
"pid"
];
product
[
"disAmount"
]
=
p
.
toObject
()[
"dis_amount"
].
toInt
();
products
.
append
(
product
);
products
.
append
(
product
);
}
}
transData
[
"productList"
]
=
products
;
transData
[
"productList"
]
=
products
;
int
orderAmount
=
getPosJsonValue
(
PosProps
.
OrderAmount
).
toInt
();
transData
[
"totalAmount"
]
=
getPosJsonValue
(
PosProps
.
OrderAmount
).
toInt
();
int
paidAmount
=
getPosJsonValue
(
PosProps
.
PaidAmount
).
toInt
();
transData
[
"payAmount"
]
=
getPosJsonValue
(
PosProps
.
PaidAmount
).
toInt
();
QJsonArray
payList
;
QJsonArray
payList
;
QString
fmId
=
getPosJsonValue
(
PosProps
.
Fm_id
).
toString
();
QByteArray
orderContent
=
FMBackup
::
instance
()
->
getOrderByFmId
(
fmId
);
QJsonObject
orderObject
=
QJsonDocument
::
fromJson
(
orderContent
).
object
();
QJsonArray
payArray
=
searchJsonValue
(
orderObject
,
"payList"
).
toArray
();
foreach
(
auto
pay_v
,
payArray
)
{
QJsonObject
pay_ob
=
pay_v
.
toObject
();
if
(
pay_ob
[
"typeModeFlag"
].
toString
()
==
"20003"
)
{
payList
.
append
(
pay_ob
);
isUseVipPay
=
true
;
int
pay_amount
=
pay_ob
[
"amount"
].
toInt
();
orderAmount
+=
pay_amount
;
paidAmount
+=
pay_amount
;
}
}
transData
[
ServerProps
(
PosProps
.
OrderAmount
)]
=
orderAmount
;
transData
[
ServerProps
(
PosProps
.
PaidAmount
)]
=
paidAmount
;
foreach
(
auto
p
,
getPosJsonValue
(
PosProps
.
Pay_ids
).
toArray
())
foreach
(
auto
p
,
getPosJsonValue
(
PosProps
.
Pay_ids
).
toArray
())
{
{
QJsonObject
pay
;
QJsonObject
pay
;
...
@@ -71,28 +61,14 @@ void TaskFinal::packageServerReq()
...
@@ -71,28 +61,14 @@ void TaskFinal::packageServerReq()
pay
[
"code"
]
=
p
.
toObject
()[
"code"
].
toString
();
pay
[
"code"
]
=
p
.
toObject
()[
"code"
].
toString
();
pay
[
ServerProps
(
PosProps
.
TransId
)]
=
getPosJsonValue
(
PosProps
.
TransId
);
pay
[
ServerProps
(
PosProps
.
TransId
)]
=
getPosJsonValue
(
PosProps
.
TransId
);
QString
typeModeFlag
=
p
.
toObject
()[
"pay_id"
].
toString
();
QString
typeModeFlag
=
p
.
toObject
()[
"pay_id"
].
toString
();
if
(
typeModeFlag
==
"0101"
)
{
//现金支付
pay
[
"typeModeFlag"
]
=
"20005"
;
}
else
if
(
typeModeFlag
==
"0301"
)
{
pay
[
"typeModeFlag"
]
=
"10011"
;
}
else
if
(
typeModeFlag
==
"0302"
)
{
pay
[
"typeModeFlag"
]
=
"10011"
;
}
else
if
(
typeModeFlag
==
"0303"
)
{
pay
[
"typeModeFlag"
]
=
"10011"
;
}
else
{
pay
[
"typeModeFlag"
]
=
typeModeFlag
;
pay
[
"typeModeFlag"
]
=
typeModeFlag
;
}
if
(
typeModeFlag
.
compare
(
"20001"
)
==
0
||
typeModeFlag
.
compare
(
"20002"
)
==
0
||
typeModeFlag
.
compare
(
"20003"
)
==
0
)
{
if
(
typeModeFlag
.
compare
(
"20001"
)
==
0
||
typeModeFlag
.
compare
(
"20002"
)
==
0
||
typeModeFlag
.
compare
(
"20003"
)
==
0
)
{
isUseVipPay
=
true
;
isUseVipPay
=
true
;
}
}
payList
.
append
(
pay
);
payList
.
append
(
pay
);
}
}
transData
[
"payList"
]
=
payList
;
transData
[
"payList"
]
=
payList
;
serverReqJsonObj
[
"data"
]
=
transData
;
serverReqJsonObj
[
"data"
]
=
transData
;
}
}
...
@@ -117,6 +93,7 @@ bool TaskFinal::sendToServer(bool isShowMsg)
...
@@ -117,6 +93,7 @@ bool TaskFinal::sendToServer(bool isShowMsg)
}
}
}
}
}
}
bool
isOk
=
(
error
()
==
FM_API_SUCCESS
);
bool
isOk
=
(
error
()
==
FM_API_SUCCESS
);
if
(
!
isOk
)
if
(
!
isOk
)
{
{
...
@@ -131,6 +108,8 @@ void TaskFinal::packagePOSRsp()
...
@@ -131,6 +108,8 @@ void TaskFinal::packagePOSRsp()
posRspJsonObj
[
PosProps
.
Msg
]
=
getServerJsonValue
(
PosProps
.
Msg
);
posRspJsonObj
[
PosProps
.
Msg
]
=
getServerJsonValue
(
PosProps
.
Msg
);
posRspJsonObj
[
PosProps
.
Fm_id
]
=
getServerJsonValue
(
PosProps
.
Fm_id
);
posRspJsonObj
[
PosProps
.
Fm_id
]
=
getServerJsonValue
(
PosProps
.
Fm_id
);
posRspJsonObj
[
PosProps
.
Prompt
]
=
1
;
posRspJsonObj
[
PosProps
.
Prompt
]
=
1
;
posRspJsonObj
[
PosProps
.
TransId
]
=
getPosJsonValue
(
ServerProps
(
PosProps
.
TransId
)).
toString
();
posRspJsonObj
[
PosProps
.
Pay_id
]
=
"1003"
;
}
}
QString
TaskFinal
::
backup
()
QString
TaskFinal
::
backup
()
...
...
task/taskfinal.h
View file @
ed18036b
#ifndef TASKFINAL_H
#
ifndef
TASKFINAL_H
#define TASKFINAL_H
#define TASKFINAL_H
#include "fmtasknownd.h"
#include "fmtasknownd.h"
...
@@ -7,7 +7,7 @@ class TaskFinal : public FMTaskNoWnd
...
@@ -7,7 +7,7 @@ class TaskFinal : public FMTaskNoWnd
Q_OBJECT
Q_OBJECT
public
:
public
:
explicit
TaskFinal
(
QJsonObject
&
jsonObj
,
Session
*
session
=
0
,
QObject
*
parent
=
0
);
explicit
TaskFinal
(
QJsonObject
&
jsonObj
,
Session
*
session
=
0
,
QObject
*
parent
=
0
);
virtual
QByteArray
doTask
();
void
packageServerReq
();
void
packageServerReq
();
bool
sendToServer
(
bool
isShowMsg
=
true
);
bool
sendToServer
(
bool
isShowMsg
=
true
);
void
packagePOSRsp
();
void
packagePOSRsp
();
...
...
task/tasklogin.cpp
View file @
ed18036b
#
include
"tasklogin.h"
#
include
"tasklogin.h"
#include "fmviplogin.h"
#include "fmviplogin.h"
#include "fmp_home_i.h"
#include "fmp_vip_settings.h"
#include "fmp_vip_settings.h"
#include "fmnetwork.h"
#include "fmnetwork.h"
#include <QJsonDocument>
#include <QJsonDocument>
#include <QSettings>
TaskLogin
::
TaskLogin
(
QJsonObject
&
jsonObj
,
Session
*
session
,
QObject
*
parent
)
TaskLogin
::
TaskLogin
(
QJsonObject
&
jsonObj
,
Session
*
session
,
QObject
*
parent
)
:
FMTask
(
jsonObj
,
FM_Login
,
session
,
parent
)
:
FMTask
(
jsonObj
,
FM_Login
,
session
,
parent
)
...
@@ -19,7 +21,9 @@ void TaskLogin::setWindow()
...
@@ -19,7 +21,9 @@ void TaskLogin::setWindow()
_window
=
new
FMVipLogin
;
_window
=
new
FMVipLogin
;
connect
(
qobject_cast
<
FMVipLogin
*>
(
_window
),
&
FMVipLogin
::
login
,
this
,
&
TaskLogin
::
onLogin
);
connect
(
qobject_cast
<
FMVipLogin
*>
(
_window
),
&
FMVipLogin
::
login
,
this
,
&
TaskLogin
::
onLogin
);
session
()
->
addData
(
"store_id"
,
getPosJsonValue
(
"store_id"
));
QSettings
settings
(
qApp
->
applicationDirPath
()
+
"/FreemudPOS.ini"
,
QSettings
::
IniFormat
);
QString
storeId
=
settings
.
value
(
FMP_INIKEY_LOGINSTOREID
).
toString
();
session
()
->
addData
(
PosProps
.
StoreId
,
storeId
);
session
()
->
addData
(
"pos_id"
,
getPosJsonValue
(
"pos_id"
));
session
()
->
addData
(
"pos_id"
,
getPosJsonValue
(
"pos_id"
));
session
()
->
addData
(
"operator_id"
,
getPosJsonValue
(
"operator_id"
));
session
()
->
addData
(
"operator_id"
,
getPosJsonValue
(
"operator_id"
));
session
()
->
addData
(
"business_date"
,
getPosJsonValue
(
"business_date"
));
session
()
->
addData
(
"business_date"
,
getPosJsonValue
(
"business_date"
));
...
@@ -30,6 +34,7 @@ void TaskLogin::packageServerReq()
...
@@ -30,6 +34,7 @@ void TaskLogin::packageServerReq()
QJsonObject
code
;
QJsonObject
code
;
code
[
ServerProps
(
PosProps
.
Member_sign
)]
=
session
()
->
data
(
PosProps
.
Member_sign
).
toString
();
code
[
ServerProps
(
PosProps
.
Member_sign
)]
=
session
()
->
data
(
PosProps
.
Member_sign
).
toString
();
serverReqJsonObj
[
"data"
]
=
code
;
serverReqJsonObj
[
"data"
]
=
code
;
serverReqJsonObj
[
ServerProps
(
PosProps
.
StoreId
)]
=
session
()
->
data
(
"store_id"
).
toString
();
}
}
void
TaskLogin
::
packagePOSRsp
()
void
TaskLogin
::
packagePOSRsp
()
...
...
task/taskothers.cpp
View file @
ed18036b
...
@@ -10,26 +10,27 @@ void TaskCoupon::packageServerReq()
...
@@ -10,26 +10,27 @@ void TaskCoupon::packageServerReq()
{
{
QJsonObject
data
;
QJsonObject
data
;
data
[
ServerProps
(
PosProps
.
Fm_open_id
)]
=
session
()
->
data
(
PosProps
.
Fm_open_id
).
toString
();
data
[
ServerProps
(
PosProps
.
Fm_open_id
)]
=
session
()
->
data
(
PosProps
.
Fm_open_id
).
toString
();
// data[ServerProps(PosProps.Fm_open_id)] = "6524402960";
// 产品列表
// 产品列表
QJsonArray
pro
p
ducts
;
QJsonArray
products
;
foreach
(
QJsonValue
pValue
,
getPosJsonValue
(
PosProps
.
Products
).
toArray
())
foreach
(
QJsonValue
pValue
,
getPosJsonValue
(
PosProps
.
Products
).
toArray
())
{
{
QJsonObject
po
=
pValue
.
toObject
();
QJsonObject
po
=
pValue
.
toObject
();
QJsonObject
spo
;
QJsonObject
spo
;
spo
[
"product_code"
]
=
po
[
PosProps
.
ProductId
];
spo
[
"product_code"
]
=
po
[
PosProps
.
ProductId
];
spo
[
"quantity"
]
=
po
[
PosProps
.
ConsumeNum
];
spo
[
"quantity"
]
=
po
[
PosProps
.
ConsumeNum
];
spo
[
ServerProps
(
PosProps
.
Price
)]
=
po
[
PosProps
.
Price
];
spo
[
"price"
]
=
po
[
PosProps
.
Price
];
spo
[
"brand_code"
]
=
""
;
spo
[
"category_code"
]
=
""
;
spo
[
"category_code"
]
=
""
;
pro
p
ducts
.
append
(
spo
);
products
.
append
(
spo
);
}
}
data
[
ServerProps
(
PosProps
.
Products
)]
=
prop
ducts
;
data
[
"products"
]
=
pro
ducts
;
serverReqJsonObj
[
"data"
]
=
data
;
serverReqJsonObj
[
"data"
]
=
data
;
serverReqJsonObj
[
ServerProps
(
PosProps
.
StoreId
)]
=
session
()
->
data
(
PosProps
.
StoreId
).
toString
();
}
}
void
TaskCoupon
::
packagePOSRsp
()
void
TaskCoupon
::
packagePOSRsp
()
{
{
int
canDisAmount
=
session
()
->
data
(
PosProps
.
OrderAmount
).
toInt
()
-
session
()
->
data
(
PosProps
.
PaidAmount
).
toInt
()
-
session
()
->
data
(
PosProps
.
UndisAmount
).
toInt
();
//
int canDisAmount = session()->data(PosProps.OrderAmount).toInt() - session()->data(PosProps.PaidAmount).toInt() - session()->data(PosProps.UndisAmount).toInt();
QMap
<
QString
,
QVariant
>
couponMap
;
QMap
<
QString
,
QVariant
>
couponMap
;
foreach
(
auto
value
,
getServerJsonValue
(
PosProps
.
CouponList
).
toArray
())
foreach
(
auto
value
,
getServerJsonValue
(
PosProps
.
CouponList
).
toArray
())
...
@@ -41,22 +42,26 @@ void TaskCoupon::packagePOSRsp()
...
@@ -41,22 +42,26 @@ void TaskCoupon::packagePOSRsp()
int
type
=
couponOb
[
ServerProps
(
PosProps
.
Coupon_type
)].
toInt
();
int
type
=
couponOb
[
ServerProps
(
PosProps
.
Coupon_type
)].
toInt
();
QString
limitTime
=
couponOb
[
"expiration_date"
].
toString
();
QString
limitTime
=
couponOb
[
"expiration_date"
].
toString
();
double
disAmount
=
qRound
((
1
-
amount
)
*
canDisAmount
/
100
);
// double disAmount = qRound((1-amount)*canDisAmount/100);
if
(
amount
<
1
)
// 折扣券
// if(amount<1) // 折扣券
{
// {
Coupon
c
(
desc
,
code
,
"discount"
,
disAmount
,
0
,
limitTime
,
false
);
// Coupon c(desc, code, "discount", disAmount , 0, limitTime, false);
c
.
setDiscountFactor
(
amount
*
10
);
// c.setDiscountFactor(amount*10);
QVariant
v
;
// QVariant v;
v
.
setValue
(
c
);
// v.setValue(c);
couponMap
[
code
]
=
v
;
// couponMap[code] = v;
}
else
{
// } else {
Coupon
c
(
desc
,
code
,
QString
::
number
(
type
),
amount
,
0
,
limitTime
,
false
);
// Coupon c(desc, code, QString::number(type), amount, 0, limitTime, false);
// QVariant v;
// v.setValue(c);
// couponMap[code] = v;
// }
Coupon
c
(
desc
,
code
,
QString
::
number
(
type
),
amount
,
0
,
limitTime
,
true
);
QVariant
v
;
QVariant
v
;
v
.
setValue
(
c
);
v
.
setValue
(
c
);
couponMap
[
code
]
=
v
;
couponMap
[
code
]
=
v
;
}
}
}
session
()
->
addData
(
PosProps
.
CouponMap
,
couponMap
);
session
()
->
addData
(
PosProps
.
CouponMap
,
couponMap
);
}
}
...
...
task/taskpay.cpp
View file @
ed18036b
...
@@ -2,16 +2,20 @@
...
@@ -2,16 +2,20 @@
#include "tasklogin.h"
#include "tasklogin.h"
#include "fmviporder.h"
#include "fmviporder.h"
#include "fmp_logger_i.h"
#include "fmp_logger_i.h"
#include "fmp_home_i.h"
#include "fmp_vip_settings.h"
#include "fmp_vip_settings.h"
#include "fmnetwork.h"
#include "fmnetwork.h"
#include "fmbackup.h"
#include "fmbackup.h"
#include "taskfinal.h"
#include <QJsonDocument>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonObject>
#include <QCryptographicHash>
#include <QCryptographicHash>
#include <QSettings>
TaskPay
::
TaskPay
(
QJsonObject
&
jsonObj
,
Session
*
session
,
QObject
*
parent
)
TaskPay
::
TaskPay
(
QJsonObject
&
jsonObj
,
Session
*
session
,
QObject
*
parent
)
:
FMTask
(
jsonObj
,
FM_Pay
,
session
,
parent
)
:
FMTask
(
jsonObj
,
FM_Pay
,
session
,
parent
)
{
{
payAmount
=
0
;
//该次支付金额
}
}
TaskPay
::~
TaskPay
()
TaskPay
::~
TaskPay
()
...
@@ -22,7 +26,6 @@ TaskPay::~TaskPay()
...
@@ -22,7 +26,6 @@ TaskPay::~TaskPay()
QByteArray
TaskPay
::
doTask
()
QByteArray
TaskPay
::
doTask
()
{
{
FMP_DEBUG
()
<<
__FUNCTION__
;
FMP_DEBUG
()
<<
__FUNCTION__
;
QString
fm_open_id_pos
=
getPosJsonValue
(
PosProps
.
Fm_open_id
).
toString
();
QString
fm_open_id_pos
=
getPosJsonValue
(
PosProps
.
Fm_open_id
).
toString
();
QString
fm_open_id_session
=
session
()
->
data
(
PosProps
.
Fm_open_id
).
toString
();
QString
fm_open_id_session
=
session
()
->
data
(
PosProps
.
Fm_open_id
).
toString
();
if
(
fm_open_id_session
==
""
||
fm_open_id_pos
!=
fm_open_id_session
||
session
()
->
data
(
PosProps
.
CanPay
).
toBool
()
==
false
)
{
if
(
fm_open_id_session
==
""
||
fm_open_id_pos
!=
fm_open_id_session
||
session
()
->
data
(
PosProps
.
CanPay
).
toBool
()
==
false
)
{
...
@@ -30,6 +33,10 @@ QByteArray TaskPay::doTask()
...
@@ -30,6 +33,10 @@ QByteArray TaskPay::doTask()
preTask
->
session
()
->
addData
(
PosProps
.
FM_Type
,
FM_Pay
);
preTask
->
session
()
->
addData
(
PosProps
.
FM_Type
,
FM_Pay
);
QByteArray
loginRst
=
preTask
->
doTask
();
QByteArray
loginRst
=
preTask
->
doTask
();
if
(
preTask
->
error
()
!=
FM_API_SUCCESS
)
{
if
(
preTask
->
error
()
!=
FM_API_SUCCESS
)
{
QJsonObject
result
=
QJsonDocument
::
fromJson
(
loginRst
).
object
();
result
[
PosProps
.
TransId
]
=
getPosJsonValue
(
PosProps
.
TransId
).
toString
();
result
[
PosProps
.
Pay_id
]
=
FM_Pay
;
loginRst
=
QJsonDocument
(
result
).
toJson
(
QJsonDocument
::
Compact
);
return
loginRst
;
return
loginRst
;
}
}
this
->
_session
=
preTask
->
session
();
this
->
_session
=
preTask
->
session
();
...
@@ -42,13 +49,67 @@ QByteArray TaskPay::doTask()
...
@@ -42,13 +49,67 @@ QByteArray TaskPay::doTask()
couponThread
=
new
TaskCouponThread
(
posReqJsonObj
,
_session
,
this
);
couponThread
=
new
TaskCouponThread
(
posReqJsonObj
,
_session
,
this
);
couponThread
->
start
();
couponThread
->
start
();
connect
(
couponThread
,
SIGNAL
(
finished
(
Session
*
)),
SLOT
(
onGetCoupons
(
Session
*
)));
connect
(
couponThread
,
SIGNAL
(
finished
(
Session
*
)),
SLOT
(
onGetCoupons
(
Session
*
)));
return
FMTask
::
doTask
();
QByteArray
resultArray
=
FMTask
::
doTask
();
QJsonObject
resultJson
=
QJsonDocument
::
fromJson
(
resultArray
).
object
();
if
(
resultJson
[
PosProps
.
StatusCode
].
toInt
()
!=
FM_API_SUCCESS
)
{
resultJson
[
PosProps
.
Pay_id
]
=
FM_Pay
;
resultJson
[
PosProps
.
TransId
]
=
getPosJsonValue
(
PosProps
.
TransId
).
toString
();
QByteArray
reply
=
QJsonDocument
(
resultJson
).
toJson
(
QJsonDocument
::
Compact
);
return
reply
;
}
else
{
posRspJsonObj
[
PosProps
.
Pay_id
]
=
FM_Pay
;
//支付成功,直接调结算接口
QJsonObject
data
=
serverReqJsonObj
[
"data"
].
toObject
();
data
[
"totalAmount"
]
=
getPosJsonValue
(
PosProps
.
OrderAmount
).
toInt
();
serverReqJsonObj
[
"data"
]
=
data
;
serverReqJsonObj
[
ServerProps
(
PosProps
.
Fm_cmd
)]
=
FM_Final
;
del_p
(
preTask
);
preTask
=
new
TaskFinal
(
serverReqJsonObj
,
_session
,
this
);
preTask
->
doTask
();
if
(
preTask
->
getServerJsonValue
(
PosProps
.
StatusCode
).
toInt
()
!=
FM_API_SUCCESS
)
{
//结算失败,退款
QJsonObject
refund
;
refund
[
"pos_ver"
]
=
getPosJsonValue
(
"pos_ver"
).
toInt
();
refund
[
PosProps
.
OperatorId
]
=
getPosJsonValue
(
PosProps
.
OperatorId
).
toString
();
refund
[
PosProps
.
PosId
]
=
getPosJsonValue
(
PosProps
.
PosId
).
toString
();
refund
[
PosProps
.
StoreId
]
=
session
()
->
data
(
PosProps
.
StoreId
).
toString
();
refund
[
PosProps
.
BussinessDate
]
=
getPosJsonValue
(
PosProps
.
BussinessDate
).
toString
();
QJsonObject
transactions
;
transactions
[
PosProps
.
Fm_transId
]
=
getPosJsonValue
(
PosProps
.
Fm_transId
).
toString
();
transactions
[
PosProps
.
Fm_id
]
=
getPosJsonValue
(
PosProps
.
Fm_id
).
toString
();
transactions
[
PosProps
.
TransId
]
=
getPosJsonValue
(
PosProps
.
TransId
).
toString
();
transactions
[
"refund_amount"
]
=
payAmount
;
refund
[
"transactions"
]
=
transactions
;
del_p
(
preTask
);
preTask
=
new
TaskRefundPay
(
refund
,
this
);
preTask
->
doTask
();
if
(
preTask
->
getServerJsonValue
(
PosProps
.
StatusCode
).
toInt
()
!=
FM_API_SUCCESS
)
{
FMP_ERROR
()
<<
QString
::
fromLocal8Bit
(
"退款失败!trans_id=%1"
).
arg
(
getPosJsonValue
(
PosProps
.
TransId
).
toString
());
}
posRspJsonObj
[
PosProps
.
StatusCode
]
=
preTask
->
getServerJsonValue
(
PosProps
.
StatusCode
).
toInt
();
posRspJsonObj
[
PosProps
.
Msg
]
=
preTask
->
getServerJsonValue
(
PosProps
.
Msg
).
toString
();
}
else
{
posRspJsonObj
[
PosProps
.
StatusCode
]
=
preTask
->
getServerJsonValue
(
PosProps
.
StatusCode
).
toInt
();
posRspJsonObj
[
PosProps
.
Msg
]
=
preTask
->
getServerJsonValue
(
PosProps
.
Msg
).
toString
();
}
}
QByteArray
result
=
QJsonDocument
(
posRspJsonObj
).
toJson
(
QJsonDocument
::
Compact
);
return
result
;
}
}
void
TaskPay
::
onGetCoupons
(
Session
*
session
)
void
TaskPay
::
onGetCoupons
(
Session
*
session
)
{
{
couponThread
->
exit
();
couponThread
->
exit
();
_session
->
addData
(
PosProps
.
CouponMap
,
session
->
getCouponMap
(
PosProps
.
CouponMap
));
_session
->
addData
(
PosProps
.
CouponMap
,
session
->
getCouponMap
(
PosProps
.
CouponMap
));
if
(
_window
!=
nullptr
)
{
if
(
_window
!=
nullptr
)
{
qobject_cast
<
FMVipOrder
*>
(
_window
)
->
initCouponItems
();
qobject_cast
<
FMVipOrder
*>
(
_window
)
->
initCouponItems
();
...
@@ -69,9 +130,8 @@ void TaskPay::packageServerReq()
...
@@ -69,9 +130,8 @@ void TaskPay::packageServerReq()
//! 会员新接口使用 data 打包业务数据
//! 会员新接口使用 data 打包业务数据
QJsonObject
transData
;
QJsonObject
transData
;
transData
[
ServerProps
(
PosProps
.
TransId
)]
=
getPosJsonValue
(
PosProps
.
TransId
);
transData
[
ServerProps
(
PosProps
.
TransId
)]
=
getPosJsonValue
(
PosProps
.
TransId
);
transData
[
ServerProps
(
PosProps
.
BussinessDate
)]
=
getPosJsonValue
(
PosProps
.
BussinessDate
);
transData
[
ServerProps
(
PosProps
.
Fm_id
)]
=
getPosJsonValue
(
PosProps
.
Fm_id
);
transData
[
ServerProps
(
PosProps
.
Fm_id
)]
=
getPosJsonValue
(
PosProps
.
Fm_id
).
toString
();
transData
[
ServerProps
(
PosProps
.
Fm_id
)]
=
""
;
transData
[
ServerProps
(
PosProps
.
Fm_open_id
)]
=
session
()
->
data
(
PosProps
.
Fm_open_id
).
toString
();
transData
[
ServerProps
(
PosProps
.
Fm_open_id
)]
=
session
()
->
data
(
PosProps
.
Fm_open_id
).
toString
();
QJsonArray
products
;
QJsonArray
products
;
...
@@ -81,9 +141,9 @@ void TaskPay::packageServerReq()
...
@@ -81,9 +141,9 @@ void TaskPay::packageServerReq()
QJsonObject
obj
=
clientArray
[
i
].
toObject
();
QJsonObject
obj
=
clientArray
[
i
].
toObject
();
QJsonObject
serverObj
;
QJsonObject
serverObj
;
serverObj
[
ServerProps
(
PosProps
.
ConsumeNum
)]
=
obj
[
PosProps
.
ConsumeNum
];
serverObj
[
ServerProps
(
PosProps
.
ConsumeNum
)]
=
obj
[
PosProps
.
ConsumeNum
];
int
price
=
obj
[
"price"
].
toInt
();
serverObj
[
"price"
]
=
obj
[
"price"
].
toInt
();
serverObj
[
"price"
]
=
price
;
serverObj
[
"productId"
]
=
obj
[
"pid"
];
serverObj
[
"productId"
]
=
obj
[
"pid"
];
serverObj
[
"disAmount"
]
=
obj
[
"disAmount"
].
toInt
();
products
.
push_back
(
serverObj
);
products
.
push_back
(
serverObj
);
}
}
...
@@ -91,11 +151,14 @@ void TaskPay::packageServerReq()
...
@@ -91,11 +151,14 @@ void TaskPay::packageServerReq()
//余额支付详情
//余额支付详情
QJsonObject
balance
;
QJsonObject
balance
;
int
codeAmount
=
session
()
->
data
(
PosProps
.
CodeAmount
).
toInt
();
int
codeAmount
=
session
()
->
data
(
PosProps
.
CodeAmount
).
toInt
();
if
(
codeAmount
!=
0
)
{
balance
[
"amount"
]
=
codeAmount
;
balance
[
"amount"
]
=
codeAmount
;
balance
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
);
balance
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
);
balance
[
"typeModeFlag"
]
=
20001
;
balance
[
"typeModeFlag"
]
=
QString
::
number
(
20001
)
;
balance
[
"thirdPayTransId"
]
=
""
;
balance
[
"thirdPayTransId"
]
=
""
;
payList
.
push_back
(
balance
);
payList
.
push_back
(
balance
);
}
// 积分支付详情
// 积分支付详情
QJsonObject
score
;
QJsonObject
score
;
...
@@ -103,12 +166,12 @@ void TaskPay::packageServerReq()
...
@@ -103,12 +166,12 @@ void TaskPay::packageServerReq()
if
(
scoreAmount
>
0
)
{
if
(
scoreAmount
>
0
)
{
score
[
"amount"
]
=
scoreAmount
;
score
[
"amount"
]
=
scoreAmount
;
score
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
);
score
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
);
score
[
"typeModeFlag"
]
=
20002
;
score
[
"typeModeFlag"
]
=
QString
::
number
(
20002
)
;
score
[
"thirdPayTransId"
]
=
""
;
score
[
"thirdPayTransId"
]
=
""
;
payList
.
push_back
(
score
);
payList
.
push_back
(
score
);
}
}
#if 0
//代金券/商品券支付详情
//代金券/商品券支付详情
QMap<QString, QVariant> coupons = session()->data("payCouponMap").toMap();
QMap<QString, QVariant> coupons = session()->data("payCouponMap").toMap();
// 将代金券按金额从小到大排序
// 将代金券按金额从小到大排序
...
@@ -121,7 +184,6 @@ void TaskPay::packageServerReq()
...
@@ -121,7 +184,6 @@ void TaskPay::packageServerReq()
return (first.disAmount() < second.disAmount());
return (first.disAmount() < second.disAmount());
});
});
// 计算使用的代金券金额
// 计算使用的代金券金额
int needAmount = session()->data(PosProps.NeedAmount).toInt();
int needAmount = session()->data(PosProps.NeedAmount).toInt();
int needCouponAmount = needAmount - codeAmount - scoreAmount;
int needCouponAmount = needAmount - codeAmount - scoreAmount;
int couponAmount = 0;
int couponAmount = 0;
...
@@ -147,13 +209,36 @@ void TaskPay::packageServerReq()
...
@@ -147,13 +209,36 @@ void TaskPay::packageServerReq()
coupon["code"] = c.code();
coupon["code"] = c.code();
payList.push_back(coupon);
payList.push_back(coupon);
}
}
#endif
//卡券支付详情
int
couponAmount
=
0
;
QMap
<
QString
,
QVariant
>
coupons
=
session
()
->
data
(
"payCouponMap"
).
toMap
();
for
(
QMap
<
QString
,
QVariant
>::
const_iterator
it
=
coupons
.
constBegin
();
it
!=
coupons
.
constEnd
();
it
++
)
{
QJsonObject
coupon
;
coupon
[
"amount"
]
=
it
.
value
().
value
<
Coupon
>
().
disAmount
()
*
100
;
coupon
[
"transId"
]
=
getPosJsonValue
(
PosProps
.
TransId
);
QString
coupon_type
=
it
.
value
().
value
<
Coupon
>
().
typeModeFlag
();
if
(
coupon_type
==
"1"
)
{
coupon
[
"typeModeFlag"
]
=
"20003"
;
}
else
{
coupon
[
"typeModeFlag"
]
=
coupon_type
;
}
coupon
[
"code"
]
=
it
.
value
().
value
<
Coupon
>
().
code
();
payList
.
push_back
(
coupon
);
couponAmount
+=
it
.
value
().
value
<
Coupon
>
().
disAmount
()
*
100
;
}
transData
[
"productList"
]
=
products
;
transData
[
"productList"
]
=
products
;
transData
[
"payList"
]
=
payList
;
transData
[
"payList"
]
=
payList
;
int
payAmount
=
codeAmount
+
scoreAmount
+
couponAmount
;
payAmount
=
codeAmount
+
scoreAmount
+
couponAmount
;
transData
[
ServerProps
(
PosProps
.
Pay_amount
)]
=
payAmount
;
transData
[
"payAmount"
]
=
payAmount
;
serverReqJsonObj
[
"data"
]
=
transData
;
serverReqJsonObj
[
"data"
]
=
transData
;
serverReqJsonObj
[
ServerProps
(
PosProps
.
StoreId
)]
=
session
()
->
data
(
PosProps
.
StoreId
).
toString
();
}
}
void
TaskPay
::
packagePOSRsp
()
void
TaskPay
::
packagePOSRsp
()
...
@@ -163,8 +248,9 @@ void TaskPay::packagePOSRsp()
...
@@ -163,8 +248,9 @@ void TaskPay::packagePOSRsp()
posRspJsonObj
[
PosProps
.
Prompt
]
=
0
;
posRspJsonObj
[
PosProps
.
Prompt
]
=
0
;
posRspJsonObj
[
PosProps
.
Settlement
]
=
1
;
posRspJsonObj
[
PosProps
.
Settlement
]
=
1
;
posRspJsonObj
[
PosProps
.
Fm_open_id
]
=
session
()
->
data
(
PosProps
.
Fm_open_id
).
toString
();
posRspJsonObj
[
PosProps
.
Fm_open_id
]
=
session
()
->
data
(
PosProps
.
Fm_open_id
).
toString
();
posRspJsonObj
[
PosProps
.
Fm_id
]
=
getServerJsonValue
(
PosProps
.
Fm_id
).
toString
();
posRspJsonObj
[
PosProps
.
TransId
]
=
getPosJsonValue
(
PosProps
.
TransId
);
posRspJsonObj
[
PosProps
.
Fm_transId
]
=
getServerJsonValue
(
PosProps
.
TransId
).
toString
();
posRspJsonObj
[
PosProps
.
Fm_id
]
=
getPosJsonValue
(
PosProps
.
Fm_id
).
toString
();
posRspJsonObj
[
PosProps
.
Fm_transId
]
=
getPosJsonValue
(
PosProps
.
TransId
).
toString
();
QJsonArray
servPayArray
=
getServerJsonValue
(
"payList"
).
toArray
();
QJsonArray
servPayArray
=
getServerJsonValue
(
"payList"
).
toArray
();
//支付方式描述
//支付方式描述
...
@@ -182,21 +268,25 @@ void TaskPay::packagePOSRsp()
...
@@ -182,21 +268,25 @@ void TaskPay::packagePOSRsp()
{
{
QJsonObject
pay_id
;
QJsonObject
pay_id
;
QString
payId
=
servPayArray
[
i
].
toObject
()[
ServerProps
(
PosProps
.
Pay_id
)].
toString
();
QString
payId
=
servPayArray
[
i
].
toObject
()[
ServerProps
(
PosProps
.
Pay_id
)].
toString
();
if
(
payId
==
"20003"
)
{
// if(payId == "20003") {
pay_id
[
PosProps
.
Pay_amount
]
=
0
;
// pay_id[PosProps.Pay_amount] = 0;
pay_id
[
"merchant_discount"
]
=
servPayArray
[
i
].
toObject
()[
ServerProps
(
PosProps
.
Pay_amount
)].
toInt
();
// pay_id["merchant_discount"] = servPayArray[i].toObject()[ServerProps(PosProps.Pay_amount)].toInt();
}
else
{
// } else {
// pay_id[PosProps.Pay_amount] = servPayArray[i].toObject()[ServerProps(PosProps.Pay_amount)].toInt();
// }
pay_id
[
PosProps
.
Pay_amount
]
=
servPayArray
[
i
].
toObject
()[
ServerProps
(
PosProps
.
Pay_amount
)].
toInt
();
pay_id
[
PosProps
.
Pay_amount
]
=
servPayArray
[
i
].
toObject
()[
ServerProps
(
PosProps
.
Pay_amount
)].
toInt
();
}
pay_id
[
PosProps
.
Pay_id
]
=
payId
;
pay_id
[
PosProps
.
Pay_id
]
=
payId
;
pay_id
[
PosProps
.
Pay_str
]
=
description
[
servPayArray
[
i
].
toObject
()[
"typeModeFlag"
].
toString
()
];
pay_id
[
PosProps
.
Pay_str
]
=
description
[
payId
];
pay_id
[
PosProps
.
Coupon_code
]
=
servPayArray
[
i
].
toObject
()[
"code"
].
toString
();
pay_id
[
PosProps
.
Coupon_code
]
=
servPayArray
[
i
].
toObject
()[
"code"
].
toString
();
pay_ids
.
push_back
(
pay_id
);
pay_ids
.
push_back
(
pay_id
);
totalPaid
+=
pay_id
[
PosProps
.
Pay_amount
].
toInt
();
totalPaid
+=
pay_id
[
PosProps
.
Pay_amount
].
toInt
();
}
}
posRspJsonObj
[
PosProps
.
Paid_total_amount
]
=
totalPaid
;
posRspJsonObj
[
PosProps
.
Paid_total_amount
]
=
totalPaid
;
posRspJsonObj
[
"invoice_amount"
]
=
getServerJsonValue
(
"invoice_amount"
).
toInt
();
posRspJsonObj
[
"discount_amount"
]
=
getServerJsonValue
(
"discount_amount"
).
toInt
();
posRspJsonObj
[
PosProps
.
Pay_ids
]
=
pay_ids
;
posRspJsonObj
[
PosProps
.
Pay_ids
]
=
pay_ids
;
posRspJsonObj
[
PosProps
.
Pay_id
]
=
"1003"
;
if
(
getServerJsonValue
(
PosProps
.
StatusCode
)
==
FM_API_SUCCESS
)
if
(
getServerJsonValue
(
PosProps
.
StatusCode
)
==
FM_API_SUCCESS
)
{
{
...
...
task/taskpay.h
View file @
ed18036b
...
@@ -24,6 +24,7 @@ private slots:
...
@@ -24,6 +24,7 @@ private slots:
private
:
private
:
TaskCouponThread
*
couponThread
;
TaskCouponThread
*
couponThread
;
int
payAmount
;
};
};
// 加载代金券的线程类
// 加载代金券的线程类
...
...
windows/forms/fmviporder.ui
View file @
ed18036b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<x>
0
</x>
<x>
0
</x>
<y>
0
</y>
<y>
0
</y>
<width>
786
</width>
<width>
786
</width>
<height>
62
4
</height>
<height>
62
6
</height>
</rect>
</rect>
</property>
</property>
<property
name=
"maximumSize"
>
<property
name=
"maximumSize"
>
...
@@ -746,6 +746,12 @@
...
@@ -746,6 +746,12 @@
</property>
</property>
<item>
<item>
<widget
class=
"QLabel"
name=
"pay_max"
>
<widget
class=
"QLabel"
name=
"pay_max"
>
<property
name=
"minimumSize"
>
<size>
<width>
259
</width>
<height>
30
</height>
</size>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
余额最多支付 0.00 元
</string>
<string>
余额最多支付 0.00 元
</string>
</property>
</property>
...
@@ -799,8 +805,8 @@
...
@@ -799,8 +805,8 @@
</property>
</property>
<property
name=
"maximumSize"
>
<property
name=
"maximumSize"
>
<size>
<size>
<width>
0
</width>
<width>
283
</width>
<height>
0
</height>
<height>
47
</height>
</size>
</size>
</property>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
...
@@ -813,10 +819,16 @@
...
@@ -813,10 +819,16 @@
</item>
</item>
<item>
<item>
<widget
class=
"QLabel"
name=
"score_label"
>
<widget
class=
"QLabel"
name=
"score_label"
>
<property
name=
"minimumSize"
>
<size>
<width>
259
</width>
<height>
30
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<property
name=
"maximumSize"
>
<size>
<size>
<width>
0
</width>
<width>
259
</width>
<height>
0
</height>
<height>
3
0
</height>
</size>
</size>
</property>
</property>
<property
name=
"text"
>
<property
name=
"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