| | |
| | | import com.ruoyi.staff.service.StaffSalaryDetailService; |
| | | import com.ruoyi.staff.service.StaffSalaryMainService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @Slf4j |
| | | public class StaffSalaryMainServiceImpl extends ServiceImpl<StaffSalaryMainMapper, StaffSalaryMain> implements StaffSalaryMainService { |
| | | |
| | | private final StaffSalaryMainMapper staffSalaryMainMapper; |
| | |
| | | if (staffSalaryMain == null || StringUtils.isEmpty(staffSalaryMain.getSalaryMonth())) { |
| | | return AjaxResult.error("参数错误"); |
| | | } |
| | | validateBankAccount(staffSalaryMain.getBankAccount()); |
| | | |
| | | Integer status = staffSalaryMain.getStatus(); |
| | | if (status != null && status == 5) { |
| | |
| | | if(staffSalaryMain == null){ |
| | | return AjaxResult.error("参数错误"); |
| | | } |
| | | validateBankAccount(staffSalaryMain.getBankAccount()); |
| | | StaffSalaryMain staffSalaryMain1 = staffSalaryMainMapper.selectById(staffSalaryMain.getId()); |
| | | if(staffSalaryMain1 == null){ |
| | | return AjaxResult.error("参数错误"); |
| | |
| | | return AjaxResult.success("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 银行账号兜底校验:仅纯数字 + 长度16-19位(不符直接拦截); |
| | | * Luhn 校验仅作告警,不阻断提交(个别老卡/特殊卡可能不通过) |
| | | */ |
| | | private void validateBankAccount(String account) { |
| | | if (account == null || account.isBlank()) { |
| | | return; |
| | | } |
| | | if (!account.matches("\\d{16,19}")) { |
| | | throw new com.ruoyi.common.exception.ServiceException("银行账号格式不正确:需为16-19位纯数字"); |
| | | } |
| | | if (!luhnValid(account)) { |
| | | log.warn("银行账号 Luhn 校验未通过(仅告警,不阻断)"); |
| | | } |
| | | } |
| | | |
| | | private boolean luhnValid(String account) { |
| | | int sum = 0; |
| | | boolean alternate = false; |
| | | for (int i = account.length() - 1; i >= 0; i--) { |
| | | int n = account.charAt(i) - '0'; |
| | | if (alternate) { |
| | | n *= 2; |
| | | if (n > 9) { |
| | | n -= 9; |
| | | } |
| | | } |
| | | sum += n; |
| | | alternate = !alternate; |
| | | } |
| | | return sum % 10 == 0; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult delete(List<Long> ids) { |
| | | if(CollectionUtils.isEmpty(ids)){ |