2021-11-05 02:48:32 +00:00
|
|
|
package cn.palmte.work.service;
|
|
|
|
|
|
2021-11-18 08:01:09 +00:00
|
|
|
import cn.palmte.work.bean.ProjectConfigBean;
|
2021-11-05 02:48:32 +00:00
|
|
|
import cn.palmte.work.model.SysConfig;
|
|
|
|
|
import cn.palmte.work.model.SysConfigRepository;
|
|
|
|
|
import cn.palmte.work.pojo.SysConfigRequest;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
2021-11-05 10:44:56 +00:00
|
|
|
import java.math.BigDecimal;
|
2021-11-05 07:04:32 +00:00
|
|
|
import java.util.Date;
|
|
|
|
|
|
2021-11-05 02:48:32 +00:00
|
|
|
@Service
|
|
|
|
|
public class SysConfigService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysConfigRepository sysConfigRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void saveOrUpdate(SysConfigRequest sysConfigRequest) {
|
2021-11-05 10:44:56 +00:00
|
|
|
SysConfig underwrittenTaxRate = sysConfigRepository.findByCodeEquals(SysConfig.KEY_UNDERWRITTENTAXRATE);
|
2021-11-05 02:48:32 +00:00
|
|
|
underwrittenTaxRate.setValue(sysConfigRequest.getUnderwrittenTaxRate());
|
2021-11-05 07:04:32 +00:00
|
|
|
underwrittenTaxRate.setUpdateTime(new Date());
|
2021-11-05 02:48:32 +00:00
|
|
|
sysConfigRepository.saveAndFlush(underwrittenTaxRate);
|
|
|
|
|
|
2021-11-05 10:44:56 +00:00
|
|
|
SysConfig projectContributionProfitRateThreshold = sysConfigRepository.findByCodeEquals(SysConfig.KEY_PROJECTCONTRIBUTIONPROFITRATETHRESHOLD);
|
2021-11-05 02:48:32 +00:00
|
|
|
projectContributionProfitRateThreshold.setValue(sysConfigRequest.getProjectContributionProfitRateThreshold());
|
2021-11-05 07:04:32 +00:00
|
|
|
projectContributionProfitRateThreshold.setUpdateTime(new Date());
|
2021-11-05 02:48:32 +00:00
|
|
|
sysConfigRepository.saveAndFlush(projectContributionProfitRateThreshold);
|
2021-11-05 10:44:56 +00:00
|
|
|
}
|
2021-11-05 02:48:32 +00:00
|
|
|
|
2021-11-05 10:44:56 +00:00
|
|
|
public BigDecimal getUnderwrittenTaxRate(){
|
|
|
|
|
return new BigDecimal(sysConfigRepository.findByCodeEquals(SysConfig.KEY_UNDERWRITTENTAXRATE).getValue());
|
|
|
|
|
}
|
|
|
|
|
public BigDecimal getProjectContributionProfitRateThreshold(){
|
|
|
|
|
return new BigDecimal(sysConfigRepository.findByCodeEquals(SysConfig.KEY_PROJECTCONTRIBUTIONPROFITRATETHRESHOLD).getValue());
|
2021-11-05 02:48:32 +00:00
|
|
|
}
|
2021-11-18 08:01:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
public ProjectConfigBean getProjectConfigBeanConfig(){
|
|
|
|
|
ProjectConfigBean projectConfigBean = new ProjectConfigBean();
|
|
|
|
|
projectConfigBean.setUnderwrittenTaxRate(getUnderwrittenTaxRate());
|
|
|
|
|
projectConfigBean.setProjectContributionProfitRateThreshold(getProjectContributionProfitRateThreshold());
|
|
|
|
|
return projectConfigBean;
|
|
|
|
|
}
|
2021-11-05 02:48:32 +00:00
|
|
|
}
|