fix: PayPal payment_method column length issue; add image model selection for storyboard; remove task restore popups; sync UserWork status on task failure
This commit is contained in:
@@ -41,6 +41,9 @@ public class PaymentService {
|
||||
@Autowired
|
||||
private AlipayService alipayService;
|
||||
|
||||
@Autowired(required = false)
|
||||
private PayPalService payPalService;
|
||||
|
||||
/**
|
||||
* 保存支付记录
|
||||
*/
|
||||
@@ -56,11 +59,11 @@ public class PaymentService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查找支付记录
|
||||
* 根据ID查找支付记录(包含User信息,避免LazyInitializationException)
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<Payment> findById(Long id) {
|
||||
return paymentRepository.findById(id);
|
||||
return paymentRepository.findByIdWithUser(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,6 +351,24 @@ public class PaymentService {
|
||||
logger.error("调用支付宝支付接口失败:", e);
|
||||
// 不抛出异常,让前端处理
|
||||
}
|
||||
} else if (paymentMethod == PaymentMethod.PAYPAL) {
|
||||
try {
|
||||
if (payPalService == null) {
|
||||
throw new RuntimeException("PayPal服务未配置");
|
||||
}
|
||||
Map<String, Object> paymentResult = payPalService.createPayment(savedPayment);
|
||||
if (paymentResult.containsKey("paymentUrl")) {
|
||||
savedPayment.setPaymentUrl(paymentResult.get("paymentUrl").toString());
|
||||
}
|
||||
if (paymentResult.containsKey("paypalPaymentId")) {
|
||||
savedPayment.setExternalTransactionId(paymentResult.get("paypalPaymentId").toString());
|
||||
}
|
||||
save(savedPayment);
|
||||
logger.info("PayPal支付链接生成成功: {}", paymentResult.get("paymentUrl"));
|
||||
} catch (Exception e) {
|
||||
logger.error("调用PayPal支付接口失败:", e);
|
||||
throw new RuntimeException("创建PayPal支付失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return savedPayment;
|
||||
|
||||
Reference in New Issue
Block a user