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
7c692847
Commit
7c692847
authored
Sep 28, 2017
by
gujin.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加退款功能
parent
ed18036b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
116 deletions
+77
-116
global.h
+3
-19
task/taskfinal.cpp
+0
-9
task/taskfinal.h
+0
-1
task/taskothers.cpp
+0
-15
task/taskpay.cpp
+70
-71
windows/fmviporder.cpp
+4
-1
No files found.
global.h
View file @
7c692847
...
...
@@ -32,8 +32,8 @@ enum FM_TYPE {
FM_Order_Revoke
,
FM_QR_Pay
=
10031
,
FM_QR_Refund
=
10041
,
FM_Refund_Pay
,
FM_Refund_Order
FM_Refund_Pay
=
1004
,
FM_Refund_Order
=
1005
};
enum
Member_Type
{
...
...
@@ -256,21 +256,8 @@ const PropsMap::value_type PropsMapPairs[] =
PropsMap
::
value_type
(
PosProps
.
ConsumeNum
,
"consumeNum"
),
};
static
PropsMap
PosToServerProps
(
PropsMapPairs
,
PropsMapPairs
+
(
sizeof
(
PropsMapPairs
)
/
sizeof
(
PropsMapPairs
[
0
])));
class
FMPropsMap
{
public
:
static
QString
get
(
QString
posProp
)
{
PropsMap
::
iterator
it
=
PosToServerProps
.
find
(
posProp
);
if
(
it
!=
PosToServerProps
.
end
())
{
return
it
->
second
;
}
return
posProp
;
}
};
#endif
#define ServerProps(posProp) FMPropsMap::get(posProp)
#define ServerProps(posProp) PosToServerProps.find(posProp) == PosToServerProps.end() ? posProp : PosToServerProps[posProp]
// 签名字段
const
static
QString
SignProps
[]
=
{
...
...
@@ -333,10 +320,7 @@ const FMErrorMap fm_error(fm_error_pairs, fm_error_pairs + (sizeof fm_error_pair
#endif
#define AppDirPath qApp->applicationDirPath()
#define QuitCMD "{\"reqType\":-1}"
#endif // GLOBAL_H
task/taskfinal.cpp
View file @
7c692847
...
...
@@ -14,15 +14,6 @@ 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
()
{
isUseVipPay
=
false
;
...
...
task/taskfinal.h
View file @
7c692847
...
...
@@ -7,7 +7,6 @@ class TaskFinal : public FMTaskNoWnd
Q_OBJECT
public
:
explicit
TaskFinal
(
QJsonObject
&
jsonObj
,
Session
*
session
=
0
,
QObject
*
parent
=
0
);
virtual
QByteArray
doTask
();
void
packageServerReq
();
bool
sendToServer
(
bool
isShowMsg
=
true
);
void
packagePOSRsp
();
...
...
task/taskothers.cpp
View file @
7c692847
...
...
@@ -42,21 +42,6 @@ void TaskCoupon::packagePOSRsp()
int
type
=
couponOb
[
ServerProps
(
PosProps
.
Coupon_type
)].
toInt
();
QString
limitTime
=
couponOb
[
"expiration_date"
].
toString
();
// double disAmount = qRound((1-amount)*canDisAmount/100);
// if(amount<1) // 折扣券
// {
// Coupon c(desc, code, "discount", disAmount , 0, limitTime, false);
// c.setDiscountFactor(amount*10);
// QVariant v;
// v.setValue(c);
// couponMap[code] = v;
// } else {
// 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
;
v
.
setValue
(
c
);
...
...
task/taskpay.cpp
View file @
7c692847
...
...
@@ -61,18 +61,68 @@ QByteArray TaskPay::doTask()
}
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
;
QJsonObject
finalReq
;
finalReq
[
"pos_ver"
]
=
getPosJsonValue
(
"pos_ver"
).
toInt
();
finalReq
[
PosProps
.
OperatorId
]
=
searchJsonObject
(
serverReqJsonObj
,
ServerProps
(
PosProps
.
OperatorId
)).
toString
();
finalReq
[
PosProps
.
Fm_cmd
]
=
FM_Final
;
finalReq
[
PosProps
.
PosId
]
=
searchJsonObject
(
serverReqJsonObj
,
ServerProps
(
PosProps
.
PosId
)).
toString
();
finalReq
[
PosProps
.
StoreId
]
=
searchJsonObject
(
serverReqJsonObj
,
ServerProps
(
PosProps
.
StoreId
)).
toString
();
finalReq
[
PosProps
.
BussinessDate
]
=
searchJsonObject
(
serverReqJsonObj
,
ServerProps
(
PosProps
.
BussinessDate
)).
toString
();
finalReq
[
PosProps
.
TransId
]
=
searchJsonObject
(
serverReqJsonObj
,
ServerProps
(
PosProps
.
TransId
)).
toString
();
finalReq
[
PosProps
.
Fm_id
]
=
searchJsonObject
(
serverRspJsonObj
,
ServerProps
(
PosProps
.
Fm_id
)).
toString
();
finalReq
[
PosProps
.
Fm_open_id
]
=
searchJsonObject
(
serverReqJsonObj
,
ServerProps
(
PosProps
.
Fm_open_id
)).
toString
();
QJsonObject
transactions
;
transactions
[
PosProps
.
OrderAmount
]
=
searchJsonObject
(
posReqJsonObj
,
PosProps
.
OrderAmount
).
toInt
();
transactions
[
PosProps
.
PaidAmount
]
=
payAmount
;
QJsonArray
pay_ids
;
foreach
(
auto
p
,
searchJsonObject
(
serverReqJsonObj
,
"payList"
).
toArray
())
{
QJsonObject
pay_id
;
QString
flag
=
p
.
toObject
()[
"typeModeFlag"
].
toString
();
pay_id
[
PosProps
.
Pay_id
]
=
flag
;
if
(
flag
==
"20001"
)
{
pay_id
[
PosProps
.
Pay_str
]
=
QString
::
fromLocal8Bit
(
"非码会员余额"
);
}
else
if
(
flag
==
"20002"
)
{
pay_id
[
PosProps
.
Pay_str
]
=
QString
::
fromLocal8Bit
(
"非码会员积分"
);
}
else
if
(
flag
==
"20003"
)
{
pay_id
[
PosProps
.
Pay_str
]
=
QString
::
fromLocal8Bit
(
"非码代金券"
);
}
else
{
pay_id
[
PosProps
.
Pay_str
]
=
QString
::
fromLocal8Bit
(
"未知"
);
}
pay_id
[
PosProps
.
Pay_amount
]
=
p
.
toObject
()[
"amount"
].
toInt
();
pay_id
[
PosProps
.
Pay_transId
]
=
p
.
toObject
()[
"thirdPayTransId"
].
toString
();
pay_id
[
"code"
]
=
p
.
toObject
()[
"code"
].
toString
();
pay_ids
.
append
(
pay_id
);
}
transactions
[
PosProps
.
Pay_ids
]
=
pay_ids
;
QJsonArray
products
;
foreach
(
auto
p
,
searchJsonObject
(
serverReqJsonObj
,
"productList"
).
toArray
())
{
QJsonObject
product
;
product
[
PosProps
.
ConsumeNum
]
=
p
.
toObject
()[
"consumeNum"
].
toInt
();
product
[
PosProps
.
Price
]
=
p
.
toObject
()[
"price"
].
toInt
();
product
[
PosProps
.
ProductId
]
=
p
.
toObject
()[
"productId"
].
toString
();
product
[
"disAmount"
]
=
p
.
toObject
()[
"disAmount"
].
toInt
();
products
.
append
(
product
);
}
transactions
[
PosProps
.
Products
]
=
products
;
finalReq
[
PosProps
.
Transaction
]
=
transactions
;
del_p
(
preTask
);
preTask
=
new
TaskFinal
(
serverReqJsonObj
,
_session
,
this
);
preTask
=
new
TaskFinal
(
finalReq
,
_session
,
this
);
preTask
->
doTask
();
if
(
preTask
->
getServerJsonValue
(
PosProps
.
StatusCode
).
toInt
()
!=
FM_API_SUCCESS
)
{
FMMsgWnd
::
FailureWnd
(
QString
::
fromLocal8Bit
(
"非码会员支付失败"
));
//结算失败,退款
QJsonObject
refund
;
refund
[
"pos_ver"
]
=
getPosJsonValue
(
"pos_ver"
).
toInt
();
...
...
@@ -100,9 +150,11 @@ QByteArray TaskPay::doTask()
{
posRspJsonObj
[
PosProps
.
StatusCode
]
=
preTask
->
getServerJsonValue
(
PosProps
.
StatusCode
).
toInt
();
posRspJsonObj
[
PosProps
.
Msg
]
=
preTask
->
getServerJsonValue
(
PosProps
.
Msg
).
toString
();
FMMsgWnd
::
SuccessWnd
(
QString
::
fromLocal8Bit
(
"非码会员支付成功"
));
}
}
posRspJsonObj
[
PosProps
.
Pay_id
]
=
FM_Pay
;
QByteArray
result
=
QJsonDocument
(
posRspJsonObj
).
toJson
(
QJsonDocument
::
Compact
);
return
result
;
}
...
...
@@ -129,20 +181,20 @@ void TaskPay::packageServerReq()
{
//! 会员新接口使用 data 打包业务数据
QJsonObject
transData
;
transData
[
ServerProps
(
PosProps
.
TransId
)]
=
getPosJsonValue
(
PosProps
.
TransId
);
transData
[
ServerProps
(
PosProps
.
BussinessDate
)]
=
getPosJsonValue
(
PosProps
.
BussinessDate
);
transData
[
ServerProps
(
PosProps
.
TransId
)]
=
getPosJsonValue
(
PosProps
.
TransId
)
.
toString
()
;
transData
[
ServerProps
(
PosProps
.
BussinessDate
)]
=
getPosJsonValue
(
PosProps
.
BussinessDate
)
.
toString
()
;
transData
[
ServerProps
(
PosProps
.
Fm_id
)]
=
getPosJsonValue
(
PosProps
.
Fm_id
).
toString
();
transData
[
ServerProps
(
PosProps
.
Fm_open_id
)]
=
session
()
->
data
(
PosProps
.
Fm_open_id
).
toString
();
QJsonArray
products
;
QJsonArray
clientArray
=
getPosJsonValue
(
"products"
).
toArray
();
QJsonArray
clientArray
=
getPosJsonValue
(
PosProps
.
Products
).
toArray
();
for
(
int
i
=
0
;
i
<
clientArray
.
size
();
i
++
)
{
QJsonObject
obj
=
clientArray
[
i
].
toObject
();
QJsonObject
serverObj
;
serverObj
[
ServerProps
(
PosProps
.
ConsumeNum
)]
=
obj
[
PosProps
.
ConsumeNum
];
serverObj
[
"price"
]
=
obj
[
"price"
].
toInt
();
serverObj
[
"productId"
]
=
obj
[
"pid"
]
;
serverObj
[
ServerProps
(
PosProps
.
ConsumeNum
)]
=
obj
[
PosProps
.
ConsumeNum
]
.
toInt
()
;
serverObj
[
"price"
]
=
obj
[
PosProps
.
Price
].
toInt
();
serverObj
[
"productId"
]
=
obj
[
PosProps
.
ProductId
].
toString
()
;
serverObj
[
"disAmount"
]
=
obj
[
"disAmount"
].
toInt
();
products
.
push_back
(
serverObj
);
}
...
...
@@ -154,9 +206,9 @@ void TaskPay::packageServerReq()
if
(
codeAmount
!=
0
)
{
balance
[
"amount"
]
=
codeAmount
;
balance
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
);
balance
[
"transId"
]
=
getPosJsonValue
(
PosProps
.
TransId
).
toString
(
);
balance
[
"typeModeFlag"
]
=
QString
::
number
(
20001
);
balance
[
"thirdPayTransId"
]
=
""
;
balance
[
"thirdPayTransId"
]
=
getPosJsonValue
(
PosProps
.
Pay_transId
).
toString
()
;
payList
.
push_back
(
balance
);
}
...
...
@@ -165,51 +217,11 @@ void TaskPay::packageServerReq()
int
scoreAmount
=
session
()
->
data
(
PosProps
.
ScoreAmount
).
toInt
();
if
(
scoreAmount
>
0
)
{
score
[
"amount"
]
=
scoreAmount
;
score
[
"transId"
]
=
getPosJsonValue
(
"trans_id"
);
score
[
"transId"
]
=
getPosJsonValue
(
PosProps
.
TransId
).
toString
(
);
score
[
"typeModeFlag"
]
=
QString
::
number
(
20002
);
score
[
"thirdPayTransId"
]
=
""
;
score
[
"thirdPayTransId"
]
=
getPosJsonValue
(
PosProps
.
Pay_transId
).
toString
()
;
payList
.
push_back
(
score
);
}
#if 0
//代金券/商品券支付详情
QMap<QString, QVariant> coupons = session()->data("payCouponMap").toMap();
// 将代金券按金额从小到大排序
QList<Coupon> couponList;
for(QMap<QString, QVariant>::const_iterator it = coupons.constBegin(); it != coupons.constEnd(); it++)
{
couponList.append(it.value().value<Coupon>());
}
qSort(couponList.begin(), couponList.end(), [=](const Coupon &first, const Coupon &second){
return (first.disAmount() < second.disAmount());
});
// 计算使用的代金券金额
int needAmount = session()->data(PosProps.NeedAmount).toInt();
int needCouponAmount = needAmount - codeAmount - scoreAmount;
int couponAmount = 0;
foreach(Coupon c, couponList)
{
if(needCouponAmount <= 0) {
break;
}
QJsonObject coupon;
int couponDisAmount = c.disAmount() * 100;
if(couponDisAmount <= needCouponAmount) {
couponDisAmount = couponDisAmount;
needCouponAmount -= couponDisAmount;
} else {
couponDisAmount = MAX(0, needCouponAmount);
needCouponAmount = 0;
}
couponAmount += couponDisAmount;
coupon["amount"] = couponDisAmount;
coupon["transId"] = getPosJsonValue(PosProps.TransId);
coupon["typeModeFlag"] = 20003;
coupon["code"] = c.code();
payList.push_back(coupon);
}
#endif
//卡券支付详情
int
couponAmount
=
0
;
...
...
@@ -218,7 +230,7 @@ void TaskPay::packageServerReq()
{
QJsonObject
coupon
;
coupon
[
"amount"
]
=
it
.
value
().
value
<
Coupon
>
().
disAmount
()
*
100
;
coupon
[
"transId"
]
=
getPosJsonValue
(
PosProps
.
TransId
);
coupon
[
"transId"
]
=
getPosJsonValue
(
PosProps
.
TransId
)
.
toString
()
;
QString
coupon_type
=
it
.
value
().
value
<
Coupon
>
().
typeModeFlag
();
if
(
coupon_type
==
"1"
)
{
...
...
@@ -268,12 +280,6 @@ void TaskPay::packagePOSRsp()
{
QJsonObject
pay_id
;
QString
payId
=
servPayArray
[
i
].
toObject
()[
ServerProps
(
PosProps
.
Pay_id
)].
toString
();
// if(payId == "20003") {
// pay_id[PosProps.Pay_amount] = 0;
// pay_id["merchant_discount"] = servPayArray[i].toObject()[ServerProps(PosProps.Pay_amount)].toInt();
// } 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_id
]
=
payId
;
pay_id
[
PosProps
.
Pay_str
]
=
description
[
payId
];
...
...
@@ -286,14 +292,7 @@ void TaskPay::packagePOSRsp()
posRspJsonObj
[
"invoice_amount"
]
=
getServerJsonValue
(
"invoice_amount"
).
toInt
();
posRspJsonObj
[
"discount_amount"
]
=
getServerJsonValue
(
"discount_amount"
).
toInt
();
posRspJsonObj
[
PosProps
.
Pay_ids
]
=
pay_ids
;
posRspJsonObj
[
PosProps
.
Pay_id
]
=
"1003"
;
if
(
getServerJsonValue
(
PosProps
.
StatusCode
)
==
FM_API_SUCCESS
)
{
QJsonDocument
json
(
serverRspJsonObj
);
QByteArray
orderContent
=
json
.
toJson
(
QJsonDocument
::
Compact
);
FMBackup
::
instance
()
->
insertNewOrder
(
getServerJsonValue
(
PosProps
.
Fm_id
).
toString
(),
orderContent
);
}
posRspJsonObj
[
PosProps
.
Pay_id
]
=
FM_Pay
;
}
void
TaskPay
::
onPay
()
...
...
windows/fmviporder.cpp
View file @
7c692847
...
...
@@ -153,7 +153,10 @@ void FMVipOrder::onSelectionChanged(const QItemSelection &selected, const QItemS
orderInfo
->
selectCouponMap
.
remove
(
coupon
.
code
());
orderInfo
->
setMaxDisAmount
(
orderInfo
->
getMaxDisAmount
()
+
coupon
.
limitAmount
());
}
orderInfo
->
enoughCoupon
();
if
(
orderInfo
->
enoughCoupon
())
{
FMMsgWnd
::
WarningWnd
(
QString
::
fromLocal8Bit
(
"已超出待付金额"
),
this
);
}
oldPayText
=
DOUBLE_STR
(
orderInfo
->
getMaxWillPay
());
setWillPayText
();
}
...
...
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