package com.ruoyi.system.service.impl;
|
|
import com.alibaba.fastjson2.JSON;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.system.mapper.SystemConfigMapper;
|
import com.ruoyi.system.domain.SystemConfig;
|
import com.ruoyi.system.pojo.dto.AddSystemConfigDTO;
|
import com.ruoyi.system.pojo.model.DrawSheet;
|
import com.ruoyi.system.pojo.vo.SystemConfigVO;
|
import com.ruoyi.system.service.SystemConfigService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
|
@Service
|
public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigMapper, SystemConfig> implements SystemConfigService {
|
@Resource
|
private SystemConfigMapper systemConfigMapper;
|
|
/**
|
* 查看系统设置 1=启动页,2=客服,3=抽单
|
*/
|
@Override
|
public SystemConfigVO getSystemConfigByType(Integer type) {
|
SystemConfigVO vo = new SystemConfigVO();
|
//根据类型查询
|
SystemConfig systemConfig = systemConfigMapper.selectOne(new LambdaQueryWrapper<SystemConfig>().eq(SystemConfig::getType, type));
|
vo.setType(type);
|
if (type!=3){
|
if (systemConfig!=null){
|
vo.setUrl(systemConfig.getContent());
|
}
|
return vo;
|
}else {
|
//抽单
|
DrawSheet drawSheet = JSON.parseObject(systemConfig.getContent(), DrawSheet.class);
|
vo.setDrawSheet(drawSheet);
|
return vo;
|
}
|
}
|
/**
|
* 设置系统设置 1=启动页,2=客服,3=抽单
|
*/
|
@Override
|
public void setSystemConfig(AddSystemConfigDTO dto) {
|
SystemConfig systemConfig = new SystemConfig();
|
systemConfig.setType(dto.getType());
|
//根据类型删除
|
systemConfigMapper.delete(new LambdaQueryWrapper<SystemConfig>().eq(SystemConfig::getType, dto.getType()));
|
if (dto.getType()==3){
|
if (dto.getPlatform().add(dto.getUser()).compareTo(BigDecimal.valueOf(100)) > 0){
|
throw new ServiceException("平台提成+绑定用户提成不能超过100");
|
}
|
//抽单设置
|
DrawSheet drawSheet = new DrawSheet();
|
drawSheet.setPlatform(dto.getPlatform());
|
drawSheet.setUser(dto.getUser());
|
String json = JSON.toJSONString(drawSheet);
|
systemConfig.setContent(json);
|
}else {
|
systemConfig.setContent(dto.getUrl());
|
}
|
systemConfigMapper.insert(systemConfig);
|
}
|
|
|
|
}
|