|
|
@@ -67,6 +67,8 @@ public class OrderPayService {
|
|
|
private final AlipayService alipayService;
|
|
|
private final PhotoAssetRepo photoAssetRepo;
|
|
|
private final PhotoAssetService photoAssetService;
|
|
|
+ private final DomainOrderService domainOrderService;
|
|
|
+ private final DomainOrderRepo domainOrderRepo;
|
|
|
|
|
|
public static void setPayChannel(String payChannel) {
|
|
|
log.info("set pay channel {}", payChannel);
|
|
|
@@ -733,7 +735,8 @@ public class OrderPayService {
|
|
|
case Constants.PayChannel.HM:
|
|
|
return hmPayService.requestAlipay(orderId + "", order.getPrice(),
|
|
|
"星图:" + order.getPicName(), HMPayService.getTimeout(order.getCreatedAt(), 180),
|
|
|
- Constants.OrderNotifyType.PIC, generalProperties.resolveFrontUrl(getCompanyId(), "/orderDetail?id=" + orderId));
|
|
|
+ Constants.OrderNotifyType.PIC, generalProperties
|
|
|
+ .resolveFrontUrl(getCompanyId(), "/orderDetail?id=" + orderId));
|
|
|
}
|
|
|
throw new BusinessException("绿洲宇宙冷却系统已启动,请稍后支付");
|
|
|
}
|
|
|
@@ -755,7 +758,8 @@ public class OrderPayService {
|
|
|
.encode(Constants.ALIPAY_URL_SCHEME + qrCode, StandardCharsets.UTF_8)
|
|
|
+ "&orderId=" + orderId + "&type=pic&returnUrl="
|
|
|
+ URLEncoder
|
|
|
- .encode(generalProperties.resolveFrontUrl(getCompanyId(), "/orderDetail?id=" + orderId), StandardCharsets.UTF_8);
|
|
|
+ .encode(generalProperties
|
|
|
+ .resolveFrontUrl(getCompanyId(), "/orderDetail?id=" + orderId), StandardCharsets.UTF_8);
|
|
|
} else {
|
|
|
return Constants.ALIPAY_URL_SCHEME + qrCode;
|
|
|
}
|
|
|
@@ -816,4 +820,103 @@ public class OrderPayService {
|
|
|
return payEaseService.pay("星图:" + order.getPicName(), orderId.toString(), order.getPrice(),
|
|
|
order.getUserId().toString(), bindCardId, Constants.OrderNotifyType.PIC);
|
|
|
}
|
|
|
+
|
|
|
+ @Cacheable(value = "payOrder", key = "'domain#'+#orderId")
|
|
|
+ public String payDomainOrder(Long orderId) {
|
|
|
+ DomainOrder order = domainOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getOrderStatus() != OrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ switch (PAY_CHANNEL) {
|
|
|
+ case Constants.PayChannel.SAND:
|
|
|
+ return sandPayService.pay(orderId + "", "域名:" + order.getPicName(), order.getPrice(),
|
|
|
+ order.getCreatedAt().plusMinutes(3), Constants.OrderNotifyType.DOMAIN);
|
|
|
+ case Constants.PayChannel.HM:
|
|
|
+ return hmPayService.requestAlipay(orderId + "", order.getPrice(),
|
|
|
+ "域名:" + order.getPicName(), HMPayService.getTimeout(order.getCreatedAt(), 180),
|
|
|
+ Constants.OrderNotifyType.DOMAIN, generalProperties
|
|
|
+ .resolveFrontUrl(getCompanyId(), "/orderDetail?id=" + orderId));
|
|
|
+ }
|
|
|
+ throw new BusinessException("绿洲宇宙冷却系统已启动,请稍后支付");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Cacheable(value = "payOrder", key = "'domain#'+#orderId")
|
|
|
+ public String payDomainAli(Long orderId) {
|
|
|
+ DomainOrder order = domainOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getOrderStatus() != OrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ String qrCode = aliRequest(orderId, order.getPrice(), "域名:" + order
|
|
|
+ .getPicName(), Constants.OrderNotifyType.DOMAIN);
|
|
|
+
|
|
|
+ String ua = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()
|
|
|
+ .getHeader("User-Agent");
|
|
|
+ if (ua.toLowerCase().contains("micromessenger")) {
|
|
|
+ return "/static/wx_alipay_bridge.html?payUrl=" + URLEncoder
|
|
|
+ .encode(Constants.ALIPAY_URL_SCHEME + qrCode, StandardCharsets.UTF_8)
|
|
|
+ + "&orderId=" + orderId + "&type=domain&returnUrl="
|
|
|
+ + URLEncoder
|
|
|
+ .encode(generalProperties
|
|
|
+ .resolveFrontUrl(getCompanyId(), "/orderDetail?id=" + orderId), StandardCharsets.UTF_8);
|
|
|
+ } else {
|
|
|
+ return Constants.ALIPAY_URL_SCHEME + qrCode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Cacheable(value = "payOrder", key = "'domain#'+#orderId")
|
|
|
+ public String payDomainQuick(Long orderId) {
|
|
|
+ DomainOrder order = domainOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getOrderStatus() != OrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ IdentityAuth identityAuth = identityAuthRepo
|
|
|
+ .findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(order.getUserId(), AuthStatus.SUCCESS)
|
|
|
+ .orElseThrow(new BusinessException("请先完成实名认证"));
|
|
|
+ return sandPayService.payQuick(orderId + "", "域名:" + order.getPicName(),
|
|
|
+ order.getPrice(), order.getCreatedAt().plusMinutes(3), Constants.OrderNotifyType.DOMAIN,
|
|
|
+ generalProperties.resolveFrontUrl(getCompanyId(), "/orderDetail?id=" + orderId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Cacheable(value = "payOrder", key = "'domain#'+#orderId")
|
|
|
+ public String payDomainQuickBind(Long orderId) {
|
|
|
+ DomainOrder order = domainOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getOrderStatus() != OrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ IdentityAuth identityAuth = identityAuthRepo
|
|
|
+ .findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(order.getUserId(), AuthStatus.SUCCESS)
|
|
|
+ .orElseThrow(new BusinessException("请先完成实名认证"));
|
|
|
+ return sandPayService.payQuickBind(orderId + "", "域名:" + order.getPicName(),
|
|
|
+ order.getPrice(), order.getCreatedAt().plusMinutes(3), Constants.OrderNotifyType.DOMAIN,
|
|
|
+ generalProperties.resolveFrontUrl(getCompanyId(), "/orderDetail?id=" + orderId),
|
|
|
+ order.getUserId(), identityAuth.getRealName(), identityAuth.getIdNo());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void payDomainOrderBalance(Long orderId, Long userId, String tradeCode) {
|
|
|
+ DomainOrder order = domainOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getOrderStatus() != OrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ checkTradeCode(userId, tradeCode, order.getUserId());
|
|
|
+ BalanceRecord record = userBalanceService.balancePay(order.getUserId(), order.getPrice(), orderId, "域名");
|
|
|
+ domainOrderService.notify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Cacheable(value = "payOrder", key = "'domain#'+#orderId")
|
|
|
+ public Map<String, Object> payDomainOrderAgreement(Long orderId, String bindCardId) {
|
|
|
+ DomainOrder order = domainOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getOrderStatus() != OrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(bindCardId)) {
|
|
|
+ bindCardId = userBankCardRepo.findByUserId(order.getUserId())
|
|
|
+ .stream().map(UserBankCard::getBindCardId).findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(bindCardId)) {
|
|
|
+ throw new BusinessException("请先绑定银行卡");
|
|
|
+ }
|
|
|
+ return payEaseService.pay("域名:" + order.getPicName(), orderId.toString(), order.getPrice(),
|
|
|
+ order.getUserId().toString(), bindCardId, Constants.OrderNotifyType.DOMAIN);
|
|
|
+ }
|
|
|
}
|