Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kaoshi-java
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
单欣鑫
kaoshi-java
Commits
a73f5574
Commit
a73f5574
authored
Jun 24, 2025
by
Wzp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
H5支付
parent
a0aa1b11
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
211 additions
and
42 deletions
+211
-42
AlipayService.java
...c/main/java/com/ruoyi/hezhi/api/entity/AlipayService.java
+59
-13
ApiPayController.java
...ain/java/com/ruoyi/hezhi/api/kaoshi/ApiPayController.java
+141
-27
application.yml
ruoyi-admin/src/main/resources/application.yml
+3
-1
pom.xml
ruoyi-common/pom.xml
+1
-1
WeiXinPayConfig.java
.../java/com/ruoyi/common/weixin/config/WeiXinPayConfig.java
+7
-0
No files found.
ruoyi-admin/src/main/java/com/ruoyi/hezhi/api/entity/AlipayService.java
View file @
a73f5574
...
@@ -6,10 +6,13 @@ import com.alipay.api.AlipayConfig;
...
@@ -6,10 +6,13 @@ import com.alipay.api.AlipayConfig;
import
com.alipay.api.DefaultAlipayClient
;
import
com.alipay.api.DefaultAlipayClient
;
import
com.alipay.api.domain.AlipayTradePagePayModel
;
import
com.alipay.api.domain.AlipayTradePagePayModel
;
import
com.alipay.api.domain.AlipayTradeRefundModel
;
import
com.alipay.api.domain.AlipayTradeRefundModel
;
import
com.alipay.api.domain.AlipayTradeWapPayModel
;
import
com.alipay.api.request.AlipayTradePagePayRequest
;
import
com.alipay.api.request.AlipayTradePagePayRequest
;
import
com.alipay.api.request.AlipayTradeRefundRequest
;
import
com.alipay.api.request.AlipayTradeRefundRequest
;
import
com.alipay.api.request.AlipayTradeWapPayRequest
;
import
com.alipay.api.response.AlipayTradePagePayResponse
;
import
com.alipay.api.response.AlipayTradePagePayResponse
;
import
com.alipay.api.response.AlipayTradeRefundResponse
;
import
com.alipay.api.response.AlipayTradeRefundResponse
;
import
com.alipay.api.response.AlipayTradeWapPayResponse
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.hezhi.domain.TbMemberOrder
;
import
com.ruoyi.hezhi.domain.TbMemberOrder
;
import
com.ruoyi.hezhi.service.ITbMemberOrderService
;
import
com.ruoyi.hezhi.service.ITbMemberOrderService
;
...
@@ -25,6 +28,7 @@ import java.util.Map;
...
@@ -25,6 +28,7 @@ import java.util.Map;
/**
/**
* 支付宝支付
* 支付宝支付
*
* @author Wzp
* @author Wzp
*/
*/
@Component
@Component
...
@@ -52,12 +56,13 @@ public class AlipayService {
...
@@ -52,12 +56,13 @@ public class AlipayService {
/**
/**
* 支付宝支付生成预付单
* 支付宝支付生成预付单
* @param realPay 支付金额
*
* @param paySn 支付单号
* @param realPay 支付金额
* @param paySn 支付单号
* @param description 描述
* @param description 描述
* @return 结果
* @return 结果
*/
*/
public
String
aliPaySubmit
(
BigDecimal
realPay
,
String
paySn
,
String
description
,
Long
examId
,
Long
memberUserId
)
{
public
String
aliPaySubmit
(
BigDecimal
realPay
,
String
paySn
,
String
description
,
Long
examId
,
Long
memberUserId
)
{
try
{
try
{
// 初始化SDK
// 初始化SDK
AlipayClient
alipayClient
=
getAlipayClient
();
AlipayClient
alipayClient
=
getAlipayClient
();
...
@@ -71,20 +76,59 @@ public class AlipayService {
...
@@ -71,20 +76,59 @@ public class AlipayService {
model
.
setProductCode
(
"FAST_INSTANT_TRADE_PAY"
);
// 设置产品码
model
.
setProductCode
(
"FAST_INSTANT_TRADE_PAY"
);
// 设置产品码
model
.
setQrPayMode
(
"1"
);
// 设置PC扫码支付的方式
model
.
setQrPayMode
(
"1"
);
// 设置PC扫码支付的方式
model
.
setQrcodeWidth
(
100L
);
// 设置商户自定义二维码宽度
model
.
setQrcodeWidth
(
100L
);
// 设置商户自定义二维码宽度
model
.
setRequestFromUrl
(
"https://www.chsie.com.cn/payTheFees?examId="
+
examId
+
"&memberUserId="
+
memberUserId
);
model
.
setRequestFromUrl
(
"https://www.chsie.com.cn/payTheFees?examId="
+
examId
+
"&memberUserId="
+
memberUserId
);
request
.
setBizModel
(
model
);
request
.
setBizModel
(
model
);
request
.
setNotifyUrl
(
aliPayConfig
.
getNotifyUrl
()
+
"/api/pay/aliPayBoilerNotify"
);
request
.
setNotifyUrl
(
aliPayConfig
.
getNotifyUrl
()
+
"/api/pay/aliPayBoilerNotify"
);
// request.setReturnUrl("https://www.chsie.com.cn/examDetail?examId="+examId);//支付成功后跳转回哪个页面
// request.setReturnUrl("https://www.chsie.com.cn/examDetail?examId="+examId);//支付成功后跳转回哪个页面
AlipayTradePagePayResponse
response
=
alipayClient
.
pageExecute
(
request
,
"POST"
);
AlipayTradePagePayResponse
response
=
alipayClient
.
pageExecute
(
request
,
"POST"
);
// 如果需要返回GET请求,请使用
// 如果需要返回GET请求,请使用
if
(
response
.
isSuccess
()){
if
(
response
.
isSuccess
())
{
return
response
.
getBody
();
return
response
.
getBody
();
}
else
{
}
else
{
throw
new
ServerCloneException
(
"支付宝支付失败"
);
throw
new
ServerCloneException
(
"支付宝支付失败"
);
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ServiceException
(
"支付宝支付异常"
);
}
}
/**
* 支付宝支付生成预付单-H5
*
* @param realPay 支付金额
* @param paySn 支付单号
* @param description 描述
* @return 结果
*/
public
String
aliPayH5Submit
(
BigDecimal
realPay
,
String
paySn
,
String
description
,
Long
examId
,
Long
memberUserId
)
{
try
{
// 初始化SDK
AlipayClient
alipayClient
=
getAlipayClient
();
// 构造请求参数以调用接口
AlipayTradeWapPayRequest
request
=
new
AlipayTradeWapPayRequest
();
AlipayTradeWapPayModel
model
=
new
AlipayTradeWapPayModel
();
model
.
setOutTradeNo
(
paySn
);
// 设置商户订单号
model
.
setTotalAmount
(
realPay
.
toString
());
// 设置订单总金额
model
.
setSubject
(
description
);
// 设置订单标题
model
.
setProductCode
(
"QUICK_WAP_WAY"
);
// 设置产品码
model
.
setQuitUrl
(
"https://h5.chsie.com.cn/#/subPages/examDetailsIndex/examDetailsIndex?examNoticeId="
+
examId
);
request
.
setBizModel
(
model
);
request
.
setNotifyUrl
(
aliPayConfig
.
getNotifyUrl
()
+
"/api/pay/aliPayBoilerNotify"
);
request
.
setReturnUrl
(
"https://h5.chsie.com.cn/#/subPages/examDetailsIndex/examDetailsIndex?examNoticeId="
+
examId
);
AlipayTradeWapPayResponse
response
=
alipayClient
.
pageExecute
(
request
,
"POST"
);
// 如果需要返回GET请求,请使用
if
(
response
.
isSuccess
())
{
return
response
.
getBody
();
}
else
{
throw
new
ServerCloneException
(
"支付宝支付失败"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
throw
new
ServiceException
(
"支付宝支付异常"
);
throw
new
ServiceException
(
"支付宝支付异常"
);
}
}
...
@@ -92,11 +136,12 @@ public class AlipayService {
...
@@ -92,11 +136,12 @@ public class AlipayService {
/**
/**
* 支付宝退款
* 支付宝退款
*
* @param orderSn 订单号
* @param orderSn 订单号
* @param payment 支付金额
* @param payment 支付金额
* @return 结果
* @return 结果
*/
*/
public
String
tradeRefund
(
String
orderSn
,
BigDecimal
payment
)
{
public
String
tradeRefund
(
String
orderSn
,
BigDecimal
payment
)
{
System
.
out
.
println
(
"开始调用支付宝退款****************"
);
System
.
out
.
println
(
"开始调用支付宝退款****************"
);
try
{
try
{
...
@@ -112,14 +157,14 @@ public class AlipayService {
...
@@ -112,14 +157,14 @@ public class AlipayService {
request
.
setBizModel
(
refundModel
);
request
.
setBizModel
(
refundModel
);
AlipayTradeRefundResponse
response
=
alipayClient
.
certificateExecute
(
request
);
AlipayTradeRefundResponse
response
=
alipayClient
.
certificateExecute
(
request
);
if
(
response
.
isSuccess
()){
if
(
response
.
isSuccess
())
{
log
.
info
(
"支付宝退款调用成功"
+
response
);
log
.
info
(
"支付宝退款调用成功"
+
response
);
return
"SUCCESS"
;
return
"SUCCESS"
;
}
else
{
}
else
{
log
.
error
(
"支付宝退款调用失败"
+
response
);
log
.
error
(
"支付宝退款调用失败"
+
response
);
return
"FAIL"
;
return
"FAIL"
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
log
.
error
(
"支付宝退款错误!"
,
e
.
getMessage
());
log
.
error
(
"支付宝退款错误!"
,
e
.
getMessage
());
return
"FAIL"
;
return
"FAIL"
;
...
@@ -128,6 +173,7 @@ public class AlipayService {
...
@@ -128,6 +173,7 @@ public class AlipayService {
/**
/**
* 校验回调参数
* 校验回调参数
*
* @param params 参数
* @param params 参数
* @return
* @return
*/
*/
...
@@ -141,7 +187,7 @@ public class AlipayService {
...
@@ -141,7 +187,7 @@ public class AlipayService {
}
}
// 验证商户app_id
// 验证商户app_id
String
appId
=
params
.
get
(
"app_id"
);
String
appId
=
params
.
get
(
"app_id"
);
if
(!
appId
.
equals
(
aliPayConfig
.
getAppId
()))
{
if
(!
appId
.
equals
(
aliPayConfig
.
getAppId
()))
{
log
.
error
(
"app_id 错误"
);
log
.
error
(
"app_id 错误"
);
return
"FAIL"
;
return
"FAIL"
;
}
}
...
...
ruoyi-admin/src/main/java/com/ruoyi/hezhi/api/kaoshi/ApiPayController.java
View file @
a73f5574
This diff is collapsed.
Click to expand it.
ruoyi-admin/src/main/resources/application.yml
View file @
a73f5574
...
@@ -231,6 +231,8 @@ wx:
...
@@ -231,6 +231,8 @@ wx:
apiV3Key
:
yFRJqhZQJ45wrwg2zJwokb40P7Yn2123
apiV3Key
:
yFRJqhZQJ45wrwg2zJwokb40P7Yn2123
# 微信支付回调通知域名
# 微信支付回调通知域名
notifyUrl
:
https://server.chsie.com.cn/api/pay/createNativePayParamNotify
notifyUrl
:
https://server.chsie.com.cn/api/pay/createNativePayParamNotify
# 微信支付回调通知域名
h5NotifyUrl
:
https://server.chsie.com.cn/api/pay/createH5PayParamNotify
# 支付宝支付回调通知域名
# 支付宝支付回调通知域名
notifyZfbUrl
:
https://server.chsie.com.cn/api/pay/aliPayBoilerNotify
notifyZfbUrl
:
https://server.chsie.com.cn/api/pay/aliPayBoilerNotify
# 商品描述
# 商品描述
...
@@ -282,4 +284,4 @@ tencentSmsCode:
...
@@ -282,4 +284,4 @@ tencentSmsCode:
# 模板 ID
# 模板 ID
templateId
:
2411208
templateId
:
2411208
# 手机验证码过期时间(分钟)
# 手机验证码过期时间(分钟)
smsCodeExpire
:
5
smsCodeExpire
:
5
\ No newline at end of file
ruoyi-common/pom.xml
View file @
a73f5574
...
@@ -178,7 +178,7 @@
...
@@ -178,7 +178,7 @@
<version>
23.4
</version>
<version>
23.4
</version>
<classifier>
jdk17
</classifier>
<classifier>
jdk17
</classifier>
<scope>
system
</scope>
<scope>
system
</scope>
<systemPath>
C:/Users/71960/.m2/repository
/com/aspose/aspose-words/23.4/aspose-words-23.4-jdk17.jar
</systemPath>
<systemPath>
F:/Maven/maven-repo
/com/aspose/aspose-words/23.4/aspose-words-23.4-jdk17.jar
</systemPath>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
ruoyi-common/src/main/java/com/ruoyi/common/weixin/config/WeiXinPayConfig.java
View file @
a73f5574
...
@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
...
@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
/**
/**
* 微信支付V3相关参数配置
* 微信支付V3相关参数配置
*
* @author Wzp
* @author Wzp
*/
*/
@Getter
@Getter
...
@@ -25,9 +26,15 @@ public class WeiXinPayConfig {
...
@@ -25,9 +26,15 @@ public class WeiXinPayConfig {
@Value
(
"${wx.pay.apiV3Key}"
)
@Value
(
"${wx.pay.apiV3Key}"
)
private
String
apiV3Key
;
private
String
apiV3Key
;
//微信回调地址
//微信回调地址
@Value
(
"${wx.pay.notifyUrl}"
)
@Value
(
"${wx.pay.notifyUrl}"
)
private
String
notifyUrl
;
private
String
notifyUrl
;
//微信H5回调地址
@Value
(
"${wx.pay.h5NotifyUrl}"
)
private
String
h5NotifyUrl
;
//支付宝回调地址
//支付宝回调地址
@Value
(
"${wx.pay.notifyZfbUrl}"
)
@Value
(
"${wx.pay.notifyZfbUrl}"
)
private
String
notifyZfbUrl
;
private
String
notifyZfbUrl
;
...
...
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