From b92e140e276a87a9402a80b3bee13169d461c500 Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 21 Feb 2019 19:36:13 +0800 Subject: [PATCH] =?UTF-8?q?[=E9=93=9C=E9=94=A3=E6=B9=BE][=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0][=E9=A2=84=E8=B4=A6=E5=8D=95]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/po/WxPropertyContract.java | 13 ++++ .../iformall/domain/po/WxRentContract.java | 17 ++++- .../iformall/mapper/WxBillPropertyMapper.java | 2 + .../com/iformall/mapper/WxBillRentMapper.java | 2 + .../mapper/WxPropertyContractMapper.java | 2 + .../service/WxRentContractService.java | 4 +- .../service/impl/WxMerchantServiceImpl.java | 2 +- .../impl/WxPropertyContractServiceImpl.java | 73 ++++++++++++++++--- .../impl/WxRentContractServiceImpl.java | 66 ++++++++++------- .../resources/mapper/WxBillPropertyMapper.xml | 4 + .../resources/mapper/WxBillRentMapper.xml | 4 + .../mapper/WxPropertyContractMapper.xml | 4 + 12 files changed, 152 insertions(+), 41 deletions(-) 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 a404c3307..343c25c5b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java @@ -166,6 +166,19 @@ public class WxPropertyContract implements Serializable { @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") private Map flowParams; + // 预账单列表 + @Transient + @io.swagger.annotations.ApiModelProperty(value = "预账单列表", name = "previewBillRentList") + private List previewBillRentList; + + public List getPreviewBillRentList() { + return previewBillRentList; + } + + public void setPreviewBillRentList(List previewBillRentList) { + this.previewBillRentList = previewBillRentList; + } + public Integer getBusinessType() { return businessType; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index fcc3b00a7..5fdc1efc4 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -205,11 +205,24 @@ public class WxRentContract implements Serializable { @io.swagger.annotations.ApiModelProperty(value = "装修期结束时间", name = "fixEndDate") private Date fixEndDate; - // 预账单列表 + // 租赁合同预账单列表 @Transient - @io.swagger.annotations.ApiModelProperty(value = "预账单列表", name = "previewBillRentList") + @io.swagger.annotations.ApiModelProperty(value = "租赁合同预账单列表", name = "previewBillRentList") private List previewBillRentList; + // 物业合同预账单列表 + @Transient + @io.swagger.annotations.ApiModelProperty(value = "物业合同预账单列表", name = "reviewBillPropertyPList") + private List reviewBillPropertyPList; + + public List getReviewBillPropertyPList() { + return reviewBillPropertyPList; + } + + public void setReviewBillPropertyPList(List reviewBillPropertyPList) { + this.reviewBillPropertyPList = reviewBillPropertyPList; + } + public List getPreviewBillRentList() { return previewBillRentList; } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java index 1065f0e3a..9537e66c9 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java @@ -31,4 +31,6 @@ public interface WxBillPropertyMapper extends CommonMapper void deletePreviewBill(WxPropertyContract wxPropertyContract); void update(WxBillProperty wxBillProperty); + + void updatePreviewStatus(WxBillProperty record); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java index 5361361e1..205a9ed62 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java @@ -27,4 +27,6 @@ public interface WxBillRentMapper extends CommonMapper { void deletePreviewBill(WxRentContract wxRentContract); void update(WxBillRent record); + + void updatePreviewStatus(WxBillRent record); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java index d1b39479f..25b866896 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java @@ -43,4 +43,6 @@ public interface WxPropertyContractMapper extends CommonMapper buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract); void buildDeposit(WxMerchant wxMerchant, Long userId); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index 675c48bb7..a5094fdf0 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -316,7 +316,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); wxRentContractMapper.updateByPrimaryKeySelective(wxRentContract); //创建账单 - wxRentContractService.buildRent(wxMerchant, userId); + wxRentContractService.buildRent(wxMerchant, userId,null); //创建押金 wxRentContractService.buildDeposit(wxMerchant, userId); } 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 439e62ee9..20535e75e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -119,6 +119,15 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService if(!CollectionUtils.isEmpty(flowRecordList)){ result.put("remark",flowRecordList.get(0).getRemark()); } + + //生成预览账单 + if(wxPropertyContract.getReceivePeriod() != null && wxPropertyContract.getLease()!=null) { + wxBillPropertyMapper.deletePreviewBill(wxPropertyContract); + //重新生成 + List billList = buildProperty(new WxMerchant(),wxPropertyContract); + wxPropertyContract.setPreviewBillRentList(billList); + } + return new ResultData(Result.SUCCESS, "查询成功", result); } @@ -253,6 +262,13 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService logger.error("启动审批流失败,e:" + e.getMessage()); throw new MallinkException(ErrorCode.FLOW_FAIL.getCode(), "FLOW FAILD " + e.getMessage()); } + + // 保存调整金额(预账单调整) + if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ + for (WxBillProperty wxBillProperty:record.getPreviewBillRentList()) { + wxBillPropertyMapper.update(wxBillProperty); + } + } return new ResultData(Result.SUCCESS, message, record); } @@ -274,11 +290,17 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService //wxBillProperty.setMerchantId(record.getMerchantId()); //List> billPropertyList = wxBillPropertyMapper.queryBillPropertyList(wxBillProperty); //if (billPropertyList.size() == 0) { + //发预览账单改为正式 + WxBillProperty billProperty = new WxBillProperty(); + billProperty.setPropertyContractId(id); + billProperty.setIsPreview(EnumIsPreview.YES.getCode()); + wxBillPropertyMapper.updatePreviewStatus(billProperty); + WxMerchant wxMerchant = new WxMerchant(); wxMerchant.setId(record.getMerchantId()); wxMerchant.setTenantId(record.getTenantId()); //物业账单 - buildProperty(wxMerchant); + //buildProperty(wxMerchant,null); //物业押金账单 buildDeposit(wxMerchant); //} @@ -346,14 +368,30 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } } + /** + * 根据商户/指定物业合同生成物业账单 + * @param wxMerchant + * @param propertyContract + * @return + */ @Transactional(rollbackFor = {Exception.class}) - public void buildProperty(WxMerchant wxMerchant) { - //根据商户ID找出合同 - WxPropertyContract wxPropertyContract = new WxPropertyContract(); - wxPropertyContract.setMerchantId(wxMerchant.getId()); - List list = wxPropertyContractMapper.findList(wxPropertyContract); - if (list.size() > 0) { - wxPropertyContract = list.get(0); + public List buildProperty(WxMerchant wxMerchant,WxPropertyContract propertyContract) { + List result = new ArrayList<>(); + + WxPropertyContract wxPropertyContract; + if(propertyContract == null){ + //根据商户ID找出合同 + wxPropertyContract = new WxPropertyContract(); + wxPropertyContract.setMerchantId(wxMerchant.getId()); + List list = wxPropertyContractMapper.findList(wxPropertyContract); + if (list.size() > 0) { + wxPropertyContract = list.get(0); + } + }else{ + wxPropertyContract = propertyContract; + } + + if (wxPropertyContract != null) { int dayType = wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH; int receivePeriod = wxPropertyContract.getReceivePeriod().intValue(); Integer lease = wxPropertyContract.getLease(); @@ -434,13 +472,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService wxBillProperty.setPeriod(i + 1); try { wxBillPropertyMapper.insertSelective(wxBillProperty); + result.add(wxBillProperty); } catch (Exception e) { logger.error("添加物业账单失败,e:" + e.getMessage()); throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); } } - } + return result; } @@ -526,7 +565,21 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService Map params = new HashMap<>(); params.put("tenantId", record.getTenantId()); params.put("rentShopType", record.getRentShopType()); - return wxPropertyContractMapper.getRentContractList(params); + List contractList = wxPropertyContractMapper.getRentContractList(params); + //生成预览账单 + if(!CollectionUtils.isEmpty(contractList)){ + for (WxRentContract wxRentContract:contractList) { + //根据租赁合同找到对应的物业合同,生成物业账单 + WxPropertyContract propertyContract = wxPropertyContractMapper.findOneByRentId(wxRentContract); + if(propertyContract!=null && propertyContract.getReceivePeriod() != null && propertyContract.getLease()!=null) { + wxBillPropertyMapper.deletePreviewBill(propertyContract); + //重新生成 + List billList = buildProperty(new WxMerchant(),propertyContract); + wxRentContract.setReviewBillPropertyPList(billList); + } + } + } + return contractList; } @Override 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 4ca1ff8aa..a889c559f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -145,6 +145,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { if(!CollectionUtils.isEmpty(flowRecordList)){ result.put("remark",flowRecordList.get(0).getRemark()); } + + //删除预账单 + if(wxRentContract.getReceivePeriod() != null && wxRentContract.getLease()!=null && wxRentContract.getRentalStartDate()!=null && wxRentContract.getPrice()!= null){ + wxBillRentMapper.deletePreviewBill(wxRentContract); + //重新生成 + List resultList = buildRent(null,null,wxRentContract); + wxRentContract.setPreviewBillRentList(resultList); + } + return new ResultData(Result.SUCCESS, "查询成功", result); } @@ -261,20 +270,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { if(record.getReceivePeriod() != null && record.getLease()!=null && record.getRentalStartDate()!=null && record.getPrice()!= null){ wxBillRentMapper.deletePreviewBill(record); //重新生成 - WxMerchant wxMerchant = new WxMerchant(); - buildRent(wxMerchant,null); - int receivePeriod = record.getReceivePeriod().intValue(); - Integer lease = record.getLease(); - Date rentalStartDate = record.getRentalStartDate(); - Integer price = record.getPrice(); - //按月计租 - List resultList; - if (record.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode())) { - resultList = buildRentMonth(wxMerchant, userId, record, receivePeriod, lease, rentalStartDate, price,EnumIsPreview.YES.getCode()); - } else { - //按日计租 - resultList = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, record, userId, wxMerchant, 0,EnumIsPreview.YES.getCode()); - } + List resultList = buildRent(null,null,record); wxRentContract.setPreviewBillRentList(resultList); } return new ResultData(wxRentContract); @@ -408,25 +404,34 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Override @Transactional(rollbackFor = {Exception.class}) - public void buildRent(WxMerchant wxMerchant, Long userId) { + public List buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract) { + List rentList = new ArrayList<>(); //根据商户ID找出合同 - WxRentContract wxRentContract = new WxRentContract(); - wxRentContract.setMerchantId(wxMerchant.getId()); - List list = wxRentContractMapper.findList(wxRentContract); - if (list.size() > 0) { - wxRentContract = list.get(0); + WxRentContract wxRentContract; + if(rentContract == null){ + wxRentContract = new WxRentContract(); + wxRentContract.setMerchantId(wxMerchant.getId()); + List list = wxRentContractMapper.findList(wxRentContract); + if (list.size() > 0) { + wxRentContract = list.get(0); + } + }else{ + wxRentContract = rentContract; + } + if (wxRentContract != null) { int receivePeriod = wxRentContract.getReceivePeriod().intValue(); Integer lease = wxRentContract.getLease(); Date rentalStartDate = wxRentContract.getRentalStartDate(); Integer price = wxRentContract.getPrice(); //按月计租 if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode())) { - buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,EnumIsPreview.NO.getCode()); + rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,EnumIsPreview.NO.getCode()); } else { //按日计租 - buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0,EnumIsPreview.NO.getCode()); + rentList = buildRent(lease, receivePeriod, price, rentalStartDate, Calendar.DAY_OF_MONTH, wxRentContract, userId, wxMerchant, 0,EnumIsPreview.NO.getCode()); } } + return rentList; } public List buildRentMonth(WxMerchant wxMerchant, Long userId, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, Integer price,Integer isPreview) { @@ -674,7 +679,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Override public PageInfo getRentContractList(WxRentContract rentContract, Integer pageIndex, Integer pageSize) { - return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.getRentContractList(rentContract)); + PageInfo pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.getRentContractList(rentContract)); + return pageInfo; } public Map updateStatus(WxRentContract record) { @@ -925,16 +931,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { record.getPrice() > 0) { WxBillRent wxBillRent = new WxBillRent(); wxBillRent.setMerchantId(record.getMerchantId()); - List> billRentList = wxBillRentMapper.queryBillRentList(wxBillRent); - if (billRentList.size() == 0) { + + //发预览账单改为正式 + WxBillRent billRent = new WxBillRent(); + billRent.setRentContractId(id); + billRent.setIsPreview(EnumIsPreview.YES.getCode()); + wxBillRentMapper.updatePreviewStatus(billRent); +// List> billRentList = wxBillRentMapper.queryBillRentList(wxBillRent); +// if (billRentList.size() == 0) { WxMerchant wxMerchant = new WxMerchant(); wxMerchant.setId(record.getMerchantId()); wxMerchant.setTenantId(record.getTenantId()); //租金 - buildRent(wxMerchant, null); +// buildRent(wxMerchant, null,null); //押金 buildDeposit(wxMerchant, null); - } +// } } return new ResultData(Result.SUCCESS, "操作成功"); } diff --git a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml index 44568b854..9abd020b3 100644 --- a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml @@ -138,4 +138,8 @@ update wx_bill_property set receive_pay = #{receivePay} where id = #{id} + + + update wx_bill_rent set is_preview = #{isPreview} where rent_contract_id = #{rentContractId} + diff --git a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml index ae3f55339..ad81224e8 100644 --- a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml @@ -133,4 +133,8 @@ update wx_bill_rent set receive_pay = #{receivePay} where id = #{id} + + + update wx_bill_rent set is_preview = #{isPreview} where rent_contract_id = #{rentContractId} + diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index ce5421d95..5eee506a5 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -201,4 +201,8 @@ and r.id = #{id} and r.rent_contract_id = #{rentContractId} + +