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
8a8288f0
Commit
8a8288f0
authored
Sep 28, 2018
by
gujin.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
功能合并;界面添加天福特定logo
parent
c04b81ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
238 additions
and
342 deletions
+238
-342
res/img.qrc
+1
-0
res/img/tflogo.png
+0
-0
task/fmtask.cpp
+22
-53
task/fmtask.h
+1
-3
task/taskfinal.cpp
+15
-60
task/tasklogin.cpp
+23
-3
task/taskpay.cpp
+121
-47
task/taskpay.h
+2
-1
windows/fmcouponwidget.cpp
+3
-1
windows/fmviplogin.cpp
+1
-31
windows/fmviporder.cpp
+0
-0
windows/fmviporder.h
+5
-132
windows/forms/fmviplogin.ui
+23
-5
windows/forms/fmviporder.ui
+20
-5
windows/forms/fmvippanel.ui
+1
-1
No files found.
res/img.qrc
View file @
8a8288f0
...
@@ -14,5 +14,6 @@
...
@@ -14,5 +14,6 @@
<file>img/tip_error.png</file>
<file>img/tip_error.png</file>
<file>img/tip_ok.png</file>
<file>img/tip_ok.png</file>
<file>img/tip_warning.png</file>
<file>img/tip_warning.png</file>
<file>img/tflogo.png</file>
</qresource>
</qresource>
</RCC>
</RCC>
res/img/tflogo.png
0 → 100644
View file @
8a8288f0
2.03 KB
task/fmtask.cpp
View file @
8a8288f0
...
@@ -22,78 +22,47 @@ FMTask::~FMTask()
...
@@ -22,78 +22,47 @@ FMTask::~FMTask()
del_p
(
_window
);
del_p
(
_window
);
}
}
Q
JsonValue
FMTask
::
searchJsonObject
(
QJsonObject
&
searchJson
,
QString
searchK
ey
)
Q
Pair
<
bool
,
QJsonValue
>
FMTask
::
search
(
const
QJsonValue
&
json
,
QString
k
ey
)
{
{
Q
JsonValue
value
;
Q
Pair
<
bool
,
QJsonValue
>
result
;
if
(
searchJson
.
contains
(
searchKey
))
if
(
json
.
isObject
(
))
{
{
return
searchJson
[
searchKey
];
QJsonObject
temp
=
json
.
toObject
();
}
if
(
temp
.
contains
(
key
))
else
{
foreach
(
QString
key
,
searchJson
.
keys
())
{
{
if
(
searchJson
[
key
].
isObject
())
result
=
qMakePair
(
true
,
temp
[
key
]);
{
}
QJsonObject
ob
=
searchJson
[
key
].
toObject
();
else
value
=
searchJsonObject
(
ob
,
searchKey
);
{
}
foreach
(
QString
k
,
temp
.
keys
())
else
if
(
searchJson
[
key
].
isArray
())
{
{
QJsonArray
arr
=
searchJson
[
key
].
toArray
();
result
=
search
(
temp
[
k
],
key
);
value
=
searchJsonArray
(
arr
,
searchKey
);
if
(
result
.
first
)
break
;
}
}
}
}
}
}
return
value
;
else
if
(
json
.
isArray
())
}
QJsonValue
FMTask
::
searchJsonArray
(
QJsonArray
&
searchJson
,
QString
searchKey
)
{
QJsonValue
value
;
for
(
int
i
=
0
;
i
<
searchJson
.
size
();
i
++
)
{
{
if
(
searchJson
[
i
].
isObject
())
QJsonArray
temp
=
json
.
toArray
();
for
(
int
i
=
0
;
i
<
temp
.
size
();
i
++
)
{
{
QJsonObject
ob
=
searchJson
[
i
].
toObject
();
result
=
search
(
temp
[
i
],
key
);
value
=
searchJsonObject
(
ob
,
searchKey
);
if
(
result
.
first
)
}
break
;
else
if
(
searchJson
[
i
].
isArray
())
{
QJsonArray
arr
=
searchJson
[
i
].
toArray
();
value
=
searchJsonArray
(
arr
,
searchKey
);
}
}
return
value
;
}
QJsonValue
FMTask
::
searchJsonValue
(
QJsonObject
&
searchJson
,
QString
searchKey
)
{
if
(
searchJson
.
contains
(
searchKey
))
{
return
searchJson
[
searchKey
];
}
else
{
qDebug
()
<<
searchJson
.
keys
();
foreach
(
QString
key
,
searchJson
.
keys
())
{
if
(
searchJson
[
key
].
isObject
())
{
QJsonObject
ob
=
searchJson
[
key
].
toObject
();
QJsonValue
value
=
searchJsonValue
(
ob
,
searchKey
);
if
(
!
value
.
isNull
()){
return
value
;
}
}
}
}
}
}
return
QJsonValue
()
;
return
result
;
}
}
QJsonValue
FMTask
::
getServerJsonValue
(
const
QString
prop
)
QJsonValue
FMTask
::
getServerJsonValue
(
const
QString
prop
)
{
{
return
search
JsonObject
(
serverRspJsonObj
,
prop
)
;
return
search
(
serverRspJsonObj
,
prop
).
second
;
}
}
QJsonValue
FMTask
::
getPosJsonValue
(
const
QString
prop
)
QJsonValue
FMTask
::
getPosJsonValue
(
const
QString
prop
)
{
{
return
search
JsonObject
(
posReqJsonObj
,
prop
)
;
return
search
(
posReqJsonObj
,
prop
).
second
;
}
}
QString
FMTask
::
sign
()
const
QString
FMTask
::
sign
()
const
...
...
task/fmtask.h
View file @
8a8288f0
...
@@ -48,9 +48,7 @@ public:
...
@@ -48,9 +48,7 @@ public:
Session
*
session
()
const
{
return
_session
;}
Session
*
session
()
const
{
return
_session
;}
QJsonValue
searchJsonValue
(
QJsonObject
&
searchJson
,
QString
searchKey
);
QPair
<
bool
,
QJsonValue
>
search
(
const
QJsonValue
&
json
,
QString
key
);
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
);
...
...
task/taskfinal.cpp
View file @
8a8288f0
...
@@ -33,10 +33,11 @@ void TaskFinal::packageServerReq()
...
@@ -33,10 +33,11 @@ void TaskFinal::packageServerReq()
serverReqJsonObj
[
"operatorId"
]
=
getPosJsonValue
(
"operator_id"
);
serverReqJsonObj
[
"operatorId"
]
=
getPosJsonValue
(
"operator_id"
);
serverReqJsonObj
[
"partnerId"
]
=
PARTNER_ID
;
serverReqJsonObj
[
"partnerId"
]
=
PARTNER_ID
;
serverReqJsonObj
[
"businessDate"
]
=
getPosJsonValue
(
"business_date"
);
serverReqJsonObj
[
"businessDate"
]
=
getPosJsonValue
(
"business_date"
);
//serverReqJsonObj["transId"] = getPosJsonValue("trans_id");
serverReqJsonObj
[
"memberTransId"
]
=
getPosJsonValue
(
"fm_transId"
).
toString
();
serverReqJsonObj
[
"memberTransId"
]
=
""
;
QJsonObject
transaction
;
QJsonObject
transaction
;
transaction
[
"account"
]
=
getPosJsonValue
(
"fm_open_id"
);
QString
fm_open_id
=
getPosJsonValue
(
"fm_open_id"
).
toString
();
fm_open_id
.
remove
(
fm_open_id
.
length
()
-
1
,
1
);
transaction
[
"account"
]
=
fm_open_id
;
transaction
[
"totalAmount"
]
=
getPosJsonValue
(
"order_amount"
);
transaction
[
"totalAmount"
]
=
getPosJsonValue
(
"order_amount"
);
transaction
[
"payAmount"
]
=
getPosJsonValue
(
"paid_amount"
);
transaction
[
"payAmount"
]
=
getPosJsonValue
(
"paid_amount"
);
...
@@ -58,57 +59,12 @@ void TaskFinal::packageServerReq()
...
@@ -58,57 +59,12 @@ void TaskFinal::packageServerReq()
{
{
QJsonObject
pay
;
QJsonObject
pay
;
pay
[
"amount"
]
=
p
.
toObject
()[
"pay_amount"
].
toInt
();
pay
[
"amount"
]
=
p
.
toObject
()[
"pay_amount"
].
toInt
();
pay
[
"thirdPayTransId"
]
=
p
.
toObject
()[
"
thirdPayT
ransId"
].
toString
();
pay
[
"thirdPayTransId"
]
=
p
.
toObject
()[
"
pay_t
ransId"
].
toString
();
pay
[
"code"
]
=
p
.
toObject
()[
"code"
].
toString
();
pay
[
"code"
]
=
p
.
toObject
()[
"code"
].
toString
();
pay
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
).
toString
();
pay
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
).
toString
();
pay
[
"payTransId"
]
=
p
.
toObject
()[
"
pay_transI
d"
].
toString
();
pay
[
"payTransId"
]
=
p
.
toObject
()[
"
fm_i
d"
].
toString
();
QString
typeModeFlag
=
p
.
toObject
()[
"pay_id"
].
toString
();
QString
typeModeFlag
=
p
.
toObject
()[
"pay_id"
].
toString
();
#if 0
if(typeModeFlag == "00")
{
//现金支付
pay["typeModeFlag"] = 20005;
}
else if(typeModeFlag == "000")
{
//非码会员支付
if(p.toObject()["code"].toString().isEmpty())
{
//券码为空,是 会员储值金支付
pay["typeModeFlag"] = 20001;
}
else
{
//否则,是代金券/商品券支付(统一转为代金券)
pay["typeModeFlag"] = 20003;
}
}
else if(typeModeFlag == "7")
{
//支付宝钱包
pay["typeModeFlag"] = 10001;
}
else if(typeModeFlag == "9")
{
//微信钱包
pay["typeModeFlag"] = 10004; //
}
else if(typeModeFlag == "2")
{
//银行卡
pay["typeModeFlag"] = 10011;
}
else if(typeModeFlag == "8")
{
//翼支付
pay["typeModeFlag"] = 10010;
}
else
{
pay["typeModeFlag"] = typeModeFlag.toInt();
FMP_ERROR() << QStringLiteral("未知的支付类型: ") << typeModeFlag;
}
#endif
if
(
typeModeFlag
==
"84"
)
if
(
typeModeFlag
==
"84"
)
{
{
//会员商品券
//会员商品券
...
@@ -124,6 +80,11 @@ void TaskFinal::packageServerReq()
...
@@ -124,6 +80,11 @@ void TaskFinal::packageServerReq()
//非码会员支付
//非码会员支付
pay
[
"typeModeFlag"
]
=
20001
;
pay
[
"typeModeFlag"
]
=
20001
;
}
}
else
if
(
typeModeFlag
==
"87"
)
{
//非码折扣券
pay
[
"typeModeFlag"
]
=
20008
;
}
else
if
(
typeModeFlag
==
"0"
)
else
if
(
typeModeFlag
==
"0"
)
{
{
//现金
//现金
...
@@ -141,12 +102,6 @@ void TaskFinal::packageServerReq()
...
@@ -141,12 +102,6 @@ void TaskFinal::packageServerReq()
FMP_ERROR
()
<<
QStringLiteral
(
"其他支付: "
)
<<
typeModeFlag
;
FMP_ERROR
()
<<
QStringLiteral
(
"其他支付: "
)
<<
typeModeFlag
;
}
}
// if(typeModeFlag == "20002")
// {
// //积分支付
// pay["typeModeFlag"] = 20002;
// }
payList
.
append
(
pay
);
payList
.
append
(
pay
);
}
}
transaction
[
"payList"
]
=
payList
;
transaction
[
"payList"
]
=
payList
;
...
@@ -205,9 +160,9 @@ bool TaskFinal::sendToServer(bool /*isShowMsg*/)
...
@@ -205,9 +160,9 @@ bool TaskFinal::sendToServer(bool /*isShowMsg*/)
// 备份
// 备份
if
(
error
()
==
FM_API_NETWORERROR
)
{
if
(
error
()
==
FM_API_NETWORERROR
)
{
if
(
searchJsonValue
(
serverReqJsonObj
,
ServerProps
(
PosProps
.
CodeAmount
)).
toInt
()
==
0
&&
if
(
getServerJsonValue
(
ServerProps
(
PosProps
.
CodeAmount
)).
toInt
()
==
0
&&
searchJsonValue
(
serverReqJsonObj
,
ServerProps
(
PosProps
.
ScoreAmount
)).
toInt
()
==
0
&&
getServerJsonValue
(
ServerProps
(
PosProps
.
ScoreAmount
)).
toInt
()
==
0
&&
searchJsonValue
(
serverReqJsonObj
,
ServerProps
(
PosProps
.
Coupons
)).
toArray
().
isEmpty
())
{
getServerJsonValue
(
ServerProps
(
PosProps
.
Coupons
)).
toArray
().
isEmpty
())
{
QString
fm_id
=
backup
();
QString
fm_id
=
backup
();
if
(
!
fm_id
.
isEmpty
()){
if
(
!
fm_id
.
isEmpty
()){
setError
(
FM_API_SUCCESS
);
setError
(
FM_API_SUCCESS
);
...
...
task/tasklogin.cpp
View file @
8a8288f0
...
@@ -17,7 +17,9 @@ QByteArray TaskLogin::doTask()
...
@@ -17,7 +17,9 @@ QByteArray TaskLogin::doTask()
if
(
posReqJsonObj
.
contains
(
"member_sign"
))
if
(
posReqJsonObj
.
contains
(
"member_sign"
))
{
{
//直接保存member_sign到_session中
//直接保存member_sign到_session中
session
()
->
addData
(
"code"
,
posReqJsonObj
[
"member_sign"
].
toString
());
QString
member_sign
=
posReqJsonObj
[
"member_sign"
].
toString
();
member_sign
.
remove
(
member_sign
.
length
()
-
1
,
1
);
session
()
->
addData
(
"code"
,
member_sign
);
onLogin
();
onLogin
();
}
}
else
else
...
@@ -116,7 +118,7 @@ void TaskLogin::packagePOSRsp()
...
@@ -116,7 +118,7 @@ void TaskLogin::packagePOSRsp()
posRspJsonObj
[
"statusCode"
]
=
getServerJsonValue
(
"statusCode"
).
toInt
();
posRspJsonObj
[
"statusCode"
]
=
getServerJsonValue
(
"statusCode"
).
toInt
();
posRspJsonObj
[
"msg"
]
=
getServerJsonValue
(
"msg"
).
toString
();
posRspJsonObj
[
"msg"
]
=
getServerJsonValue
(
"msg"
).
toString
();
posRspJsonObj
[
"prompt"
]
=
getServerJsonValue
(
"prompt"
).
toInt
();
posRspJsonObj
[
"prompt"
]
=
getServerJsonValue
(
"prompt"
).
toInt
();
posRspJsonObj
[
"fm_open_id"
]
=
getServerJsonValue
(
"account"
).
toString
();
posRspJsonObj
[
"fm_open_id"
]
=
getServerJsonValue
(
"account"
).
toString
()
.
append
(
QString
::
number
(
getServerJsonValue
(
"canPay"
).
toInt
()))
;
posRspJsonObj
[
"account"
]
=
getServerJsonValue
(
"memberNo"
).
toString
();
posRspJsonObj
[
"account"
]
=
getServerJsonValue
(
"memberNo"
).
toString
();
posRspJsonObj
[
"type_code"
]
=
getServerJsonValue
(
"typecode"
).
toString
();
posRspJsonObj
[
"type_code"
]
=
getServerJsonValue
(
"typecode"
).
toString
();
posRspJsonObj
[
"type_name"
]
=
getServerJsonValue
(
"typename"
).
toString
();
posRspJsonObj
[
"type_name"
]
=
getServerJsonValue
(
"typename"
).
toString
();
...
@@ -145,7 +147,25 @@ void TaskLogin::onLogin()
...
@@ -145,7 +147,25 @@ void TaskLogin::onLogin()
QString
info
=
serverRspJsonObj
[
"msg"
].
toString
();
QString
info
=
serverRspJsonObj
[
"msg"
].
toString
();
FMP_WARN
()
<<
"Login failed: "
<<
info
;
FMP_WARN
()
<<
"Login failed: "
<<
info
;
}
}
if
(
_window
!=
nullptr
)
if
(
session
()
->
data
(
"fm_entry"
).
toInt
()
==
FM_Pay
)
{
if
(
getServerJsonValue
(
"canPay"
).
toInt
())
{
if
(
_window
!=
nullptr
)
_window
->
close
();
}
else
{
//如果服务端返回该会员不能支付,则不关闭窗口,继续输入支付码
if
(
_window
!=
nullptr
)
{
FMMsgWnd
::
WarningWnd
(
QString
::
fromLocal8Bit
(
"请输入支付码!"
),
_window
);
_window
->
resetWnd
();
}
}
}
else
if
(
_window
!=
nullptr
)
{
{
_window
->
close
();
_window
->
close
();
}
}
...
...
task/taskpay.cpp
View file @
8a8288f0
...
@@ -8,6 +8,9 @@
...
@@ -8,6 +8,9 @@
#include <QJsonDocument>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonObject>
#include <QCryptographicHash>
#include <QCryptographicHash>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
TaskPay
::
TaskPay
(
QJsonObject
&
jsonObj
,
Session
*
session
,
QObject
*
parent
)
TaskPay
::
TaskPay
(
QJsonObject
&
jsonObj
,
Session
*
session
,
QObject
*
parent
)
:
FMTask
(
jsonObj
,
session
,
parent
)
:
FMTask
(
jsonObj
,
session
,
parent
)
...
@@ -15,10 +18,9 @@ TaskPay::TaskPay(QJsonObject &jsonObj, Session *session, QObject *parent)
...
@@ -15,10 +18,9 @@ TaskPay::TaskPay(QJsonObject &jsonObj, Session *session, QObject *parent)
}
}
QByteArray
TaskPay
::
doTask
()
QByteArray
TaskPay
::
doTask
()
{
{
FMP_DEBUG
()
<<
__FUNCTION__
;
//判断是否真的是会员,如果不是,则先认证
//判断是否真的是会员,如果不是,则先认证
if
(
!
posReqJsonObj
.
contains
(
"fm_open_id"
)
||
posReqJsonObj
[
"fm_open_id"
].
toString
().
isEmpty
())
if
(
!
posReqJsonObj
.
contains
(
"fm_open_id"
)
||
posReqJsonObj
[
"fm_open_id"
].
toString
().
isEmpty
()
||
posReqJsonObj
[
"fm_open_id"
].
toString
().
endsWith
(
"0"
)
)
{
{
QJsonObject
reqObj
;
QJsonObject
reqObj
;
reqObj
[
"pos_ver"
]
=
getPosJsonValue
(
"pos_ver"
);
reqObj
[
"pos_ver"
]
=
getPosJsonValue
(
"pos_ver"
);
...
@@ -28,6 +30,7 @@ QByteArray TaskPay::doTask()
...
@@ -28,6 +30,7 @@ QByteArray TaskPay::doTask()
reqObj
[
"store_id"
]
=
getPosJsonValue
(
"store_id"
);
reqObj
[
"store_id"
]
=
getPosJsonValue
(
"store_id"
);
reqObj
[
"business_date"
]
=
getPosJsonValue
(
"business_date"
);
reqObj
[
"business_date"
]
=
getPosJsonValue
(
"business_date"
);
session
()
->
addData
(
"fm_entry"
,
FM_Pay
);
TaskLogin
taskLogin
(
reqObj
,
session
());
TaskLogin
taskLogin
(
reqObj
,
session
());
QByteArray
ret
=
taskLogin
.
doTask
();
QByteArray
ret
=
taskLogin
.
doTask
();
if
(
taskLogin
.
error
()
!=
FM_API_SUCCESS
)
if
(
taskLogin
.
error
()
!=
FM_API_SUCCESS
)
...
@@ -36,7 +39,16 @@ QByteArray TaskPay::doTask()
...
@@ -36,7 +39,16 @@ QByteArray TaskPay::doTask()
}
}
//认证成功,使用返回的fm_open_id进行会员支付
//认证成功,使用返回的fm_open_id进行会员支付
posReqJsonObj
[
"fm_open_id"
]
=
QJsonDocument
::
fromJson
(
ret
).
object
()[
"fm_open_id"
];
QString
fm_open_id
=
QJsonDocument
::
fromJson
(
ret
).
object
()[
"fm_open_id"
].
toString
();
fm_open_id
=
fm_open_id
.
remove
(
fm_open_id
.
length
()
-
1
,
1
);
posReqJsonObj
[
"fm_open_id"
]
=
fm_open_id
;
}
else
{
//如果可以直接会员支付,则需要将pos传入的fm_open_id的最后一位去掉
QString
fm_open_id
=
posReqJsonObj
[
"fm_open_id"
].
toString
();
fm_open_id
.
remove
(
fm_open_id
.
length
()
-
1
,
1
);
posReqJsonObj
[
"fm_open_id"
]
=
fm_open_id
;
}
}
//获取可用的代金券
//获取可用的代金券
...
@@ -59,16 +71,9 @@ QByteArray TaskPay::doTask()
...
@@ -59,16 +71,9 @@ QByteArray TaskPay::doTask()
session
()
->
addData
(
"name"
,
getServerJsonValue
(
"name"
));
session
()
->
addData
(
"name"
,
getServerJsonValue
(
"name"
));
//清空相应json对象
//清空相应json对象
QStringList
keys
=
serverReqJsonObj
.
keys
();
//清空相应json对象
foreach
(
QString
key
,
keys
)
serverReqJsonObj
=
QJsonObject
();
{
serverRspJsonObj
=
QJsonObject
();
serverReqJsonObj
.
remove
(
key
);
}
keys
=
serverRspJsonObj
.
keys
();
foreach
(
QString
key
,
keys
)
{
serverRspJsonObj
.
remove
(
key
);
}
RunFunction
(
setWindow
);
RunFunction
(
setWindow
);
RunFunction
(
showWindow
);
RunFunction
(
showWindow
);
...
@@ -170,7 +175,6 @@ void TaskPay::packageServerReq()
...
@@ -170,7 +175,6 @@ void TaskPay::packageServerReq()
int
payAmount
=
0
;
//该次会员支付的总金额
int
payAmount
=
0
;
//该次会员支付的总金额
transaction
[
"memberTransId"
]
=
""
;
transaction
[
"memberTransId"
]
=
""
;
transaction
[
"account"
]
=
getPosJsonValue
(
"fm_open_id"
);
transaction
[
"account"
]
=
getPosJsonValue
(
"fm_open_id"
);
// transaction["payAmount"] = getPosJsonValue("need_amount");
transaction
[
"isUseScore"
]
=
session
()
->
data
(
"isUseScore"
).
toInt
();
transaction
[
"isUseScore"
]
=
session
()
->
data
(
"isUseScore"
).
toInt
();
QJsonArray
products
;
QJsonArray
products
;
...
@@ -187,13 +191,16 @@ void TaskPay::packageServerReq()
...
@@ -187,13 +191,16 @@ void TaskPay::packageServerReq()
QJsonArray
payList
;
QJsonArray
payList
;
//余额支付详情
//余额支付详情
QJsonObject
balance
;
if
(
session
()
->
data
(
"codeAmount"
).
toInt
()
>
0
)
balance
[
"amount"
]
=
session
()
->
data
(
"codeAmount"
).
toInt
();
{
balance
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
);
QJsonObject
balance
;
balance
[
"typeModeFlag"
]
=
20001
;
balance
[
"amount"
]
=
session
()
->
data
(
"codeAmount"
).
toInt
();
balance
[
"code"
]
=
""
;
balance
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
);
payList
.
push_back
(
balance
);
balance
[
"typeModeFlag"
]
=
20001
;
payAmount
+=
session
()
->
data
(
"codeAmount"
).
toInt
();
balance
[
"code"
]
=
""
;
payList
.
push_back
(
balance
);
payAmount
+=
session
()
->
data
(
"codeAmount"
).
toInt
();
}
//积分支付详情(天福目前没有积分支付)
//积分支付详情(天福目前没有积分支付)
if
(
transaction
[
"isUseScore"
].
toInt
())
if
(
transaction
[
"isUseScore"
].
toInt
())
...
@@ -282,48 +289,114 @@ void TaskPay::packagePOSRsp()
...
@@ -282,48 +289,114 @@ void TaskPay::packagePOSRsp()
//支付方式
//支付方式
QMap
<
int
,
QString
>
typeModeFlags
;
QMap
<
int
,
QString
>
typeModeFlags
;
typeModeFlags
[
20005
]
=
"0"
;
//现金
typeModeFlags
[
20005
]
=
"0"
;
//现金
typeModeFlags
[
10011
]
=
"2"
;
//银行卡
typeModeFlags
[
20004
]
=
"84"
;
//会员商品券
typeModeFlags
[
10001
]
=
"7"
;
//支付宝支付
typeModeFlags
[
20003
]
=
"85"
;
//会员代金券
typeModeFlags
[
20004
]
=
"77"
;
//商品券
typeModeFlags
[
20001
]
=
"86"
;
//非码会员余额
typeModeFlags
[
10010
]
=
"8"
;
//翼支付
typeModeFlags
[
20008
]
=
"87"
;
//非码折扣券
typeModeFlags
[
20003
]
=
"76"
;
//代金券
typeModeFlags
[
10004
]
=
"9"
;
//微信支付
typeModeFlags
[
20001
]
=
"20001"
;
//会员储值金支付
typeModeFlags
[
20002
]
=
"20002"
;
//会员积分支付
//支付方式描述
//支付方式描述
QMap
<
int
,
QString
>
description
;
QMap
<
int
,
QString
>
description
;
description
[
20001
]
=
QStringLiteral
(
"会员储值金支付"
);
description
[
20005
]
=
QStringLiteral
(
"现金"
);
description
[
20002
]
=
QStringLiteral
(
"会员积分支付"
);
description
[
20004
]
=
QStringLiteral
(
"会员商品券"
);
description
[
20003
]
=
QStringLiteral
(
"代金券支付"
);
description
[
20003
]
=
QStringLiteral
(
"会员代金券"
);
description
[
20004
]
=
QStringLiteral
(
"商品券支付"
);
description
[
20001
]
=
QStringLiteral
(
"非码会员余额"
);
description
[
20005
]
=
QStringLiteral
(
"现金支付"
);
description
[
20008
]
=
QStringLiteral
(
"非码折扣券"
);
description
[
10011
]
=
QStringLiteral
(
"银行卡支付"
);
description
[
10001
]
=
QStringLiteral
(
"支付宝支付"
);
description
[
10010
]
=
QStringLiteral
(
"翼支付"
);
description
[
10004
]
=
QStringLiteral
(
"微信支付"
);
//计算总支付额
//计算总支付额
int
totalPaid
=
getServerJsonValue
(
"scoreAmount"
).
toInt
()
int
totalPaid
=
0
;
+
getServerJsonValue
(
"disAmount"
).
toInt
()
bool
useCoupon
=
false
;
+
getServerJsonValue
(
"codeAmount"
).
toInt
();
for
(
int
i
=
0
;
i
<
servPayArray
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
servPayArray
.
size
();
i
++
)
{
{
QJsonObject
pay_id
;
QJsonObject
pay_id
;
pay_id
[
"pay_id"
]
=
typeModeFlags
[
servPayArray
[
i
].
toObject
()[
"typeModeFlag"
].
toInt
()];
QJsonObject
currentPay
=
servPayArray
[
i
].
toObject
();
pay_id
[
"pay_str"
]
=
description
[
servPayArray
[
i
].
toObject
()[
"typeModeFlag"
].
toInt
()];
int
type
=
currentPay
[
"typeModeFlag"
].
toInt
();
pay_id
[
"pay_amount"
]
=
servPayArray
[
i
].
toObject
()[
"amount"
].
toInt
();
pay_id
[
"code"
]
=
servPayArray
[
i
].
toObject
()[
"code"
].
toString
();
if
(
type
==
20003
||
type
==
20004
||
type
==
20008
)
useCoupon
=
true
;
pay_id
[
"pay_id"
]
=
typeModeFlags
.
contains
(
type
)
?
typeModeFlags
[
type
]
:
QStringLiteral
(
"未知"
);
pay_id
[
"pay_str"
]
=
description
.
contains
(
type
)
?
description
[
type
]
:
QStringLiteral
(
"未知"
);
pay_id
[
"pay_amount"
]
=
currentPay
[
"amount"
].
toInt
();
pay_id
[
"code"
]
=
currentPay
[
"code"
].
toString
();
pay_id
[
"act_id"
]
=
currentPay
[
"couponFkId"
].
toString
();
pay_ids
.
push_back
(
pay_id
);
pay_ids
.
push_back
(
pay_id
);
//
totalPaid += pay_id["pay_amount"].toInt();
totalPaid
+=
pay_id
[
"pay_amount"
].
toInt
();
}
}
posRspJsonObj
[
"paid_total_amount"
]
=
totalPaid
;
posRspJsonObj
[
"paid_total_amount"
]
=
totalPaid
;
posRspJsonObj
[
"pay_ids"
]
=
pay_ids
;
posRspJsonObj
[
"pay_ids"
]
=
pay_ids
;
//如果支付成功,且本次使用了优惠券,则记录流水号,以限制一笔订单只使用一张券
if
(
useCoupon
&&
posRspJsonObj
[
PosProps
.
StatusCode
].
toInt
()
==
FM_API_SUCCESS
)
{
storeUseCoupon
(
posReqJsonObj
[
PosProps
.
TransId
].
toString
());
}
}
}
void
TaskPay
::
onPay
()
void
TaskPay
::
onPay
()
{
{
sendToServer
();
sendToServer
();
_window
->
close
();
_window
->
close
();
}
void
TaskPay
::
storeUseCoupon
(
QString
transId
)
{
QString
appPath
=
QApplication
::
applicationDirPath
();
QSqlDatabase
db
=
QSqlDatabase
::
addDatabase
(
"QSQLITE"
,
"couponConnection"
);
db
.
setDatabaseName
(
appPath
+
"/coupon.db"
);
if
(
!
db
.
open
())
return
;
QString
storeId
=
session
()
->
data
(
"store_id"
).
toString
();
if
(
storeId
.
length
()
==
4
)
transId
=
transId
.
mid
(
0
,
20
);
else
transId
=
transId
.
mid
(
0
,
21
);
QSqlQuery
query
(
db
);
QString
sql
=
QString
(
"select * from coupon where trans_id='%1'"
).
arg
(
transId
);
if
(
!
query
.
exec
(
sql
))
{
FMP_ERROR
()
<<
query
.
lastError
().
text
();
db
.
close
();
return
;
}
while
(
query
.
next
())
{
bool
used
=
query
.
value
(
"used"
).
toBool
();
if
(
used
)
{
db
.
close
();
return
;
}
else
{
QMap
<
QString
,
QVariant
>
coupons
=
session
()
->
data
(
"payCouponMap"
).
toMap
();
if
(
coupons
.
size
())
{
if
(
!
query
.
exec
(
QString
(
"update coupon set used=1 where trans_id='%1'"
).
arg
(
transId
)))
{
FMP_ERROR
()
<<
query
.
lastError
().
text
();
db
.
close
();
return
;
}
}
}
}
//是一笔新订单,则先清空数据库
if
(
!
query
.
exec
(
"delete from coupon"
))
{
FMP_ERROR
()
<<
query
.
lastError
().
text
();
}
//插入新记录
sql
=
QString
(
"insert into coupon values('%1',1)"
).
arg
(
transId
);
if
(
!
query
.
exec
(
sql
))
{
FMP_ERROR
()
<<
query
.
lastError
().
text
();
}
db
.
close
();
return
;
}
}
\ No newline at end of file
task/taskpay.h
View file @
8a8288f0
#ifndef TASKPAY_H
#
ifndef
TASKPAY_H
#define TASKPAY_H
#define TASKPAY_H
#include "fmtask.h"
#include "fmtask.h"
#include "taskcoupon.h"
#include "taskcoupon.h"
...
@@ -19,6 +19,7 @@ public:
...
@@ -19,6 +19,7 @@ public:
private
slots
:
private
slots
:
void
onPay
();
void
onPay
();
void
storeUseCoupon
(
QString
transId
);
};
};
#endif // TASKPAY_H
#endif // TASKPAY_H
windows/fmcouponwidget.cpp
View file @
8a8288f0
#include "fmcouponwidget.h"
#
include
"fmcouponwidget.h"
#include "ui_fmcouponwidget.h"
#include "ui_fmcouponwidget.h"
#include <QPainter>
#include <QPainter>
...
@@ -8,6 +8,8 @@ FMCouponWidget::FMCouponWidget(Coupon conpon, QWidget *parent) :
...
@@ -8,6 +8,8 @@ FMCouponWidget::FMCouponWidget(Coupon conpon, QWidget *parent) :
{
{
ui
->
setupUi
(
this
);
ui
->
setupUi
(
this
);
ui
->
code_lab
->
setText
(
conpon
.
code
);
ui
->
code_lab
->
setText
(
conpon
.
code
);
ui
->
code_lab
->
hide
();
ui
->
amount_lab
->
setText
(
QString
::
number
(
conpon
.
disAmount
/
100
,
'f'
,
2
));
ui
->
amount_lab
->
setText
(
QString
::
number
(
conpon
.
disAmount
/
100
,
'f'
,
2
));
ui
->
desc_lab
->
setText
(
conpon
.
desc
);
ui
->
desc_lab
->
setText
(
conpon
.
desc
);
}
}
...
...
windows/fmviplogin.cpp
View file @
8a8288f0
...
@@ -54,37 +54,7 @@ QString FMVipLogin::getVersionInfo()
...
@@ -54,37 +54,7 @@ QString FMVipLogin::getVersionInfo()
}
}
void
FMVipLogin
::
on_login_btn_clicked
()
void
FMVipLogin
::
on_login_btn_clicked
()
{
{
QJsonObject
result
;
QJsonObject
req
;
//req["ver"] = 1;
//req["action"] = "redeem";
req
[
"store_id"
]
=
"99998"
;
req
[
"operator_id"
]
=
"00000002"
;
req
[
"station_id"
]
=
1
;
req
[
"trans_id"
]
=
QDateTime
::
currentDateTime
().
toString
(
"yyyyMMddHHmmsszzz"
);
req
[
"business_date"
]
=
QDate
::
currentDate
().
toString
(
"yyyyMMdd"
);
if
(
ctxTest
!=
nullptr
)
{
try
{
//! Verify pointer
ctxTest
->
getPlugin
();
ctkServiceReference
ref
=
ctxTest
->
getServiceReference
<
FMPRedeemInterface
>
();
FMPRedeemInterface
*
redeem
=
ctxTest
->
getService
<
FMPRedeemInterface
>
(
ref
);
redeem
->
StartService
();
result
=
redeem
->
Redeem
(
QJsonObject
(),
req
);
qDebug
()
<<
result
;
}
catch
(
const
ctkException
&
)
{
qDebug
()
<<
"Invalid context"
<<
ctxTest
;
}
}
return
;
QString
id
=
ui
->
login_edit
->
text
();
QString
id
=
ui
->
login_edit
->
text
();
_session
->
addData
(
"code"
,
id
);
_session
->
addData
(
"code"
,
id
);
...
...
windows/fmviporder.cpp
View file @
8a8288f0
This diff is collapsed.
Click to expand it.
windows/fmviporder.h
View file @
8a8288f0
...
@@ -28,149 +28,22 @@ signals:
...
@@ -28,149 +28,22 @@ signals:
public
slots
:
public
slots
:
void
on_pay_btn_clicked
();
void
on_pay_btn_clicked
();
void
on_pay_chk_clicked
(
bool
checked
);
void
on_pay_chk_clicked
(
bool
checked
);
void
onItemClicked
(
QListWidgetItem
*
);
void
onItemClicked
(
QListWidgetItem
*
);
private
slots
:
private
slots
:
void
on_coupon_prev_btn_clicked
();
void
on_coupon_prev_btn_clicked
();
void
on_coupon_next_btn_clicked
();
void
on_coupon_next_btn_clicked
();
void
on_pay_edit_textChanged
(
const
QString
&
text
);
void
on_pay_edit_textChanged
(
const
QString
&
text
);
private
:
private
:
class
OrderInfo
{
public
:
OrderInfo
()
{
_amountStr
=
_scoreStr
=
_needPayStr
=
""
;
_amount
=
_score
=
_needPay
=
_maxWillPay
=
_useScore
=
_couponAmount
=
0
;
}
OrderInfo
(
QString
amountStr
,
QString
scoreStr
,
QString
needPayStr
)
{
this
->
_amountStr
=
amountStr
;
this
->
_scoreStr
=
scoreStr
;
this
->
_needPayStr
=
needPayStr
;
_amount
=
_amountStr
.
toDouble
()
/
100
;
_score
=
_scoreStr
.
toDouble
()
/
100
;
_needPay
=
_needPayStr
.
toDouble
()
/
100
;
_maxWillPay
=
_useScore
=
_couponAmount
=
0
;
setMaxWillPay
();
}
QString
getAmountStr
()
{
return
DOUBLE_STR
(
_amount
);
}
QString
getNeedPayStr
()
{
return
DOUBLE_STR
(
_needPay
);
}
QString
getScoreAmount
()
{
return
DOUBLE_STR
(
MIN
(
_score
,
_needPay
));
}
int
getPayAmount
(
QString
amountStr
)
{
double
payAmount
=
MIN
(
_needPay
,
(
amountStr
.
toDouble
()
+
_couponAmount
+
_useScore
))
*
100
;
return
QString
::
number
(
payAmount
).
toInt
();
}
// 代金券总额超过待付时返回true
bool
enoughCoupon
()
{
_couponAmount
=
0
.
0
;
foreach
(
auto
coupon
,
selectCouponMap
)
{
//_couponAmount += coupon.disAmount / 100;
if
(
coupon
.
typeModeFlag
==
20003
)
{
//代金券
_couponAmount
+=
coupon
.
disAmount
/
100
;
}
else
if
(
coupon
.
typeModeFlag
==
20004
)
{
//商品券
_couponAmount
+=
coupon
.
dis_price
/
100
;
}
}
qDebug
()
<<
"_couponAmount: "
<<
_couponAmount
;
qDebug
()
<<
"_needPay: "
<<
_needPay
;
bool
isEnough
=
(
_couponAmount
>
_needPay
);
setMaxWillPay
();
return
isEnough
;
}
void
setUseScore
(
bool
isUse
)
{
if
(
isUse
)
{
_useScore
=
MIN
(
_score
,
_needPay
);
}
else
{
_useScore
=
0
;
}
setMaxWillPay
();
}
double
getUseScore
()
{
return
_useScore
;
}
int
isUseScore
()
{
return
(
_useScore
==
0
?
0
:
1
);
}
// 设置付款金额的最大值
void
setMaxWillPay
()
{
double
willPay
=
_needPay
-
_useScore
-
_couponAmount
;
_maxWillPay
=
MIN
(
MAX
(
willPay
,
0
),
_amount
);
}
double
getMaxWillPay
()
{
return
_maxWillPay
;
}
/// 代金券列表
void
setCouponMap
(
QMap
<
QString
,
Coupon
>
couponMap
)
{
this
->
_couponMap
=
couponMap
;
_maxPage
=
(
couponMap
.
count
()
-
1
)
/
6
+
1
;
_nowPage
=
-
1
;
}
QMap
<
QString
,
Coupon
>
couponMap
()
{
return
_couponMap
;
}
QMap
<
QString
,
Coupon
>
selectCouponMap
;
private
:
QString
_amountStr
,
_scoreStr
,
_needPayStr
;
double
_amount
,
_score
,
_needPay
;
QMap
<
QString
,
Coupon
>
_couponMap
;
int
_maxPage
,
_nowPage
;
// 代金券金额 使用积分金额 余额将付金额
double
_couponAmount
,
_useScore
,
_maxWillPay
;
};
private
:
Ui
::
FMVipOrder
*
ui
;
Ui
::
FMVipOrder
*
ui
;
QMap
<
QString
,
Coupon
>
_couponMap
;
QMap
<
QString
,
Coupon
>
_selectCouponMap
;
double
_amount
,
_score
,
_needPay
,
_couponAmount
;
FMVipOrder
::
OrderInfo
*
orderInfo
;
bool
enoughCoupon
();
QString
oldPayText
;
void
initCouponItems
();
void
initCouponItems
();
bool
canUseCoupon
(
QString
curTransId
);
//一笔订单的多次支付间,只能使用一张券
};
};
#endif // FMVIPORDER_H
#endif // FMVIPORDER_H
windows/forms/fmviplogin.ui
View file @
8a8288f0
...
@@ -46,9 +46,14 @@
...
@@ -46,9 +46,14 @@
}
}
#logo_label {
#logo_label {
font: 75 22px
"
微软雅黑
"
;;
font: 75 22px
"
微软雅黑
"
;;
color: rgb(220, 220, 220);
/*color: rgb(220, 220, 220);*/
min-width: 120px; min-height: 54px;
color: rgb(255, 0, 0);
margin-left: 20;
min-width: 100px; min-height: 55px;
}
#tflogo
{
image:url(:/img/tflogo.png);
background-repeat:no-repeat;
}
}
#close_btn {
#close_btn {
min-width: 54;
min-width: 54;
...
@@ -280,6 +285,19 @@
...
@@ -280,6 +285,19 @@
<number>
0
</number>
<number>
0
</number>
</property>
</property>
<item>
<item>
<widget
class=
"QLabel"
name=
"tflogo"
>
<property
name=
"minimumSize"
>
<size>
<width>
55
</width>
<height>
55
</height>
</size>
</property>
<property
name=
"text"
>
<string/>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"logo_label"
>
<widget
class=
"QLabel"
name=
"logo_label"
>
<property
name=
"maximumSize"
>
<property
name=
"maximumSize"
>
<size>
<size>
...
@@ -288,7 +306,7 @@
...
@@ -288,7 +306,7 @@
</size>
</size>
</property>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
非码会员
</string>
<string>
天福会员管理系统
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
@@ -317,7 +335,7 @@
...
@@ -317,7 +335,7 @@
</item>
</item>
</layout>
</layout>
</widget>
</widget>
<widget
class=
"QWidget"
name=
""
>
<widget
class=
"QWidget"
name=
"
layoutWidget
"
>
<property
name=
"geometry"
>
<property
name=
"geometry"
>
<rect>
<rect>
<x>
0
</x>
<x>
0
</x>
...
...
windows/forms/fmviporder.ui
View file @
8a8288f0
...
@@ -50,11 +50,13 @@
...
@@ -50,11 +50,13 @@
border-bottom: 0 solid silver;
border-bottom: 0 solid silver;
}
}
#logo_label {
#logo_label {
font: 75 22px
"
微软雅黑
"
;
;
font: 75 22px
"
微软雅黑
"
;
color: rgb(2
20, 220, 22
0);
color: rgb(2
55, 0,
0);
min-width: 120px; min-height: 54px;
min-width: 120px; min-height: 54px;
margin-left: 20;
}
/*image: url(
"
:/img_logo.png
"
);*/
#tflogo{
image:url(:/img/tflogo.png);
background-repeat:no-repeat;
}
}
#close_btn {
#close_btn {
min-width: 54;
min-width: 54;
...
@@ -327,6 +329,19 @@
...
@@ -327,6 +329,19 @@
<number>
0
</number>
<number>
0
</number>
</property>
</property>
<item>
<item>
<widget
class=
"QLabel"
name=
"tflogo"
>
<property
name=
"minimumSize"
>
<size>
<width>
55
</width>
<height>
55
</height>
</size>
</property>
<property
name=
"text"
>
<string/>
</property>
</widget>
</item>
<item>
<widget
class=
"QLabel"
name=
"logo_label"
>
<widget
class=
"QLabel"
name=
"logo_label"
>
<property
name=
"maximumSize"
>
<property
name=
"maximumSize"
>
<size>
<size>
...
@@ -335,7 +350,7 @@
...
@@ -335,7 +350,7 @@
</size>
</size>
</property>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
非码会员
</string>
<string>
天福会员管理系统
</string>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
...
windows/forms/fmvippanel.ui
View file @
8a8288f0
...
@@ -179,7 +179,7 @@
...
@@ -179,7 +179,7 @@
</size>
</size>
</property>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string
/
>
<string
>
天福会员管理系统
</string
>
</property>
</property>
</widget>
</widget>
</item>
</item>
...
...
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