Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmp_epay
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_epay
Commits
96735c51
Commit
96735c51
authored
Sep 11, 2017
by
gujin.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善卡券核销和冲正相关问题
parent
c988b99a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
44 deletions
+98
-44
fmp_epay_p.cpp
+73
-3
fmp_epayview_dialog.cpp
+22
-39
fmp_epayview_dialog.h
+3
-2
No files found.
fmp_epay_p.cpp
View file @
96735c51
...
@@ -84,7 +84,8 @@ FMPePayPrivate::FMPePayPrivate(FMPePay *parent)
...
@@ -84,7 +84,8 @@ FMPePayPrivate::FMPePayPrivate(FMPePay *parent)
"pay_id varchar(50),"
"pay_id varchar(50),"
"code varchar(20),"
"code varchar(20),"
"pid varchar(20),"
"pid varchar(20),"
"total_amount integer)"
;
//卡券抵扣额,以分为单位
"total_amount integer,"
//卡券抵扣额,以分为单位
"redeem_json text)"
;
//卡券核销时的请求字符串,用于后续冲正
FMP_INFO
()
<<
"create table sql: "
<<
sql
;
FMP_INFO
()
<<
"create table sql: "
<<
sql
;
if
(
_db
->
creat
(
sql
)
==
false
)
if
(
_db
->
creat
(
sql
)
==
false
)
{
{
...
@@ -333,6 +334,19 @@ QByteArray FMPePayPrivate::DockPayRespond()
...
@@ -333,6 +334,19 @@ QByteArray FMPePayPrivate::DockPayRespond()
pay_ch
[
"ext"
]
=
_origin_response
[
"ext"
];
pay_ch
[
"ext"
]
=
_origin_response
[
"ext"
];
}
}
pay_channels
.
append
(
pay_ch
);
pay_channels
.
append
(
pay_ch
);
//添加卡券支付详情
foreach
(
QJsonObject
result
,
_payDialog
->
_redeem_results
)
{
QJsonObject
pay_ch
;
pay_ch
[
FMP_EPAY_PAY_ID
]
=
result
[
"couponType"
];
pay_ch
[
FMP_EPAY_PAY_DESC
]
=
result
[
"couponDesc"
];
pay_ch
[
"code"
]
=
result
[
"code"
];
pay_ch
[
"pay_amount"
]
=
result
[
"discount"
];
pay_ch
[
"pay_account"
]
=
_origin_response
[
"pay_acount"
].
toString
();
pay_ch
[
"platform_discount"
]
=
_origin_response
[
"mcoupon_amount"
].
toInt
();
pay_ch
[
"merchant_discount"
]
=
_origin_response
[
"pcoupon_amount"
].
toInt
();
pay_channels
.
append
(
pay_ch
);
}
_docked_response
[
FMP_EPAY_PAY_IDS
]
=
pay_channels
;
_docked_response
[
FMP_EPAY_PAY_IDS
]
=
pay_channels
;
}
}
...
@@ -694,6 +708,49 @@ void FMPePayPrivate::ControlRefundJson(const QJsonObject &trans)
...
@@ -694,6 +708,49 @@ void FMPePayPrivate::ControlRefundJson(const QJsonObject &trans)
if
(
_is_api
)
{
if
(
_is_api
)
{
_origin_response
=
outjson
;
_origin_response
=
outjson
;
}
}
//退款后冲正被核销的卡券
//先从fmp_pay表中根据fmId查找到 trans_id
tmpquery
.
clear
();
if
(
!
_db
->
find
(
q
->
_table
,
tmpquery
,
QStringList
(),
QString
(
"fmId='%1'"
).
arg
(
fmTransId
)))
{
FMP_ERROR
()
<<
"cannot find the order's trans_id, coupon reversal failed"
;
}
else
{
if
(
!
tmpquery
.
first
())
{
FMP_ERROR
()
<<
"there is no such order."
;
}
else
{
QString
transId
=
tmpquery
.
value
(
"trans_id"
).
toString
();
tmpquery
.
clear
();
if
(
_db
->
find
(
q
->
_redeem_table
,
tmpquery
,
QStringList
(),
QString
(
"trans_id='%1'"
).
arg
(
transId
)))
{
while
(
tmpquery
.
next
())
{
QByteArray
redeemReq
=
tmpquery
.
value
(
"redeem_json"
).
toByteArray
();
QJsonParseError
e
;
QJsonDocument
redeemDoc
=
QJsonDocument
::
fromJson
(
redeemReq
,
&
e
);
if
(
e
.
error
!=
QJsonParseError
::
NoError
)
{
FMP_ERROR
()
<<
e
.
errorString
();
}
else
{
QJsonObject
redeemObj
=
redeemDoc
.
object
();
_payDialog
->
Reverse
(
redeemObj
);
}
}
}
else
{
FMP_ERROR
()
<<
"search fmp_redeem table failed, or there is no relevant coupon need to reverse."
;
}
}
}
emit
finished
(
outjson
);
emit
finished
(
outjson
);
}
}
...
@@ -891,10 +948,23 @@ void FMPePayPrivate::writeOrderToSqlite()
...
@@ -891,10 +948,23 @@ void FMPePayPrivate::writeOrderToSqlite()
pay_ch
[
"ext"
]
=
_origin_response
[
"ext"
];
pay_ch
[
"ext"
]
=
_origin_response
[
"ext"
];
}
}
pay_channels
.
append
(
pay_ch
);
pay_channels
.
append
(
pay_ch
);
//添加卡券支付详情
foreach
(
QJsonObject
result
,
_payDialog
->
_redeem_results
)
{
QJsonObject
pay_ch
;
pay_ch
[
FMP_EPAY_PAY_ID
]
=
result
[
"couponType"
];
pay_ch
[
FMP_EPAY_PAY_DESC
]
=
result
[
"couponDesc"
];
pay_ch
[
"code"
]
=
result
[
"code"
];
pay_ch
[
"pay_amount"
]
=
result
[
"discount"
];
pay_ch
[
"pay_account"
]
=
_origin_response
[
"pay_acount"
].
toString
();
pay_ch
[
"platform_discount"
]
=
_origin_response
[
"mcoupon_amount"
].
toInt
();
pay_ch
[
"merchant_discount"
]
=
_origin_response
[
"pcoupon_amount"
].
toInt
();
pay_channels
.
append
(
pay_ch
);
}
response
[
FMP_EPAY_PAY_IDS
]
=
pay_channels
;
response
[
FMP_EPAY_PAY_IDS
]
=
pay_channels
;
QByteArray
json
=
QJsonDocument
(
response
).
toJson
();
QByteArray
json
=
QJsonDocument
(
response
).
toJson
();
if
(
!
SendToMonitor
(
json
)){
if
(
!
SendToMonitor
(
json
)){
emit
error
(
QString
::
fromLocal8Bit
(
"数据发送监控程序失败!"
));
emit
error
(
QString
::
fromLocal8Bit
(
"数据发送监控程序失败!"
));
FMP_ERROR
()
<<
"数据发送监控程序失败:"
<<
json
;
FMP_ERROR
()
<<
"数据发送监控程序失败:"
<<
json
;
...
@@ -974,7 +1044,7 @@ void FMPePayPrivate::setPosTransId(QString orderId)
...
@@ -974,7 +1044,7 @@ void FMPePayPrivate::setPosTransId(QString orderId)
bool
FMPePayPrivate
::
SendToMonitor
(
const
QByteArray
&
data
)
bool
FMPePayPrivate
::
SendToMonitor
(
const
QByteArray
&
data
)
{
{
FMP_
INFO
()
<<
"SendToMonitor:"
<<
data
;
FMP_
DEBUG
()
<<
"SendToMonitor:"
<<
data
;
bool
result
=
true
;
bool
result
=
true
;
QTcpSocket
client
;
QTcpSocket
client
;
...
...
fmp_epayview_dialog.cpp
View file @
96735c51
...
@@ -868,33 +868,19 @@ void FMPPayDialog::onBtnConfirmClicked()
...
@@ -868,33 +868,19 @@ void FMPPayDialog::onBtnConfirmClicked()
fakeResponse
[
"statusCode"
]
=
100
;
fakeResponse
[
"statusCode"
]
=
100
;
fakeResponse
[
"pay_acount"
]
=
""
;
fakeResponse
[
"pay_acount"
]
=
""
;
fakeResponse
[
"pay_ebcode"
]
=
""
;
fakeResponse
[
"pay_ebcode"
]
=
""
;
fakeResponse
[
"pay_id"
]
=
QString
::
fromLocal8Bit
(
"
非码卡券支付
"
);
fakeResponse
[
"pay_id"
]
=
QString
::
fromLocal8Bit
(
"
微信当面付[条码]
"
);
fakeResponse
[
"pay_transId"
]
=
""
;
fakeResponse
[
"pay_transId"
]
=
""
;
fakeResponse
[
"fmId"
]
=
""
;
fakeResponse
[
"fmId"
]
=
""
;
fakeResponse
[
"total_amount"
]
=
_should_pay
;
fakeResponse
[
"total_amount"
]
=
0
;
fakeResponse
[
"alipay_amount"
]
=
0
;
fakeResponse
[
"alipay_amount"
]
=
0
;
fakeResponse
[
"mcoupon_amount"
]
=
0
;
fakeResponse
[
"mcoupon_amount"
]
=
0
;
fakeResponse
[
"invoice_amount"
]
=
_pay_total
;
fakeResponse
[
"invoice_amount"
]
=
_pay_total
;
fakeResponse
[
"pay_total"
]
=
_pay_total
;
fakeResponse
[
"pay_total"
]
=
_pay_total
;
fakeResponse
[
"pay_ebcode"
]
=
"10004"
;
fakeResponse
[
"isrefund"
]
=
false
;
fakeResponse
[
"isrefund"
]
=
false
;
QJsonObject
ext
;
QString
desc
=
QString
::
fromLocal8Bit
(
"
\r\n
卡券支付明细
\r\n
"
);
desc
.
append
(
"----------------------------------------
\r\n
"
);
foreach
(
QString
item
,
couponDes
)
{
desc
.
append
(
item
);
desc
.
append
(
"
\r\n
"
);
}
desc
.
append
(
QString
::
fromLocal8Bit
(
"商户交易号:"
).
append
(
_control
->
_pos_trans_id
).
append
(
"
\r\n
"
));
desc
.
append
(
"----------------------------------------"
);
ext
[
"print"
]
=
desc
;
fakeResponse
[
"ext"
]
=
ext
;
qDebug
()
<<
fakeResponse
;
qDebug
()
<<
fakeResponse
;
_control
->
writeOrderToSqlite
(
fakeResponse
);
_control
->
writeOrderToSqlite
(
fakeResponse
);
_control
->
finished
(
fakeResponse
);
_control
->
finished
(
fakeResponse
);
// _api_force_close=true;
// _control->ClosePayWindow(DIALOG_FORCE_CLOSE);
// this->close();
// _control->Uninit();
return
;
return
;
}
}
...
@@ -1066,6 +1052,9 @@ void FMPPayDialog::on_cash_pay()
...
@@ -1066,6 +1052,9 @@ void FMPPayDialog::on_cash_pay()
}
}
void
FMPPayDialog
::
on_force_close
()
void
FMPPayDialog
::
on_force_close
()
{
{
//交易未完成的情况下关闭窗口,则尝试冲正已使用的卡券
Reverse
();
_api_force_close
=
true
;
_api_force_close
=
true
;
_control
->
ClosePayWindow
(
DIALOG_FORCE_CLOSE
);
_control
->
ClosePayWindow
(
DIALOG_FORCE_CLOSE
);
this
->
close
();
this
->
close
();
...
@@ -1149,25 +1138,6 @@ void FMPPayDialog::redeem()
...
@@ -1149,25 +1138,6 @@ void FMPPayDialog::redeem()
double
needPay
=
ui
->
lineedit_num
->
text
().
toDouble
();
double
needPay
=
ui
->
lineedit_num
->
text
().
toDouble
();
FMPRedeemInterface
*
redeem
=
FMP
::
GetService
<
FMPRedeemInterface
>
();
FMPRedeemInterface
*
redeem
=
FMP
::
GetService
<
FMPRedeemInterface
>
();
redeem
->
StartService
();
redeem
->
StartService
();
// QJsonObject request;
// request["business_date"] = "20170825";
// request["clientReqCount"] = 2;
// request["operator_id"] = "001";
// request["partnerId"] = 1371;
// request["reqtype"] = 71;
// request["station_id"] = "01";
// request["store_id"] = "fm99999";
// request["trans_id"] = "1503649216";
// QJsonArray transactions;
// QJsonObject transaction;
// transaction["code"] = "779335294";
// transaction["ebcode"] = "0000000252";
// transactions.append(transaction);
// request["transactions"] = transactions;
// request["ver"] = 2;
// redeem->Reverse(request);
// return;
QJsonObject
result
=
redeem
->
Redeem
(
needPay
,
_products_info
);
QJsonObject
result
=
redeem
->
Redeem
(
needPay
,
_products_info
);
FMP_DEBUG
()
<<
"redeem result: "
<<
result
;
FMP_DEBUG
()
<<
"redeem result: "
<<
result
;
...
@@ -1176,6 +1146,8 @@ void FMPPayDialog::redeem()
...
@@ -1176,6 +1146,8 @@ void FMPPayDialog::redeem()
if
(
result
[
"statusCode"
].
toInt
()
==
100
)
if
(
result
[
"statusCode"
].
toInt
()
==
100
)
{
{
_redeem_results
.
push_back
(
result
);
//增加该笔订单的总支付额
//增加该笔订单的总支付额
_pay_total
+=
result
[
"discount"
].
toInt
();
_pay_total
+=
result
[
"discount"
].
toInt
();
...
@@ -1183,14 +1155,15 @@ void FMPPayDialog::redeem()
...
@@ -1183,14 +1155,15 @@ void FMPPayDialog::redeem()
couponDes
.
append
(
QString
::
fromLocal8Bit
(
"%1:%2元"
).
arg
(
result
[
"couponType"
].
toString
()).
arg
(
result
[
"discount"
].
toInt
()
/
100.0
));
couponDes
.
append
(
QString
::
fromLocal8Bit
(
"%1:%2元"
).
arg
(
result
[
"couponType"
].
toString
()).
arg
(
result
[
"discount"
].
toInt
()
/
100.0
));
//保存该卡券的核销参数,以便后续冲正
//保存该卡券的核销参数,以便后续冲正
reverses
.
push_back
(
redeem
->
GetRedeemJson
());
_
reverses
.
push_back
(
redeem
->
GetRedeemJson
());
//记录核销详情
//记录核销详情
QJsonObject
redeemInfo
;
QJsonObject
redeemInfo
;
redeemInfo
[
"pay_id"
]
=
result
[
"coupon
Type
"
].
toString
();
redeemInfo
[
"pay_id"
]
=
result
[
"coupon
Desc
"
].
toString
();
redeemInfo
[
"code"
]
=
result
[
"code"
];
redeemInfo
[
"code"
]
=
result
[
"code"
];
redeemInfo
[
"pid"
]
=
result
[
"pid"
];
redeemInfo
[
"pid"
]
=
result
[
"pid"
];
redeemInfo
[
"total_amount"
]
=
result
[
"discount"
].
toInt
();
redeemInfo
[
"total_amount"
]
=
result
[
"discount"
].
toInt
();
redeemInfo
[
"redeem_json"
]
=
QString
::
fromLocal8Bit
(
QJsonDocument
(
result
[
"redeem_json"
].
toObject
()).
toJson
(
QJsonDocument
::
Compact
));
_control
->
WriteRedeemToSqlite
(
redeemInfo
);
_control
->
WriteRedeemToSqlite
(
redeemInfo
);
}
}
}
}
...
@@ -1229,11 +1202,20 @@ void FMPPayDialog::ShowPayDetail(const QModelIndex &index)
...
@@ -1229,11 +1202,20 @@ void FMPPayDialog::ShowPayDetail(const QModelIndex &index)
detailDlg
.
exec
();
detailDlg
.
exec
();
}
}
//用于退款时卡券冲正
void
FMPPayDialog
::
Reverse
(
const
QJsonObject
&
reverseReq
)
{
_reverses
.
push_back
(
reverseReq
);
Reverse
();
}
//用于支付失败时卡券冲正
void
FMPPayDialog
::
Reverse
()
void
FMPPayDialog
::
Reverse
()
{
{
FMPRedeemInterface
*
redeem
=
FMP
::
GetService
<
FMPRedeemInterface
>
();
FMPRedeemInterface
*
redeem
=
FMP
::
GetService
<
FMPRedeemInterface
>
();
redeem
->
StartService
();
redeem
->
StartService
();
foreach
(
QJsonObject
obj
,
reverses
)
{
foreach
(
QJsonObject
obj
,
_reverses
)
{
QJsonObject
result
=
redeem
->
Reverse
(
obj
);
QJsonObject
result
=
redeem
->
Reverse
(
obj
);
if
(
result
[
"statusCode"
].
toInt
()
==
100
)
if
(
result
[
"statusCode"
].
toInt
()
==
100
)
{
{
...
@@ -1246,4 +1228,5 @@ void FMPPayDialog::Reverse()
...
@@ -1246,4 +1228,5 @@ void FMPPayDialog::Reverse()
}
}
}
}
}
}
_reverses
.
clear
();
}
}
fmp_epayview_dialog.h
View file @
96735c51
...
@@ -111,6 +111,7 @@ public:
...
@@ -111,6 +111,7 @@ public:
void
setShowFunc
();
void
setShowFunc
();
void
Reverse
();
void
Reverse
();
void
Reverse
(
const
QJsonObject
&
reverseReq
);
private
:
private
:
...
@@ -139,7 +140,7 @@ private:
...
@@ -139,7 +140,7 @@ private:
public
:
public
:
int
_pay_total
;
//一笔订单的支付总额,包括 扫码支付额、卡券支付额......
int
_pay_total
;
//一笔订单的支付总额,包括 扫码支付额、卡券支付额......
QStringList
couponDes
;
QStringList
couponDes
;
QVector
<
QJsonObject
>
_redeem_results
;
//保存每张券的核销结果
private:
private:
Ui
::
FMPPayDialog
*
ui
;
Ui
::
FMPPayDialog
*
ui
;
...
@@ -160,7 +161,7 @@ private:
...
@@ -160,7 +161,7 @@ private:
bool
_api_force_close
;
bool
_api_force_close
;
QPoint
_mMovePosition
;
QPoint
_mMovePosition
;
QJsonArray
_products_info
;
QJsonArray
_products_info
;
QVector
<
QJsonObject
>
reverses
;
//存放卡券冲正的请求数据
QVector
<
QJsonObject
>
_
reverses
;
//存放卡券冲正的请求数据
int
_should_pay
;
//支付请求的应付金额,即amount
int
_should_pay
;
//支付请求的应付金额,即amount
};
};
...
...
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