| | |
| | | |
| | | |
| | | public long caculateRentFee(TBill bill){ |
| | | return bill.getPayableFeesMoney().add(bill.getPayableFeesPenalty()) |
| | | .subtract(bill.getActualMoney()) |
| | | .multiply(AmountConstant.b100) |
| | | .setScale(0, RoundingMode.HALF_DOWN) |
| | | return bill.getOutstandingMoney() |
| | | .longValue(); |
| | | } |
| | | |
| | |
| | | if (bill == null) { |
| | | throw new ServiceException("账单不存在"); |
| | | } |
| | | //计算欠费金额:租金+违约金-实收金额 |
| | | long rent = caculateRentFee(bill); |
| | | //欠费金额转成单位分比较 |
| | | long rent = bill.getOutstandingMoney().multiply(AmountConstant.b100) |
| | | .setScale(2,RoundingMode.HALF_DOWN).longValue(); |
| | | if (rent==0){ |
| | | throw new ServiceException("该订单已缴费"); |
| | | throw new ServiceException("该账单已缴费"); |
| | | } |
| | | if (rent>dto.getAmount()){ |
| | | if (rent<dto.getAmount()){ |
| | | throw new ServiceException("支付金额超过了账单欠费金额"); |
| | | } |
| | | |
| | |
| | | order.setAmount(dto.getAmount()); |
| | | order.setUserId(user.getId()); |
| | | order.setPhone(user.getPhone()); |
| | | order.setOpenId(dto.getOpenId()); |
| | | order.setUserName(user.getResidentName()); |
| | | save(order); |
| | | TOrderBill tOrderBill = new TOrderBill(); |
| | |
| | | orderBills.add(new TOrderBill(orderNo,bill.getId())); |
| | | return bill; |
| | | }).collect(Collectors.toList()); |
| | | long sumRent = bills.stream().mapToLong((bill) -> caculateRentFee(bill)).sum(); |
| | | //欠费金额转成单位分比较 |
| | | long sumRent = bills.stream().mapToLong((bill) |
| | | -> bill.getOutstandingMoney().multiply(AmountConstant.b100) |
| | | .setScale(2,RoundingMode.HALF_DOWN).longValue()) |
| | | .sum(); |
| | | if (sumRent==0){ |
| | | throw new ServiceException("账单已缴费"); |
| | | } |
| | |
| | | order.setAmount(dto.getAmount()); |
| | | order.setUserId(user.getId()); |
| | | order.setPhone(user.getPhone()); |
| | | order.setOpenId(dto.getOpenId()); |
| | | order.setUserName(user.getResidentName()); |
| | | save(order); |
| | | tOrderBillService.saveBatch(orderBills); |