|
|
@@ -2,18 +2,22 @@ package com.fs.his.utils;
|
|
|
|
|
|
import com.fs.his.config.IntegralConfig;
|
|
|
import com.fs.his.constant.IntegralTaskConstants;
|
|
|
+import com.fs.system.vo.DictVO;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
- * 积分任务展示端(app / mini)配置
|
|
|
+ * 积分任务 / 流水类型展示端(app / mini)配置
|
|
|
*/
|
|
|
public final class IntegralTaskScopeHelper {
|
|
|
|
|
|
+ public static final String INTEGRAL_LOG_TYPE_DICT = "sys_integral_log_type";
|
|
|
+
|
|
|
private IntegralTaskScopeHelper() {
|
|
|
}
|
|
|
|
|
|
@@ -39,6 +43,40 @@ public final class IntegralTaskScopeHelper {
|
|
|
return scopes;
|
|
|
}
|
|
|
|
|
|
+ public static Map<String, String> defaultLogTypeDisplayScope() {
|
|
|
+ Map<String, String> taskScopes = defaultTaskDisplayScope();
|
|
|
+ Map<String, String> map = new LinkedHashMap<>();
|
|
|
+ applyTaskScopeToLogType(map, taskScopes, IntegralTaskConstants.TASK_SIGN, "1");
|
|
|
+ applyTaskScopeToLogType(map, taskScopes, IntegralTaskConstants.TASK_SHARE, "3");
|
|
|
+ applyTaskScopeToLogType(map, taskScopes, IntegralTaskConstants.TASK_COURSE, "10");
|
|
|
+ applyTaskScopeToLogType(map, taskScopes, IntegralTaskConstants.TASK_BROWSE_MALL, "13");
|
|
|
+ applyTaskScopeToLogType(map, taskScopes, IntegralTaskConstants.TASK_INVITE, "18");
|
|
|
+ applyTaskScopeToLogType(map, taskScopes, IntegralTaskConstants.TASK_INVITED, "19");
|
|
|
+ applyTaskScopeToLogType(map, taskScopes, IntegralTaskConstants.TASK_REGISTER, "20");
|
|
|
+ applyTaskScopeToLogType(map, taskScopes, IntegralTaskConstants.TASK_DOWNLOAD_APP, "28");
|
|
|
+ applyTaskScopeToLogType(map, taskScopes, IntegralTaskConstants.TASK_FIRST_PURCHASE, "32");
|
|
|
+ map.put("33", "app,mini");
|
|
|
+ for (int i = 1; i <= 33; i++) {
|
|
|
+ map.putIfAbsent(String.valueOf(i), "app,mini");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Map<String, String> resolveLogTypeDisplayScope(IntegralConfig config) {
|
|
|
+ Map<String, String> scopes = defaultLogTypeDisplayScope();
|
|
|
+ if (config != null && config.getLogTypeDisplayScope() != null) {
|
|
|
+ scopes.putAll(config.getLogTypeDisplayScope());
|
|
|
+ }
|
|
|
+ return scopes;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void applyTaskScopeToLogType(Map<String, String> logTypeScopes,
|
|
|
+ Map<String, String> taskScopes,
|
|
|
+ String taskCode,
|
|
|
+ String logType) {
|
|
|
+ logTypeScopes.put(logType, getTaskDisplayScope(taskScopes, taskCode));
|
|
|
+ }
|
|
|
+
|
|
|
public static String normalizePlatform(String platform) {
|
|
|
if (StringUtils.isBlank(platform)) {
|
|
|
return "app";
|
|
|
@@ -51,11 +89,19 @@ public final class IntegralTaskScopeHelper {
|
|
|
}
|
|
|
|
|
|
public static boolean isTaskVisible(Map<String, String> scopes, String taskCode, String platform) {
|
|
|
- if (StringUtils.isBlank(taskCode)) {
|
|
|
+ return isScopeVisible(scopes, taskCode, platform);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static boolean isLogTypeVisible(Map<String, String> scopes, String logType, String platform) {
|
|
|
+ return isScopeVisible(scopes, logType, platform);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static boolean isScopeVisible(Map<String, String> scopes, String code, String platform) {
|
|
|
+ if (StringUtils.isBlank(code)) {
|
|
|
return true;
|
|
|
}
|
|
|
String normalizedPlatform = normalizePlatform(platform);
|
|
|
- String scope = scopes.get(taskCode);
|
|
|
+ String scope = scopes.get(code);
|
|
|
if (StringUtils.isBlank(scope)) {
|
|
|
return true;
|
|
|
}
|
|
|
@@ -63,6 +109,30 @@ public final class IntegralTaskScopeHelper {
|
|
|
return platforms.contains(normalizedPlatform);
|
|
|
}
|
|
|
|
|
|
+ public static boolean shouldFilterIntegralLogType(String dictType, String platform) {
|
|
|
+ return INTEGRAL_LOG_TYPE_DICT.equals(dictType) && StringUtils.isNotBlank(platform);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<DictVO> filterLogTypesByPlatform(List<DictVO> dicts, IntegralConfig config, String platform) {
|
|
|
+ if (dicts == null || dicts.isEmpty()) {
|
|
|
+ return dicts;
|
|
|
+ }
|
|
|
+ Map<String, String> scopes = resolveLogTypeDisplayScope(config);
|
|
|
+ String normalizedPlatform = normalizePlatform(platform);
|
|
|
+ List<DictVO> result = new ArrayList<>();
|
|
|
+ for (DictVO dict : dicts) {
|
|
|
+ if (isLogTypeVisible(scopes, dict.getDictValue(), normalizedPlatform)) {
|
|
|
+ result.add(dict);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getLogTypeDisplayScope(Map<String, String> scopes, String logType) {
|
|
|
+ String scope = scopes.get(logType);
|
|
|
+ return StringUtils.isBlank(scope) ? "app,mini" : scope;
|
|
|
+ }
|
|
|
+
|
|
|
public static String getTaskDisplayScope(Map<String, String> scopes, String taskCode) {
|
|
|
String scope = scopes.get(taskCode);
|
|
|
return StringUtils.isBlank(scope) ? "app,mini" : scope;
|