From 648fc6c17badf68e66ad34f650247de7548cb987 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Thu, 8 Aug 2019 13:12:32 +0800 Subject: [PATCH] =?UTF-8?q?[=E8=B4=A6=E5=8D=95][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=B9=8B=E5=90=8E=E7=9A=84=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxBillAllServiceImpl.java | 162 +++++++----------- 1 file changed, 59 insertions(+), 103 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java index 554146065..00fc9ef0b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java @@ -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 bill:mapList) { Long merchantId = (Long)bill.get("merchantId"); List> currList = result.get(merchantId); - if(currList == null) currList = new ArrayList<>(); + if (currList == null) { + currList = new ArrayList<>(); + } currList.add(bill); result.put(merchantId,currList); }