Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
405659b4
Commit
405659b4
authored
Nov 16, 2023
by
YG8999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付回调
parent
02cb26ea
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
10 deletions
+30
-10
CallbackController.java
.../java/share/web/controller/system/CallbackController.java
+1
-1
PayConstants.java
...mon/src/main/java/share/common/constant/PayConstants.java
+2
-2
WeChatConstants.java
.../src/main/java/share/common/constant/WeChatConstants.java
+13
-1
SecurityConfig.java
.../src/main/java/share/framework/config/SecurityConfig.java
+1
-1
CallbackServiceImpl.java
...n/java/share/system/service/impl/CallbackServiceImpl.java
+6
-5
OrderPayServiceImpl.java
...n/java/share/system/service/impl/OrderPayServiceImpl.java
+2
-0
WxPayUtil.java
share-system/src/main/java/share/system/util/WxPayUtil.java
+5
-0
No files found.
share-admin/src/main/java/share/web/controller/system/CallbackController.java
View file @
405659b4
...
...
@@ -18,7 +18,7 @@ import javax.servlet.http.HttpServletRequest;
*/
@Slf4j
@RestController
@RequestMapping
(
"
api
/admin/payment/callback"
)
@RequestMapping
(
"/admin/payment/callback"
)
@Api
(
tags
=
"支付回调"
)
public
class
CallbackController
{
...
...
share-common/src/main/java/share/common/constant/PayConstants.java
View file @
405659b4
...
...
@@ -32,9 +32,9 @@ public class PayConstants {
// 微信查询订单
public
static
final
String
WX_PAY_ORDER_QUERY_API_URI
=
"pay/orderquery"
;
// 微信支付回调地址
public
static
final
String
WX_PAY_NOTIFY_API_URI
=
"/api/admin/payment/callback/wechat"
;
public
static
final
String
WX_PAY_NOTIFY_API_URI
=
"/
prod-
api/admin/payment/callback/wechat"
;
// 微信退款回调地址
public
static
final
String
WX_PAY_REFUND_NOTIFY_API_URI
=
"/api/admin/payment/callback/wechat/refund"
;
public
static
final
String
WX_PAY_REFUND_NOTIFY_API_URI
=
"/
prod-
api/admin/payment/callback/wechat/refund"
;
public
static
final
String
WX_PAY_SIGN_TYPE_MD5
=
"MD5"
;
public
static
final
String
WX_PAY_SIGN_TYPE_SHA256
=
"HMAC-SHA256"
;
...
...
share-common/src/main/java/share/common/constant/WeChatConstants.java
View file @
405659b4
...
...
@@ -213,7 +213,7 @@ public class WeChatConstants {
//微信支付接口请求地址
public
static
final
String
PAY_API_URL
=
"https://api.mch.weixin.qq.com/"
;
public
static
final
String
PAY_API_URI
=
"pay/unifiedorder"
;
public
static
final
String
PAY_NOTIFY_API_URI_WECHAT
=
"/api/admin/payment/callback/wechat"
;
public
static
final
String
PAY_NOTIFY_API_URI_WECHAT
=
"/
prod-
api/admin/payment/callback/wechat"
;
// 公共号退款
public
static
final
String
PAY_REFUND_API_URI_WECHAT
=
"secapi/pay/refund"
;
...
...
@@ -379,4 +379,16 @@ public class WeChatConstants {
public
static
final
String
WECAHT_CALLBACK_EVENT_SPU_AUDIT
=
"open_product_spu_audit"
;
/** 微信小程序回调,品牌审核回调事件 */
public
static
final
String
WECAHT_CALLBACK_EVENT_BRAND_AUDIT
=
"open_product_brand_audit"
;
// 微信回调标识
/**
* 通用成功标识
*/
public
static
final
String
SUCCESS
=
"SUCCESS"
;
/**
* 通用失败标识
*/
public
static
final
String
FAIL
=
"FAIL"
;
}
share-framework/src/main/java/share/framework/config/SecurityConfig.java
View file @
405659b4
...
...
@@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
// 过滤请求
.
authorizeRequests
()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
.
antMatchers
(
"/login"
,
"/register"
,
"/captchaImage"
).
permitAll
()
.
antMatchers
(
"/login"
,
"/register"
,
"/captchaImage"
,
"/admin/payment/callback/**"
).
permitAll
()
// 静态资源,可匿名访问
.
antMatchers
(
HttpMethod
.
GET
,
"/"
,
"/*.html"
,
"/**/*.html"
,
"/**/*.css"
,
"/**/*.js"
,
"/profile/**"
).
permitAll
()
.
antMatchers
(
"/swagger-ui.html"
,
"/swagger-resources/**"
,
"/webjars/**"
,
"/*/api-docs"
,
"/druid/**"
).
permitAll
()
...
...
share-system/src/main/java/share/system/service/impl/CallbackServiceImpl.java
View file @
405659b4
...
...
@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
share.common.config.WeChatConfig
;
import
share.common.constant.Constants
;
import
share.common.constant.WeChatConstants
;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.OrderStatusEnum
;
import
share.common.enums.OrderTypeEnum
;
...
...
@@ -85,7 +86,7 @@ public class CallbackServiceImpl implements CallbackService {
HashMap
<
String
,
Object
>
map
=
WxPayUtil
.
processResponseXml
(
xmlInfo
);
// 通信是否成功
String
returnCode
=
(
String
)
map
.
get
(
"return_code"
);
if
(!
returnCode
.
equals
(
Constants
.
SUCCESS
))
{
if
(!
returnCode
.
equals
(
WeChat
Constants
.
SUCCESS
))
{
sb
.
append
(
"<return_code><![CDATA[SUCCESS]]></return_code>"
);
sb
.
append
(
"<return_msg><![CDATA[OK]]></return_msg>"
);
sb
.
append
(
"</xml>"
);
...
...
@@ -94,7 +95,7 @@ public class CallbackServiceImpl implements CallbackService {
}
// 交易是否成功
String
resultCode
=
(
String
)
map
.
get
(
"result_code"
);
if
(!
resultCode
.
equals
(
Constants
.
SUCCESS
))
{
if
(!
resultCode
.
equals
(
WeChat
Constants
.
SUCCESS
))
{
sb
.
append
(
"<return_code><![CDATA[SUCCESS]]></return_code>"
);
sb
.
append
(
"<return_msg><![CDATA[OK]]></return_msg>"
);
sb
.
append
(
"</xml>"
);
...
...
@@ -178,7 +179,7 @@ public class CallbackServiceImpl implements CallbackService {
logger
.
error
(
"wechat pay error : 业务异常==》"
+
e
.
getMessage
());
}
sb
.
append
(
"</xml>"
);
logger
.
error
(
"wechat callback response : "
+
sb
.
toString
());
logger
.
info
(
"wechat callback response : "
+
sb
.
toString
());
return
sb
.
toString
();
}
...
...
@@ -277,7 +278,7 @@ public class CallbackServiceImpl implements CallbackService {
notifyRecord
.
setColums
(
_strMap2ObjMap
(
respMap
));
// 这里的可以应该根据小程序还是公众号区分
String
return_code
=
respMap
.
get
(
"return_code"
);
if
(
return_code
.
equals
(
Constants
.
SUCCESS
))
{
if
(
return_code
.
equals
(
WeChat
Constants
.
SUCCESS
))
{
String
appid
=
respMap
.
get
(
"appid"
);
String
signKey
=
getSignKey
(
appid
);
// 解码加密信息
...
...
@@ -289,7 +290,7 @@ public class CallbackServiceImpl implements CallbackService {
notifyRecord
.
setColums
(
_strMap2ObjMap
(
infoMap
));
String
refund_status
=
infoMap
.
get
(
"refund_status"
);
refundRecord
.
set
(
"isRefund"
,
refund_status
.
equals
(
Constants
.
SUCCESS
));
refundRecord
.
set
(
"isRefund"
,
refund_status
.
equals
(
WeChat
Constants
.
SUCCESS
));
}
catch
(
Exception
e
)
{
refundRecord
.
set
(
"isRefund"
,
false
);
logger
.
error
(
"微信退款回调异常,e==》"
+
e
.
getMessage
());
...
...
share-system/src/main/java/share/system/service/impl/OrderPayServiceImpl.java
View file @
405659b4
package
share
.
system
.
service
.
impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -129,6 +130,7 @@ public class OrderPayServiceImpl implements OrderPayService {
vo
.
setSign_type
(
PayConstants
.
WX_PAY_SIGN_TYPE_MD5
);
vo
.
setAttach
(
JSONObject
.
toJSONString
(
attachVo
));
vo
.
setOut_trade_no
(
BaseUtil
.
getOrderNo
(
"wxNo"
));
vo
.
setBody
(
StrUtil
.
concat
(
true
,
sOrder
.
getTimeLong
(),
"小时麻将房畅玩!"
));
// 订单中使用的是BigDecimal,这里要转为Integer类型
vo
.
setTotal_fee
(
sOrder
.
getPayPrice
().
multiply
(
BigDecimal
.
TEN
).
multiply
(
BigDecimal
.
TEN
).
intValue
());
vo
.
setNotify_url
(
apiDomain
+
PayConstants
.
WX_PAY_NOTIFY_API_URI
);
...
...
share-system/src/main/java/share/system/util/WxPayUtil.java
View file @
405659b4
...
...
@@ -9,6 +9,7 @@ import org.w3c.dom.Node;
import
org.w3c.dom.NodeList
;
import
share.common.constant.Constants
;
import
share.common.constant.PayConstants
;
import
share.common.constant.WeChatConstants
;
import
share.common.exception.base.BaseException
;
import
share.common.utils.BaseUtil
;
import
share.common.utils.XmlUtil
;
...
...
@@ -50,6 +51,10 @@ public class WxPayUtil {
return
respData
;
}
else
if
(
return_code
.
equals
(
Constants
.
SUCCESS
))
{
return
respData
;
}
else
if
(
return_code
.
equals
(
WeChatConstants
.
FAIL
))
{
return
respData
;
}
else
if
(
return_code
.
equals
(
WeChatConstants
.
SUCCESS
))
{
return
respData
;
}
else
{
throw
new
BaseException
(
String
.
format
(
"return_code value %s is invalid in XML: %s"
,
return_code
,
xmlStr
));
}
...
...
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