|
|
@@ -11,7 +11,9 @@ import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
import com.xuekairui.common.BusinessException;
|
|
|
import com.xuekairui.common.ErrorCode;
|
|
|
import com.xuekairui.payment.config.PaymentProperties;
|
|
|
-import com.xuekairui.payment.dto.*;
|
|
|
+import com.xuekairui.payment.dto.CreateOrderRequest;
|
|
|
+import com.xuekairui.payment.dto.OrderResponse;
|
|
|
+import com.xuekairui.payment.dto.PaymentResultResponse;
|
|
|
import com.xuekairui.payment.entity.PaymentOrder;
|
|
|
import com.xuekairui.payment.entity.PaymentPlan;
|
|
|
import com.xuekairui.payment.enums.PaymentChannel;
|
|
|
@@ -76,7 +78,7 @@ public class PaymentOrderService {
|
|
|
qrContent = "MOCK_PAY:" + orderNo;
|
|
|
} else {
|
|
|
// 生产模式:调用对应渠道预下单接口获取支付链接
|
|
|
- PrepayResult prepayResult = createPrepay(channel, orderNo, plan.getPrice(), plan.getPlanName());
|
|
|
+ PrepayResult prepayResult = createPrepay(channel, orderNo, plan.getPrice(), plan.getPlanName(), plan.getDescription());
|
|
|
qrContent = prepayResult.getQrContent();
|
|
|
payUrl = prepayResult.getPayUrl();
|
|
|
}
|
|
|
@@ -282,14 +284,15 @@ public class PaymentOrderService {
|
|
|
* @param channel 支付渠道
|
|
|
* @param orderNo 订单号
|
|
|
* @param amount 金额
|
|
|
- * @param subject 商品描述
|
|
|
+ * @param subject 商品标题
|
|
|
+ * @param body 商品详细描述
|
|
|
* @return 预下单结果
|
|
|
*/
|
|
|
private PrepayResult createPrepay(PaymentChannel channel, String orderNo,
|
|
|
- java.math.BigDecimal amount, String subject) {
|
|
|
+ java.math.BigDecimal amount, String subject, String body) {
|
|
|
return switch (channel) {
|
|
|
case WECHAT -> createWechatPrepay(orderNo, amount, subject);
|
|
|
- case ALIPAY -> createAlipayPrepay(orderNo, amount, subject);
|
|
|
+ case ALIPAY -> createAlipayPrepay(orderNo, amount, subject, body);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
@@ -357,7 +360,7 @@ public class PaymentOrderService {
|
|
|
*
|
|
|
* @see <a href="https://opendocs.alipay.com/open/02ekfh">统一收单线下交易预创建</a>
|
|
|
*/
|
|
|
- private PrepayResult createAlipayPrepay(String orderNo, java.math.BigDecimal amount, String subject) {
|
|
|
+ private PrepayResult createAlipayPrepay(String orderNo, java.math.BigDecimal amount, String subject, String body) {
|
|
|
PaymentProperties.Alipay al = paymentProperties.getAlipay();
|
|
|
if (al.getAppId() == null || al.getAppPrivateKey() == null) {
|
|
|
throw new BusinessException(ErrorCode.PAY_CHANNEL_NOT_CONFIGURED,
|
|
|
@@ -377,6 +380,9 @@ public class PaymentOrderService {
|
|
|
model.setOutTradeNo(orderNo);
|
|
|
model.setTotalAmount(amount.toPlainString());
|
|
|
model.setSubject(subject);
|
|
|
+ if (body != null && !body.isBlank()) {
|
|
|
+ model.setBody(body);
|
|
|
+ }
|
|
|
model.setProductCode("QR_CODE_OFFLINE");
|
|
|
model.setTimeoutExpress(paymentProperties.getOrderExpireMinutes() + "m");
|
|
|
request.setBizModel(model);
|