fix:支付和通知相关模块代码恢复
This commit is contained in:
@@ -2,12 +2,9 @@ package com.central.order;
|
||||
|
||||
import com.central.common.lb.annotation.EnableFeignInterceptor;
|
||||
import com.central.search.annotation.EnableSearchClient;
|
||||
import com.zlt.wechat.config.WechatAutoConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
@@ -18,8 +15,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@EnableTransactionManagement
|
||||
@EnableFeignInterceptor
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients(basePackages = {"com.central"})
|
||||
@Import(WechatAutoConfiguration.class)
|
||||
public class OrderCenterApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OrderCenterApp.class, args);
|
||||
|
||||
+98
-98
@@ -1,98 +1,98 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.central.common.context.LoginUserContextHolder;
|
||||
import com.central.common.exception.BusinessException;
|
||||
import com.central.common.model.SysUser;
|
||||
import com.central.order.feign.UserCenterService;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.QrCode;
|
||||
import com.central.wechat.wechat.entity.WechatConfig;
|
||||
import com.central.wechat.wechat.feign.WechatConfigService;
|
||||
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.*;
|
||||
import com.zlt.wechat.config.WxPayConfigFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PaymentService {
|
||||
@Autowired
|
||||
private WxPayConfigFactory wxPayConfigFactory;
|
||||
@Autowired
|
||||
private UserCenterService userCenterService;
|
||||
@Autowired
|
||||
private IOrderService orderService;
|
||||
@Autowired
|
||||
private IQrCodeService qrCodeService;
|
||||
@Autowired
|
||||
private IProfitSharingService profitSharingService;
|
||||
@Autowired
|
||||
private WechatConfigService configService;
|
||||
|
||||
|
||||
|
||||
public PrepayWithRequestPaymentResponse createPayment(Long orderId) {
|
||||
// 1. 获取用户和订单信息
|
||||
SysUser user = userCenterService.findUserById(LoginUserContextHolder.getUser().getId());
|
||||
Order order = orderService.getById(orderId);
|
||||
if (order == null) {
|
||||
throw new BusinessException("订单数据不存在");
|
||||
}
|
||||
|
||||
// 2. 获取二维码信息
|
||||
QrCode qrCode = qrCodeService.getByCodeId(order.getCodeId());
|
||||
if (qrCode == null) {
|
||||
throw new BusinessException("二维码不存在");
|
||||
}
|
||||
|
||||
// 3. 创建支付请求
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
|
||||
// 设置基本支付信息
|
||||
Amount amount = new Amount();
|
||||
amount.setTotal(Integer.parseInt(order.getOrderAmount()));
|
||||
request.setAmount(amount);
|
||||
|
||||
// 从二维码配置中获取支付配置
|
||||
WechatConfig payConfig = configService.getConfig("PAY", qrCode.getTenantId());
|
||||
request.setAppid(payConfig.getAppId());
|
||||
request.setMchid(payConfig.getMerchantId());
|
||||
request.setDescription(order.getOrderNo());
|
||||
request.setNotifyUrl(payConfig.getNotifyUrl());
|
||||
request.setOutTradeNo(order.getOrderNo());
|
||||
|
||||
// 设置支付者信息
|
||||
Payer payer = new Payer();
|
||||
payer.setOpenid(user.getOpenId());
|
||||
request.setPayer(payer);
|
||||
|
||||
// 设置分账信息
|
||||
SettleInfo settleInfo = new SettleInfo();
|
||||
if (isEnableProfit(qrCode)) {
|
||||
settleInfo.setProfitSharing(true);
|
||||
request.setSettleInfo(settleInfo);
|
||||
// 创建分账记录
|
||||
profitSharingService.createProfitSharing(order, qrCode);
|
||||
} else {
|
||||
settleInfo.setProfitSharing(false);
|
||||
request.setSettleInfo(settleInfo);
|
||||
}
|
||||
|
||||
// 4. 创建对应租户的支付服务
|
||||
JsapiServiceExtension jsapiService = wxPayConfigFactory.createJsapiService(qrCode.getTenantId());
|
||||
|
||||
// 5. 调用支付接口
|
||||
return jsapiService.prepayWithRequestPayment(request);
|
||||
}
|
||||
|
||||
private boolean isEnableProfit(QrCode qrCode) {
|
||||
return qrCode != null &&
|
||||
Integer.valueOf(1).equals(qrCode.getEnableProfit()) &&
|
||||
qrCode.getPayeeStatus() != null &&
|
||||
qrCode.getPayeeStatus() == 1 &&
|
||||
qrCode.getPayeeAccount() != null &&
|
||||
qrCode.getProfitRate() != null;
|
||||
}
|
||||
}
|
||||
//package com.central.order.service;
|
||||
//
|
||||
//import com.central.common.context.LoginUserContextHolder;
|
||||
//import com.central.common.exception.BusinessException;
|
||||
//import com.central.common.model.SysUser;
|
||||
//import com.central.order.feign.UserCenterService;
|
||||
//import com.central.order.model.Order;
|
||||
//import com.central.order.model.QrCode;
|
||||
//import com.central.wechat.wechat.entity.WechatConfig;
|
||||
//import com.central.wechat.wechat.feign.WechatConfigService;
|
||||
//import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||
//import com.wechat.pay.java.service.payments.jsapi.model.*;
|
||||
//import com.zlt.wechat.config.WxPayConfigFactory;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//@Slf4j
|
||||
//@Service
|
||||
//public class PaymentService {
|
||||
// @Autowired
|
||||
// private WxPayConfigFactory wxPayConfigFactory;
|
||||
// @Autowired
|
||||
// private UserCenterService userCenterService;
|
||||
// @Autowired
|
||||
// private IOrderService orderService;
|
||||
// @Autowired
|
||||
// private IQrCodeService qrCodeService;
|
||||
// @Autowired
|
||||
// private IProfitSharingService profitSharingService;
|
||||
// @Autowired
|
||||
// private WechatConfigService configService;
|
||||
//
|
||||
//
|
||||
//
|
||||
// public PrepayWithRequestPaymentResponse createPayment(Long orderId) {
|
||||
// // 1. 获取用户和订单信息
|
||||
// SysUser user = userCenterService.findUserById(LoginUserContextHolder.getUser().getId());
|
||||
// Order order = orderService.getById(orderId);
|
||||
// if (order == null) {
|
||||
// throw new BusinessException("订单数据不存在");
|
||||
// }
|
||||
//
|
||||
// // 2. 获取二维码信息
|
||||
// QrCode qrCode = qrCodeService.getByCodeId(order.getCodeId());
|
||||
// if (qrCode == null) {
|
||||
// throw new BusinessException("二维码不存在");
|
||||
// }
|
||||
//
|
||||
// // 3. 创建支付请求
|
||||
// PrepayRequest request = new PrepayRequest();
|
||||
//
|
||||
// // 设置基本支付信息
|
||||
// Amount amount = new Amount();
|
||||
// amount.setTotal(Integer.parseInt(order.getOrderAmount()));
|
||||
// request.setAmount(amount);
|
||||
//
|
||||
// // 从二维码配置中获取支付配置
|
||||
// WechatConfig payConfig = configService.getConfig("PAY", qrCode.getTenantId());
|
||||
// request.setAppid(payConfig.getAppId());
|
||||
// request.setMchid(payConfig.getMerchantId());
|
||||
// request.setDescription(order.getOrderNo());
|
||||
// request.setNotifyUrl(payConfig.getNotifyUrl());
|
||||
// request.setOutTradeNo(order.getOrderNo());
|
||||
//
|
||||
// // 设置支付者信息
|
||||
// Payer payer = new Payer();
|
||||
// payer.setOpenid(user.getOpenId());
|
||||
// request.setPayer(payer);
|
||||
//
|
||||
// // 设置分账信息
|
||||
// SettleInfo settleInfo = new SettleInfo();
|
||||
// if (isEnableProfit(qrCode)) {
|
||||
// settleInfo.setProfitSharing(true);
|
||||
// request.setSettleInfo(settleInfo);
|
||||
// // 创建分账记录
|
||||
// profitSharingService.createProfitSharing(order, qrCode);
|
||||
// } else {
|
||||
// settleInfo.setProfitSharing(false);
|
||||
// request.setSettleInfo(settleInfo);
|
||||
// }
|
||||
//
|
||||
// // 4. 创建对应租户的支付服务
|
||||
// JsapiServiceExtension jsapiService = wxPayConfigFactory.createJsapiService(qrCode.getTenantId());
|
||||
//
|
||||
// // 5. 调用支付接口
|
||||
// return jsapiService.prepayWithRequestPayment(request);
|
||||
// }
|
||||
//
|
||||
// private boolean isEnableProfit(QrCode qrCode) {
|
||||
// return qrCode != null &&
|
||||
// Integer.valueOf(1).equals(qrCode.getEnableProfit()) &&
|
||||
// qrCode.getPayeeStatus() != null &&
|
||||
// qrCode.getPayeeStatus() == 1 &&
|
||||
// qrCode.getPayeeAccount() != null &&
|
||||
// qrCode.getProfitRate() != null;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -117,3 +117,12 @@ wx:
|
||||
video-complete: TEMPLATE_ID_2 # 视频完成通知模板ID
|
||||
video-failure: TEMPLATE_ID_3 # 视频失败通知模板ID
|
||||
|
||||
mini:
|
||||
app-id: ${zlt.wxpay.appId}
|
||||
secret: ${zlt.security.tencent.app-secret}
|
||||
template:
|
||||
pay-success: nSy7NGq1443YCfhgR81fgkeOVv9cSM5Ysp3nMoQYVpc
|
||||
service-process: rgQCI3fMKPpgO-9nO3TzP-omohraGxX2suVioq7hQhk
|
||||
activity-start: lgwkRnbdDc3mEwk3RMob43LpLHnLfglZtTkbFRPsPCA
|
||||
order-complete: ZeIlAA6ImQLxBiLmo-53lM7wkL4KnuKKTGKWBZwYAdM
|
||||
video-edit-complete: IXpL-Voztm3GM-zFj3sxA39qy8oRtAcxTiT7_Qsyz9Q
|
||||
|
||||
Reference in New Issue
Block a user