Pu Zhibing
2025-02-28 16face1a901a018eee1122f27745eff8d5a6ea98
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
package com.ruoyi.system.service.impl.config;
 
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ibm.icu.util.LocaleData;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.constant.ConfigEnum;
import com.ruoyi.system.api.constant.SecurityConstant;
import com.ruoyi.system.api.domain.dto.BoardMemberTotalDto;
import com.ruoyi.system.api.domain.poji.config.Activeness;
import com.ruoyi.system.api.domain.poji.sys.SysUser;
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;
import com.ruoyi.system.api.service.RemoteOrderService;
import com.ruoyi.system.api.service.RemoteShopService;
import com.ruoyi.system.domain.dto.*;
import com.ruoyi.system.domain.pojo.config.Advert;
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.MgtOperLogPageVo;
import com.ruoyi.system.mapper.config.CustomConfigMapper;
import com.ruoyi.system.service.config.*;
import com.ruoyi.system.service.sys.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 系统配置 服务实现类
 * </p>
 *
 * @author jqs
 * @since 2023-04-25
 */
@Service
public class CustomConfigServiceImpl extends ServiceImpl<CustomConfigMapper, CustomConfig> implements CustomConfigService {
 
    @Resource
    private CustomConfigMapper customConfigMapper;
 
    @Resource
    private AdvertService advertService;
 
    @Resource
    private ActivenessService activenessService;
 
    @Resource
    private RemoteMemberService remoteMemberService;
 
    @Resource
    private RecommendCooperationService recommendCooperationService;
 
    @Resource
    private RemoteShopService remoteShopService;
 
    @Resource
    private RemoteOrderService remoteOrderService;
 
    @Resource
    private RemoteActivityService remoteActivityService;
 
    @Resource
    private StaffSuggestService staffSuggestService;
 
    @Resource
    private RedisService redisService;
 
    @Autowired
    private ISysUserService sysUserService;
 
 
 
 
    /**
     * @param key
     * @return CustomConfig
     * @description 通过key获取系统自定义配置
     * @author jqs
     * @date 2023/6/6 11:55
     */
    @Override
    public CustomConfig getByKey(String key) {
        return customConfigMapper.getByKey(key);
    }
 
    /**
     * @param mgtServiceMobileEditDto
     * @return void
     * @description 修改客服号码
     * @author jqs
     * @date 2023/6/6 11:53
     */
    @Override
    public void editServiceMobile(MgtServiceMobileEditDto mgtServiceMobileEditDto) {
        // 获取平台服务电话的配置
        CustomConfig customConfig = getByKey(ConfigEnum.PLATFORM_SERVICE_PHONE.getKey());
        // 如果配置不存在,则创建一个新的配置
        if (customConfig == null) {
            customConfig = new CustomConfig();
            customConfig.setCreateTime(new Date());
            customConfig.setDelFlag(0);
        }
        // 设置配置的类型、键、名称、值和更新时间
        customConfig.setConfigType(ConfigEnum.PLATFORM_SERVICE_PHONE.getKeyType());
        customConfig.setConfigKey(ConfigEnum.PLATFORM_SERVICE_PHONE.getKey());
        customConfig.setConfigName(ConfigEnum.PLATFORM_SERVICE_PHONE.getKeyName());
        customConfig.setConfigValue(mgtServiceMobileEditDto.getServiceMobile());
        customConfig.setUpdateTime(new Date());
        // 保存或更新配置
        this.saveOrUpdate(customConfig);
    }
 
    /**
     * @description  修改客服二维码
     * @author  jqs
     * @date    2023/7/25 16:17
     * @param mgtServiceCodeEditDto
     * @return  void
     */
    @Override
    public void editServiceCode(MgtServiceCodeEditDto mgtServiceCodeEditDto){
        // 获取平台服务电话的配置
        CustomConfig customConfig = getByKey(ConfigEnum.PLATFORM_SERVICE_CODE.getKey());
        // 如果配置不存在,则创建一个新的配置
        if (customConfig == null) {
            customConfig = new CustomConfig();
            customConfig.setCreateTime(new Date());
            customConfig.setDelFlag(0);
        }
        // 设置配置的类型、键、名称、值和更新时间
        customConfig.setConfigType(ConfigEnum.PLATFORM_SERVICE_CODE.getKeyType());
        customConfig.setConfigKey(ConfigEnum.PLATFORM_SERVICE_CODE.getKey());
        customConfig.setConfigName(ConfigEnum.PLATFORM_SERVICE_CODE.getKeyName());
        customConfig.setConfigValue(mgtServiceCodeEditDto.getServiceCodeUrl());
        customConfig.setUpdateTime(new Date());
        // 保存或更新配置
        this.saveOrUpdate(customConfig);
    }
 
