Commit 89191dca authored by shiyu's avatar shiyu

兼容多个小程序配置

parent a4a82dba
...@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
...@@ -51,7 +52,7 @@ public class WxLoginManager { ...@@ -51,7 +52,7 @@ public class WxLoginManager {
@Autowired @Resource(name = "wxMaService")
private WxMaService wxMaService; private WxMaService wxMaService;
@Autowired @Autowired
......
...@@ -8,6 +8,7 @@ import com.github.binarywang.wxpay.config.WxPayConfig; ...@@ -8,6 +8,7 @@ import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -18,6 +19,7 @@ public class QdWxConfig { ...@@ -18,6 +19,7 @@ public class QdWxConfig {
private QdWxProperties qdWxProperties; private QdWxProperties qdWxProperties;
@Bean(name = "qdWxMaConfig") @Bean(name = "qdWxMaConfig")
@Qualifier()
public WxMaConfig qdWxMaConfig() { public WxMaConfig qdWxMaConfig() {
WxMaInMemoryConfig config = new WxMaInMemoryConfig(); WxMaInMemoryConfig config = new WxMaInMemoryConfig();
config.setAppid(qdWxProperties.getQdAppId()); config.setAppid(qdWxProperties.getQdAppId());
...@@ -32,23 +34,4 @@ public class QdWxConfig { ...@@ -32,23 +34,4 @@ public class QdWxConfig {
return service; return service;
} }
@Bean
public WxPayConfig qdWxPayConfig() {
WxPayConfig payConfig = new WxPayConfig();
payConfig.setAppId(qdWxProperties.getQdAppId());
payConfig.setMchId(qdWxProperties.getMchId());
payConfig.setMchKey(qdWxProperties.getMchKey());
payConfig.setNotifyUrl(qdWxProperties.getNotifyUrl());
payConfig.setKeyPath(qdWxProperties.getKeyPath());
payConfig.setTradeType("JSAPI");
payConfig.setSignType("MD5");
return payConfig;
}
@Bean
public WxPayService qdWxPayService(WxPayConfig wxPayConfig) {
WxPayService wxPayService = new WxPayServiceImpl();
wxPayService.setConfig(wxPayConfig);
return wxPayService;
}
} }
\ No newline at end of file
...@@ -13,10 +13,11 @@ import org.springframework.context.annotation.Configuration; ...@@ -13,10 +13,11 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class WxConfig { public class WxConfig {
@Autowired @Autowired
private WxProperties properties; private WxProperties properties;
@Bean @Bean(name = "wxMaConfig")
public WxMaConfig wxMaConfig() { public WxMaConfig wxMaConfig() {
WxMaInMemoryConfig config = new WxMaInMemoryConfig(); WxMaInMemoryConfig config = new WxMaInMemoryConfig();
config.setAppid(properties.getAppId()); config.setAppid(properties.getAppId());
...@@ -24,10 +25,10 @@ public class WxConfig { ...@@ -24,10 +25,10 @@ public class WxConfig {
return config; return config;
} }
@Bean @Bean(name = "wxMaService")
public WxMaService wxMaService(WxMaConfig maConfig) { public WxMaService wxMaService(WxMaConfig wxMaConfig) {
WxMaService service = new WxMaServiceImpl(); WxMaService service = new WxMaServiceImpl();
service.setWxMaConfig(maConfig); service.setWxMaConfig(wxMaConfig);
return service; return service;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment