44 lines
1.3 KiB
Java
44 lines
1.3 KiB
Java
package com.example.building.service;
|
||
|
||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
import com.example.building.entity.SystemConfig;
|
||
import com.example.building.mapper.SystemConfigMapper;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Service;
|
||
|
||
import java.time.LocalDate;
|
||
|
||
@Service
|
||
public class SystemConfigService {
|
||
|
||
@Autowired
|
||
private SystemConfigMapper systemConfigMapper;
|
||
|
||
/**
|
||
* 获取顾客订单可见天数配置
|
||
* 默认180天(半年)
|
||
*/
|
||
public int getCustomerOrderVisibleDays() {
|
||
LambdaQueryWrapper<SystemConfig> wrapper = new LambdaQueryWrapper<>();
|
||
wrapper.eq(SystemConfig::getConfigKey, "customer_order_visible_days");
|
||
SystemConfig config = systemConfigMapper.selectOne(wrapper);
|
||
|
||
if (config != null && config.getConfigValue() != null) {
|
||
try {
|
||
return Integer.parseInt(config.getConfigValue());
|
||
} catch (NumberFormatException e) {
|
||
return 180;
|
||
}
|
||
}
|
||
return 180; // 默认半年
|
||
}
|
||
|
||
/**
|
||
* 获取顾客可见订单开始日期
|
||
*/
|
||
public LocalDate getCustomerOrderStartDate() {
|
||
int days = getCustomerOrderVisibleDays();
|
||
return LocalDate.now().minusDays(days);
|
||
}
|
||
}
|