    /**
     * @description  修改统一分成
     * @author  jqs
     * @date    2023/9/4 18:05
     * @param mgtShopCommonProportionEditDto
     * @return  void
     */
    @Override
    public void editShopProportion(MgtShopCommonProportionEditDto mgtShopCommonProportionEditDto){
        // 获取平台统一分成的配置
        CustomConfig customConfig = getByKey(ConfigEnum.SHOP_COMMON_PROPORTION.getKey());
        // 如果配置不存在,则创建一个新的配置
        if (customConfig == null) {
            customConfig = new CustomConfig();
            customConfig.setCreateTime(new Date());
            customConfig.setDelFlag(0);
        }
        // 设置配置的类型、键、名称、值和更新时间
        customConfig.setConfigType(ConfigEnum.SHOP_COMMON_PROPORTION.getKeyType());
        customConfig.setConfigKey(ConfigEnum.SHOP_COMMON_PROPORTION.getKey());
        customConfig.setConfigName(ConfigEnum.SHOP_COMMON_PROPORTION.getKeyName());
        customConfig.setConfigValue(mgtShopCommonProportionEditDto.getShopCommonProportion());
        customConfig.setUpdateTime(new Date());
        // 保存或更新配置
        this.saveOrUpdate(customConfig);
        redisService.setCacheObject(SecurityConstant.SHOP_COMMON_PROPORTION,mgtShopCommonProportionEditDto.getShopCommonProportion());
    }
 
