yshop2.0.1微信公众号与支付配置新增redis标识解决必须api模块必须重启配置才能生效的问题

This commit is contained in:
hupeng
2020-03-10 01:16:24 +08:00
5 changed files with 65 additions and 33 deletions

View File

@ -38,6 +38,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -56,24 +57,35 @@ import java.util.*;
@Slf4j
@Service
@Builder
@AllArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, YxStoreCart> implements YxStoreCartService {
private final YxStoreCartMapper yxStoreCartMapper;
private final YxStoreSeckillMapper storeSeckillMapper;
private final YxStoreBargainMapper yxStoreBargainMapper;
private final YxStoreCombinationMapper storeCombinationMapper;
@Autowired
private YxStoreCartMapper yxStoreCartMapper;
@Autowired
private YxStoreSeckillMapper storeSeckillMapper;
@Autowired
private YxStoreBargainMapper yxStoreBargainMapper;
@Autowired
private YxStoreCombinationMapper storeCombinationMapper;
private final YxStoreProductService productService;
private final YxStoreProductAttrService productAttrService;
private final YxStoreCombinationService storeCombinationService;
private final YxStoreSeckillService storeSeckillService;
private final YxStoreBargainService storeBargainService;
private final YxStoreOrderService storeOrderService;
private final YxUserService userService;
@Autowired
private YxStoreProductService productService;
@Autowired
private YxStoreProductAttrService productAttrService;
@Autowired
private YxStoreCombinationService storeCombinationService;
@Autowired
private YxStoreSeckillService storeSeckillService;
@Autowired
private YxStoreBargainService storeBargainService;
@Autowired
private YxStoreOrderService storeOrderService;
@Autowired
private YxUserService userService;
private final CartMap cartMap;
@Autowired
private CartMap cartMap;
/**
* 删除购物车

View File

@ -31,6 +31,7 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -51,20 +52,27 @@ import java.util.Map;
*/
@Slf4j
@Service
@AllArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class YxStoreProductServiceImpl extends BaseServiceImpl<YxStoreProductMapper, YxStoreProduct> implements YxStoreProductService {
private final YxStoreProductMapper yxStoreProductMapper;
private final YxStoreProductAttrValueMapper storeProductAttrValueMapper;
@Autowired
private YxStoreProductMapper yxStoreProductMapper;
@Autowired
private YxStoreProductAttrValueMapper storeProductAttrValueMapper;
private final YxStoreProductAttrService storeProductAttrService;
private final YxStoreProductRelationService relationService;
private final YxStoreProductReplyService replyService;
private final YxUserService userService;
private final YxSystemStoreService systemStoreService;
@Autowired
private YxStoreProductAttrService storeProductAttrService;
@Autowired
private YxStoreProductRelationService relationService;
@Autowired
private YxStoreProductReplyService replyService;
@Autowired
private YxUserService userService;
@Autowired
private YxSystemStoreService systemStoreService;
private final YxStoreProductMap storeProductMap;
@Autowired
private YxStoreProductMap storeProductMap;

View File

@ -34,6 +34,8 @@ public interface ShopConstants {
*/
String YSHOP_WEIXIN_MP_SERVICE = "yshop_weixin_mp_service";
/**
* 商城默认密码
*/

View File

@ -1,7 +1,9 @@
package co.yixiang.mp.config;
import cn.hutool.core.util.StrUtil;
import co.yixiang.constant.ShopConstants;
import co.yixiang.mp.handler.*;
import co.yixiang.utils.RedisUtil;
import com.google.common.collect.Maps;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
@ -65,16 +67,20 @@ public class WxMpConfiguration {
public static WxMpService getWxMpService() {
WxMpService wxMpService = mpServices.get(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
if(wxMpService == null) {
//增加一个redis标识
if(wxMpService == null || RedisUtil.get(ShopConstants.YSHOP_WEIXIN_MP_SERVICE) == null) {
WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
configStorage.setAppId(redisHandler.getVal("wechat_appid"));
configStorage.setSecret(redisHandler.getVal("wechat_appsecret"));
configStorage.setToken(redisHandler.getVal("wechat_token"));
configStorage.setAesKey(redisHandler.getVal("wechat_encodingaeskey"));
configStorage.setAppId(RedisUtil.get("wechat_appid"));
configStorage.setSecret(RedisUtil.get("wechat_appsecret"));
configStorage.setToken(RedisUtil.get("wechat_token"));
configStorage.setAesKey(RedisUtil.get("wechat_encodingaeskey"));
wxMpService = new WxMpServiceImpl();
wxMpService.setWxMpConfigStorage(configStorage);
mpServices.put(ShopConstants.YSHOP_WEIXIN_MP_SERVICE, wxMpService);
routers.put(ShopConstants.YSHOP_WEIXIN_MP_SERVICE, newRouter(wxMpService));
//增加标识
RedisUtil.set(ShopConstants.YSHOP_WEIXIN_MP_SERVICE,"yshop");
}
return wxMpService;
}
@ -83,6 +89,7 @@ public class WxMpConfiguration {
* 移除WxMpService
*/
public static void removeWxMpService(){
RedisUtil.del(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
mpServices.remove(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
routers.remove(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
}

View File

@ -2,6 +2,7 @@ package co.yixiang.mp.config;
import co.yixiang.constant.ShopConstants;
import co.yixiang.mp.handler.RedisHandler;
import co.yixiang.utils.RedisUtil;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
@ -36,19 +37,20 @@ public class WxPayConfiguration {
*/
public static WxPayService getPayService() {
WxPayService wxPayService = payServices.get(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE);
if(wxPayService == null) {
if(wxPayService == null || RedisUtil.get(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE) == null) {
WxPayConfig payConfig = new WxPayConfig();
payConfig.setAppId(redisHandler.getVal("wxpay_appId"));
payConfig.setMchId(redisHandler.getVal("wxpay_mchId"));
payConfig.setMchKey(redisHandler.getVal("wxpay_mchKey"));
payConfig.setKeyPath(redisHandler.getVal("wxpay_keyPath"));
payConfig.setAppId(RedisUtil.get("wxpay_appId"));
payConfig.setMchId(RedisUtil.get("wxpay_mchId"));
payConfig.setMchKey(RedisUtil.get("wxpay_mchKey"));
payConfig.setKeyPath(RedisUtil.get("wxpay_keyPath"));
// 可以指定是否使用沙箱环境
payConfig.setUseSandboxEnv(false);
wxPayService = new WxPayServiceImpl();
wxPayService.setConfig(payConfig);
payServices.put(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE, wxPayService);
//增加标识
RedisUtil.set(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE,"yshop");
}
return wxPayService;
}
@ -57,6 +59,7 @@ public class WxPayConfiguration {
* 移除WxPayService
*/
public static void removeWxPayService(){
RedisUtil.del(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE);
payServices.remove(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE);
}
}