yshop2.0.1微信公众号与支付配置新增redis标识解决必须api模块必须重启配置才能生效的问题
This commit is contained in:
@ -38,6 +38,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -56,24 +57,35 @@ import java.util.*;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@Builder
|
@Builder
|
||||||
@AllArgsConstructor
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, YxStoreCart> implements YxStoreCartService {
|
public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, YxStoreCart> implements YxStoreCartService {
|
||||||
|
|
||||||
private final YxStoreCartMapper yxStoreCartMapper;
|
@Autowired
|
||||||
private final YxStoreSeckillMapper storeSeckillMapper;
|
private YxStoreCartMapper yxStoreCartMapper;
|
||||||
private final YxStoreBargainMapper yxStoreBargainMapper;
|
@Autowired
|
||||||
private final YxStoreCombinationMapper storeCombinationMapper;
|
private YxStoreSeckillMapper storeSeckillMapper;
|
||||||
|
@Autowired
|
||||||
|
private YxStoreBargainMapper yxStoreBargainMapper;
|
||||||
|
@Autowired
|
||||||
|
private YxStoreCombinationMapper storeCombinationMapper;
|
||||||
|
|
||||||
private final YxStoreProductService productService;
|
@Autowired
|
||||||
private final YxStoreProductAttrService productAttrService;
|
private YxStoreProductService productService;
|
||||||
private final YxStoreCombinationService storeCombinationService;
|
@Autowired
|
||||||
private final YxStoreSeckillService storeSeckillService;
|
private YxStoreProductAttrService productAttrService;
|
||||||
private final YxStoreBargainService storeBargainService;
|
@Autowired
|
||||||
private final YxStoreOrderService storeOrderService;
|
private YxStoreCombinationService storeCombinationService;
|
||||||
private final YxUserService userService;
|
@Autowired
|
||||||
|
private YxStoreSeckillService storeSeckillService;
|
||||||
|
@Autowired
|
||||||
|
private YxStoreBargainService storeBargainService;
|
||||||
|
@Autowired
|
||||||
|
private YxStoreOrderService storeOrderService;
|
||||||
|
@Autowired
|
||||||
|
private YxUserService userService;
|
||||||
|
|
||||||
private final CartMap cartMap;
|
@Autowired
|
||||||
|
private CartMap cartMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除购物车
|
* 删除购物车
|
||||||
|
@ -31,6 +31,7 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -51,20 +52,27 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public class YxStoreProductServiceImpl extends BaseServiceImpl<YxStoreProductMapper, YxStoreProduct> implements YxStoreProductService {
|
public class YxStoreProductServiceImpl extends BaseServiceImpl<YxStoreProductMapper, YxStoreProduct> implements YxStoreProductService {
|
||||||
|
|
||||||
private final YxStoreProductMapper yxStoreProductMapper;
|
@Autowired
|
||||||
private final YxStoreProductAttrValueMapper storeProductAttrValueMapper;
|
private YxStoreProductMapper yxStoreProductMapper;
|
||||||
|
@Autowired
|
||||||
|
private YxStoreProductAttrValueMapper storeProductAttrValueMapper;
|
||||||
|
|
||||||
private final YxStoreProductAttrService storeProductAttrService;
|
@Autowired
|
||||||
private final YxStoreProductRelationService relationService;
|
private YxStoreProductAttrService storeProductAttrService;
|
||||||
private final YxStoreProductReplyService replyService;
|
@Autowired
|
||||||
private final YxUserService userService;
|
private YxStoreProductRelationService relationService;
|
||||||
private final YxSystemStoreService systemStoreService;
|
@Autowired
|
||||||
|
private YxStoreProductReplyService replyService;
|
||||||
|
@Autowired
|
||||||
|
private YxUserService userService;
|
||||||
|
@Autowired
|
||||||
|
private YxSystemStoreService systemStoreService;
|
||||||
|
|
||||||
private final YxStoreProductMap storeProductMap;
|
@Autowired
|
||||||
|
private YxStoreProductMap storeProductMap;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ public interface ShopConstants {
|
|||||||
*/
|
*/
|
||||||
String YSHOP_WEIXIN_MP_SERVICE = "yshop_weixin_mp_service";
|
String YSHOP_WEIXIN_MP_SERVICE = "yshop_weixin_mp_service";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商城默认密码
|
* 商城默认密码
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package co.yixiang.mp.config;
|
package co.yixiang.mp.config;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import co.yixiang.constant.ShopConstants;
|
import co.yixiang.constant.ShopConstants;
|
||||||
import co.yixiang.mp.handler.*;
|
import co.yixiang.mp.handler.*;
|
||||||
|
import co.yixiang.utils.RedisUtil;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import me.chanjar.weixin.common.api.WxConsts;
|
import me.chanjar.weixin.common.api.WxConsts;
|
||||||
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
|
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
|
||||||
@ -65,16 +67,20 @@ public class WxMpConfiguration {
|
|||||||
public static WxMpService getWxMpService() {
|
public static WxMpService getWxMpService() {
|
||||||
|
|
||||||
WxMpService wxMpService = mpServices.get(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
|
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();
|
WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
|
||||||
configStorage.setAppId(redisHandler.getVal("wechat_appid"));
|
configStorage.setAppId(RedisUtil.get("wechat_appid"));
|
||||||
configStorage.setSecret(redisHandler.getVal("wechat_appsecret"));
|
configStorage.setSecret(RedisUtil.get("wechat_appsecret"));
|
||||||
configStorage.setToken(redisHandler.getVal("wechat_token"));
|
configStorage.setToken(RedisUtil.get("wechat_token"));
|
||||||
configStorage.setAesKey(redisHandler.getVal("wechat_encodingaeskey"));
|
configStorage.setAesKey(RedisUtil.get("wechat_encodingaeskey"));
|
||||||
wxMpService = new WxMpServiceImpl();
|
wxMpService = new WxMpServiceImpl();
|
||||||
wxMpService.setWxMpConfigStorage(configStorage);
|
wxMpService.setWxMpConfigStorage(configStorage);
|
||||||
mpServices.put(ShopConstants.YSHOP_WEIXIN_MP_SERVICE, wxMpService);
|
mpServices.put(ShopConstants.YSHOP_WEIXIN_MP_SERVICE, wxMpService);
|
||||||
routers.put(ShopConstants.YSHOP_WEIXIN_MP_SERVICE, newRouter(wxMpService));
|
routers.put(ShopConstants.YSHOP_WEIXIN_MP_SERVICE, newRouter(wxMpService));
|
||||||
|
|
||||||
|
//增加标识
|
||||||
|
RedisUtil.set(ShopConstants.YSHOP_WEIXIN_MP_SERVICE,"yshop");
|
||||||
}
|
}
|
||||||
return wxMpService;
|
return wxMpService;
|
||||||
}
|
}
|
||||||
@ -83,6 +89,7 @@ public class WxMpConfiguration {
|
|||||||
* 移除WxMpService
|
* 移除WxMpService
|
||||||
*/
|
*/
|
||||||
public static void removeWxMpService(){
|
public static void removeWxMpService(){
|
||||||
|
RedisUtil.del(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
|
||||||
mpServices.remove(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
|
mpServices.remove(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
|
||||||
routers.remove(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
|
routers.remove(ShopConstants.YSHOP_WEIXIN_MP_SERVICE);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package co.yixiang.mp.config;
|
|||||||
|
|
||||||
import co.yixiang.constant.ShopConstants;
|
import co.yixiang.constant.ShopConstants;
|
||||||
import co.yixiang.mp.handler.RedisHandler;
|
import co.yixiang.mp.handler.RedisHandler;
|
||||||
|
import co.yixiang.utils.RedisUtil;
|
||||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
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;
|
||||||
@ -36,19 +37,20 @@ public class WxPayConfiguration {
|
|||||||
*/
|
*/
|
||||||
public static WxPayService getPayService() {
|
public static WxPayService getPayService() {
|
||||||
WxPayService wxPayService = payServices.get(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE);
|
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();
|
WxPayConfig payConfig = new WxPayConfig();
|
||||||
payConfig.setAppId(redisHandler.getVal("wxpay_appId"));
|
payConfig.setAppId(RedisUtil.get("wxpay_appId"));
|
||||||
payConfig.setMchId(redisHandler.getVal("wxpay_mchId"));
|
payConfig.setMchId(RedisUtil.get("wxpay_mchId"));
|
||||||
payConfig.setMchKey(redisHandler.getVal("wxpay_mchKey"));
|
payConfig.setMchKey(RedisUtil.get("wxpay_mchKey"));
|
||||||
payConfig.setKeyPath(redisHandler.getVal("wxpay_keyPath"));
|
payConfig.setKeyPath(RedisUtil.get("wxpay_keyPath"));
|
||||||
// 可以指定是否使用沙箱环境
|
// 可以指定是否使用沙箱环境
|
||||||
payConfig.setUseSandboxEnv(false);
|
payConfig.setUseSandboxEnv(false);
|
||||||
wxPayService = new WxPayServiceImpl();
|
wxPayService = new WxPayServiceImpl();
|
||||||
wxPayService.setConfig(payConfig);
|
wxPayService.setConfig(payConfig);
|
||||||
payServices.put(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE, wxPayService);
|
payServices.put(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE, wxPayService);
|
||||||
|
|
||||||
|
//增加标识
|
||||||
|
RedisUtil.set(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE,"yshop");
|
||||||
}
|
}
|
||||||
return wxPayService;
|
return wxPayService;
|
||||||
}
|
}
|
||||||
@ -57,6 +59,7 @@ public class WxPayConfiguration {
|
|||||||
* 移除WxPayService
|
* 移除WxPayService
|
||||||
*/
|
*/
|
||||||
public static void removeWxPayService(){
|
public static void removeWxPayService(){
|
||||||
|
RedisUtil.del(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE);
|
||||||
payServices.remove(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE);
|
payServices.remove(ShopConstants.YSHOP_WEIXIN_PAY_SERVICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user