    /**
     * @param
     * @return MgtCustomConfigVo
     * @description 平台获取自定义配置
     * @author jqs
     * @date 2023/6/7 15:02
     */
    @Override
    public MgtAllCustomConfigVo getAllCustomConfig() {
        MgtAllCustomConfigVo mgtAllCustomConfigVo = new MgtAllCustomConfigVo();
        //获取自定义配置
        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":
                        mgtAllCustomConfigVo.setShareIntegral(Integer.valueOf(value.getConfigValue()));
                        break;
                    case "SUGGEST_PLATFORM_INTEGRAL":
                        mgtAllCustomConfigVo.setSuggestPlatformIntegral(Integer.valueOf(value.getConfigValue()));
                        break;
                    case "SIGN_IN_INTEGRAL":
                        mgtAllCustomConfigVo.setSignInIntegral(Integer.valueOf(value.getConfigValue()));
                        break;
                    case "SUGGEST_SHOP_INTEGRAL":
                        mgtAllCustomConfigVo.setSuggestShopIntegral(Integer.valueOf(value.getConfigValue()));
                        break;
                    case "PAY_MONEY_INTEGRAL":
                        mgtAllCustomConfigVo.setPayMoneyIntegral(Integer.valueOf(value.getConfigValue()));
                        break;
                    case "ORDER_AUTO_CANCEL_TIME":
                        mgtAllCustomConfigVo.setOrderAutoCancelTime(Integer.valueOf(value.getConfigValue()));
                        break;
                    case "HOME_STYLE":
                        mgtAllCustomConfigVo.setHomeStyle(Integer.valueOf(value.getConfigValue()));
                        break;
                    case "SHOP_EMERGENCY_DEGREE":
                        mgtAllCustomConfigVo.setShopEmergencyDegree(value.getConfigValue());
                        break;
                    case "SHOP_COMMON_PROPORTION":
                        mgtAllCustomConfigVo.setShopCommonProportion(value.getConfigValue());
                        break;
                    case "SHOP_FOLLOW_TYPE":
                        mgtAllCustomConfigVo.setShopFollowType(value.getConfigValue());
                        break;
                    case "SHOP_CUSTOM_STATUS":
                        mgtAllCustomConfigVo.setShopCustomStatus(value.getConfigValue());
                        break;
                    case "SHOP_SOURCE_CHANNEL":
                        mgtAllCustomConfigVo.setShopSourceChannel(value.getConfigValue());
                        break;
                    case "MEMBER_SOURCE_CHANNEL":
                        mgtAllCustomConfigVo.setMemberSourceChannel(value.getConfigValue());
                        break;
                    case "MEMBER_CHARACTER":
                        mgtAllCustomConfigVo.setMemberCharacter(value.getConfigValue());
                        break;
                    case "MEMBER_LEVEL":
                        mgtAllCustomConfigVo.setMemberLevel(value.getConfigValue());
                        break;
                    case "MEMBER_TYPE":
                        mgtAllCustomConfigVo.setMemberType(value.getConfigValue());
                        break;
                    case "NURSE_PROBLEM":
                        mgtAllCustomConfigVo.setNurseProblem(value.getConfigValue());
                        break;
                    case "STORE_COURSE_DISPLAY_NAME":
                        mgtAllCustomConfigVo.setStoreCourseDisplayName(value.getConfigValue());
                        break;
                    case "STORE_COURSE_DISPLAY_PASSWORD":
                        mgtAllCustomConfigVo.setStoreCourseDisplayPassword(value.getConfigValue());
                        break;
                    default:
                        break;
                }
            });
        });
        //获取广告配置
        Advert advert = advertService.getAdvert();
        if (advert != null) {
            mgtAllCustomConfigVo.setHomeSlogan(advert.getAdContent());
            mgtAllCustomConfigVo.setHomeLogo(advert.getLogoUrl());
            mgtAllCustomConfigVo.setAdUrl(advert.getAdUrl());
            mgtAllCustomConfigVo.setTargetType(advert.getTargetType());
            mgtAllCustomConfigVo.setLinkType(advert.getLinkType());
            mgtAllCustomConfigVo.setLinkUrl(advert.getLinkUrl());
            mgtAllCustomConfigVo.setJumpType(advert.getJumpType());
            mgtAllCustomConfigVo.setJumpId(advert.getJumpId());
        }
        //获取活跃度配置
        List<Activeness> activenessList = activenessService.listActiveness();
        if (activenessList != null && !activenessList.isEmpty()) {
            List<MgtActivenessVo> mgtActivenessVoList = activenessList.stream()
                    .map(activeness -> {
                        MgtActivenessVo mgtActivenessVo = new MgtActivenessVo();
                        mgtActivenessVo.setActivenessId(activeness.getActivenessId());
                        mgtActivenessVo.setActivenessName(activeness.getActivenessName());
                        mgtActivenessVo.setStartDay(activeness.getStartDay());
                        mgtActivenessVo.setEndDay(activeness.getEndDay());
                        return mgtActivenessVo;
                    })
                    .collect(Collectors.toList());
            mgtAllCustomConfigVo.setMgtActivenessVoList(mgtActivenessVoList);
        }
        return mgtAllCustomConfigVo;
    }
 
 
    /**
     * @param mgtOtherConfigEditDto
     * @return void
     * @description 修改其他设置
     * @author jqs
     * @date 2023/6/7 16:07
     */
    @Override
    public void editOtherConfig(MgtOtherConfigEditDto mgtOtherConfigEditDto) {
        // 获取当前时间
        Date updateTime = new Date();
        // 删除历史配置
        deletePastConfig(updateTime);
        // 新建配置
        createNewConfig(mgtOtherConfigEditDto, updateTime);
    }
    
    
    /**
     * 修改门店课程配置
     * @param mgtStoreCurriculumEditDto
     */
    @Override
    public void editStoreCurriculum(MgtStoreCurriculumEditDto mgtStoreCurriculumEditDto) {
        customConfigMapper.delete(new QueryWrapper<CustomConfig>().eq("config_type", ConfigEnum.STORE_COURSE_DISPLAY_NAME.getKeyType())
                .eq("config_key", ConfigEnum.STORE_COURSE_DISPLAY_NAME.getKey()));
        customConfigMapper.delete(new QueryWrapper<CustomConfig>().eq("config_type", ConfigEnum.STORE_COURSE_DISPLAY_PASSWORD.getKeyType())
                .eq("config_key", ConfigEnum.STORE_COURSE_DISPLAY_PASSWORD.getKey()));
    
        CustomConfig customConfig = new CustomConfig();
        customConfig.setDelFlag(0);
        customConfig.setConfigType(2);
        customConfig.setConfigKey(ConfigEnum.STORE_COURSE_DISPLAY_NAME.getKey());
        customConfig.setConfigName(ConfigEnum.STORE_COURSE_DISPLAY_NAME.getKeyName());
        customConfig.setCreateTime(new Date());
        customConfig.setUpdateTime(new Date());
        customConfig.setConfigValue(mgtStoreCurriculumEditDto.getStoreCourseDisplayName());
        this.saveOrUpdate(customConfig);
        
        customConfig = new CustomConfig();
        customConfig.setDelFlag(0);
        customConfig.setConfigType(2);
        customConfig.setConfigKey(ConfigEnum.STORE_COURSE_DISPLAY_PASSWORD.getKey());
        customConfig.setConfigName(ConfigEnum.STORE_COURSE_DISPLAY_PASSWORD.getKeyName());
        customConfig.setCreateTime(new Date());
        customConfig.setUpdateTime(new Date());
        customConfig.setConfigValue(mgtStoreCurriculumEditDto.getStoreCourseDisplayPassword());
        this.saveOrUpdate(customConfig);
    }
    
    
 
    /**
     * @param updateTime
     * @return void
     * @description 删除历史配置
     * @author jqs
     * @date 2023/6/7 16:37
     */
    private void deletePastConfig(Date updateTime) {
        List<CustomConfig> customConfigList = customConfigMapper.selectList(new LambdaQueryWrapper<CustomConfig>()
                .eq(CustomConfig::getDelFlag, 0)
                .eq(CustomConfig::getConfigType, 2));
        for (CustomConfig customConfig : customConfigList) {
            customConfig.setDelFlag(1);
            customConfig.setUpdateTime(updateTime);
        }
        this.saveOrUpdateBatch(customConfigList);
    }
 
    /**
     * @param mgtOtherConfigEditDto
     * @param updateTime
     * @return void
     * @description 新建配置
     * @author jqs
     * @date 2023/6/7 16:37
     */
    private void createNewConfig(MgtOtherConfigEditDto mgtOtherConfigEditDto, Date updateTime) {
        for (ConfigEnum configEnum : ConfigEnum.values()) {
            CustomConfig customConfig = new CustomConfig();
            customConfig.setDelFlag(0);
            customConfig.setConfigType(configEnum.getKeyType());
            customConfig.setConfigKey(configEnum.getKey());
            customConfig.setConfigName(configEnum.getKeyName());
            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;
            }
        }
    }
 
 
    /**
     * @param mgtShopConfigEditDto
     * @return void
     * @description 修改合作商配置
     * @author jqs
     * @date 2023/6/7 16:41
     */
    @Override
    public void editShopConfig(MgtShopConfigEditDto mgtShopConfigEditDto) {
        // 获取当前时间
        Date updateTime = new Date();
        // 查询所有未删除、类型为3的自定义配置
        List<CustomConfig> customConfigList = customConfigMapper.selectList(
                new LambdaQueryWrapper<CustomConfig>()
                        .eq(CustomConfig::getDelFlag, 0)
                        .eq(CustomConfig::getConfigType, 3)
        );
        if (customConfigList != null && !customConfigList.isEmpty()) {
            String key;
            String oldValue;
            String newValue = null;
            List<CustomConfig> updatedCustomConfigs = new ArrayList<>();
            // 遍历配置列表,根据 key 更新配置值
            for (CustomConfig customConfig : customConfigList) {
                key = customConfig.getConfigKey();
                oldValue = customConfig.getConfigValue();
                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;
                    case "SHOP_COMMON_PROPORTION":
                        newValue = mgtShopConfigEditDto.getShopCommonProportion();
                        customConfig.setConfigValue(newValue);
                        customConfig.setUpdateTime(updateTime);
                        updatedCustomConfigs.add(customConfig);
                        redisService.setCacheObject(SecurityConstant.SHOP_COMMON_PROPORTION,mgtShopConfigEditDto.getShopCommonProportion());
                        break;
                    default:
                        break;
                }
 
            }
            this.saveOrUpdateBatch(updatedCustomConfigs);
        } else {
            // 如果没有配置,则创建新配置
            createNewConfig(ConfigEnum.SHOP_EMERGENCY_DEGREE, mgtShopConfigEditDto.getShopEmergencyDegree(), updateTime);
            createNewConfig(ConfigEnum.SHOP_FOLLOW_TYPE, mgtShopConfigEditDto.getShopFollowType(), updateTime);
            createNewConfig(ConfigEnum.SHOP_CUSTOM_STATUS, mgtShopConfigEditDto.getShopCustomStatus(), updateTime);
            createNewConfig(ConfigEnum.SHOP_SOURCE_CHANNEL, mgtShopConfigEditDto.getShopSourceChannel(), updateTime);
            createNewConfig(ConfigEnum.SHOP_COMMON_PROPORTION, mgtShopConfigEditDto.getShopCommonProportion(), updateTime);
        }
    }
 
    /**
     * @description  修改会员配置
     * @author  jqs
     * @date    2023/6/7 17:16
     * @param mgtMemberConfigEditDto
     * @return  void
     */
    @Override
    public void editMemberConfig(MgtMemberConfigEditDto mgtMemberConfigEditDto){
        // 获取当前时间
        Date updateTime = new Date();
        // 查询所有未删除、类型为3的自定义配置
        List<CustomConfig> customConfigList = customConfigMapper.selectList(
                new LambdaQueryWrapper<CustomConfig>()
                        .eq(CustomConfig::getDelFlag, 0)
                        .eq(CustomConfig::getConfigType, 4)
        );
        if (customConfigList != null && !customConfigList.isEmpty()) {
            String key;
            String oldValue;
            String newValue = null;
            List<CustomConfig> updatedCustomConfigs = new ArrayList<>();
            // 遍历配置列表,根据 key 更新配置值
            for (CustomConfig customConfig : customConfigList) {
                key = customConfig.getConfigKey();
                oldValue = customConfig.getConfigValue();
                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;
                }
            }
            this.saveOrUpdateBatch(updatedCustomConfigs);
        } else {
            // 如果没有配置,则创建新配置
            createNewConfig(ConfigEnum.MEMBER_SOURCE_CHANNEL, mgtMemberConfigEditDto.getMemberSourceChannel(), updateTime);
            createNewConfig(ConfigEnum.MEMBER_CHARACTER, mgtMemberConfigEditDto.getMemberCharacter(), updateTime);
            createNewConfig(ConfigEnum.MEMBER_LEVEL, mgtMemberConfigEditDto.getMemberLevel(), updateTime);
            createNewConfig(ConfigEnum.MEMBER_TYPE, mgtMemberConfigEditDto.getMemberType(), updateTime);
            createNewConfig(ConfigEnum.NURSE_PROBLEM, mgtMemberConfigEditDto.getNurseProblem(), updateTime);
        }
    }
 
    /**
     * @description  新建配置
     * @author  jqs
     * @date    2023/6/7 17:06
     * @param configEnum
     * @param value
     * @param updateTime
     * @return  void
     */
    private void createNewConfig(ConfigEnum configEnum, String value, Date updateTime) {
        CustomConfig customConfig = new CustomConfig();
        customConfig.setDelFlag(0);
        customConfig.setConfigType(configEnum.getKeyType());
        customConfig.setConfigKey(configEnum.getKey());
        customConfig.setConfigName(configEnum.getKeyName());
        customConfig.setConfigValue(value);
        customConfig.setCreateTime(updateTime);
        customConfig.setUpdateTime(updateTime);
        this.saveOrUpdate(customConfig);
    }
 
    /**
     * @description  处理变动
     * @author  jqs
     * @date    2023/6/7 17:06
     * @param oldValue
     * @param newValue
     * @param key
     * @return  void
     */
    private void handleChangeConfig(String oldValue, String newValue, String key) {
        Set<String> oldSet = new HashSet<>(Arrays.asList(oldValue.split(",")));
        Set<String> newSet = new HashSet<>(Arrays.asList(newValue.split(",")));
        List<String> changeList = new ArrayList<>(oldSet);
        changeList.removeAll(newSet);
        if(changeList!=null&&!changeList.isEmpty()){
            switch(key){
                case "SHOP_EMERGENCY_DEGREE":
                    break;
                case "SHOP_FOLLOW_TYPE":
                    break;
                case "SHOP_CUSTOM_STATUS":
                    break;
                case "SHOP_SOURCE_CHANNEL":
                    break;
                case "MEMBER_SOURCE_CHANNEL":
                    break;
                case "MEMBER_CHARACTER":
                    break;
                case "MEMBER_LEVEL":
                    break;
                case "MEMBER_TYPE":
                    break;
                case "NURSE_PROBLEM":
                    break;
                default:
                    break;
            }
        }
    }
 
 
    /**
     * @description  分页获取操作日志
     * @author  jqs
     * @date    2023/6/8 11:52
     * @param page
     * @param mgtOperLogPageDto
     * @return  List<MgtOperLogPageVo>
     */
    @Override
    public List<MgtOperLogPageVo> pageOperLog(Page page, MgtOperLogPageDto mgtOperLogPageDto){
        return customConfigMapper.pageOperLog(page, mgtOperLogPageDto);
    }
 
    /**
     * @description  删除日志
     * @author  jqs
     * @date    2023/8/1 19:39
     * @param
     * @return  void
     */
    @Override
    public void deleteOperlog(){
        customConfigMapper.deleteOperlog();
    }
 
    /**
     * @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
     * @param mgtCustomConfigDto
     * @return  MgtCustomConfigVo
     */
    @Override
    public List<String> getCustomConfig(MgtCustomConfigDto mgtCustomConfigDto){
        CustomConfig customConfig = this.getByKey(mgtCustomConfigDto.getConfigType());
        List<String> list = new ArrayList<>();
        if(customConfig!=null&&StringUtils.isNotBlank(customConfig.getConfigValue())){
            list = Arrays.asList(customConfig.getConfigValue().split(","));
        }
        return list;
    }
 
    /**
     * @description getBulletinBoard
     * @param
     * @return MgtBulletinBoardVo
     * @author jqs34
     * @date 2023/6/18 16:41
     */
    @Override
    public MgtBulletinBoardVo getBulletinBoard(){
        List<Long> userIds = sysUserService.getScopeOfAuthorityUserId();
        // 创建 MgtBulletinBoardVo 对象
        MgtBulletinBoardVo mgtBulletinBoardVo = new MgtBulletinBoardVo();
        // 获取会员信息
        BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto();
        boardMemberTotalDto.setUserIds(userIds);
 
        MgtBulletinBoardVo mgtBulletinBoardVoMember = remoteMemberService.boardMemberTotal(boardMemberTotalDto).getData();
        mgtBulletinBoardVo.setMemberTotal(mgtBulletinBoardVoMember.getMemberTotal());
        mgtBulletinBoardVo.setMemberToday(mgtBulletinBoardVoMember.getMemberToday());
        // 获取推荐合作信息
        MgtBulletinBoardVo mgtBulletinBoardVoCustom = recommendCooperationService.boardMemberTotal(userIds);
        mgtBulletinBoardVo.setCustomTotal(mgtBulletinBoardVoCustom.getCustomTotal());
        mgtBulletinBoardVo.setCustomToday(mgtBulletinBoardVoCustom.getCustomToday());
        mgtBulletinBoardVo.setFollowUserToday(mgtBulletinBoardVoCustom.getFollowUserToday());
        // 获取店铺信息
        MgtBulletinBoardVo mgtBulletinBoardVoShop = remoteShopService.boardShopTotal(boardMemberTotalDto).getData();
        mgtBulletinBoardVo.setShopTotal(mgtBulletinBoardVoShop.getShopTotal());
        mgtBulletinBoardVo.setAgencyTotal(mgtBulletinBoardVoShop.getAgencyTotal());
        mgtBulletinBoardVo.setDealerTotal(mgtBulletinBoardVoShop.getDealerTotal());
        mgtBulletinBoardVo.setFollowShopToday(mgtBulletinBoardVoShop.getFollowShopToday());
        // 获取订单信息
        MgtBulletinBoardVo mgtBulletinBoardVoOrder = remoteOrderService.boardOrderTotal(boardMemberTotalDto).getData();
        mgtBulletinBoardVo.setSalesTotal(mgtBulletinBoardVoOrder.getSalesTotal());
        mgtBulletinBoardVo.setUnUseOrderTotal(mgtBulletinBoardVoOrder.getUnUseOrderTotal());
        mgtBulletinBoardVo.setActivityOrderTotal(mgtBulletinBoardVoOrder.getActivityOrderTotal());
        mgtBulletinBoardVo.setActivityUserTotal(mgtBulletinBoardVoOrder.getActivityUserTotal());
        // 获取活动信息
        //MgtBulletinBoardVo mgtBulletinBoardVoActivity = remoteActivityService.boardActivityTotal().getData();
        //待回复建议数量
        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;
    }
}