liujie
2026-06-09 642330d06db0dc17fbcc3aae3ac7600f291d500d
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
package com.xiaopeng.operation.controller;
 
import com.xiaopeng.api.model.operation.XpSystemSetting;
import com.xiaopeng.common.core.constant.CacheConstants;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.utils.DateUtils;
import com.xiaopeng.common.core.web.controller.BaseController;
import com.xiaopeng.common.core.web.domain.AjaxResult;
import com.xiaopeng.common.log.annotation.AdminOperationLog;
import com.xiaopeng.common.log.enums.AdminBusinessType;
import com.xiaopeng.common.log.enums.AdminOperationType;
import com.xiaopeng.common.redis.service.RedisService;
import com.xiaopeng.operation.job.base.QuartzManager;
import com.xiaopeng.operation.job.base.TimeJobType;
import com.xiaopeng.operation.job.jobs.HotFixJob;
import com.xiaopeng.operation.service.XpSystemSettingService;
import com.xiaopeng.operation.vo.CustomerServicePhoneVo;
import com.xiaopeng.unifiedverification.interceptor.XpClientCheck;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.time.LocalDateTime;
import java.util.HashMap;
 
@Slf4j
@Validated
@RestController
public class XpSystemSettingController extends BaseController {
 
    // 系统设置实现类
    private final XpSystemSettingService xpSystemSettingService;
    private final RedisService redisService;
 
    public XpSystemSettingController(XpSystemSettingService xpSystemSettingService, RedisService redisService) {
        this.xpSystemSettingService = xpSystemSettingService;
        this.redisService = redisService;
    }
 
 
    @GetMapping("/base/v1/mini-program/support/phone")
    @ApiOperation(value = "获取客服电话",tags = {"小程序首页"},response = String.class)
    public AjaxResult<CustomerServicePhoneVo> getCustomerServicePhone() {
        Object customerServicePhone = redisService.getCacheObject(CacheConstants.CUSTOMER_SERVICE_PHONE);
        if(customerServicePhone!=null){
            return success(new CustomerServicePhoneVo(customerServicePhone.toString()));
        }else {
            return success(new CustomerServicePhoneVo(xpSystemSettingService.getCustomerServicePhone()));
        }
    }
 
 
 
    @GetMapping("/base/v1/mini-program/support/getOrderDistance")
    @XpClientCheck(checkToken = false, checkOtpToken = true)
    @ApiOperation(value = "获取下单距离",tags = {"小程序首页-服务调用获取下单距离"},response = Integer.class)
    public R getOrderDistance() {
        return R.ok(xpSystemSettingService.getOrderDistance());
    }
 
 
    @GetMapping("/base/v1/support/getOrderDistance")
    @ApiOperation(value = "获取下单距离",tags = {"小程序首页-服务调用获取下单距离"},response = Integer.class)
    public R getOrderDistance1() {
        return R.ok(xpSystemSettingService.getOrderDistance());
    }
 
    @GetMapping("/logan/rt/v1/getMinOrderDistance")
    @ApiOperation(value = "获取最小下单距离", notes = "内部服务调用,返回起终点允许发单的最小距离阈值,单位米", tags = {"内部接口-获取最小下单距离"}, response = Integer.class)
    public R<Integer> getMinOrderDistance() {
        return R.ok(xpSystemSettingService.getMinOrderDistance());
    }
 
 
    @ApiOperation(value = "获取自动结束行程时间",tags = {"小程序-业务流程"},response = Integer.class)
    @GetMapping("/api/v1/mini-program/support/getOrderFinishTime")
    @XpClientCheck(checkToken = false, checkOtpToken = true)
    public R<Integer> getOrderFinishTime() {
        return R.ok(xpSystemSettingService.getOrderFinishTime());
    }
 
 
    @GetMapping("/api/v1/support/getOrderFinishTime")
    public R<Integer> getOrderFinishTime1() {
        return R.ok(xpSystemSettingService.getOrderFinishTime());
    }
 
 
    @GetMapping("/maintenance-app/base/v1/support/phone")
    @ApiOperation(value = "获取客服电话", tags = {"运维APP-个人中心"}, response = String.class)
    public R<CustomerServicePhoneVo> getCustomerPhone() {
        Object customerServicePhone = redisService.getCacheObject(CacheConstants.CUSTOMER_SERVICE_PHONE);
        if (customerServicePhone != null) {
            return R.ok(new CustomerServicePhoneVo(customerServicePhone.toString()));
        } else {
            return R.ok(new CustomerServicePhoneVo(xpSystemSettingService.getCustomerServicePhone()));
        }
    }
    @ApiOperation(value = "获取系统配置、热修复", tags = {"管理后台-系统"})
    @GetMapping("/api/v1/systemSetting/getOne")
    public R<XpSystemSetting> getSystemSettingOne(){
        return R.ok(xpSystemSettingService.getSystemSettingOne());
    }
 
    @ApiOperation(value = "获取系统配置、热修复", tags = {"管理后台-系统"})
    @GetMapping("/api/v1/systemSetting")
    public R<XpSystemSetting> getSystemSetting(){
        return R.ok(xpSystemSettingService.lambdaQuery().last("limit 1").one());
    }
 
    @ApiOperation(value = "保存系统配置、热修复", tags = {"管理后台-系统"})
    @PostMapping("/api/v1/systemSetting/save")
    @AdminOperationLog(
            businessType = AdminBusinessType.SYSTEM_SETTING_MANAGEMENT,
            operationType = AdminOperationType.EDIT,
            content = "保存系统配置、热修复",
            appendRequestData = true
    )
    public R<?> saveSystemSetting(@RequestBody XpSystemSetting xpSystemSetting){
        xpSystemSettingService.saveSystemSetting(xpSystemSetting);
        if(null != xpSystemSetting.getHotfixStatus() && xpSystemSetting.getHotfixStatus()==1){
            // 开启定时任务去关闭
            // 计算当前时间与结束时间的秒数
            LocalDateTime hotfixEndTime = xpSystemSetting.getHotfixEndTime();
            QuartzManager.addJob(
                    HotFixJob.class,
                    (HotFixJob.name ).toUpperCase(),
                    TimeJobType.HOT_FIX,
                    DateUtils.localDateTimeToDate(hotfixEndTime),
                    new HashMap<>()
            );
        }
 
        return R.ok();
    }
}