diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java index 02f953189..af268d1e6 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java @@ -175,6 +175,17 @@ public class WxPropertyContract implements Serializable { @io.swagger.annotations.ApiModelProperty(value = "物业预账单列表", name = "previewBillRentList") private List previewBillRentList; + @io.swagger.annotations.ApiModelProperty(value = "租金信息", name = "rentInfo") + private String rentInfo; + + public String getRentInfo() { + return rentInfo; + } + + public void setRentInfo(String rentInfo) { + this.rentInfo = rentInfo; + } + public String getAdjustRatio() { return adjustRatio; 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 ebcb677fc..d059bc974 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -1,6 +1,7 @@ package com.iformall.service.impl; import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.iformall.common.ErrorCode; @@ -390,6 +391,16 @@ 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)); try { wxBillPropertyDepositMapper.insertSelective(wxBillDeposit); } catch (Exception e) { @@ -401,6 +412,15 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService public List buildRentMonth(WxMerchant wxMerchant, Long userId, WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, Integer price,Integer isPreview) { String adjustRatio = wxPropertyContract.getAdjustRatio(); + 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")); + } + } List integers = JSONArray.parseArray(adjustRatio, Integer.class); integers.add(0, 0); int size = integers.size(); @@ -429,7 +449,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService instance.setTime(rentalStartDate); //开始时间 instance.add(Calendar.MONTH, month * i); - Map resultMap = buildRent(leaseArr[i], receivePeriod, priceArr[i], instance.getTime(), Calendar.MONTH, wxPropertyContract, userId, wxMerchant, billcount,isPreview); + Map resultMap = buildRent(leaseArr[i], receivePeriod, priceArr[i], instance.getTime(), Calendar.MONTH, wxPropertyContract, userId, wxMerchant, billcount, isPreview, shopInfo); List billRentList = (List)resultMap.get("billList"); billcount = (Integer)resultMap.get("billcount"); resultList.addAll(billRentList); @@ -437,7 +457,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService return resultList; } - public Map buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxPropertyContract wxPropertyContract, Long userId, WxMerchant wxMerchant, int billcount,Integer isPreview) { + public Map buildRent(int lease, int receivePeriod, int price, Date startdate, int dayType, WxPropertyContract wxPropertyContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview, Map shopInfo) { Map resultMap = new HashedMap(); List resultList = new ArrayList<>(); int extralease = lease % receivePeriod; @@ -446,12 +466,12 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService int index = paycount - 1; final IdWorker idWorker = IdWorker.get(); for (int i = 0; i < paycount; i++) { - WxBillProperty wxBillRent = new WxBillProperty(); - wxBillRent.setIsPreview(isPreview); + WxBillProperty wxBillProperty = new WxBillProperty(); + wxBillProperty.setIsPreview(isPreview); - wxBillRent.setId(idWorker.nextId()); - wxBillRent.setPropertyContractId(wxPropertyContract.getId()); - wxBillRent.setPay(0); + wxBillProperty.setId(idWorker.nextId()); + wxBillProperty.setPropertyContractId(wxPropertyContract.getId()); + wxBillProperty.setPay(0); int needpay = price * receivePeriod; Date date = new Date(); @@ -460,70 +480,73 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService instance.add(dayType, receivePeriod * i); instance.add(Calendar.DAY_OF_MONTH, -1); Date time = instance.getTime(); - wxBillRent.setReceiveDate(time); + wxBillProperty.setReceiveDate(time); //账单开始时间 instance.clear(); - instance.setTime(wxBillRent.getReceiveDate()); + instance.setTime(wxBillProperty.getReceiveDate()); instance.add(Calendar.DAY_OF_MONTH, 1); - wxBillRent.setStarttime(instance.getTime()); + wxBillProperty.setStarttime(instance.getTime()); //账单结束时间 instance.clear(); - instance.setTime(wxBillRent.getStarttime()); + instance.setTime(wxBillProperty.getStarttime()); instance.add(dayType, receivePeriod); instance.add(Calendar.DAY_OF_MONTH, -1); - wxBillRent.setEndtime(instance.getTime()); + wxBillProperty.setEndtime(instance.getTime()); if (extracount > 0 && i == index) { //账单开始时间 instance.clear(); - instance.setTime(wxBillRent.getReceiveDate()); + instance.setTime(wxBillProperty.getReceiveDate()); instance.add(Calendar.DAY_OF_MONTH, 1); - wxBillRent.setStarttime(instance.getTime()); + wxBillProperty.setStarttime(instance.getTime()); //账单结束时间 instance.clear(); - instance.setTime(wxBillRent.getStarttime()); + instance.setTime(wxBillProperty.getStarttime()); instance.add(dayType, extralease); instance.add(Calendar.DAY_OF_MONTH, -1); - wxBillRent.setEndtime(instance.getTime()); + wxBillProperty.setEndtime(instance.getTime()); needpay = price * extralease; } - wxBillRent.setNeedPay(needpay); - wxBillRent.setOwe(needpay); - wxBillRent.setReceivePay(needpay); + wxBillProperty.setNeedPay(needpay); + wxBillProperty.setOwe(needpay); + wxBillProperty.setReceivePay(needpay); //截止收租日在当前时间之前 - if (wxBillRent.getReceiveDate().before(date)) { + if (wxBillProperty.getReceiveDate().before(date)) { long day = (time.getTime() - date.getTime()) / (24 * 60 * 60 * 1000); - wxBillRent.setStatus(EnumBillRentStatus.NOT_PAID.getCode()); - wxBillRent.setExpiredDay(day); + 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(wxBillRent.getReceiveDate())) { - wxBillRent.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); - wxBillRent.setExpiredDay(0L); + if (currenttime.before(wxBillProperty.getReceiveDate())) { + wxBillProperty.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode()); + wxBillProperty.setExpiredDay(0L); } else { - wxBillRent.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); - wxBillRent.setExpiredDay(0L); + wxBillProperty.setStatus(EnumBillRentStatus.WAIT_PAY.getCode()); + wxBillProperty.setExpiredDay(0L); } } - wxBillRent.setTenantId(wxMerchant.getTenantId()); - wxBillRent.setIsDel(0); - wxBillRent.setMerchantId(wxMerchant.getId()); - wxBillRent.setUserId(userId); - wxBillRent.setShopId(wxPropertyContract.getShopId()); - wxBillRent.setCreatetime(date); - wxBillRent.setUpdatetime(date); - wxBillRent.setIsDel(EnumDelStatus.NOT_DEL.getCode()); - wxBillRent.setRentShopType(wxPropertyContract.getRentShopType()); - wxBillRent.setPeriod(++billcount); + wxBillProperty.setTenantId(wxMerchant.getTenantId()); + wxBillProperty.setIsDel(0); + wxBillProperty.setMerchantId(wxMerchant.getId()); + wxBillProperty.setUserId(userId); + wxBillProperty.setShopId(wxPropertyContract.getShopId()); + wxBillProperty.setCreatetime(date); + wxBillProperty.setUpdatetime(date); + wxBillProperty.setIsDel(EnumDelStatus.NOT_DEL.getCode()); + wxBillProperty.setRentShopType(wxPropertyContract.getRentShopType()); + wxBillProperty.setPeriod(++billcount); + if (shopInfo != null) { + wxBillProperty.setShopInfo(JSONObject.toJSONString(shopInfo)); + } try { - wxBillPropertyMapper.insertSelective(wxBillRent); - resultList.add(wxBillRent); + wxBillPropertyMapper.insertSelective(wxBillProperty); + resultList.add(wxBillProperty); } catch (Exception e) { logger.error("添加租赁账单失败,e:" + e.getMessage()); throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); @@ -568,7 +591,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview); } else { //按日计租 - Map resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, propertyContract, userId, wxMerchant, 0,isPreview); + Map resultMap = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, propertyContract, userId, wxMerchant, 0, isPreview, null); result = (List)resultMap.get("billList"); } } diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index 95765b823..3567fd561 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -36,6 +36,7 @@ + @@ -45,7 +46,7 @@ `deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`, `shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`, `link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`, - `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio + `start_date`,`end_date`,`apply_status`,`adjust_period`,`business_type`,adjust_ratio,`rent_info` @@ -104,7 +105,8 @@ f.floor_name floorName,b.building_name buildingName,receive_period receivePeriod, rc.lease,rc.filepath,rc.filename,rc.pay_account payAccount,rc.sign_date signDate, start_date startDate,end_date endDate,rc.rent_contract_id rentContractId,br.`name` brandName, - s.addr,rc.apply_status applyStatus,rc.adjust_period adjustPeriod,rc.business_type businessType,rc.adjust_ratio adjustRatio + s.addr,rc.apply_status applyStatus,rc.adjust_period adjustPeriod,rc.business_type businessType, + rc.adjust_ratio adjustRatio,rc.rent_info rentInfo from wx_property_contract rc left join wx_shop s on rc.shop_id=s.id left join wx_mall_floor f on s.floor=f.id