From cfd0118ef446a66f91999afc7b1e46ca607adf50 Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期四, 13 七月 2023 20:32:35 +0800
Subject: [PATCH] 定时任务 统计

---
 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/config/CustomConfigServiceImpl.java |  168 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 149 insertions(+), 19 deletions(-)

diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/config/CustomConfigServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/config/CustomConfigServiceImpl.java
index 0ea858e..f25a3be 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/config/CustomConfigServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/config/CustomConfigServiceImpl.java
@@ -3,8 +3,12 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.redis.service.RedisService;
 import com.ruoyi.system.api.constant.ConfigEnum;
+import com.ruoyi.system.api.constant.SecurityConstant;
 import com.ruoyi.system.api.domain.poji.config.Activeness;
+import com.ruoyi.system.api.domain.vo.AppOtherConfigGetVo;
 import com.ruoyi.system.api.domain.vo.MgtBulletinBoardVo;
 import com.ruoyi.system.api.service.RemoteActivityService;
 import com.ruoyi.system.api.service.RemoteMemberService;
@@ -15,13 +19,9 @@
 import com.ruoyi.system.domain.pojo.config.CustomConfig;
 import com.ruoyi.system.domain.vo.MgtActivenessVo;
 import com.ruoyi.system.domain.vo.MgtAllCustomConfigVo;
-import com.ruoyi.system.domain.vo.MgtCustomConfigVo;
 import com.ruoyi.system.domain.vo.MgtOperLogPageVo;
 import com.ruoyi.system.mapper.config.CustomConfigMapper;
-import com.ruoyi.system.service.config.ActivenessService;
-import com.ruoyi.system.service.config.AdvertService;
-import com.ruoyi.system.service.config.CustomConfigService;
-import com.ruoyi.system.service.config.RecommendCooperationService;
+import com.ruoyi.system.service.config.*;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -63,6 +63,12 @@
 
     @Resource
     private RemoteActivityService remoteActivityService;
