From 57968ae2e8f4fdf9f16a94375c284e29cccbad31 Mon Sep 17 00:00:00 2001
From: Iamasoldier <1272745473@qq.com>
Date: Tue, 3 Jun 2025 10:43:31 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E7=99=BB=E5=BD=95=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E9=80=9A=E8=BF=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
zlt-business/order-center/pom.xml | 3 +-
.../order/config/ProfitSharingProperties.java | 2 +-
.../order/config/TencentPayConfiguration.java | 290 +++++++++---------
.../order/config/TencentPayProperties.java | 50 +--
.../central/order/config/WxMaProperties.java | 18 +-
.../order/config/WxMpConfiguration.java | 136 ++++----
.../central/order/config/WxMpProperties.java | 108 +++----
.../order/controller/OrderController.java | 8 -
.../order/controller/RefundController.java | 3 +-
.../order/controller/WxPayController.java | 3 +-
.../order/controller/WxTestController.java | 4 +-
.../order/handler/WxMessageHandler.java | 3 +-
.../central/order/service/PaymentService.java | 33 +-
.../impl/ProfitSharingServiceImpl.java | 16 +-
.../impl/WxAccessTokenServiceImpl.java | 3 +-
.../impl/WxMiniSubscribeServiceImpl.java | 19 +-
.../impl/WxTemplateMessageServiceImpl.java | 66 ++--
.../order/service/impl/WxUserServiceImpl.java | 20 +-
.../config/WechatAutoConfiguration.java | 8 +-
.../TencentAuthenticationProvider.java | 3 +-
20 files changed, 381 insertions(+), 415 deletions(-)
diff --git a/zlt-business/order-center/pom.xml b/zlt-business/order-center/pom.xml
index af052ff2..042ee6a8 100644
--- a/zlt-business/order-center/pom.xml
+++ b/zlt-business/order-center/pom.xml
@@ -111,7 +111,7 @@
com.github.binarywang
weixin-java-miniapp
- 4.6.0
+ 4.5.0
@@ -148,6 +148,7 @@
com.zlt
zlt-wechat-spring-boot-starter
+ ${project.version}
diff --git a/zlt-business/order-center/src/main/java/com/central/order/config/ProfitSharingProperties.java b/zlt-business/order-center/src/main/java/com/central/order/config/ProfitSharingProperties.java
index 7757afdc..0b6f75e9 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/config/ProfitSharingProperties.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/config/ProfitSharingProperties.java
@@ -55,4 +55,4 @@ public class ProfitSharingProperties {
*/
@Builder.Default
private int asyncPoolSize = 5;
-}
\ No newline at end of file
+}
diff --git a/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayConfiguration.java b/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayConfiguration.java
index fd7c3105..70dda925 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayConfiguration.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayConfiguration.java
@@ -1,145 +1,145 @@
-package com.central.order.config;
-
-import com.wechat.pay.java.core.Config;
-import com.wechat.pay.java.core.RSAAutoCertificateConfig;
-import com.wechat.pay.java.core.notification.NotificationConfig;
-import com.wechat.pay.java.core.notification.NotificationParser;
-import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
-import com.wechat.pay.java.service.payments.jsapi.model.SettleInfo;
-import com.wechat.pay.java.service.profitsharing.ProfitsharingService;
-import com.wechat.pay.java.service.refund.RefundService;
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.springframework.beans.factory.annotation.Qualifier;
-
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * 支付配置类
- *
- * @author lsl
- * @date 2025-01-14
- *
- */
-@Getter
-@Setter
-@Configuration
-@ConfigurationProperties(prefix = "tencent")
-@EnableConfigurationProperties(ProfitSharingProperties.class)
-public class TencentPayConfiguration {
-
- private String merchantId;
-
- private String merchantSerialNumber;
-
- private String apiV3Key;
-
- private String privateKeyPath;
-
- private String appId;
-
- private String appSecret;
-
- private String notifyUrl;
-
- /**
- * jsapi支付方式 支持小程序公众号支付
- * @return
- */
- @Bean
- public JsapiServiceExtension initialJsapiServiceExtension() {
- // 构建service
- return new JsapiServiceExtension.Builder().config(getConfig()).build();
- }
-
- @Bean
- public RefundService initialRefundService() {
- // 构建service
- return new RefundService.Builder().config(getConfig()).build();
- }
-
- /**
- * 微信支付配置获取
- * @return
- */
- public Config getConfig() {
- return new RSAAutoCertificateConfig.Builder()
- .merchantId(merchantId)
- .privateKeyFromPath(privateKeyPath)
- .merchantSerialNumber(merchantSerialNumber)
- .apiV3Key(apiV3Key)
- .build();
- }
-
-
- @Bean
- public NotificationConfig initialNotificationConfig() {
- // . 如果你仍在使用微信支付平台证书,则使用 RSAAutoCertificateConfig
- return new RSAAutoCertificateConfig.Builder()
- .merchantId(merchantId)
- .privateKeyFromPath(privateKeyPath)
- .merchantSerialNumber(merchantSerialNumber)
- .apiV3Key(apiV3Key)
- .build();
- }
-
- @Bean
- public TencentPayProperties initTencentPayProperties() {
- TencentPayProperties tencentPayProperties = new TencentPayProperties();
- tencentPayProperties.setApiV3Key(apiV3Key);
- tencentPayProperties.setMerchantId(merchantId);
- tencentPayProperties.setMerchantSerialNumber(merchantSerialNumber);
- tencentPayProperties.setAppId(appId);
- tencentPayProperties.setAppSecret(appSecret);
- tencentPayProperties.setNotifyUrl(notifyUrl);
- return tencentPayProperties;
- }
-
- @Value("${wechat.pay.profit-sharing.enabled:true}")
- private boolean profitSharingEnabled;
-
- @Bean
- public SettleInfo defaultSettleInfo() {
- SettleInfo settleInfo = new SettleInfo();
- settleInfo.setProfitSharing(profitSharingEnabled);
- return settleInfo;
- }
-
- @Bean
- public NotificationParser notificationParser(NotificationConfig config) {
- return new NotificationParser(config);
- }
-
- @Bean
- public ProfitsharingService profitsharingService() {
- // 使用已有的配置方法
- Config config = getConfig();
- return new ProfitsharingService.Builder()
- .config(config)
- .build();
- }
-
- @Bean
- public Executor profitSharingExecutor(@Qualifier("wechat.pay.profit-sharing-com.central.order.config.ProfitSharingProperties")
- ProfitSharingProperties properties) {
- if (!properties.isAsyncEnabled()) {
- return null;
- }
-
- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
- executor.setCorePoolSize(properties.getAsyncPoolSize());
- executor.setMaxPoolSize(properties.getAsyncPoolSize());
- executor.setQueueCapacity(100);
- executor.setThreadNamePrefix("profit-sharing-");
- executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
- executor.initialize();
- return executor;
- }
-}
+//package com.central.order.config;
+//
+//import com.wechat.pay.java.core.Config;
+//import com.wechat.pay.java.core.RSAAutoCertificateConfig;
+//import com.wechat.pay.java.core.notification.NotificationConfig;
+//import com.wechat.pay.java.core.notification.NotificationParser;
+//import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
+//import com.wechat.pay.java.service.payments.jsapi.model.SettleInfo;
+//import com.wechat.pay.java.service.profitsharing.ProfitsharingService;
+//import com.wechat.pay.java.service.refund.RefundService;
+//import lombok.Getter;
+//import lombok.Setter;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.boot.context.properties.ConfigurationProperties;
+//import org.springframework.boot.context.properties.EnableConfigurationProperties;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+//import org.springframework.beans.factory.annotation.Qualifier;
+//
+//import java.util.concurrent.Executor;
+//import java.util.concurrent.ThreadPoolExecutor;
+//
+///**
+// * 支付配置类
+// *
+// * @author lsl
+// * @date 2025-01-14
+// *
+// */
+//@Getter
+//@Setter
+//@Configuration
+//@ConfigurationProperties(prefix = "tencent")
+//@EnableConfigurationProperties(ProfitSharingProperties.class)
+//public class TencentPayConfiguration {
+//
+// private String merchantId;
+//
+// private String merchantSerialNumber;
+//
+// private String apiV3Key;
+//
+// private String privateKeyPath;
+//
+// private String appId;
+//
+// private String appSecret;
+//
+// private String notifyUrl;
+//
+// /**
+// * jsapi支付方式 支持小程序公众号支付
+// * @return
+// */
+// @Bean
+// public JsapiServiceExtension initialJsapiServiceExtension() {
+// // 构建service
+// return new JsapiServiceExtension.Builder().config(getConfig()).build();
+// }
+//
+// @Bean
+// public RefundService initialRefundService() {
+// // 构建service
+// return new RefundService.Builder().config(getConfig()).build();
+// }
+//
+// /**
+// * 微信支付配置获取
+// * @return
+// */
+// public Config getConfig() {
+// return new RSAAutoCertificateConfig.Builder()
+// .merchantId(merchantId)
+// .privateKeyFromPath(privateKeyPath)
+// .merchantSerialNumber(merchantSerialNumber)
+// .apiV3Key(apiV3Key)
+// .build();
+// }
+//
+//
+// @Bean
+// public NotificationConfig initialNotificationConfig() {
+// // . 如果你仍在使用微信支付平台证书,则使用 RSAAutoCertificateConfig
+// return new RSAAutoCertificateConfig.Builder()
+// .merchantId(merchantId)
+// .privateKeyFromPath(privateKeyPath)
+// .merchantSerialNumber(merchantSerialNumber)
+// .apiV3Key(apiV3Key)
+// .build();
+// }
+//
+// @Bean
+// public TencentPayProperties initTencentPayProperties() {
+// TencentPayProperties tencentPayProperties = new TencentPayProperties();
+// tencentPayProperties.setApiV3Key(apiV3Key);
+// tencentPayProperties.setMerchantId(merchantId);
+// tencentPayProperties.setMerchantSerialNumber(merchantSerialNumber);
+// tencentPayProperties.setAppId(appId);
+// tencentPayProperties.setAppSecret(appSecret);
+// tencentPayProperties.setNotifyUrl(notifyUrl);
+// return tencentPayProperties;
+// }
+//
+// @Value("${wechat.pay.profit-sharing.enabled:true}")
+// private boolean profitSharingEnabled;
+//
+// @Bean
+// public SettleInfo defaultSettleInfo() {
+// SettleInfo settleInfo = new SettleInfo();
+// settleInfo.setProfitSharing(profitSharingEnabled);
+// return settleInfo;
+// }
+//
+// @Bean
+// public NotificationParser notificationParser(NotificationConfig config) {
+// return new NotificationParser(config);
+// }
+//
+// @Bean
+// public ProfitsharingService profitsharingService() {
+// // 使用已有的配置方法
+// Config config = getConfig();
+// return new ProfitsharingService.Builder()
+// .config(config)
+// .build();
+// }
+//
+// @Bean
+// public Executor profitSharingExecutor(@Qualifier("wechat.pay.profit-sharing-com.central.order.config.ProfitSharingProperties")
+// ProfitSharingProperties properties) {
+// if (!properties.isAsyncEnabled()) {
+// return null;
+// }
+//
+// ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+// executor.setCorePoolSize(properties.getAsyncPoolSize());
+// executor.setMaxPoolSize(properties.getAsyncPoolSize());
+// executor.setQueueCapacity(100);
+// executor.setThreadNamePrefix("profit-sharing-");
+// executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+// executor.initialize();
+// return executor;
+// }
+//}
diff --git a/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayProperties.java b/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayProperties.java
index 61b449fe..581dbc77 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayProperties.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayProperties.java
@@ -1,25 +1,25 @@
-package com.central.order.config;
-
-
-import lombok.Getter;
-import lombok.Setter;
-
-@Getter
-@Setter
-public class TencentPayProperties {
-
- private String merchantId;
-
- private String merchantSerialNumber;
-
- private String apiV3Key;
-
- private String privateKeyPath;
-
- private String appId;
-
- private String appSecret;
-
- private String notifyUrl;
-
-}
+//package com.central.order.config;
+//
+//
+//import lombok.Getter;
+//import lombok.Setter;
+//
+//@Getter
+//@Setter
+//public class TencentPayProperties {
+//
+// private String merchantId;
+//
+// private String merchantSerialNumber;
+//
+// private String apiV3Key;
+//
+// private String privateKeyPath;
+//
+// private String appId;
+//
+// private String appSecret;
+//
+// private String notifyUrl;
+//
+//}
diff --git a/zlt-business/order-center/src/main/java/com/central/order/config/WxMaProperties.java b/zlt-business/order-center/src/main/java/com/central/order/config/WxMaProperties.java
index 66b79b90..0a0dffc1 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/config/WxMaProperties.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/config/WxMaProperties.java
@@ -1,9 +1,9 @@
-package com.central.order.config;
-
-import lombok.Data;
-
-@Data
-public class WxMaProperties {
- private String appId;
- private String secret;
-}
+//package com.central.order.config;
+//
+//import lombok.Data;
+//
+//@Data
+//public class WxMaProperties {
+// private String appId;
+// private String secret;
+//}
diff --git a/zlt-business/order-center/src/main/java/com/central/order/config/WxMpConfiguration.java b/zlt-business/order-center/src/main/java/com/central/order/config/WxMpConfiguration.java
index a5d9d1b4..9d687c40 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/config/WxMpConfiguration.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/config/WxMpConfiguration.java
@@ -1,68 +1,68 @@
-package com.central.order.config;
-
-import cn.binarywang.wx.miniapp.api.WxMaService;
-import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
-import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import lombok.RequiredArgsConstructor;
-import me.chanjar.weixin.mp.api.WxMpService;
-import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
-import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.converter.StringHttpMessageConverter;
-import org.springframework.web.client.RestTemplate;
-
-import java.nio.charset.StandardCharsets;
-
-@Configuration
-@RequiredArgsConstructor
-public class WxMpConfiguration {
-
- @Bean
- @ConfigurationProperties(prefix = "wx.mp")
- public WxMpProperties wxMpProperties() {
- return new WxMpProperties();
- }
-
- @Bean
- public WxMpService wxMpService(WxMpProperties wxMpProperties) {
- WxMpService service = new WxMpServiceImpl();
- WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
-
- config.setAppId(wxMpProperties.getAppId());
- config.setSecret(wxMpProperties.getSecret());
-
- service.setWxMpConfigStorage(config);
- return service;
- }
-
- @Bean
- public RestTemplate restTemplate() {
- RestTemplate restTemplate = new RestTemplate();
- restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
- return restTemplate;
- }
-
- @Bean
- public ObjectMapper objectMapper() {
- return new ObjectMapper();
- }
-
- @Bean
- @ConfigurationProperties(prefix = "wx.mini")
- public WxMaProperties wxMaProperties() {
- return new WxMaProperties();
- }
-
- @Bean
- public WxMaService wxMaService(WxMaProperties wxMaProperties) {
- WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
- config.setAppid(wxMaProperties.getAppId());
- config.setSecret(wxMaProperties.getSecret());
- WxMaService service = new WxMaServiceImpl();
- service.setWxMaConfig(config);
- return service;
- }
-}
+//package com.central.order.config;
+//
+//import cn.binarywang.wx.miniapp.api.WxMaService;
+//import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
+//import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
+//import com.fasterxml.jackson.databind.ObjectMapper;
+//import lombok.RequiredArgsConstructor;
+//import me.chanjar.weixin.mp.api.WxMpService;
+//import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
+//import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
+//import org.springframework.boot.context.properties.ConfigurationProperties;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.http.converter.StringHttpMessageConverter;
+//import org.springframework.web.client.RestTemplate;
+//
+//import java.nio.charset.StandardCharsets;
+//
+//@Configuration
+//@RequiredArgsConstructor
+//public class WxMpConfiguration {
+//
+// @Bean
+// @ConfigurationProperties(prefix = "wx.mp")
+// public WxMpProperties wxMpProperties() {
+// return new WxMpProperties();
+// }
+//
+// @Bean
+// public WxMpService wxMpService(WxMpProperties wxMpProperties) {
+// WxMpService service = new WxMpServiceImpl();
+// WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
+//
+// config.setAppId(wxMpProperties.getAppId());
+// config.setSecret(wxMpProperties.getSecret());
+//
+// service.setWxMpConfigStorage(config);
+// return service;
+// }
+//
+// @Bean
+// public RestTemplate restTemplate() {
+// RestTemplate restTemplate = new RestTemplate();
+// restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
+// return restTemplate;
+// }
+//
+// @Bean
+// public ObjectMapper objectMapper() {
+// return new ObjectMapper();
+// }
+//
+// @Bean
+// @ConfigurationProperties(prefix = "wx.mini")
+// public WxMaProperties wxMaProperties() {
+// return new WxMaProperties();
+// }
+//
+// @Bean
+// public WxMaService wxMaService(WxMaProperties wxMaProperties) {
+// WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
+// config.setAppid(wxMaProperties.getAppId());
+// config.setSecret(wxMaProperties.getSecret());
+// WxMaService service = new WxMaServiceImpl();
+// service.setWxMaConfig(config);
+// return service;
+// }
+//}
diff --git a/zlt-business/order-center/src/main/java/com/central/order/config/WxMpProperties.java b/zlt-business/order-center/src/main/java/com/central/order/config/WxMpProperties.java
index b0b53fb0..86c56f79 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/config/WxMpProperties.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/config/WxMpProperties.java
@@ -1,54 +1,54 @@
-package com.central.order.config;
-
-import lombok.Data;
-
-@Data
-public class WxMpProperties {
- /**
- * 设置微信公众号的appid
- */
- private String appId;
-
- /**
- * 设置微信公众号的app secret
- */
- private String secret;
-
- /**
- * 设置云托管环境ID
- */
- private String cloudEnv;
-
- /**
- * 设置服务基础URL
- */
- private String baseUrl;
-
- /**
- * 模板ID配置
- */
- private TemplateConfig templateId = new TemplateConfig();
-
- @Data
- public static class TemplateConfig {
- /**
- * 支付成功通知模板ID
- * 模板内容:
- * 服务名称:{{thing2.DATA}}
- * 出行时间:{{time3.DATA}}
- * 订单号:{{character_string1.DATA}}
- * 支付金额:{{amount4.DATA}}
- */
- private String paymentSuccess;
-
- /**
- * 视频处理完成通知模板ID
- */
- private String videoComplete;
-
- /**
- * 视频处理失败通知模板ID
- */
- private String videoFail;
- }
-}
+//package com.central.order.config;
+//
+//import lombok.Data;
+//
+//@Data
+//public class WxMpProperties {
+// /**
+// * 设置微信公众号的appid
+// */
+// private String appId;
+//
+// /**
+// * 设置微信公众号的app secret
+// */
+// private String secret;
+//
+// /**
+// * 设置云托管环境ID
+// */
+// private String cloudEnv;
+//
+// /**
+// * 设置服务基础URL
+// */
+// private String baseUrl;
+//
+// /**
+// * 模板ID配置
+// */
+// private TemplateConfig templateId = new TemplateConfig();
+//
+// @Data
+// public static class TemplateConfig {
+// /**
+// * 支付成功通知模板ID
+// * 模板内容:
+// * 服务名称:{{thing2.DATA}}
+// * 出行时间:{{time3.DATA}}
+// * 订单号:{{character_string1.DATA}}
+// * 支付金额:{{amount4.DATA}}
+// */
+// private String paymentSuccess;
+//
+// /**
+// * 视频处理完成通知模板ID
+// */
+// private String videoComplete;
+//
+// /**
+// * 视频处理失败通知模板ID
+// */
+// private String videoFail;
+// }
+//}
diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java
index d0f0d12f..5856b6ce 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java
@@ -8,7 +8,6 @@ import com.central.common.model.LoginAppUser;
import com.central.common.model.PageResult;
import com.central.common.model.Result;
import com.central.log.annotation.AuditLog;
-import com.central.order.config.TencentPayProperties;
import com.central.order.enums.CommonStatus;
import com.central.order.enums.OrderStatus;
import com.central.order.feign.DeviceCenterService;
@@ -16,7 +15,6 @@ import com.central.order.feign.FileCenterService;
import com.central.order.feign.UserCenterService;
import com.central.order.model.*;
import com.central.order.service.*;
-import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@@ -70,15 +68,9 @@ public class OrderController {
@Autowired
private FileCenterService fileCenterService;
- @Autowired
- private JsapiServiceExtension service;
-
@Autowired
private IQrCodeService qrCodeService;
- @Autowired
- private TencentPayProperties tencentPayProperties;
-
@Value("${file.oss-url}")
private String cdnOssUrl;
diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/RefundController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/RefundController.java
index b2e7998e..843d0e77 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/controller/RefundController.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/controller/RefundController.java
@@ -16,6 +16,7 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
@@ -27,7 +28,7 @@ import java.util.Map;
@RequestMapping("/refund")
public class RefundController {
- @Autowired
+ @Qualifier
private RefundService service;
@Autowired
diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/WxPayController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/WxPayController.java
index 4ec10a51..74704adc 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/controller/WxPayController.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/controller/WxPayController.java
@@ -20,6 +20,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
@@ -44,7 +45,7 @@ public class WxPayController {
@Autowired
private IProfitSharingService profitSharingService;
- @Autowired
+ @Qualifier
private NotificationConfig config;
@PostMapping("/pay/notify")
diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/WxTestController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/WxTestController.java
index 967832bb..13f03428 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/controller/WxTestController.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/controller/WxTestController.java
@@ -27,8 +27,8 @@ public class WxTestController {
// 发送消息
- templateMessageService.sendPaymentSuccessNotice(
- openId, orderNo, serviceName, rank);
+// templateMessageService.sendPaymentSuccessNotice(
+// openId, orderNo, serviceName, rank);
return Result.succeed("发送成功");
} catch (Exception e) {
diff --git a/zlt-business/order-center/src/main/java/com/central/order/handler/WxMessageHandler.java b/zlt-business/order-center/src/main/java/com/central/order/handler/WxMessageHandler.java
index b7199fdb..0e991d33 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/handler/WxMessageHandler.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/handler/WxMessageHandler.java
@@ -6,7 +6,6 @@ import com.central.order.service.IWxTemplateMessageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxConsts;
-import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.stereotype.Component;
@@ -18,7 +17,7 @@ import java.time.LocalDateTime;
@RequiredArgsConstructor
public class WxMessageHandler {
- private final WxMpService wxMpService;
+// private final WxMpService wxMpService;
private final IWxTemplateMessageService templateMessageService;
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage) {
diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/PaymentService.java b/zlt-business/order-center/src/main/java/com/central/order/service/PaymentService.java
index 80a25ad9..61f33265 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/service/PaymentService.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/service/PaymentService.java
@@ -12,31 +12,26 @@ 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.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class PaymentService {
- private final WxPayConfigFactory wxPayConfigFactory;
- private final UserCenterService userCenterService;
- private final IOrderService orderService;
- private final IQrCodeService qrCodeService;
- private final IProfitSharingService profitSharingService;
- private final WechatConfigService configService;
+ @Qualifier
+ private WxPayConfigFactory wxPayConfigFactory;
- public PaymentService(WxPayConfigFactory wxPayConfigFactory,
- UserCenterService userCenterService,
- IOrderService orderService,
- IQrCodeService qrCodeService,
- IProfitSharingService profitSharingService,
- WechatConfigService configService) {
- this.wxPayConfigFactory = wxPayConfigFactory;
- this.userCenterService = userCenterService;
- this.orderService = orderService;
- this.qrCodeService = qrCodeService;
- this.profitSharingService = profitSharingService;
- this.configService = configService;
- }
+ @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. 获取用户和订单信息
diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/impl/ProfitSharingServiceImpl.java b/zlt-business/order-center/src/main/java/com/central/order/service/impl/ProfitSharingServiceImpl.java
index 00dd9a88..0ccaeb24 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/service/impl/ProfitSharingServiceImpl.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/service/impl/ProfitSharingServiceImpl.java
@@ -6,7 +6,6 @@ import com.central.common.exception.BusinessException;
import com.central.common.model.PageResult;
import com.central.common.service.impl.SuperServiceImpl;
import com.central.order.config.ProfitSharingProperties;
-import com.central.order.config.TencentPayProperties;
import com.central.order.constants.ProfitSharingConstants;
import com.central.order.enums.ProfitSharingStatusEnum;
import com.central.order.mapper.ProfitSharingMapper;
@@ -24,6 +23,7 @@ import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@@ -43,10 +43,7 @@ import java.util.stream.Collectors;
@Service
public class ProfitSharingServiceImpl extends SuperServiceImpl implements IProfitSharingService {
- @Autowired
- private TencentPayProperties tencentPayProperties;
-
- @Autowired
+ @Qualifier
private ProfitsharingService profitsharingService;
@Autowired
@@ -55,7 +52,7 @@ public class ProfitSharingServiceImpl extends SuperServiceImpl dataList = new ArrayList<>();
@@ -63,7 +62,7 @@ public class WxMiniSubscribeServiceImpl implements WxMiniSubscribeService {
try {
WxMaSubscribeMessage msg = new WxMaSubscribeMessage();
msg.setToUser(openId);
- msg.setTemplateId(serviceProcessTemplateId);
+ msg.setTemplateId("serviceProcessTemplateId");
msg.setPage(pageUrl); // 可选跳转页面 "pages/task/task"
List dataList = new ArrayList<>();
diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/impl/WxTemplateMessageServiceImpl.java b/zlt-business/order-center/src/main/java/com/central/order/service/impl/WxTemplateMessageServiceImpl.java
index 9bcb1d46..e4b63f6a 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/service/impl/WxTemplateMessageServiceImpl.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/service/impl/WxTemplateMessageServiceImpl.java
@@ -1,9 +1,6 @@
package com.central.order.service.impl;
import com.central.common.exception.BusinessException;
-import com.central.order.config.TencentPayProperties;
-import com.central.order.config.WxMpProperties;
-import com.central.order.enums.CommonStatus;
import com.central.order.model.WxMessageRecord;
import com.central.order.service.IWxMessageRecordService;
import com.central.order.service.IWxTemplateMessageService;
@@ -12,10 +9,10 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
-import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
@@ -25,23 +22,18 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.Arrays;
@Slf4j
@Service
@RequiredArgsConstructor
public class WxTemplateMessageServiceImpl implements IWxTemplateMessageService {
- @Autowired
+ @Qualifier
private WxMpService wxMpService;
- @Autowired
- private WxMpProperties wxMpProperties;
@Autowired
private IWxUserService wxUserService;
- @Autowired
- private TencentPayProperties tencentPayProperties;
@Autowired
private IWxMessageRecordService wxMessageRecordService;
@@ -57,41 +49,33 @@ public class WxTemplateMessageServiceImpl implements IWxTemplateMessageService {
throw new BusinessException("参数不能为空");
}
- try {
- String openId = wxUserService.getMpOpenIdByUnionId(unionId);
- log.info("获取到服务号openId={}", openId);
- // 构建模板消息
- WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
- .toUser(openId)
- .templateId(wxMpProperties.getTemplateId().getPaymentSuccess())
- .data(Arrays.asList(
- new WxMpTemplateData("thing2", tourismName+"提示: 您当前排在第"+rank+"位!"),
- new WxMpTemplateData("time3", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))),
- new WxMpTemplateData("character_string1", orderNo)
-// new WxMpTemplateData("amount4", "19.90")
- ))
- .miniProgram(new WxMpTemplateMessage.MiniProgram(
- tencentPayProperties.getAppId(),
- "pages/index/index",
- true))
- .build();
+ String openId = wxUserService.getMpOpenIdByUnionId(unionId);
+ log.info("获取到服务号openId={}", openId);
+ // 构建模板消息
+// WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
+// .toUser(openId)
+//// .templateId(wxMpProperties.getTemplateId().getPaymentSuccess())
+// .data(Arrays.asList(
+// new WxMpTemplateData("thing2", tourismName+"提示: 您当前排在第"+rank+"位!"),
+// new WxMpTemplateData("time3", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))),
+// new WxMpTemplateData("character_string1", orderNo)
+//// new WxMpTemplateData("amount4", "19.90")
+// ))
+// .miniProgram(new WxMpTemplateMessage.MiniProgram(
+// tencentPayProperties.getAppId(),
+// "pages/index/index",
+// true))
+// .build();
- // 发送消息并获取消息ID
- String msgId = wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
+ // 发送消息并获取消息ID
+// String msgId = wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
- // 记录发送结果
- log.info("模板消息发送成功: openId={}, orderNo={}, msgId={}", openId, orderNo, msgId);
+ // 记录发送结果
+// log.info("模板消息发送成功: openId={}, orderNo={}, msgId={}", openId, orderNo, msgId);
- // 保存发送记录
- saveMessageRecord(openId, msgId, templateMessage,CommonStatus.ENABLE.getId());
-
- } catch (WxErrorException e) {
- log.error("发送模板消息失败: unionId={}, orderNo={}, errorCode={}, errorMsg={}",
- unionId, orderNo, e.getError().getErrorCode(), e.getError().getErrorMsg());
- // 保存发送记录 @TODO
+ // 保存发送记录
// saveMessageRecord(openId, msgId, templateMessage,CommonStatus.ENABLE.getId());
- throw new BusinessException("发送失败:" + e.getError().getErrorMsg());
- }
+
}
private String formatDateTime(LocalDateTime dateTime) {
diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/impl/WxUserServiceImpl.java b/zlt-business/order-center/src/main/java/com/central/order/service/impl/WxUserServiceImpl.java
index 0c3da5cf..2d3feace 100644
--- a/zlt-business/order-center/src/main/java/com/central/order/service/impl/WxUserServiceImpl.java
+++ b/zlt-business/order-center/src/main/java/com/central/order/service/impl/WxUserServiceImpl.java
@@ -7,7 +7,7 @@ import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.WxMpUserService;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.mp.bean.result.WxMpUserList;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Service;
@Service
public class WxUserServiceImpl implements IWxUserService {
- @Autowired
+ @Qualifier
private WxMpService wxMpService;
@Override
@@ -25,10 +25,10 @@ public class WxUserServiceImpl implements IWxUserService {
public String getMpOpenIdByUnionId(String targetUnionId) {
try {
log.info("开始查找 unionId: {} 对应的 openId", targetUnionId);
-
+
WxMpUserService userService = wxMpService.getUserService();
String nextOpenId = null;
-
+
do {
// 获取关注者列表
WxMpUserList userList = userService.userList(nextOpenId);
@@ -36,7 +36,7 @@ public class WxUserServiceImpl implements IWxUserService {
log.warn("未找到关注用户");
break;
}
-
+
// 批量获取用户信息
for (String openId : userList.getOpenids()) {
try {
@@ -50,23 +50,23 @@ public class WxUserServiceImpl implements IWxUserService {
continue; // 单个用户获取失败继续处理下一个
}
}
-
+
nextOpenId = userList.getNextOpenid();
} while (nextOpenId != null && !nextOpenId.isEmpty());
-
+
log.warn("未找到 unionId: {} 对应的 openId", targetUnionId);
return null;
-
+
} catch (WxErrorException e) {
log.error("获取 MP openId 失败,unionId: {},错误: {}", targetUnionId, e.getMessage(), e);
throw new RuntimeException("获取 MP openId 失败", e);
}
}
-
+
@Recover
public String recover(Exception e, String targetUnionId) {
log.error("获取 MP openId 重试耗尽,unionId: {},最终错误: {}", targetUnionId, e.getMessage());
// 可以在这里添加告警通知
return null;
}
-}
\ No newline at end of file
+}
diff --git a/zlt-commons/zlt-wechat-spring-boot-starter/src/main/java/com/zlt/wechat/config/WechatAutoConfiguration.java b/zlt-commons/zlt-wechat-spring-boot-starter/src/main/java/com/zlt/wechat/config/WechatAutoConfiguration.java
index 72177ace..d344c13d 100644
--- a/zlt-commons/zlt-wechat-spring-boot-starter/src/main/java/com/zlt/wechat/config/WechatAutoConfiguration.java
+++ b/zlt-commons/zlt-wechat-spring-boot-starter/src/main/java/com/zlt/wechat/config/WechatAutoConfiguration.java
@@ -4,7 +4,6 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.central.common.context.TenantContextHolder;
-import com.central.wechat.wechat.config.WechatProperties;
import com.central.wechat.wechat.entity.WechatConfig;
import com.central.wechat.wechat.feign.PrivateKeyService;
import com.central.wechat.wechat.feign.WechatConfigService;
@@ -12,20 +11,16 @@ import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
-import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import com.wechat.pay.java.service.payments.jsapi.model.SettleInfo;
import com.wechat.pay.java.service.profitsharing.ProfitsharingService;
-import com.wechat.pay.java.service.refund.RefundService;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
@@ -33,7 +28,6 @@ import java.util.concurrent.ThreadPoolExecutor;
@Slf4j
@Configuration
-@EnableConfigurationProperties(WechatProperties.class)
public class WechatAutoConfiguration {
@Bean
@@ -82,7 +76,7 @@ public class WechatAutoConfiguration {
@Bean
public WxPayConfigFactory wxPayConfigFactory(
- WechatConfigService configService,
+ WechatConfigService configService,
PrivateKeyService privateKeyService) {
return new WxPayConfigFactory(configService, privateKeyService);
}
diff --git a/zlt-uaa/src/main/java/com/central/oauth/support/tencent/TencentAuthenticationProvider.java b/zlt-uaa/src/main/java/com/central/oauth/support/tencent/TencentAuthenticationProvider.java
index 02616404..d727da34 100644
--- a/zlt-uaa/src/main/java/com/central/oauth/support/tencent/TencentAuthenticationProvider.java
+++ b/zlt-uaa/src/main/java/com/central/oauth/support/tencent/TencentAuthenticationProvider.java
@@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.MapUtils;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -88,7 +89,7 @@ public class TencentAuthenticationProvider extends BaseAuthenticationProvider {
String openId = wxLoginResult.get("openid").toString();
String sessionKey = wxLoginResult.get("session_key").toString();
log.info("openId:{},sessionKey:{},res:{}", openId, sessionKey,wxLoginResult);
- String unionId = wxLoginResult.get("unionid").toString();
+ String unionId = MapUtils.getString(wxLoginResult, "unionid");
String mobile = decryptPhoneNumber(encryptedData,sessionKey,iv);
userDetails = userDetailsServiceFactory.getService(authToken).loadUserByWxOpenId(openId,mobile, unionId);