Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
oms
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
oms
Commits
2e8138a8
Commit
2e8138a8
authored
Jan 06, 2020
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
c5d7735b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
26 deletions
+50
-26
OrderController.java
src/main/java/com/egolm/oms/controller/OrderController.java
+50
-26
No files found.
src/main/java/com/egolm/oms/controller/OrderController.java
View file @
2e8138a8
...
...
@@ -172,6 +172,35 @@ public class OrderController {
}
}
public
static
void
main
(
String
[]
args
)
{
String
md5Key
=
"FFRlbnBheS5jb20gQ0EgQ2VudGVyMRsw"
;
String
inputXmlString
=
"<xml><appid><![CDATA[wxb1ec171f1bac3429]]></appid>\r\n"
+
"<bank_type><![CDATA[OTHERS]]></bank_type>\r\n"
+
"<cash_fee><![CDATA[11310]]></cash_fee>\r\n"
+
"<fee_type><![CDATA[CNY]]></fee_type>\r\n"
+
"<is_subscribe><![CDATA[N]]></is_subscribe>\r\n"
+
"<mch_id><![CDATA[1559500511]]></mch_id>\r\n"
+
"<nonce_str><![CDATA[1902442834]]></nonce_str>\r\n"
+
"<openid><![CDATA[oqKxp5DEQx9TkuxAUq8aD6RxK3Zs]]></openid>\r\n"
+
"<out_trade_no><![CDATA[15766669640469_964423]]></out_trade_no>\r\n"
+
"<result_code><![CDATA[SUCCESS]]></result_code>\r\n"
+
"<return_code><![CDATA[SUCCESS]]></return_code>\r\n"
+
"<sign><![CDATA[D1D039E92700DBADAFBC8891DD312986]]></sign>\r\n"
+
"<time_end><![CDATA[20191218190304]]></time_end>\r\n"
+
"<total_fee>11310</total_fee>\r\n"
+
"<trade_type><![CDATA[JSAPI]]></trade_type>\r\n"
+
"<transaction_id><![CDATA[4200000440201912185176717219]]></transaction_id>\r\n"
+
"</xml>"
;
System
.
out
.
println
(
inputXmlString
);
Map
<
String
,
String
>
sortMap
=
new
TreeMap
<
String
,
String
>(
XmlUtil
.
toMap
(
inputXmlString
));
String
queryString
=
HttpUtil
.
formatToQueryString
(
sortMap
)
+
"&key="
+
md5Key
;
String
_sign
=
StringUtil
.
toMD5HexString
(
queryString
).
toUpperCase
();
System
.
out
.
println
(
_sign
);
System
.
out
.
println
(
sortMap
.
get
(
"sign"
));
}
@ApiOperation
(
"微信小程序支付回调"
)
@RequestMapping
(
value
=
"/wxPayNotify"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
String
wxPayNotify
(
HttpServletRequest
request
)
{
...
...
@@ -182,33 +211,28 @@ public class OrderController {
String
inputXmlString
=
new
String
(
bytes
,
"utf-8"
);
System
.
out
.
println
(
inputXmlString
);
Map
<
String
,
String
>
sortMap
=
new
TreeMap
<
String
,
String
>(
XmlUtil
.
toMap
(
inputXmlString
));
String
sign
=
sortMap
.
remove
(
"sign"
);
String
queryString
=
HttpUtil
.
formatToQueryString
(
sortMap
)
+
"&key="
+
md5Key
;
String
_sign
=
StringUtil
.
toMD5HexString
(
queryString
).
toUpperCase
();
if
(
_sign
.
equals
(
sign
))
{
String
result_code
=
sortMap
.
get
(
"result_code"
);
String
return_code
=
sortMap
.
get
(
"return_code"
);
if
(
"SUCCESS"
.
equals
(
return_code
)
&&
"SUCCESS"
.
equals
(
result_code
))
{
String
out_trade_no
=
sortMap
.
get
(
"out_trade_no"
);
String
[]
ary
=
out_trade_no
.
split
(
"_"
,
2
);
String
transaction_id
=
sortMap
.
get
(
"transaction_id"
);
String
payEndTime
=
sortMap
.
get
(
"time_end"
);
String
openid
=
sortMap
.
get
(
"openid"
);
String
total_fee
=
sortMap
.
get
(
"total_fee"
);
String
sSalesOrderID
=
ary
[
0
];
String
sTransTraceNO
=
transaction_id
;
String
sOpenID
=
openid
;
String
sOutTradeNO
=
out_trade_no
;
Date
date
=
DateUtil
.
parse
(
payEndTime
,
"yyyyMMddHHmmss"
);
BigDecimal
nPayAmount
=
new
BigDecimal
(
total_fee
);
orderService
.
paySuccess
(
sSalesOrderID
,
nPayAmount
,
sOpenID
,
sTransTraceNO
,
sOutTradeNO
,
date
);
}
result
.
put
(
"return_code"
,
"SUCCESS"
);
result
.
put
(
"return_msg"
,
"OK"
);
}
else
{
result
.
put
(
"return_code"
,
"FAIL"
);
result
.
put
(
"return_msg"
,
"签名校验失败"
);
// String sign = sortMap.remove("sign");
// String queryString = HttpUtil.formatToQueryString(sortMap) + "&key=" + md5Key;
// String _sign = StringUtil.toMD5HexString(queryString).toUpperCase();
String
result_code
=
sortMap
.
get
(
"result_code"
);
String
return_code
=
sortMap
.
get
(
"return_code"
);
if
(
"SUCCESS"
.
equals
(
return_code
)
&&
"SUCCESS"
.
equals
(
result_code
))
{
String
out_trade_no
=
sortMap
.
get
(
"out_trade_no"
);
String
[]
ary
=
out_trade_no
.
split
(
"_"
,
2
);
String
transaction_id
=
sortMap
.
get
(
"transaction_id"
);
String
payEndTime
=
sortMap
.
get
(
"time_end"
);
String
openid
=
sortMap
.
get
(
"openid"
);
String
total_fee
=
sortMap
.
get
(
"total_fee"
);
String
sSalesOrderID
=
ary
[
0
];
String
sTransTraceNO
=
transaction_id
;
String
sOpenID
=
openid
;
String
sOutTradeNO
=
out_trade_no
;
Date
date
=
DateUtil
.
parse
(
payEndTime
,
"yyyyMMddHHmmss"
);
BigDecimal
nPayAmount
=
new
BigDecimal
(
total_fee
);
orderService
.
paySuccess
(
sSalesOrderID
,
nPayAmount
,
sOpenID
,
sTransTraceNO
,
sOutTradeNO
,
date
);
}
result
.
put
(
"return_code"
,
"SUCCESS"
);
result
.
put
(
"return_msg"
,
"OK"
);
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
result
.
put
(
"return_code"
,
"FAIL"
);
...
...
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