+
+    @Resource
+    private StaffSuggestService staffSuggestService;
+
+    @Resource
+    private RedisService redisService;
 
     /**
      * @param key
@@ -256,27 +262,43 @@
             customConfig.setCreateTime(updateTime);
             customConfig.setUpdateTime(updateTime);
             switch (configEnum) {
+                //分享小程序可获得积分
                 case SHARE_INTEGRAL:
                     customConfig.setConfigValue(mgtOtherConfigEditDto.getShareIntegral().toString());
                     this.saveOrUpdate(customConfig);
+                    break;
+                //平台建议可获得积分
                 case SUGGEST_PLATFORM_INTEGRAL:
                     customConfig.setConfigValue(mgtOtherConfigEditDto.getSuggestPlatformIntegral().toString());
                     this.saveOrUpdate(customConfig);
+                    break;
+                //每日签到可获得积分
                 case SIGN_IN_INTEGRAL:
                     customConfig.setConfigValue(mgtOtherConfigEditDto.getSignInIntegral().toString());
                     this.saveOrUpdate(customConfig);
+                    break;
+                //门店建议可获得积分
                 case SUGGEST_SHOP_INTEGRAL:
                     customConfig.setConfigValue(mgtOtherConfigEditDto.getSuggestShopIntegral().toString());
                     this.saveOrUpdate(customConfig);
+                    break;
+                //C端订单自动取消时间
                 case ORDER_AUTO_CANCEL_TIME:
                     customConfig.setConfigValue(mgtOtherConfigEditDto.getOrderAutoCancelTime().toString());
+                    redisService.setCacheObject(SecurityConstant.AUTO_CANCEL_ORDER_TIME,mgtOtherConfigEditDto.getOrderAutoCancelTime());
                     this.saveOrUpdate(customConfig);
+                    break;
+                //购物满1元可获得积分
                 case PAY_MONEY_INTEGRAL:
                     customConfig.setConfigValue(mgtOtherConfigEditDto.getPayMoneyIntegral().toString());
+                    redisService.setCacheObject(SecurityConstant.PAY_MONEY_INTEGRAL,mgtOtherConfigEditDto.getPayMoneyIntegral());
                     this.saveOrUpdate(customConfig);
+                    break;
+                //首页风格
                 case HOME_STYLE:
                     customConfig.setConfigValue(mgtOtherConfigEditDto.getHomeStyle().toString());
                     this.saveOrUpdate(customConfig);
+                    break;
                 default:
                     break;
             }
@@ -313,23 +335,44 @@
                 switch (key) {
                     case "SHOP_EMERGENCY_DEGREE":
                         newValue = mgtShopConfigEditDto.getShopEmergencyDegree();
+                        customConfig.setConfigValue(newValue);
+                        customConfig.setUpdateTime(updateTime);
+                        if(oldValue!=null&&!oldValue.isEmpty()){
+                            handleChangeConfig(oldValue, newValue, key);
+                            updatedCustomConfigs.add(customConfig);
+                        }
                         break;
                     case "SHOP_FOLLOW_TYPE":
                         newValue = mgtShopConfigEditDto.getShopFollowType();
+                        customConfig.setConfigValue(newValue);
+                        customConfig.setUpdateTime(updateTime);
+                        if(oldValue!=null&&!oldValue.isEmpty()){
+                            handleChangeConfig(oldValue, newValue, key);
+                            updatedCustomConfigs.add(customConfig);
+                        }
                         break;
                     case "SHOP_CUSTOM_STATUS":
                         newValue = mgtShopConfigEditDto.getShopCustomStatus();
+                        customConfig.setConfigValue(newValue);
+                        customConfig.setUpdateTime(updateTime);
+                        if(oldValue!=null&&!oldValue.isEmpty()){
+                            handleChangeConfig(oldValue, newValue, key);
+                            updatedCustomConfigs.add(customConfig);
+                        }
                         break;
                     case "SHOP_SOURCE_CHANNEL":
                         newValue = mgtShopConfigEditDto.getShopSourceChannel();
+                        customConfig.setConfigValue(newValue);
+                        customConfig.setUpdateTime(updateTime);
+                        if(oldValue!=null&&!oldValue.isEmpty()){
+                            handleChangeConfig(oldValue, newValue, key);
+                            updatedCustomConfigs.add(customConfig);
+                        }
                         break;
                     default:
                         break;
                 }
-                customConfig.setConfigValue(newValue);
-                customConfig.setUpdateTime(updateTime);
-                handleChangeConfig(oldValue, newValue, key);
-                updatedCustomConfigs.add(customConfig);
+
             }
             this.saveOrUpdateBatch(updatedCustomConfigs);
         } else {
@@ -370,26 +413,52 @@
                 switch (key) {
                     case "MEMBER_SOURCE_CHANNEL":
                         newValue = mgtMemberConfigEditDto.getMemberSourceChannel();
+                        customConfig.setConfigValue(newValue);
+                        customConfig.setUpdateTime(updateTime);
+                        if(oldValue!=null&&!oldValue.isEmpty()){
+                            handleChangeConfig(oldValue, newValue, key);
+                            updatedCustomConfigs.add(customConfig);
+                        }
                         break;
                     case "MEMBER_CHARACTER":
                         newValue = mgtMemberConfigEditDto.getMemberCharacter();
+                        customConfig.setConfigValue(newValue);
+                        customConfig.setUpdateTime(updateTime);
+                        if(oldValue!=null&&!oldValue.isEmpty()){
+                            handleChangeConfig(oldValue, newValue, key);
+                            updatedCustomConfigs.add(customConfig);
+                        }
                         break;
                     case "MEMBER_LEVEL":
                         newValue = mgtMemberConfigEditDto.getMemberLevel();
+                        customConfig.setConfigValue(newValue);
+                        customConfig.setUpdateTime(updateTime);
+                        if(oldValue!=null&&!oldValue.isEmpty()){
+                            handleChangeConfig(oldValue, newValue, key);
+                            updatedCustomConfigs.add(customConfig);
+                        }
                         break;
                     case "MEMBER_TYPE":
                         newValue = mgtMemberConfigEditDto.getMemberType();
+                        customConfig.setConfigValue(newValue);
+                        customConfig.setUpdateTime(updateTime);
+                        if(oldValue!=null&&!oldValue.isEmpty()){
+                            handleChangeConfig(oldValue, newValue, key);
+                            updatedCustomConfigs.add(customConfig);
+                        }
                         break;
                     case "NURSE_PROBLEM":
                         newValue = mgtMemberConfigEditDto.getNurseProblem();
+                        customConfig.setConfigValue(newValue);
+                        customConfig.setUpdateTime(updateTime);
+                        if(oldValue!=null&&!oldValue.isEmpty()){
+                            handleChangeConfig(oldValue, newValue, key);
+                            updatedCustomConfigs.add(customConfig);
+                        }
                         break;
                     default:
                         break;
                 }
-                customConfig.setConfigValue(newValue);
-                customConfig.setUpdateTime(updateTime);
-                handleChangeConfig(oldValue, newValue, key);
-                updatedCustomConfigs.add(customConfig);
             }
             this.saveOrUpdateBatch(updatedCustomConfigs);
         } else {
@@ -478,6 +547,18 @@
     }
 
     /**
+     * @description
+     * @author  jqs
+     * @date    2023/7/13 15:52
+     * @param
+     * @return  List<String>
+     */
+    @Override
+    public List<String> listOperTitle(){
+        return customConfigMapper.listOperTitle();
+    }
+
+    /**
      * @description  获取单个自定义配置
      * @author  jqs
      * @date    2023/6/9 15:40
@@ -485,14 +566,13 @@
      * @return  MgtCustomConfigVo
      */
     @Override
