From 115688ce7dc90b3d43bc6c737722c0cfc4359fdc Mon Sep 17 00:00:00 2001 From: luozukai Date: Tue, 2 Jul 2019 20:08:37 +0800 Subject: [PATCH] =?UTF-8?q?[=E9=A2=84=E8=B4=A6=E5=8D=95][=E4=BF=AE?= =?UTF-8?q?=E6=94=B9][=E5=90=8C=E4=BF=9D=E6=A5=BC=E6=96=B0=E9=9C=80?= =?UTF-8?q?=E6=B1=82]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WxPropertyContractController.java | 1 - .../impl/WxPropertyContractServiceImpl.java | 97 +++++++++++++------ .../impl/WxRentContractServiceImpl.java | 95 ++++++++++++------ 3 files changed, 137 insertions(+), 56 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java index 9e2afe7d7..fc0ddd668 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java @@ -78,7 +78,6 @@ public class WxPropertyContractController extends BaseController { return wxPropertyContractService.saveOrUpdate(propertyContract, user.getId(), user.getName()); } - @PostMapping("update") @SystemControllerLog(description = "物业合同-修改") public ResultData update(@RequestBody WxPropertyContract wxPropertyContract) { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index 52a1c0df6..6e5813322 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -209,13 +209,45 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return wxBillPropertyMapper.findList(wxBillRent); } + /** + * 重新生成账单(预账单调整) + */ + public void savePreviewBill(WxPropertyContract record){ + if(CollectionUtils.isEmpty(record.getPreviewBillRentList())){ + return; + } + wxBillPropertyMapper.deletePreviewBill(record); + final IdWorker idWorker = IdWorker.get(); + int count = 1; + for (WxBillProperty bill:record.getPreviewBillRentList()) { + bill.setId(idWorker.nextId()); + bill.setPropertyContractId(record.getId()); + bill.setCreatetime(new Date()); + bill.setTenantId(record.getTenantId()); + bill.setOwe(bill.getReceivePay()); + bill.setNeedPay(bill.getReceivePay()); + bill.setUpdatetime(new Date()); + bill.setRentShopType(record.getRentShopType()); + bill.setPeriod(count); + bill.setIsPreview(EnumIsPreview.YES.getCode()); + bill.setShopInfo(getShopInfoStr(record)); + bill.setRevenue(0l); + bill.setLatePayRatio(0); + bill.setPay(0l); + bill.setIsDel(0); + setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); + count++; + } + wxBillPropertyMapper.insertBills(record.getPreviewBillRentList()); + } + @Override @Transactional(rollbackFor = {Exception.class}) public ResultData saveOrUpdate(WxPropertyContract record, Long userId, String userName) { // 保存调整金额(预账单调整) boolean haspreview = false; if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ - wxBillPropertyMapper.updateBills(record.getPreviewBillRentList()); + savePreviewBill(record); haspreview = true; } @@ -469,16 +501,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService wxBillDeposit.setUpdatetime(date); wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode()); wxBillDeposit.setRentShopType(wxPropertyContract.getRentShopType()); - String rentInfo = wxPropertyContract.getRentInfo(); - Map shopInfo = new HashMap<>(); - if (rentInfo != null) { - JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); - for (int i = 0, size = rentInfoArray.size(); i < size; i++) { - JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); - shopInfo.put(rentInfoObject.getString("shopNumber"), rentInfoObject.get("buildArea")); - } - } - wxBillDeposit.setShopInfo(JSONObject.toJSONString(shopInfo)); + wxBillDeposit.setShopInfo(getShopInfoStr(wxPropertyContract)); try { wxBillPropertyDepositMapper.insertSelective(wxBillDeposit); } catch (Exception e) { @@ -488,6 +511,19 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } } + public String getShopInfoStr(WxPropertyContract wxPropertyContract){ + String rentInfo = wxPropertyContract.getRentInfo(); + Map shopInfo = new HashMap<>(); + if (rentInfo != null) { + JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); + for (int i = 0, size = rentInfoArray.size(); i < size; i++) { + JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); + shopInfo.put(rentInfoObject.getString("shopNumber"), rentInfoObject.get("buildArea")); + } + } + return JSONObject.toJSONString(shopInfo); + } + public List buildRentMonth(WxMerchant wxMerchant, Long userId, WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview) { String adjustRatio = wxPropertyContract.getAdjustRatio(); String rentInfo = wxPropertyContract.getRentInfo(); @@ -650,23 +686,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService //截止收租日在当前时间之前 Date date = new Date(); - if (wxBillProperty.getReceiveDate().before(date)) { - long day = (wxBillProperty.getReceiveDate().getTime() - date.getTime()) / (24 * 60 * 60 * 1000); - wxBillProperty.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); - wxBillProperty.setExpiredDay(day); - } else {//截止收租日在当前时间之后 - Calendar now = Calendar.getInstance(); - now.add(dayType, receivePeriod); - Date currenttime = now.getTime(); - //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 - if (currenttime.before(wxBillProperty.getReceiveDate())) { - wxBillProperty.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); - wxBillProperty.setExpiredDay(0L); - } else { - wxBillProperty.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); - wxBillProperty.setExpiredDay(0L); - } - } + setExpiredDay(wxBillProperty,dayType,receivePeriod); wxBillProperty.setTenantId(wxPropertyContract.getTenantId()); wxBillProperty.setIsDel(0); wxBillProperty.setMerchantId(wxPropertyContract.getMerchantId()); @@ -691,6 +711,27 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return resultMap; } + public void setExpiredDay(WxBillProperty wxBillProperty,int dayType, int receivePeriod){ + Date date = new Date(); + if (wxBillProperty.getReceiveDate().before(date)) { + long day = (wxBillProperty.getReceiveDate().getTime() - date.getTime()) / (24 * 60 * 60 * 1000); + wxBillProperty.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); + wxBillProperty.setExpiredDay(day); + } else {//截止收租日在当前时间之后 + Calendar now = Calendar.getInstance(); + now.add(dayType, receivePeriod); + Date currenttime = now.getTime(); + //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 + if (currenttime.before(wxBillProperty.getReceiveDate())) { + wxBillProperty.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); + wxBillProperty.setExpiredDay(0L); + } else { + wxBillProperty.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); + wxBillProperty.setExpiredDay(0L); + } + } + } + public boolean isFirstDay(Date date){ int dateInt = Integer.parseInt(new SimpleDateFormat("d").format(date)); if(dateInt == 1){ diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index d1d7bf18a..04eb48def 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -435,15 +435,46 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } - // 保存调整金额(预账单调整) - if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ - wxBillRentMapper.updateBills(record.getPreviewBillRentList()); - } + //保存调整金额(预账单调整) + savePreviewBill(record); + WxRentContract wxRentContract = (WxRentContract)resultData.data; wxRentContract.setPreviewBillRentList(resultList); return new ResultData(wxRentContract); } + /** + * 重新生成账单(预账单调整) + */ + public void savePreviewBill(WxRentContract record){ + if(CollectionUtils.isEmpty(record.getPreviewBillRentList())){ + return; + } + wxBillRentMapper.deletePreviewBill(record); + final IdWorker idWorker = IdWorker.get(); + int count = 1; + for (WxBillRent bill:record.getPreviewBillRentList()) { + bill.setId(idWorker.nextId()); + bill.setRentContractId(record.getId()); + bill.setCreatetime(new Date()); + bill.setTenantId(record.getTenantId()); + bill.setOwe(bill.getReceivePay()); + bill.setNeedPay(bill.getReceivePay()); + bill.setUpdatetime(new Date()); + bill.setRentShopType(record.getRentShopType()); + bill.setPeriod(count); + bill.setIsPreview(EnumIsPreview.YES.getCode()); + bill.setShopInfo(getShopInfoStr(record)); + bill.setRevenue(0l); + bill.setLatePayRatio(0); + bill.setPay(0l); + bill.setIsDel(0); + setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod()); + count++; + } + wxBillRentMapper.insertBills(record.getPreviewBillRentList()); + } + public ResultData getResultDataForUpdate(WxRentContract record, Long userId,int from,Date oldRentStartDate) { //更新租赁合同信息 WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getId()); @@ -919,6 +950,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { } + String shopInfoStr = getShopInfoStr(wxRentContract); + Map resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr); + List billRentList = (List)resultMap.get("billList"); + resultList.addAll(billRentList); + return resultList; + } + + public String getShopInfoStr(WxRentContract wxRentContract){ String shopInfoStr = null; if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { String rentInfo = wxRentContract.getRentInfo(); @@ -931,11 +970,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { } shopInfoStr = JSONObject.toJSONString(shopInfoMap); } - - Map resultMap = buildRent(receivePeriod, priceArrs, yearList, Calendar.MONTH, wxRentContract, userId, billcount, isPreview, shopInfoStr); - List billRentList = (List)resultMap.get("billList"); - resultList.addAll(billRentList); - return resultList; + return shopInfoStr; } public Map buildRent(int receivePeriod, long[] priceArrs, List yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr) { @@ -1032,23 +1067,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { //截止收租日在当前时间之前 Date date = new Date(); - if (wxBillRent.getReceiveDate().before(date)) { - long day = (wxBillRent.getReceiveDate().getTime() - date.getTime()) / (24 * 60 * 60 * 1000); - wxBillRent.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); - wxBillRent.setExpiredDay(day); - } else {//截止收租日在当前时间之后 - Calendar now = Calendar.getInstance(); - now.add(dayType, receivePeriod); - Date currenttime = now.getTime(); - //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 - if (currenttime.before(wxBillRent.getReceiveDate())) { - wxBillRent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); - wxBillRent.setExpiredDay(0L); - } else { - wxBillRent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); - wxBillRent.setExpiredDay(0L); - } - } + setExpiredDay(wxBillRent,dayType,receivePeriod); wxBillRent.setRevenue(0L); wxBillRent.setTenantId(wxRentContract.getTenantId()); wxBillRent.setIsDel(0); @@ -1073,6 +1092,28 @@ public class WxRentContractServiceImpl implements WxRentContractService { return resultMap; } + public void setExpiredDay(WxBillRent wxBillRent,int dayType, int receivePeriod){ + //截止收租日在当前时间之前 + Date date = new Date(); + if (wxBillRent.getReceiveDate().before(date)) { + long day = (wxBillRent.getReceiveDate().getTime() - date.getTime()) / (24 * 60 * 60 * 1000); + wxBillRent.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); + wxBillRent.setExpiredDay(day); + } else {//截止收租日在当前时间之后 + Calendar now = Calendar.getInstance(); + now.add(dayType, receivePeriod); + Date currenttime = now.getTime(); + //当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴 + if (currenttime.before(wxBillRent.getReceiveDate())) { + wxBillRent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); + wxBillRent.setExpiredDay(0L); + } else { + wxBillRent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); + wxBillRent.setExpiredDay(0L); + } + } + } + public boolean isFirstDay(Date date){ int dateInt = Integer.parseInt(new SimpleDateFormat("d").format(date)); if(dateInt == 1){ @@ -1298,7 +1339,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { public ResultData updateFile(WxRentContract record, Long userId,String userName,Date oldRentStartDate) { // 保存调整金额(预账单调整) if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ - wxBillRentMapper.updateBills(record.getPreviewBillRentList()); + savePreviewBill(record); } ResultData resultData = getResultDataForUpdate(record, userId,0,oldRentStartDate); if (resultData.code != Result.SUCCESS) {