订单
This commit is contained in:
@@ -36,7 +36,7 @@ public class OrderInfo extends BaseEntity
|
|||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/** 金额 分 */
|
/** 金额 分 */
|
||||||
@Excel(name = "金额 分")
|
@Excel(name = "金额 元")
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
|
|
||||||
/** 支付方式 aliPay / wechatPay / applePay */
|
/** 支付方式 aliPay / wechatPay / applePay */
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付工具类
|
* 支付工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2025-01-27
|
* @date 2025-01-27
|
||||||
*/
|
*/
|
||||||
@@ -22,25 +22,25 @@ public class PaymentUtil {
|
|||||||
*/
|
*/
|
||||||
public Map<String, Object> processAliPay(OrderInfo orderInfo, PaymentRequest request) {
|
public Map<String, Object> processAliPay(OrderInfo orderInfo, PaymentRequest request) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
// TODO: 调用支付宝SDK进行支付
|
// TODO: 调用支付宝SDK进行支付
|
||||||
// 这里只是模拟返回支付参数
|
// 这里只是模拟返回支付参数
|
||||||
|
|
||||||
// 构建支付宝支付参数
|
// 构建支付宝支付参数
|
||||||
Map<String, Object> aliPayParams = new HashMap<>();
|
Map<String, Object> aliPayParams = new HashMap<>();
|
||||||
aliPayParams.put("out_trade_no", orderInfo.getOrderId().toString());
|
aliPayParams.put("out_trade_no", orderInfo.getOrderId().toString());
|
||||||
aliPayParams.put("total_amount", orderInfo.getAmount() / 100.0);
|
aliPayParams.put("total_amount", orderInfo.getAmount());
|
||||||
aliPayParams.put("subject", StringUtils.isNotEmpty(request.getSubject()) ? request.getSubject() : orderInfo.getOrderName());
|
aliPayParams.put("subject", StringUtils.isNotEmpty(request.getSubject()) ? request.getSubject() : orderInfo.getOrderName());
|
||||||
aliPayParams.put("body", StringUtils.isNotEmpty(request.getBody()) ? request.getBody() : "购买VIP会员服务");
|
aliPayParams.put("body", StringUtils.isNotEmpty(request.getBody()) ? request.getBody() : "购买VIP会员服务");
|
||||||
aliPayParams.put("timeout_express", (request.getTimeoutMinutes() != null ? request.getTimeoutMinutes() : 30) + "m");
|
aliPayParams.put("timeout_express", (request.getTimeoutMinutes() != null ? request.getTimeoutMinutes() : 30) + "m");
|
||||||
aliPayParams.put("product_code", "QUICK_WAP_WAY");
|
aliPayParams.put("product_code", "QUICK_WAP_WAY");
|
||||||
|
|
||||||
result.put("paymentUrl", "https://openapi.alipay.com/gateway.do?");
|
result.put("paymentUrl", "https://openapi.alipay.com/gateway.do?");
|
||||||
result.put("orderId", orderInfo.getOrderId());
|
result.put("orderId", orderInfo.getOrderId());
|
||||||
result.put("amount", orderInfo.getAmount());
|
result.put("amount", orderInfo.getAmount());
|
||||||
result.put("payType", "aliPay");
|
result.put("payType", "aliPay");
|
||||||
result.put("params", aliPayParams);
|
result.put("params", aliPayParams);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,59 +49,30 @@ public class PaymentUtil {
|
|||||||
*/
|
*/
|
||||||
public Map<String, Object> processWechatPay(OrderInfo orderInfo, PaymentRequest request) {
|
public Map<String, Object> processWechatPay(OrderInfo orderInfo, PaymentRequest request) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
// TODO: 调用微信支付SDK进行支付
|
// TODO: 调用微信支付SDK进行支付
|
||||||
// 这里只是模拟返回支付参数
|
// 这里只是模拟返回支付参数
|
||||||
|
|
||||||
// 构建微信支付参数
|
// 构建微信支付参数
|
||||||
Map<String, Object> wechatPayParams = new HashMap<>();
|
Map<String, Object> wechatPayParams = new HashMap<>();
|
||||||
wechatPayParams.put("out_trade_no", orderInfo.getOrderId().toString());
|
wechatPayParams.put("out_trade_no", orderInfo.getOrderId().toString());
|
||||||
wechatPayParams.put("total_fee", orderInfo.getAmount());
|
wechatPayParams.put("total_fee", orderInfo.getAmount());
|
||||||
wechatPayParams.put("body", StringUtils.isNotEmpty(request.getBody()) ? request.getBody() : orderInfo.getOrderName());
|
wechatPayParams.put("body", StringUtils.isNotEmpty(request.getBody()) ? request.getBody() : orderInfo.getOrderName());
|
||||||
wechatPayParams.put("attach", StringUtils.isNotEmpty(request.getAttach()) ? request.getAttach() : "VIP会员服务");
|
wechatPayParams.put("attach", StringUtils.isNotEmpty(request.getAttach()) ? request.getAttach() : "VIP会员服务");
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(request.getOpenid())) {
|
if (StringUtils.isNotEmpty(request.getOpenid())) {
|
||||||
wechatPayParams.put("openid", request.getOpenid());
|
wechatPayParams.put("openid", request.getOpenid());
|
||||||
}
|
}
|
||||||
|
|
||||||
result.put("prepayId", "wx_prepay_id_" + System.currentTimeMillis());
|
result.put("prepayId", "wx_prepay_id_" + System.currentTimeMillis());
|
||||||
result.put("orderId", orderInfo.getOrderId());
|
result.put("orderId", orderInfo.getOrderId());
|
||||||
result.put("amount", orderInfo.getAmount());
|
result.put("amount", orderInfo.getAmount());
|
||||||
result.put("payType", "wechatPay");
|
result.put("payType", "wechatPay");
|
||||||
result.put("params", wechatPayParams);
|
result.put("params", wechatPayParams);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理Apple Pay支付
|
|
||||||
*/
|
|
||||||
public Map<String, Object> processApplePay(OrderInfo orderInfo, PaymentRequest request) {
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
|
|
||||||
// TODO: 调用Apple Pay SDK进行支付
|
|
||||||
// 这里只是模拟返回支付参数
|
|
||||||
|
|
||||||
// 构建Apple Pay支付参数
|
|
||||||
Map<String, Object> applePayParams = new HashMap<>();
|
|
||||||
applePayParams.put("orderId", orderInfo.getOrderId().toString());
|
|
||||||
applePayParams.put("amount", orderInfo.getAmount() / 100.0);
|
|
||||||
applePayParams.put("currency", "CNY");
|
|
||||||
applePayParams.put("merchantIdentifier", StringUtils.isNotEmpty(request.getMerchantIdentifier()) ?
|
|
||||||
request.getMerchantIdentifier() : "merchant.com.example");
|
|
||||||
|
|
||||||
if (StringUtils.isNotEmpty(request.getPaymentToken())) {
|
|
||||||
applePayParams.put("paymentToken", request.getPaymentToken());
|
|
||||||
}
|
|
||||||
|
|
||||||
result.put("paymentToken", "apple_payment_token_" + System.currentTimeMillis());
|
|
||||||
result.put("orderId", orderInfo.getOrderId());
|
|
||||||
result.put("amount", orderInfo.getAmount());
|
|
||||||
result.put("payType", "applePay");
|
|
||||||
result.put("params", applePayParams);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证支付回调
|
* 验证支付回调
|
||||||
@@ -109,11 +80,11 @@ public class PaymentUtil {
|
|||||||
public boolean verifyPaymentCallback(String orderId, String tradeNo, String payType, String signature) {
|
public boolean verifyPaymentCallback(String orderId, String tradeNo, String payType, String signature) {
|
||||||
// TODO: 根据不同的支付方式验证回调签名
|
// TODO: 根据不同的支付方式验证回调签名
|
||||||
// 这里只是模拟验证
|
// 这里只是模拟验证
|
||||||
|
|
||||||
if (StringUtils.isEmpty(orderId) || StringUtils.isEmpty(tradeNo) || StringUtils.isEmpty(payType)) {
|
if (StringUtils.isEmpty(orderId) || StringUtils.isEmpty(tradeNo) || StringUtils.isEmpty(payType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证签名逻辑
|
// 验证签名逻辑
|
||||||
switch (payType) {
|
switch (payType) {
|
||||||
case "aliPay":
|
case "aliPay":
|
||||||
@@ -156,7 +127,7 @@ public class PaymentUtil {
|
|||||||
*/
|
*/
|
||||||
public boolean processRefund(String orderId, Long refundAmount, String payType) {
|
public boolean processRefund(String orderId, Long refundAmount, String payType) {
|
||||||
// TODO: 根据不同的支付方式调用相应的退款接口
|
// TODO: 根据不同的支付方式调用相应的退款接口
|
||||||
|
|
||||||
switch (payType) {
|
switch (payType) {
|
||||||
case "aliPay":
|
case "aliPay":
|
||||||
return processAliPayRefund(orderId, refundAmount);
|
return processAliPayRefund(orderId, refundAmount);
|
||||||
@@ -192,4 +163,4 @@ public class PaymentUtil {
|
|||||||
// TODO: 调用Apple Pay退款接口
|
// TODO: 调用Apple Pay退款接口
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="selectOrderInfoVOList" parameterType="OrderInfo" resultMap="OrderInfoVOResult">
|
<select id="selectOrderInfoVOList" parameterType="OrderInfo" resultMap="OrderInfoVOResult">
|
||||||
SELECT
|
SELECT
|
||||||
|
o.amount as amount_yuan,
|
||||||
o.order_id,
|
o.order_id,
|
||||||
su.nickname as user_nickname,
|
su.nickname as user_nickname,
|
||||||
su.phone as phone,
|
su.phone as phone,
|
||||||
@@ -182,7 +183,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
WHEN o.package_type = '4' THEN '一年'
|
WHEN o.package_type = '4' THEN '一年'
|
||||||
ELSE '未知套餐'
|
ELSE '未知套餐'
|
||||||
END as package_name,
|
END as package_name,
|
||||||
ROUND(o.amount / 100.0, 2) as amount_yuan,
|
|
||||||
CASE
|
CASE
|
||||||
WHEN o.pay_type = 'aliPay' THEN '支付宝'
|
WHEN o.pay_type = 'aliPay' THEN '支付宝'
|
||||||
WHEN o.pay_type = 'wechatPay' THEN '微信支付'
|
WHEN o.pay_type = 'wechatPay' THEN '微信支付'
|
||||||
@@ -193,10 +193,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
o.end_time,
|
o.end_time,
|
||||||
CASE
|
CASE
|
||||||
WHEN o.pay_status = 1 THEN '待支付'
|
WHEN o.pay_status = 1 THEN '待支付'
|
||||||
WHEN o.pay_status = 2 THEN '待出货'
|
WHEN o.pay_status = 2 THEN '已完成'
|
||||||
WHEN o.pay_status = 3 THEN '待退款'
|
WHEN o.pay_status = 3 THEN '待退款'
|
||||||
WHEN o.pay_status = 4 THEN '已退款'
|
WHEN o.pay_status = 4 THEN '已退款'
|
||||||
WHEN o.pay_status = 5 THEN '已完成'
|
|
||||||
ELSE '未知状态'
|
ELSE '未知状态'
|
||||||
END as status_name,
|
END as status_name,
|
||||||
o.create_time
|
o.create_time
|
||||||
|
|||||||
Reference in New Issue
Block a user