-    public MgtCustomConfigVo getCustomConfig(MgtCustomConfigDto mgtCustomConfigDto){
+    public List<String> getCustomConfig(MgtCustomConfigDto mgtCustomConfigDto){
         CustomConfig customConfig = this.getByKey(mgtCustomConfigDto.getConfigType());
-        MgtCustomConfigVo mgtCustomConfigVo = new MgtCustomConfigVo();
-        if(customConfig!=null){
-            mgtCustomConfigVo.setCustomConfig(customConfig.getConfigValue());
-            mgtCustomConfigVo.setConfigType(mgtCustomConfigDto.getConfigType());
+        List<String> list = new ArrayList<>();
+        if(customConfig!=null&&StringUtils.isNotBlank(customConfig.getConfigValue())){
+            list = Arrays.asList(customConfig.getConfigValue().split(","));
         }
-        return mgtCustomConfigVo;
+        return list;
     }
 
     /**
@@ -529,8 +609,58 @@
         // 获取活动信息
         MgtBulletinBoardVo mgtBulletinBoardVoActivity = remoteActivityService.boardActivityTotal().getData();
         mgtBulletinBoardVo.setActivityUserTotal(mgtBulletinBoardVoActivity.getActivityUserTotal());
+        //待回复建议数量
+        Integer countA = remoteMemberService.getUnReplaySuggestVo().getData();
+        Integer countB = remoteShopService.getUnReplaySuggestVo().getData();
+        Integer countC = staffSuggestService.getUnReplaySuggestVo();
+        mgtBulletinBoardVo.setUnReplaySuggestTotal(countA+countB+countC);
         // 返回 MgtBulletinBoardVo 对象
         return mgtBulletinBoardVo;
     }
 
+    /**
+     * @description  获取其他设置
+     * @author  jqs
+     * @date    2023/7/12 15:28
+     * @param
+     * @return  AppOtherConfigGetVo
+     */
+    @Override
+    public AppOtherConfigGetVo getAppOtherConfigGetVo(){
+        AppOtherConfigGetVo appOtherConfigGetVo = new AppOtherConfigGetVo();
+        //获取自定义配置
+        List<CustomConfig> customConfigList = customConfigMapper.selectList(new LambdaQueryWrapper<CustomConfig>().eq(CustomConfig::getDelFlag, 0));
+        Optional.ofNullable(customConfigList).ifPresent(list -> {
+            Map<String, CustomConfig> configMap = list.stream().collect(Collectors.toMap(CustomConfig::getConfigKey, Function.identity()));
+            // 遍历配置映射,设置相应的属性值
+            configMap.forEach((key, value) -> {
+                switch (key) {
+                    case "SHARE_INTEGRAL":
+                        appOtherConfigGetVo.setShareIntegral(Integer.valueOf(value.getConfigValue()));
+                        break;
+                    case "SUGGEST_PLATFORM_INTEGRAL":
+                        appOtherConfigGetVo.setSuggestPlatformIntegral(Integer.valueOf(value.getConfigValue()));
+                        break;
+                    case "SIGN_IN_INTEGRAL":
+                        appOtherConfigGetVo.setSignInIntegral(Integer.valueOf(value.getConfigValue()));
+                        break;
+                    case "SUGGEST_SHOP_INTEGRAL":
+                        appOtherConfigGetVo.setSuggestShopIntegral(Integer.valueOf(value.getConfigValue()));
+                        break;
+                    case "PAY_MONEY_INTEGRAL":
+                        appOtherConfigGetVo.setPayMoneyIntegral(Integer.valueOf(value.getConfigValue()));
+                        break;
+                    case "ORDER_AUTO_CANCEL_TIME":
+                        appOtherConfigGetVo.setOrderAutoCancelTime(Integer.valueOf(value.getConfigValue()));
+                        break;
+                    case "HOME_STYLE":
+                        appOtherConfigGetVo.setHomeStyle(Integer.valueOf(value.getConfigValue()));
+                        break;
+                    default:
+                        break;
+                }
+            });
+        });
+        return appOtherConfigGetVo;
+    }
 }

--
Gitblit v1.7.1