yuhongqi 3 tygodni temu
rodzic
commit
829d62c293

+ 3 - 0
fs-service/src/main/java/com/fs/his/config/IntegralConfig.java

@@ -51,4 +51,7 @@ public class IntegralConfig implements Serializable {
 
     /** 任务展示端配置,key=任务code,value=app / mini / app,mini */
     private Map<String, String> taskDisplayScope;
+
+    /** 积分流水类型展示端配置,key=logType(dict_value),value=app / mini / app,mini */
+    private Map<String, String> logTypeDisplayScope;
 }

+ 7 - 0
fs-service/src/main/java/com/fs/his/utils/IntegralConfigHelper.java

@@ -59,5 +59,12 @@ public final class IntegralConfigHelper {
             merged.putAll(config.getTaskDisplayScope());
             config.setTaskDisplayScope(merged);
         }
+        if (config.getLogTypeDisplayScope() == null || config.getLogTypeDisplayScope().isEmpty()) {
+            config.setLogTypeDisplayScope(IntegralTaskScopeHelper.defaultLogTypeDisplayScope());
+        } else {
+            Map<String, String> merged = IntegralTaskScopeHelper.defaultLogTypeDisplayScope();
+            merged.putAll(config.getLogTypeDisplayScope());
+            config.setLogTypeDisplayScope(merged);
+        }
     }
 }

+ 73 - 3
fs-service/src/main/java/com/fs/his/utils/IntegralTaskScopeHelper.java

@@ -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;

+ 23 - 0
fs-service/src/main/resources/db/changelog/changes/20260613-live-user-add-is-del.sql

@@ -165,4 +165,27 @@ ALTER TABLE `fs_integral_goods`
     ADD COLUMN `visible_scope` varchar(64) NOT NULL DEFAULT 'app,mini' COMMENT '可见范围 app,mini 多选' AFTER `app_ids`;
 --rollback ALTER TABLE fs_integral_goods DROP COLUMN visible_scope;
 
+--changeset yhq:20250701-sys-integral-log-type-first-purchase
+--preconditions onFail:MARK_RAN
+--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM sys_dict_data WHERE dict_type = 'sys_integral_log_type' AND dict_value = '32'
+INSERT INTO `sys_dict_data`
+(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
+VALUES
+    (32, '首次完成购物', '32', 'sys_integral_log_type', NULL, 'default', 'N', '0', 'admin', NOW(), '', NULL, NULL);
+--rollback DELETE FROM sys_dict_data WHERE dict_type = 'sys_integral_log_type' AND dict_value = '32';
+
+--changeset yhq:20250701-sys-integral-log-type-comment
+--preconditions onFail:MARK_RAN
+--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM sys_dict_data WHERE dict_type = 'sys_integral_log_type' AND dict_value = '33'
+INSERT INTO `sys_dict_data`
+(`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
+VALUES
+    (33, '内容留言积分', '33', 'sys_integral_log_type', NULL, 'default', 'N', '0', 'admin', NOW(), '', NULL, NULL);
+--rollback DELETE FROM sys_dict_data WHERE dict_type = 'sys_integral_log_type' AND dict_value = '33';
+
+--changeset yhq:20250701-sys-integral-log-type-28-label-fix
+UPDATE sys_dict_data
+SET dict_label = '首次下载APP获取积分', dict_sort = 28
+WHERE dict_type = 'sys_integral_log_type' AND dict_value = '28';
+--rollback UPDATE sys_dict_data SET dict_label = '管理员后台扣除', dict_sort = 28 WHERE dict_type = 'sys_integral_log_type' AND dict_value = '28';
 

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

@@ -50,6 +50,8 @@ import com.fs.his.param.FsInquiryOrderFinishParam;
 import com.fs.his.service.*;
 
 import com.fs.his.utils.ConfigUtil;
+import com.fs.his.utils.IntegralConfigHelper;
+import com.fs.his.utils.IntegralTaskScopeHelper;
 import com.fs.his.vo.InquirySubTypeVo;
 import com.fs.hisStore.mapper.FsWechatTemplateScrmMapper;
 import com.fs.hisStore.service.IFsWechatTemplateScrmService;
@@ -340,9 +342,14 @@ public class CommonController {
 
 	@ApiOperation("获取数据字典")
 	@GetMapping("/getDictByKey")
-    @Cacheable(value="dicts", key="#key")
-	public R getDictByKey(@RequestParam(value = "key", required = false) String key){
+    @Cacheable(value="dicts", key="#key + ':' + (#platform != null ? #platform : 'all')")
+	public R getDictByKey(@RequestParam(value = "key", required = false) String key,
+						  @RequestParam(value = "platform", required = false) String platform){
 		List<DictVO> dicts=dictDataService.selectDictDataListByType(key);
+		if (IntegralTaskScopeHelper.shouldFilterIntegralLogType(key, platform)) {
+			dicts = IntegralTaskScopeHelper.filterLogTypesByPlatform(
+					dicts, IntegralConfigHelper.load(configService), platform);
+		}
 		return R.ok().put("data",dicts);
 	}
 

+ 8 - 1
fs-user-app/src/main/java/com/fs/app/controller/store/CommonScrmController.java

@@ -20,6 +20,8 @@ import com.fs.erp.service.IErpShopService;
 import com.fs.erp.service.IErpUserService;
 import com.fs.his.service.IFsCityService;
 import com.fs.his.utils.ConfigUtil;
+import com.fs.his.utils.IntegralConfigHelper;
+import com.fs.his.utils.IntegralTaskScopeHelper;
 import com.fs.hisStore.config.StoreConfig;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
 import com.fs.hisStore.dto.ExpressDataDTO;
@@ -421,8 +423,13 @@ public class CommonScrmController extends AppBaseController {
 
     @ApiOperation("获取数据字典")
     @GetMapping("/getDictByKey")
-    public R getDictByKey(@ApiParam(required = false, name = "key", value = "key") @RequestParam(value = "key", required = false) String key) {
+    public R getDictByKey(@ApiParam(required = false, name = "key", value = "key") @RequestParam(value = "key", required = false) String key,
+                          @ApiParam(required = false, name = "platform", value = "app/mini") @RequestParam(value = "platform", required = false) String platform) {
         List<DictVO> dictVOS = dictDataService.selectDictDataListByType(key);
+        if (IntegralTaskScopeHelper.shouldFilterIntegralLogType(key, platform)) {
+            dictVOS = IntegralTaskScopeHelper.filterLogTypesByPlatform(
+                    dictVOS, IntegralConfigHelper.load(configService), platform);
+        }
         return R.ok().put("data", dictVOS);
     }