xuhy
2026-03-11 bdd6243be6ee535b13e02a6db7c62cbb273b25fd
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
package com.xiaopeng.operation.service.impl;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaopeng.api.vo.HotFixInfoVo;
import com.xiaopeng.common.redis.service.RedisService;
import com.xiaopeng.operation.mapper.XpSystemSettingMapper;
import com.xiaopeng.api.model.operation.XpSystemSetting;
import com.xiaopeng.operation.service.XpSystemSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.cache.RedisCache;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Objects;
 
/**
 * <p>
 * 系统设置表 服务实现类
 * </p>
 *
 * @author liu
 * @since 2026-02-03
 */
@Service
public class XpSystemSettingServiceImpl extends ServiceImpl<XpSystemSettingMapper, XpSystemSetting> implements XpSystemSettingService {
    @Autowired
    private RedisService redisService;
    @Override
    public String getCustomerServicePhone() {
        XpSystemSetting xpSystemSetting = this.getOne(null);
        if (xpSystemSetting != null) {
            return xpSystemSetting.getCustomerServicePhone();
        }
        return "";
    }
 
    @Override
    public Integer getOrderDistance() {
        XpSystemSetting xpSystemSetting = this.getOne(null);
        if (xpSystemSetting != null) {
            return xpSystemSetting.getOrderDistance();
        }
        return 0;
    }
 
    @Override
    public Integer getOrderFinishTime() {
        XpSystemSetting xpSystemSetting = this.getOne(null);
        if (xpSystemSetting != null) {
            return xpSystemSetting.getArriveTime();
        }
        return 15;
    }
 
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveSystemSetting(XpSystemSetting xpSystemSetting) {
        if (Objects.nonNull(xpSystemSetting.getId())) {
            update(xpSystemSetting, new LambdaQueryWrapper<XpSystemSetting>().eq(XpSystemSetting::getId, xpSystemSetting.getId()));
        } else {
            save(xpSystemSetting);
        }
        //保存热修复信息到redis
        HotFixInfoVo hotFixInfoVo = new HotFixInfoVo();
        hotFixInfoVo.setHotfixStatus(xpSystemSetting.getHotfixStatus() == null ? 0 : xpSystemSetting.getHotfixStatus());
        hotFixInfoVo.setHotfixStartTime(xpSystemSetting.getHotfixStartTime());
        redisService.setCacheObject("HOT_FIX_INFO", hotFixInfoVo);
    }
}