package cn.iocoder.yudao.module.hrm.service.salary; import cn.iocoder.yudao.module.hrm.dal.dataobject.salary.HrmTaxRateConfigDO; import cn.iocoder.yudao.module.hrm.dal.mysql.salary.HrmTaxRateConfigMapper; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import java.time.LocalDate; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.TAX_RATE_CONFIG_NOT_EXISTS; /** * 个税税率配置 Service 实现类 * * @author 芋道源码 */ @Service @Validated public class HrmTaxRateConfigServiceImpl implements HrmTaxRateConfigService { @Resource private HrmTaxRateConfigMapper taxRateConfigMapper; @Override @Transactional(rollbackFor = Exception.class) public void createTaxRateConfigList(List configList) { for (HrmTaxRateConfigDO config : configList) { taxRateConfigMapper.insert(config); } } @Override public void updateTaxRateConfig(HrmTaxRateConfigDO config) { validateTaxRateConfigExists(config.getId()); taxRateConfigMapper.updateById(config); } @Override public void deleteTaxRateConfig(Long id) { validateTaxRateConfigExists(id); taxRateConfigMapper.deleteById(id); } @Override public HrmTaxRateConfigDO getTaxRateConfig(Long id) { return taxRateConfigMapper.selectById(id); } @Override public List getTaxRateConfigList() { return taxRateConfigMapper.selectListByStatus(null); } @Override public List getEffectiveTaxRateConfigList(LocalDate effectiveDate) { return taxRateConfigMapper.selectListByEffectiveDate(effectiveDate); } private void validateTaxRateConfigExists(Long id) { if (taxRateConfigMapper.selectById(id) == null) { throw exception(TAX_RATE_CONFIG_NOT_EXISTS); } } }