| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.uuid.UUID; |
| | | import com.ruoyi.system.mapper.TBillMapper; |
| | | import com.ruoyi.system.model.TBill; |
| | | import com.ruoyi.system.model.TContract; |
| | |
| | | private TContractService contractService; |
| | | @Autowired |
| | | private TBillMapper billMapper; |
| | | @Autowired |
| | | RedisCache redisCache; |
| | | // 用于更新违约金账单 |
| | | // 每分钟执行一次的定时任务 |
| | | |
| | |
| | | public void dayOfProportionBill() { |
| | | try { |
| | | // 查询所有未缴费账单 |
| | | List<TBill> list = billMapper.selectList(new LambdaQueryWrapper<TBill>().eq(TBill::getPayFeesStatus, 1) |
| | | .le(TBill::getPayableFeesTime,LocalDate.now())); |
| | | List<TBill> list = billMapper.selectList(new LambdaQueryWrapper<TBill>().ne(TBill::getPayFeesStatus, 5) |
| | | .ne(TBill::getOutstandingMoney,0)); |
| | | for (TBill tBill : list) { |
| | | tBill.setPayFeesStatus("4"); |
| | | TContract contract = contractService.getById(tBill.getContractId()); |
| | |
| | | // 违约金比例 |
| | | BigDecimal proportion = contract.getProportion(); |
| | | // 按每天 待缴费金额 * XX% 增加违约金费用 |
| | | if (tBill.getOutstandingMoney().compareTo(new BigDecimal("0"))==0){ |
| | | if (contract.getTotalYear().compareTo(new BigDecimal("0"))==0){ |
| | | tBill.setPayFeesStatus("3"); |
| | | billMapper.updateById(tBill); |
| | | continue; |
| | | } |
| | | String requestId = UUID.fastUUID().toString(); |
| | | String lockkey = CacheConstants.BILL_UPDATE_LOCK_KEY + tBill.getId(); |
| | | boolean isok = redisCache.trylockLoop(lockkey, requestId, 60); |
| | | if (isok){ |
| | | try { |
| | | BigDecimal money = tBill.getOutstandingMoney().multiply(new BigDecimal(100).add(proportion)).divide(new BigDecimal(100),2, BigDecimal.ROUND_DOWN); |
| | | tBill.setOverDays((int) l); |
| | | BigDecimal bigDecimal = tBill.getOutstandingMoney().multiply(proportion).setScale(2, BigDecimal.ROUND_DOWN); |
| | | tBill.setPayableFeesPenalty(tBill.getPayableFeesPenalty()!=null?tBill.getPayableFeesPenalty():new BigDecimal("0").add(bigDecimal)); |
| | | tBill.setOutstandingMoney(money); |
| | | billMapper.updateById(tBill); |
| | | |
| | | }finally { |
| | | redisCache.unlock(lockkey,requestId); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |