diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 7b2f97fe..3066b3cc 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -42,22 +42,22 @@ spring: test-on-return: false datasource: master: - url: jdbc:p6spy:mysql://192.168.10.250:3306/ruoyi-vue-pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 + url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 driver-class-name: com.p6spy.engine.spy.P6SpyDriver username: root password: root slave: # 模拟从库,可根据自己需要修改 - url: jdbc:p6spy:mysql://192.168.10.250:3306/ruoyi-vue-pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 + url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 driver-class-name: com.p6spy.engine.spy.P6SpyDriver username: root password: root bxg: # 农场数据源 - url: jdbc:p6spy:mysql://192.168.10.250:3306/bxg?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 + url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro_bxg?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 driver-class-name: com.p6spy.engine.spy.P6SpyDriver username: root password: root erp: # 进销存 - url: jdbc:p6spy:mysql://192.168.10.250:3306/erp?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 + url: jdbc:p6spy:mysql://192.168.10.250:3306/vue_pro_erp?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 driver-class-name: com.p6spy.engine.spy.P6SpyDriver username: root password: root @@ -239,4 +239,11 @@ dubbo: consumer: check: false application: - name: zsw-farm \ No newline at end of file + name: zsw-farm + +bxg: + shop: + API_URL: http://192.168.10.129:48080/bxgApp + SITE_URL: http://192.168.10.129:48080/bxgApp + UNI_SITE_URL: http://192.168.10.129:48080/bxgApp + ADMIN_API_URL: http://192.168.10.129:48080/bxg \ No newline at end of file diff --git a/yudao-server/src/main/resources/application-prod.yaml b/yudao-server/src/main/resources/application-prod.yaml index c467ea7b..d3b38450 100644 --- a/yudao-server/src/main/resources/application-prod.yaml +++ b/yudao-server/src/main/resources/application-prod.yaml @@ -244,4 +244,11 @@ dubbo: consumer: check: false application: - name: zsw-farm \ No newline at end of file + name: zsw-farm + +bxg: + shop: + API_URL: https://farm.lotus-wallet.com/bxgApp + SITE_URL: http://project.lotus-wallet.com/ + UNI_SITE_URL: https://farm.lotus-wallet.com/bxgApp + ADMIN_API_URL: https://farm.lotus-wallet.com/bxg \ No newline at end of file diff --git a/yudao-ui-admin b/yudao-ui-admin index 9cc97d75..c7b0740f 160000 --- a/yudao-ui-admin +++ b/yudao-ui-admin @@ -1 +1 @@ -Subproject commit 9cc97d7585b411f115e1fbddad9d4f04a0d02ddf +Subproject commit c7b0740fa3d4d78923c86b4c236d3fae2424d52a diff --git a/zsw-bxg/src/main/java/co/yixiang/app/common/util/SmsUtils.java b/zsw-bxg/src/main/java/co/yixiang/app/common/util/SmsUtils.java index a7c8f07d..d874e2dd 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/common/util/SmsUtils.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/common/util/SmsUtils.java @@ -9,6 +9,7 @@ package co.yixiang.app.common.util; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.utils.RedisUtils; import com.aliyuncs.CommonRequest; import com.aliyuncs.CommonResponse; @@ -20,6 +21,7 @@ import com.aliyuncs.profile.DefaultProfile; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; /** * @ClassName 阿里云短信 @@ -30,11 +32,10 @@ import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) public class SmsUtils { - private static RedisUtils redisUtils; - + private static YxSystemConfigService systemConfigService; @Autowired - public SmsUtils(RedisUtils redisUtils){ - SmsUtils.redisUtils = redisUtils; + public SmsUtils(YxSystemConfigService systemConfigService){ + SmsUtils.systemConfigService = systemConfigService; } /** * 发送短信 @@ -42,11 +43,11 @@ public class SmsUtils { * @param templateParam 短信模板变量对应的实际值,JSON格式 */ public static void sendSms(String phoneNumbers, String templateParam) throws ClientException { - String regionId = redisUtils.getY("sms_region"); - String accessKeyId = redisUtils.getY("sms_access_key"); - String accessKeySecret = redisUtils.getY("sms_access_secret"); - String sign = redisUtils.getY("sms_sign"); - String templateId = redisUtils.getY("sms_templateId"); + String regionId = systemConfigService.getData("sms_region"); + String accessKeyId = systemConfigService.getData("sms_access_key"); + String accessKeySecret = systemConfigService.getData("sms_access_secret"); + String sign = systemConfigService.getData("sms_sign"); + String templateId = systemConfigService.getData("sms_templateId"); DefaultProfile profile = DefaultProfile.getProfile( regionId, accessKeyId, diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/rest/LetterAppAuthController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/rest/LetterAppAuthController.java index 355dbcaf..aa8827e5 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/rest/LetterAppAuthController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/auth/rest/LetterAppAuthController.java @@ -106,8 +106,7 @@ public class LetterAppAuthController { @ApiOperation(value = "小程序获取用户信息", notes = "小程序获取用户信息") public ApiResult loginAuth(@Validated @RequestBody LoginParam loginParam) { Long uid = LocalUser.getUidByToken(); - String sessionKey = redisUtil.getY(ShopConstants.ZSW_MINI_SESSION_KET + uid); - YxUser yxUser = authService.loginAuth(loginParam, uid, sessionKey); + YxUser yxUser = authService.loginAuth(loginParam, uid); return ApiResult.ok(yxUser).setMsg("获取成功"); } diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/AppAuthService.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/AppAuthService.java index 0f9668d0..3ab44bff 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/AppAuthService.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/AppAuthService.java @@ -25,6 +25,7 @@ import co.yixiang.modules.mp.config.WxMaConfiguration; import co.yixiang.modules.mp.config.WxMpConfiguration; import co.yixiang.modules.shop.domain.YxSystemAttachment; import co.yixiang.modules.shop.service.YxSystemAttachmentService; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.user.domain.YxUser; import co.yixiang.modules.user.service.YxUserService; import co.yixiang.modules.user.service.dto.WechatUserDto; @@ -32,6 +33,7 @@ import co.yixiang.modules.user.vo.OnlineUser; import co.yixiang.utils.*; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.bean.WxOAuth2UserInfo; import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken; @@ -62,6 +64,7 @@ public class AppAuthService { private final RedisUtils redisUtils; private static Integer expiredTimeIn; private final YxSystemAttachmentService systemAttachmentService; + private final YxSystemConfigService systemConfigService; @Value("${bxg.security.token-expired-in}") public void setExpiredTimeIn(Integer expiredTimeIn) { @@ -74,26 +77,22 @@ public class AppAuthService { * * @param loginParam loginParam * @param uid - * @param sessionKey + * @param * @return long */ + @SneakyThrows @Transactional(rollbackFor = Exception.class) - public YxUser loginAuth(LoginParam loginParam,Long uid,String sessionKey) { -// String code = loginParam.getCode(); + public YxUser loginAuth(LoginParam loginParam,Long uid) { + String code = loginParam.getCode(); String encryptedData = loginParam.getEncryptedData(); String iv = loginParam.getIv(); String spread = loginParam.getSpread(); - //读取redis配置 - String appId = redisUtils.getY(ShopKeyUtils.getWxAppAppId()); - String secret = redisUtils.getY(ShopKeyUtils.getWxAppSecret()); - if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) { - throw new YshopException("请先配置小程序"); - } + WxMaService wxMaService = WxMaConfiguration.getWxMaService(); - //WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code); + WxMaJscode2SessionResult session = wxMaService.getUserService().getSessionInfo(code); WxMaUserInfo wxMpUser = wxMaService.getUserService() - .getUserInfo(sessionKey, encryptedData, iv); + .getUserInfo(session.getSessionKey(), encryptedData, iv); YxUser yxUser = userService.getById(uid); //过滤掉表情 @@ -134,8 +133,8 @@ public class AppAuthService { String spread = loginParam.getSpread(); try { //读取redis配置 - String appId = redisUtils.getY(ShopKeyUtils.getWxAppAppId()); - String secret = redisUtils.getY(ShopKeyUtils.getWxAppSecret()); + String appId = systemConfigService.getData(ShopKeyUtils.getWxAppAppId()); + String secret = systemConfigService.getData(ShopKeyUtils.getWxAppSecret()); if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) { throw new YshopException("请先配置小程序"); } diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/CreatShareProductService.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/CreatShareProductService.java index 4b1d29c2..fc517649 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/CreatShareProductService.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/CreatShareProductService.java @@ -87,7 +87,7 @@ public class CreatShareProductService { public YxStoreOrderQueryVo handleQrcode(YxStoreOrderQueryVo storeOrder,String path){ //门店 if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(storeOrder.getShippingType())){ - String mapKey = redisUtils.getY(SystemConfigConstants.TENGXUN_MAP_KEY); + String mapKey = systemConfigService.getData(SystemConfigConstants.TENGXUN_MAP_KEY); if(StrUtil.isBlank(mapKey)) { throw new YshopException("请配置腾讯地图key"); } diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java index b1e5c0c5..3ac16830 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/services/OrderSupplyService.java @@ -192,7 +192,7 @@ public class OrderSupplyService { } else if(AppFromEnum.ROUNTINE.getValue().equals(from)){ map.put("status","WECHAT_PAY"); WxPayMpOrderResult wxPayMpOrderResult = (WxPayMpOrderResult)weixinPayService - .unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"小程序商品购买"); + .unifyPay(orderId,from, BillDetailEnum.TYPE_3.getValue(),"小程序订单"); jsConfig.put("appId",wxPayMpOrderResult.getAppId()); jsConfig.put("timeStamp",wxPayMpOrderResult.getTimeStamp()); jsConfig.put("paySign",wxPayMpOrderResult.getPaySign()); diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java index 3f2d7250..5cfbd495 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/shop/rest/BxgIndexController.java @@ -24,6 +24,7 @@ import co.yixiang.modules.product.vo.YxSystemStoreQueryVo; import co.yixiang.modules.shop.domain.YxAppVersion; import co.yixiang.app.modules.shop.param.YxSystemStoreQueryParam; import co.yixiang.modules.shop.service.YxAppVersionService; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.shop.service.YxSystemGroupDataService; import co.yixiang.modules.shop.service.YxSystemStoreService; import co.yixiang.modules.shop.vo.AppCheckVersion; @@ -72,7 +73,7 @@ public class BxgIndexController { private final YxStoreSeckillService storeSeckillService; private final YxWechatLiveService wechatLiveService; private final RedisUtils redisUtils; - + private final YxSystemConfigService systemConfigService; private final StoreCanvasService storeCanvasService; @GetMapping("/getCanvas") @@ -95,7 +96,7 @@ public class BxgIndexController { .combinationList(storeCombinationService.getList(1,8).getStoreCombinationQueryVos()) .firstList(storeProductService.getList(1,6,ProductEnum.TYPE_3.getValue())) .likeInfo(storeProductService.getList(1,80,ProductEnum.TYPE_2.getValue())) - .mapKey(redisUtils.get(ShopKeyUtils.getTengXunMapKey()).toString()) + .mapKey(systemConfigService.getData(ShopKeyUtils.getTengXunMapKey())) .menus(systemGroupDataService.getDatas(ShopConstants.ZSW_HOME_MENUS)) .roll(systemGroupDataService.getDatas(ShopConstants.ZSW_HOME_ROLL_NEWS)) .seckillList(storeSeckillService.getList(1, 4)) diff --git a/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WxMaUserController.java b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WxMaUserController.java index 93770922..faec4803 100644 --- a/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WxMaUserController.java +++ b/zsw-bxg/src/main/java/co/yixiang/app/modules/wechat/rest/controller/WxMaUserController.java @@ -19,6 +19,7 @@ import co.yixiang.app.modules.wechat.rest.param.WxPhoneParam; import co.yixiang.constant.ShopConstants; import co.yixiang.logging.aop.log.AppLog; import cn.iocoder.yudao.framework.security.core.annotations.AuthCheck; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.user.domain.YxUser; import co.yixiang.modules.user.service.YxUserService; import co.yixiang.modules.mp.config.WxMaConfiguration; @@ -47,6 +48,7 @@ import java.util.Map; public class WxMaUserController { private final YxUserService userService; + private final YxSystemConfigService systemConfigService; private final RedisUtils redisUtils; @AppLog(value = "公众号绑定手机号", type = 1) @@ -84,15 +86,15 @@ public class WxMaUserController { } //读取redis配置 - String appId = redisUtils.getY(ShopKeyUtils.getWxAppAppId()); - String secret = redisUtils.getY(ShopKeyUtils.getWxAppSecret()); + String appId = systemConfigService.getData(ShopKeyUtils.getWxAppAppId()); + String secret = systemConfigService.getData(ShopKeyUtils.getWxAppSecret()); if (StrUtil.isBlank(appId) || StrUtil.isBlank(secret)) { throw new YshopException("请先配置小程序"); } WxMaService wxMaService = WxMaConfiguration.getWxMaService(); String phone = ""; try { - String sessionKey = redisUtils.getY(ShopConstants.ZSW_MINI_SESSION_KET + user.getUid()); + String sessionKey = systemConfigService.getData(ShopConstants.ZSW_MINI_SESSION_KET + user.getUid()); WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService() .getPhoneNoInfo(sessionKey, param.getEncryptedData(), param.getIv()); phone = phoneNoInfo.getPhoneNumber(); diff --git a/zsw-bxg/src/main/java/co/yixiang/aspect/TenantInitAspect.java b/zsw-bxg/src/main/java/co/yixiang/aspect/TenantInitAspect.java index f8144c28..20271a07 100644 --- a/zsw-bxg/src/main/java/co/yixiang/aspect/TenantInitAspect.java +++ b/zsw-bxg/src/main/java/co/yixiang/aspect/TenantInitAspect.java @@ -6,8 +6,10 @@ import co.yixiang.modules.canvas.domain.StoreCanvas; import co.yixiang.modules.canvas.service.StoreCanvasService; import co.yixiang.modules.shop.domain.YxSystemConfig; import co.yixiang.modules.shop.domain.YxSystemGroupData; +import co.yixiang.modules.shop.domain.YxSystemStore; import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.shop.service.YxSystemGroupDataService; +import co.yixiang.modules.shop.service.YxSystemStoreService; import co.yixiang.tools.domain.QiniuConfig; import co.yixiang.tools.service.QiniuConfigService; import lombok.extern.slf4j.Slf4j; @@ -41,6 +43,8 @@ public class TenantInitAspect { private QiniuConfigService qiniuConfigService; @Autowired private YxSystemConfigService systemConfigService; + @Autowired + private YxSystemStoreService storeService; @Pointcut("execution(* cn.iocoder.yudao.module.system.service.tenant.TenantService.createTenant(..))") public void tenantInit(){} @@ -71,6 +75,9 @@ public class TenantInitAspect { }); TenantContextHolder.apply(tenantId,()->systemConfigService.saveBatch(configs)); + YxSystemStore store = TenantContextHolder.apply(0L,()->storeService.getById(1)); + store.setId(null); + TenantContextHolder.apply(tenantId,()->storeService.save(store)); } } diff --git a/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java b/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java index 22e42627..621d8fa2 100644 --- a/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java +++ b/zsw-bxg/src/main/java/co/yixiang/constant/ShopConstants.java @@ -177,6 +177,5 @@ public interface ShopConstants { /**公众号二维码*/ String WECHAT_FOLLOW_IMG="wechat_follow_img"; - /**后台api地址*/ - String ADMIN_API_URL="admin_api_url"; + } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java index 29ba6b4e..fc27366e 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCombinationServiceImpl.java @@ -44,6 +44,7 @@ import co.yixiang.modules.product.service.dto.FromatDetailDto; import co.yixiang.modules.product.service.dto.ProductFormatDto; import co.yixiang.modules.product.service.dto.ProductResultDto; import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.template.domain.YxShippingTemplates; import co.yixiang.modules.template.service.YxShippingTemplatesService; import co.yixiang.utils.FileUtil; @@ -99,6 +100,8 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl returnMap = yxStoreProductAttrService.getProductAttrDetail(storeSeckill.getProductId()); //获取运费模板名称 - String storeFreePostage = redisUtils.getY("store_free_postage"); + String storeFreePostage = systemConfigService.getData("store_free_postage"); String tempName = ""; if(StrUtil.isBlank(storeFreePostage) || !NumberUtil.isNumber(storeFreePostage) diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/canvas/rest/StoreCanvasController.java b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/rest/StoreCanvasController.java index ef8a2b96..7fe265be 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/canvas/rest/StoreCanvasController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/canvas/rest/StoreCanvasController.java @@ -14,6 +14,8 @@ import cn.iocoder.yudao.framework.common.exception.YshopException; import co.yixiang.constant.ShopConstants; import co.yixiang.constant.SystemConfigConstants; import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.mp.config.BxgConstans; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.tools.domain.QiniuContent; import co.yixiang.tools.service.LocalStorageService; import co.yixiang.tools.service.QiNiuService; @@ -46,6 +48,7 @@ public class StoreCanvasController { private final LocalStorageService localStorageService; private final QiNiuService qiNiuService; private final RedisUtils redisUtils; + private final YxSystemConfigService systemConfigService; @PostMapping("/saveCanvas") @@ -62,11 +65,8 @@ public class StoreCanvasController { @RequestParam(defaultValue = "") String type, @RequestParam("file") MultipartFile file) { - String localUrl = redisUtils.getY(ShopConstants.ADMIN_API_URL); - if(StrUtil.isBlank(type)){ - localUrl = redisUtils.getY(SystemConfigConstants.API_URL) + "/api"; - } - String mode = redisUtils.getY(SystemConfigConstants.FILE_STORE_MODE); + String localUrl = BxgConstans.ADMIN_API_URL; + String mode = systemConfigService.getData(SystemConfigConstants.FILE_STORE_MODE); StringBuilder url = new StringBuilder(); if (ShopCommonEnum.STORE_MODE_1.getValue().toString().equals(mode)) { //存在走本地 if(StrUtil.isBlank(localUrl)){ diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/QrCodeController.java b/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/QrCodeController.java index a260b41d..e5e67bb7 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/QrCodeController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/customer/rest/QrCodeController.java @@ -4,7 +4,9 @@ import cn.hutool.core.util.StrUtil; import co.yixiang.annotation.AnonymousAccess; import co.yixiang.constant.ShopConstants; import co.yixiang.exception.BadRequestException; +import co.yixiang.modules.mp.config.BxgConstans; import co.yixiang.modules.mp.config.WxMpConfiguration; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.utils.RecodeUtil; import co.yixiang.utils.RedisUtils; @@ -41,6 +43,7 @@ import java.net.URLEncoder; public class QrCodeController { private final RedisUtils redisUtils; + private final YxSystemConfigService systemConfigService; /** * 生成微信图片二维码 * @@ -51,10 +54,7 @@ public class QrCodeController { @AnonymousAccess @GetMapping("/qrcode") public void qrcode(HttpServletRequest request, HttpServletResponse response, @RequestParam("key") String key) { - String adminApiUrl = redisUtils.getY(ShopConstants.ADMIN_API_URL); - if(StrUtil.isBlank(adminApiUrl)){ - throw new BadRequestException("请配置后台-->商城配置-->商城系统配置-->后台Api地址"); - } + String adminApiUrl = BxgConstans.ADMIN_API_URL; final WxMpService wxService = WxMpConfiguration.getWxMpService(); if (wxService == null) { throw new IllegalArgumentException("未找到对应配置的服务,请核实!"); @@ -71,7 +71,7 @@ public class QrCodeController { @AnonymousAccess @GetMapping("/wechatCode") public ResponseEntity wechatCode() { - String wechatFollowImg = redisUtils.getY(ShopConstants.WECHAT_FOLLOW_IMG); + String wechatFollowImg = systemConfigService.getData(ShopConstants.WECHAT_FOLLOW_IMG); if(StrUtil.isBlank(wechatFollowImg)){ throw new BadRequestException("请配置后台-->微信管理-->公众号配置->关注二维码"); } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/RedisServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/RedisServiceImpl.java index 632fd967..31643969 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/RedisServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/monitor/service/impl/RedisServiceImpl.java @@ -2,6 +2,7 @@ package co.yixiang.modules.monitor.service.impl; import co.yixiang.modules.monitor.domain.vo.RedisVo; import co.yixiang.modules.monitor.service.RedisService; +import co.yixiang.modules.mp.config.BxgConstans; import co.yixiang.utils.PageUtil; import co.yixiang.utils.ShopKeyUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -41,7 +42,7 @@ public class RedisServiceImpl implements RedisService { || s.toString().indexOf("user::loadUserByUsername") != -1 || s.toString().indexOf("wechat") != -1 || s.toString().indexOf("wxpay") != -1 - || s.toString().indexOf(ShopKeyUtils.getSiteUrl()) != -1) { + ) { continue; } DataType dataType = redisTemplate.type(s.toString()); diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/BxgConstans.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/BxgConstans.java new file mode 100644 index 00000000..58a802fe --- /dev/null +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/BxgConstans.java @@ -0,0 +1,27 @@ +package co.yixiang.modules.mp.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class BxgConstans { + + public static String API_URL; + public static String SITE_URL; + public static String ADMIN_API_URL; + + @Value("${bxg.shop.API_URL}") + public void setApiUrl(String apiUrl) { + API_URL = apiUrl; + } + + @Value("${bxg.shop.SITE_URL}") + public void setSiteUrl(String siteUrl) { + SITE_URL = siteUrl; + } + + @Value("${bxg.shop.ADMIN_API_URL}") + public void setAdminApiUrl(String adminApiUrl) { + ADMIN_API_URL = adminApiUrl; + } +} diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMaConfiguration.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMaConfiguration.java index 053a0092..2fde5712 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMaConfiguration.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxMaConfiguration.java @@ -7,6 +7,7 @@ import cn.binarywang.wx.miniapp.message.WxMaMessageHandler; import cn.binarywang.wx.miniapp.message.WxMaMessageRouter; import co.yixiang.constant.SystemConfigConstants; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.utils.RedisUtils; import co.yixiang.utils.ShopKeyUtils; import com.google.common.collect.Maps; @@ -25,13 +26,14 @@ public class WxMaConfiguration { private static Map routers = Maps.newHashMap(); private static RedisUtils redisUtils; private static WxMaMessageHandler wxMaMessageHandler; - + private static YxSystemConfigService systemConfigService; public static WxMaMessageRouter getRouter(String appid) { return routers.get(appid); } @Autowired - public WxMaConfiguration(RedisUtils redisUtils) { + public WxMaConfiguration(RedisUtils redisUtils,YxSystemConfigService systemConfigService) { WxMaConfiguration.redisUtils = redisUtils; + WxMaConfiguration.systemConfigService = systemConfigService; } public static WxMaService getWxMaService() { @@ -40,16 +42,16 @@ public class WxMaConfiguration { if(wxMaService == null || redisUtils.get(ShopKeyUtils.getYshopWeiXinMaSevice()) == null){ WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); config.setMsgDataFormat("JSON"); - config.setAppid(redisUtils.get(ShopKeyUtils.getWxAppAppId()).toString()); - config.setSecret(redisUtils.get(ShopKeyUtils.getWxAppSecret()).toString()); - config.setToken(redisUtils.get(ShopKeyUtils.getWechatMaToken()).toString()); - config.setAesKey(redisUtils.get(ShopKeyUtils.getWechatMaEncodingAESKey()).toString()); + config.setAppid(systemConfigService.getData(ShopKeyUtils.getWxAppAppId())); + config.setSecret(systemConfigService.getData(ShopKeyUtils.getWxAppSecret())); + config.setToken(systemConfigService.getData(ShopKeyUtils.getWechatMaToken())); + config.setAesKey(systemConfigService.getData(ShopKeyUtils.getWechatMaEncodingAESKey())); wxMaService = new WxMaServiceImpl(); wxMaService.setWxMaConfig(config); maServices.put(ShopKeyUtils.getYshopWeiXinMaSevice(), wxMaService); routers.put(ShopKeyUtils.getYshopWeiXinMaSevice(), newRouter(wxMaService)); //增加标识 - redisUtils.set(ShopKeyUtils.getYshopWeiXinMaSevice(),"yshop"); + redisUtils.set(ShopKeyUtils.getYshopWeiXinMaSevice(),"zsw"); } return wxMaService; diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxPayConfiguration.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxPayConfiguration.java index 2dde2ace..da327195 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxPayConfiguration.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/config/WxPayConfiguration.java @@ -7,6 +7,7 @@ package co.yixiang.modules.mp.config; import co.yixiang.enums.PayMethodEnum; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.utils.RedisUtils; import co.yixiang.utils.ShopKeyUtils; import com.github.binarywang.wxpay.config.WxPayConfig; @@ -31,10 +32,11 @@ public class WxPayConfiguration { private static Map payServices = Maps.newHashMap(); private static RedisUtils redisUtils; - + private static YxSystemConfigService systemConfigService; @Autowired - public WxPayConfiguration(RedisUtils redisUtils) { + public WxPayConfiguration(RedisUtils redisUtils,YxSystemConfigService systemConfigService) { WxPayConfiguration.redisUtils = redisUtils; + WxPayConfiguration.systemConfigService = systemConfigService; } /** @@ -48,19 +50,19 @@ public class WxPayConfiguration { WxPayConfig payConfig = new WxPayConfig(); switch (payMethodEnum){ case WECHAT: - payConfig.setAppId(redisUtils.getY(ShopKeyUtils.getWechatAppId())); + payConfig.setAppId(systemConfigService.getData(ShopKeyUtils.getWechatAppId())); break; case WXAPP: - payConfig.setAppId(redisUtils.get(ShopKeyUtils.getWxAppAppId()).toString()); + payConfig.setAppId(systemConfigService.getData(ShopKeyUtils.getWxAppAppId())); break; case APP: - payConfig.setAppId(redisUtils.get(ShopKeyUtils.getWxNativeAppAppId()).toString()); + payConfig.setAppId(systemConfigService.getData(ShopKeyUtils.getWxNativeAppAppId())); break; default: } - payConfig.setMchId(redisUtils.getY(ShopKeyUtils.getWxPayMchId())); - payConfig.setMchKey(redisUtils.getY(ShopKeyUtils.getWxPayMchKey())); - payConfig.setKeyPath(redisUtils.getY(ShopKeyUtils.getWxPayKeyPath())); + payConfig.setMchId(systemConfigService.getData(ShopKeyUtils.getWxPayMchId())); + payConfig.setMchKey(systemConfigService.getData(ShopKeyUtils.getWxPayMchKey())); + payConfig.setKeyPath(systemConfigService.getData(ShopKeyUtils.getWxPayKeyPath())); // 可以指定是否使用沙箱环境 payConfig.setUseSandboxEnv(false); wxPayService = new WxPayServiceImpl(); diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java index ea0856af..07285162 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java @@ -19,6 +19,7 @@ import co.yixiang.enums.BillDetailEnum; import co.yixiang.enums.OrderInfoEnum; import co.yixiang.enums.PayMethodEnum; import co.yixiang.enums.PayTypeEnum; +import co.yixiang.modules.mp.config.BxgConstans; import co.yixiang.modules.order.service.YxStoreOrderService; import co.yixiang.modules.order.vo.YxStoreOrderQueryVo; import co.yixiang.modules.user.domain.YxUser; @@ -38,6 +39,7 @@ import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.math.BigDecimal; @@ -126,7 +128,7 @@ public class WeixinPayService { orderRequest.setOutTradeNo(orderId); orderRequest.setTotalFee(payPrice); orderRequest.setSpbillCreateIp(IpUtil.getLocalIP()); - orderRequest.setNotifyUrl(this.getApiUrl() + "/bxgApp/wechat/notify/"+ TenantContextHolder.getTenantId().toString()); + orderRequest.setNotifyUrl(BxgConstans.API_URL + "/bxgApp/wechat/notify/"+ TenantContextHolder.getTenantId().toString()); orderRequest.setBody(body); orderRequest.setAttach(attach); @@ -184,7 +186,7 @@ public class WeixinPayService { wxPayRefundRequest.setOutRefundNo(orderSn); //退款金额 wxPayRefundRequest.setRefundFee(refundFee); - wxPayRefundRequest.setNotifyUrl(this.getApiUrl() + "/bxgApp/notify/refund/"+ TenantContextHolder.getTenantId().toString()); + wxPayRefundRequest.setNotifyUrl(BxgConstans.API_URL + "/bxgApp/notify/refund/"+ TenantContextHolder.getTenantId().toString()); try { wxPayService.refundV2(wxPayRefundRequest); } catch (WxPayException e) { @@ -217,18 +219,4 @@ public class WeixinPayService { } - - /** - * 返回H5 url - * @return url - */ - private String getApiUrl(){ - String apiUrl = redisUtils.getY(ShopKeyUtils.getApiUrl()); - if(StrUtil.isBlank(apiUrl)){ - throw new YshopException("请配置移动端api地址"); - } - return apiUrl; - } - - } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java index 297ec7a1..8f41a6fe 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/mp/service/WeixinTemplateService.java @@ -12,8 +12,10 @@ import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.exception.YshopException; import co.yixiang.constant.ShopConstants; import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.modules.mp.config.BxgConstans; import co.yixiang.modules.mp.config.WxMpConfiguration; import co.yixiang.modules.mp.domain.YxWechatTemplate; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.user.domain.YxUser; import co.yixiang.modules.user.service.YxUserService; import co.yixiang.modules.user.service.dto.WechatUserDto; @@ -49,8 +51,8 @@ public class WeixinTemplateService { @Autowired private YxWechatTemplateService yxWechatTemplateService; - - + @Autowired + private YxSystemConfigService systemConfigService; /** * 充值成功通知 @@ -73,7 +75,7 @@ public class WeixinTemplateService { map.put("remark", ShopConstants.ZSW_WECHAT_PUSH_REMARK); String tempId = this.getTempId(WechatTempateEnum.RECHARGE_SUCCESS.getValue()); if(StrUtil.isNotBlank(tempId)) { - this.sendWxMpTemplateMessage( openid, tempId, this.getSiteUrl()+"/user/account",map); + this.sendWxMpTemplateMessage( openid, tempId, BxgConstans.SITE_URL +"/user/account",map); } } @@ -100,7 +102,7 @@ public class WeixinTemplateService { map.put("remark",ShopConstants.ZSW_WECHAT_PUSH_REMARK); String tempId = this.getTempId(WechatTempateEnum.PAY_SUCCESS.getValue()); if(StrUtil.isNotBlank(tempId)) { - this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map); + this.sendWxMpTemplateMessage( openid,tempId, BxgConstans.SITE_URL+"/order/detail/"+orderId,map); } } @@ -119,13 +121,13 @@ public class WeixinTemplateService { map.put("keyword2",price); map.put("remark",ShopConstants.ZSW_WECHAT_PUSH_REMARK); String tempId = this.getTempId(WechatTempateEnum.PAY_SUCCESS.getValue()); - String appId=redisUtils.getY(ShopKeyUtils.getWxAppAppId()); + String appId=systemConfigService.getData(ShopKeyUtils.getWxAppAppId()); if(StrUtil.isNotBlank(tempId)) { if(StrUtil.isBlank(appId)){ - this.sendWxMpTemplateMessage( openId,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map); + this.sendWxMpTemplateMessage( openId,tempId, BxgConstans.SITE_URL+"/order/detail/"+orderId,map); }else{ WxMpTemplateMessage.MiniProgram miniProgram = new WxMpTemplateMessage.MiniProgram(); - miniProgram.setAppid(redisUtils.getY(ShopKeyUtils.getWxAppAppId())); + miniProgram.setAppid(systemConfigService.getData(ShopKeyUtils.getWxAppAppId())); miniProgram.setPagePath("pages/orderAdmin/AdminOrder/index?oid=" + orderId); this.sendWxMpTemplateMessageToWx(openId, tempId, miniProgram, map); } @@ -160,7 +162,7 @@ public class WeixinTemplateService { map.put("remark",ShopConstants.ZSW_WECHAT_PUSH_REMARK); String tempId = this.getTempId(WechatTempateEnum.REFUND_SUCCESS.getValue()); if(StrUtil.isNotBlank(tempId)) { - this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map); + this.sendWxMpTemplateMessage( openid,tempId, BxgConstans.SITE_URL+"/order/detail/"+orderId,map); } } @@ -181,13 +183,13 @@ public class WeixinTemplateService { map.put("keyword3", time); map.put("remark",ShopConstants.ZSW_WECHAT_PUSH_REMARK); String tempId = this.getTempId(WechatTempateEnum.REFUND_SUCCESS.getValue()); - String appId=redisUtils.getY(ShopKeyUtils.getWxAppAppId()); + String appId=systemConfigService.getData(ShopKeyUtils.getWxAppAppId()); if(StrUtil.isNotBlank(tempId)) { if(StrUtil.isBlank(appId)){ - this.sendWxMpTemplateMessage( openId,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map); + this.sendWxMpTemplateMessage( openId,tempId, BxgConstans.SITE_URL+"/order/detail/"+orderId,map); }else{ WxMpTemplateMessage.MiniProgram miniProgram = new WxMpTemplateMessage.MiniProgram(); - miniProgram.setAppid(redisUtils.getY(ShopKeyUtils.getWxAppAppId())); + miniProgram.setAppid(systemConfigService.getData(ShopKeyUtils.getWxAppAppId())); miniProgram.setPagePath("pages/orderAdmin/AdminOrder/index?oid=" + orderId); this.sendWxMpTemplateMessageToWx(openId, tempId, miniProgram, map); } @@ -218,7 +220,7 @@ public class WeixinTemplateService { map.put("remark",ShopConstants.ZSW_WECHAT_PUSH_REMARK); String tempId = this.getTempId(WechatTempateEnum.DELIVERY_SUCCESS.getValue()); if(StrUtil.isNotBlank(tempId)) { - this.sendWxMpTemplateMessage( openid,tempId, this.getSiteUrl()+"/order/detail/"+orderId,map); + this.sendWxMpTemplateMessage( openid,tempId, BxgConstans.SITE_URL+"/order/detail/"+orderId,map); } } @@ -292,17 +294,6 @@ public class WeixinTemplateService { return yxWechatTemplate.getTempid(); } - /** - * 返回H5 url - * @return url - */ - private String getSiteUrl(){ - String apiUrl = redisUtils.getY(ShopKeyUtils.getSiteUrl()); - if(StrUtil.isBlank(apiUrl)){ - return ""; - } - return apiUrl; - } /** * 获取openid diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java index 86953108..259d5b70 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductServiceImpl.java @@ -49,6 +49,7 @@ import co.yixiang.modules.product.vo.ProductVo; import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo; import co.yixiang.modules.product.vo.YxStoreProductQueryVo; import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.shop.service.YxSystemStoreService; import co.yixiang.modules.template.domain.YxShippingTemplates; import co.yixiang.modules.template.service.YxShippingTemplatesService; @@ -104,7 +105,7 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl 0) { //添加足迹 YxStoreProductRelation foot = relationService.getOne(new LambdaQueryWrapper() diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreController.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreController.java index c554ff47..eb9bd236 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreController.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/rest/SystemStoreController.java @@ -12,6 +12,7 @@ import co.yixiang.exception.BadRequestException; import co.yixiang.logging.aop.log.Log; import co.yixiang.modules.aop.ForbidSubmit; import co.yixiang.modules.shop.domain.YxSystemStore; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.shop.service.YxSystemStoreService; import co.yixiang.modules.shop.service.dto.YxSystemStoreDto; import co.yixiang.modules.shop.service.dto.YxSystemStoreQueryCriteria; @@ -53,12 +54,12 @@ public class SystemStoreController { private final YxSystemStoreService yxSystemStoreService; private final IGenerator generator; - private final RedisUtils redisUtils; + private final YxSystemConfigService systemConfigService; - public SystemStoreController(YxSystemStoreService yxSystemStoreService, IGenerator generator, RedisUtils redisUtils) { + public SystemStoreController(YxSystemStoreService yxSystemStoreService, IGenerator generator, YxSystemConfigService systemConfigService) { this.yxSystemStoreService = yxSystemStoreService; this.generator = generator; - this.redisUtils = redisUtils; + this.systemConfigService = systemConfigService; } @@ -95,7 +96,7 @@ public class SystemStoreController { String addr = jsonObject.getString("addr"); - String key = redisUtils.getY(ShopKeyUtils.getTengXunMapKey()); + String key = systemConfigService.getData(ShopKeyUtils.getTengXunMapKey()); if (StrUtil.isBlank(key)) { throw new BadRequestException("请先配置腾讯地图key"); } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreServiceImpl.java index 4c3c65d7..6ba43c4d 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/shop/service/impl/YxSystemStoreServiceImpl.java @@ -16,6 +16,7 @@ import co.yixiang.dozer.service.IGenerator; import co.yixiang.enums.ShopCommonEnum; import co.yixiang.modules.product.vo.YxSystemStoreQueryVo; import co.yixiang.modules.shop.domain.YxSystemStore; +import co.yixiang.modules.shop.service.YxSystemConfigService; import co.yixiang.modules.shop.service.YxSystemStoreService; import co.yixiang.modules.shop.service.dto.YxSystemStoreDto; import co.yixiang.modules.shop.service.dto.YxSystemStoreQueryCriteria; @@ -54,7 +55,7 @@ public class YxSystemStoreServiceImpl extends BaseServiceImpl