| @@ -1038,22 +1038,11 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| if (daily != null) { | |||
| if (!daily.getStatus().equals(EnumBillRentStatus.PAID.getCode())) { | |||
| long allPay = new BigDecimal(daily.getPay()).add(new BigDecimal(pay)).longValueExact(); | |||
| daily.setExpiredDay(0L); | |||
| if (allPay >= receivePay) { | |||
| daily.setStatus(EnumBillRentStatus.PAID.getCode()); | |||
| } else { | |||
| Date payDate = bill.getPayDate(); | |||
| Date receiveDate = bill.getReceiveDate(); | |||
| if (payDate.after(receiveDate)) { | |||
| int expiredDay = DateUtils.daysBetween(receiveDate, payDate); | |||
| daily.setExpiredDay((long) expiredDay); | |||
| daily.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| } else { | |||
| daily.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| } | |||
| WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), receivePay, allPay, false); | |||
| daily.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||
| daily.setStatus(expiredDayAndStatus.getStatus()); | |||
| daily.setReceivePay(receivePay); | |||
| daily.setPay(daily.getPay() + pay); | |||
| daily.setPay(allPay); | |||
| daily.setOwe(0L); | |||
| long owe = daily.getReceivePay() - daily.getPay(); | |||
| if (owe > 0) { | |||
| @@ -1086,24 +1075,13 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| Date date = new Date(); | |||
| daily.setCreatetime(date); | |||
| daily.setUpdatetime(date); | |||
| daily.setExpiredDay(0L); | |||
| daily.setOwe(receivePay - pay); | |||
| daily.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| daily.setStarttime(bill.getStarttime()); | |||
| daily.setEndtime(bill.getEndtime()); | |||
| if (receivePay <= pay) { | |||
| daily.setStatus(EnumBillRentStatus.PAID.getCode()); | |||
| } else { | |||
| Date payDate = daily.getPayDate(); | |||
| Date receiveDate = daily.getReceiveDate(); | |||
| int expiredDay = DateUtils.daysBetween(receiveDate, payDate); | |||
| if (expiredDay > 0) { | |||
| daily.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| daily.setExpiredDay((long) expiredDay); | |||
| } else { | |||
| daily.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| } | |||
| WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), receivePay, pay, false); | |||
| daily.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||
| daily.setStatus(expiredDayAndStatus.getStatus()); | |||
| wxBillDailyMapper.insertSelective(daily); | |||
| addActionImport(daily.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr()); | |||
| } | |||
| @@ -1119,24 +1097,13 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| if (other != null) { | |||
| if (!other.getStatus().equals(EnumBillRentStatus.PAID.getCode())) { | |||
| long allPay = new BigDecimal(other.getPay()).add(new BigDecimal(pay)).longValueExact(); | |||
| other.setExpiredDay(0L); | |||
| if (allPay >= receivePay) { | |||
| other.setStatus(EnumBillRentStatus.PAID.getCode()); | |||
| } else { | |||
| Date payDate = bill.getPayDate(); | |||
| Date receiveDate = bill.getReceiveDate(); | |||
| if (payDate.after(receiveDate)) { | |||
| int expiredDay = DateUtils.daysBetween(receiveDate, payDate); | |||
| other.setExpiredDay((long) expiredDay); | |||
| other.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| } else { | |||
| other.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| } | |||
| WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), receivePay, allPay, false); | |||
| other.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||
| other.setStatus(expiredDayAndStatus.getStatus()); | |||
| other.setReceivePay(receivePay); | |||
| other.setName(bill.getBillAttr()); | |||
| other.setComments(bill.getBillAttr()); | |||
| other.setPay(other.getPay() + pay); | |||
| other.setPay(allPay); | |||
| other.setOwe(0L); | |||
| long owe = other.getReceivePay() - other.getPay(); | |||
| if (owe > 0) { | |||
| @@ -1170,24 +1137,13 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| Date date = new Date(); | |||
| other.setCreatetime(date); | |||
| other.setUpdatetime(date); | |||
| other.setExpiredDay(0L); | |||
| other.setOwe(receivePay - pay); | |||
| other.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| other.setStarttime(bill.getStarttime()); | |||
| other.setEndtime(bill.getEndtime()); | |||
| if (receivePay <= pay) { | |||
| other.setStatus(EnumBillRentStatus.PAID.getCode()); | |||
| } else { | |||
| Date payDate = other.getPayDate(); | |||
| Date receiveDate = other.getReceiveDate(); | |||
| int expiredDay = DateUtils.daysBetween(receiveDate, payDate); | |||
| if (expiredDay > 0) { | |||
| other.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| other.setExpiredDay((long) expiredDay); | |||
| } else { | |||
| other.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| } | |||
| WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), receivePay, pay, false); | |||
| other.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||
| other.setStatus(expiredDayAndStatus.getStatus()); | |||
| wxBillOtherMapper.insertSelective(other); | |||
| addActionImport(other.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr()); | |||
| } | |||
| @@ -1207,18 +1163,10 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| if (allPay >= receivePay) { | |||
| otherDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||
| } else { | |||
| Date payDate = bill.getPayDate(); | |||
| Date receiveDate = bill.getReceiveDate(); | |||
| if (payDate.after(receiveDate)) { | |||
| int expiredDay = DateUtils.daysBetween(receiveDate, payDate); | |||
| otherDeposit.setExpiredDay((long) expiredDay); | |||
| otherDeposit.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| } else { | |||
| otherDeposit.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| otherDeposit.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| otherDeposit.setReceivePay(receivePay); | |||
| otherDeposit.setPay(otherDeposit.getPay() + pay); | |||
| otherDeposit.setPay(allPay); | |||
| otherDeposit.setOwe(0L); | |||
| long owe = otherDeposit.getReceivePay() - otherDeposit.getPay(); | |||
| if (owe > 0) { | |||
| @@ -1261,13 +1209,7 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| if (receivePay <= pay) { | |||
| otherDeposit.setStatus(EnumBillRentStatus.PAID.getCode()); | |||
| } else { | |||
| Date payDate = otherDeposit.getPayDate(); | |||
| Date receiveDate = otherDeposit.getReceiveDate(); | |||
| int expiredDay = DateUtils.daysBetween(receiveDate, payDate); | |||
| otherDeposit.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| if (expiredDay > 0) { | |||
| otherDeposit.setExpiredDay((long) expiredDay); | |||
| } | |||
| } | |||
| wxBillOtherDepositMapper.insertSelective(otherDeposit); | |||
| addActionImport(otherDeposit.getId(), bill.getPayWay(), bill.getPayDate(), user, bill.getPayStr()); | |||
| @@ -1281,6 +1223,40 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| } | |||
| public WxBillRent getExpiredDayAndStatus(Date startDate, Date endDate, Long owe, Long pay, boolean flag) { | |||
| WxBillRent rent = new WxBillRent(); | |||
| rent.setExpiredDay(0L); | |||
| if (owe <= pay) { | |||
| rent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||
| int expiredDay = DateUtils.daysBetween(startDate, endDate); | |||
| int timePeriod = 0; | |||
| if (expiredDay > timePeriod) { | |||
| rent.setExpiredDay((long) expiredDay); | |||
| } | |||
| } else { | |||
| Date now = new Date(); | |||
| int day = DateUtils.daysBetween(startDate, now); | |||
| int timePeriod = 0; | |||
| if (day < timePeriod) { | |||
| rent.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| long expiredDay = Long.valueOf(Math.abs(day)); | |||
| rent.setExpiredDay(expiredDay); | |||
| } else { | |||
| if (flag) { | |||
| timePeriod = 30; | |||
| if (day > timePeriod) { | |||
| rent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); | |||
| } else { | |||
| rent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| } else { | |||
| rent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| } | |||
| } | |||
| return rent; | |||
| } | |||
| @Override | |||
| public void importBill(String tenantId, String importKey, WxBillExcelTemplate bill, MallUserInfo user) { | |||
| //租金 | |||
| @@ -1300,20 +1276,9 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| WxBillRent rent = wxBillRentMapper.selectBillOne(rentQuery); | |||
| if (rent != null && !rent.getStatus().equals(EnumBillRentStatus.PAID.getCode())) { | |||
| long pay = new BigDecimal(bill.getPayStr()).multiply(new BigDecimal(100)).longValueExact(); | |||
| rent.setExpiredDay(0L); | |||
| if (rent.getOwe() <= pay) { | |||
| rent.setStatus(EnumBillRentStatus.PAID.getCode()); | |||
| } else { | |||
| Date payDate = bill.getPayDate(); | |||
| Date receiveDate = bill.getReceiveDate(); | |||
| if (payDate.after(receiveDate)) { | |||
| int expiredDay = DateUtils.daysBetween(receiveDate, payDate); | |||
| rent.setExpiredDay((long) expiredDay); | |||
| rent.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| } else { | |||
| rent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| } | |||
| WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), rent.getOwe(), pay, true); | |||
| rent.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||
| rent.setStatus(expiredDayAndStatus.getStatus()); | |||
| rent.setPay(rent.getPay() + pay); | |||
| rent.setOwe(rent.getOwe() - pay); | |||
| rent.setPayDate(bill.getPayDate()); | |||
| @@ -1336,20 +1301,9 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| WxBillProperty property = wxBillPropertyMapper.selectBillOne(propertyQuery); | |||
| if (property != null && !property.getStatus().equals(EnumBillRentStatus.PAID.getCode())) { | |||
| long pay = new BigDecimal(bill.getPayStr()).multiply(new BigDecimal(100)).longValueExact(); | |||
| property.setExpiredDay(0L); | |||
| if (property.getOwe() <= pay) { | |||
| property.setStatus(EnumBillRentStatus.PAID.getCode()); | |||
| } else { | |||
| Date payDate = bill.getPayDate(); | |||
| Date receiveDate = bill.getReceiveDate(); | |||
| if (payDate.after(receiveDate)) { | |||
| int expiredDay = DateUtils.daysBetween(receiveDate, payDate); | |||
| property.setExpiredDay((long) expiredDay); | |||
| property.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); | |||
| } else { | |||
| property.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); | |||
| } | |||
| } | |||
| WxBillRent expiredDayAndStatus = getExpiredDayAndStatus(bill.getReceiveDate(), bill.getPayDate(), property.getOwe(), pay, true); | |||
| property.setExpiredDay(expiredDayAndStatus.getExpiredDay()); | |||
| property.setStatus(expiredDayAndStatus.getStatus()); | |||
| property.setPay(property.getPay() + pay); | |||
| property.setOwe(property.getOwe() - pay); | |||
| property.setPayDate(bill.getPayDate()); | |||
| @@ -1426,7 +1380,9 @@ public class WxBillAllServiceImpl implements WxBillAllService { | |||
| for (Map<String, Object> bill:mapList) { | |||
| Long merchantId = (Long)bill.get("merchantId"); | |||
| List<Map<String, Object>> currList = result.get(merchantId); | |||
| if(currList == null) currList = new ArrayList<>(); | |||
| if (currList == null) { | |||
| currList = new ArrayList<>(); | |||
| } | |||
| currList.add(bill); | |||
| result.put(merchantId,currList); | |||
| } | |||