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-22 10:59:33 +00:00
|
|
|
import cn.palmte.work.bean.ResponseMsg;
|
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;
|
2021-11-22 10:59:33 +00:00
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2021-11-05 02:48:32 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
2021-11-22 10:59:33 +00:00
|
|
|
public ResponseMsg saveOrUpdate(String json) {
|
|
|
|
|
JSONObject obj = JSON.parseObject(json);
|
2022-04-28 07:17:14 +00:00
|
|
|
|
|
|
|
|
double rate = Double.parseDouble(obj.getString("underwrittenTaxRate"));
|
|
|
|
|
|
|
|
|
|
if(rate <= 0){
|
|
|
|
|
return ResponseMsg.buildFailedMsg("项目年利率应大于0");
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-05 10:44:56 +00:00
|
|
|
SysConfig underwrittenTaxRate = sysConfigRepository.findByCodeEquals(SysConfig.KEY_UNDERWRITTENTAXRATE);
|
2021-11-22 10:59:33 +00:00
|
|
|
underwrittenTaxRate.setValue(obj.getString("underwrittenTaxRate"));
|
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-22 10:59:33 +00:00
|
|
|
projectContributionProfitRateThreshold.setValue(obj.getString("projectContributionProfitRateThreshold"));
|
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-22 10:59:33 +00:00
|
|
|
return ResponseMsg.buildSuccessMsg("配置成功");
|
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
|
|
|
}
|