Explorar el Código

优化协议取值逻辑2

yjwang hace 1 semana
padre
commit
c4f1338f59

+ 1 - 1
fs-service/src/main/java/com/fs/course/service/IFsCoursePlaySourceConfigService.java

@@ -21,5 +21,5 @@ public interface IFsCoursePlaySourceConfigService extends IService<FsCoursePlayS
      * @param appId 小程序ID
      * @param key 缓存KEY
      * **/
-    FsCoursePlaySourceConfig selectConfigByAppId(String appId,String key);
+    String selectConfigByAppId(String appId,String key);
 }

+ 5 - 11
fs-service/src/main/java/com/fs/course/service/impl/FsCoursePlaySourceConfigServiceImpl.java

@@ -45,26 +45,20 @@ public class FsCoursePlaySourceConfigServiceImpl extends ServiceImpl<FsCoursePla
     }
 
     @Override
-    public FsCoursePlaySourceConfig selectConfigByAppId(String appId, String key) {
+    public String selectConfigByAppId(String appId, String key) {
         String configValue = Convert.toStr(redisCache.getCacheObject(key));
         if (StringUtils.isNotEmpty(configValue)) {
-            return converter(configValue);
+            return configValue;
         }
         Object keyLock = KEY_LOCKS.computeIfAbsent(key, k -> new Object());
         synchronized (keyLock){
             FsCoursePlaySourceConfig config = baseMapper.selectOne(new LambdaQueryWrapper<FsCoursePlaySourceConfig>().eq(FsCoursePlaySourceConfig::getAppid,appId).ne(FsCoursePlaySourceConfig::getSettingsProtocolType,0));
            if(config != null){
-               redisCache.setCacheObject(key, JSON.toJSONString(config));
-               return config;
+               String congigValue = JSON.toJSONString(config);
+               redisCache.setCacheObject(key,congigValue);
+               return congigValue;
            }
         }
         return null;
     }
-
-    private FsCoursePlaySourceConfig  converter(String value){
-        if(StringUtils.isNotEmpty(value)){
-            return JSON.parseObject(value,FsCoursePlaySourceConfig.class);
-        }
-        return null;
-    }
 }

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/controller/CommonController.java

@@ -320,7 +320,7 @@ public class CommonController {
 			//获取APPID信息
 			String newKey = "ProtocolConfig:"+appId;
 			//获取小程序配置数据
-			FsCoursePlaySourceConfig config = fsCoursePlaySourceConfigService.selectConfigByAppId(appId , newKey);
+			String config = fsCoursePlaySourceConfigService.selectConfigByAppId(appId , key);
 			if(config != null){
 				return R.ok().put("data",config);
 			}

+ 19 - 4
fs-user-app/src/main/java/com/fs/app/controller/store/CommonScrmController.java

@@ -14,6 +14,8 @@ import com.fs.common.exception.file.OssException;
 import com.fs.company.service.ICompanyMoneyLogsService;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
+import com.fs.course.service.IFsCoursePlaySourceConfigService;
 import com.fs.erp.service.IErpGoodsService;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.erp.service.IErpShopService;
@@ -43,6 +45,7 @@ import com.tencentyun.TLSSigAPIv2;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -141,6 +144,9 @@ public class CommonScrmController extends AppBaseController {
     @Autowired
     IFsStorePaymentScrmService paymentService;
 
+    @Autowired
+    private IFsCoursePlaySourceConfigService fsCoursePlaySourceConfigService;
+
     @ApiOperation("支付手动通知")
     @GetMapping("payNotify")
     public R payNotify(String payCode) throws Exception {
@@ -413,10 +419,19 @@ public class CommonScrmController extends AppBaseController {
 
     @GetMapping(value = "/getConfigByKey")
     @ApiOperation("获取配置")
-    public R getConfigByKey(@RequestParam(value = "key", required = false) String key) {
-        String config = configService.selectConfigByKey(key);
-        return R.ok().put("data", config);
-
+    public R getConfigByKey(@RequestParam(value = "key", required = false) String key,@RequestParam(value = "appId",required = false) String appId)
+    {
+        if(StringUtils.isNotEmpty(appId) && "his.agreementConfig".equals(key)){
+            //获取APPID信息
+            String newKey = "ProtocolConfig:"+appId;
+            //获取小程序配置数据
+            String config = fsCoursePlaySourceConfigService.selectConfigByAppId(appId , newKey);
+            if(config != null){
+                return R.ok().put("data",config);
+            }
+        }
+        String config=configService.selectConfigByKey(key);
+        return  R.ok().put("data",config);
     }
 
     @ApiOperation("获取数据字典")