| @@ -166,6 +166,19 @@ public class WxPropertyContract implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value = "审批流参数", name = "flowParams") | |||
| private Map<String, Object> flowParams; | |||
| // 预账单列表 | |||
| @Transient | |||
| @io.swagger.annotations.ApiModelProperty(value = "预账单列表", name = "previewBillRentList") | |||
| private List<WxBillProperty> previewBillRentList; | |||
| public List<WxBillProperty> getPreviewBillRentList() { | |||
| return previewBillRentList; | |||
| } | |||
| public void setPreviewBillRentList(List<WxBillProperty> previewBillRentList) { | |||
| this.previewBillRentList = previewBillRentList; | |||
| } | |||
| public Integer getBusinessType() { | |||
| return businessType; | |||
| } | |||
| @@ -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<WxBillRent> previewBillRentList; | |||
| // 物业合同预账单列表 | |||
| @Transient | |||
| @io.swagger.annotations.ApiModelProperty(value = "物业合同预账单列表", name = "reviewBillPropertyPList") | |||
| private List<WxBillProperty> reviewBillPropertyPList; | |||
| public List<WxBillProperty> getReviewBillPropertyPList() { | |||
| return reviewBillPropertyPList; | |||
| } | |||
| public void setReviewBillPropertyPList(List<WxBillProperty> reviewBillPropertyPList) { | |||
| this.reviewBillPropertyPList = reviewBillPropertyPList; | |||
| } | |||
| public List<WxBillRent> getPreviewBillRentList() { | |||
| return previewBillRentList; | |||
| } | |||
| @@ -31,4 +31,6 @@ public interface WxBillPropertyMapper extends CommonMapper<WxBillProperty, Long> | |||
| void deletePreviewBill(WxPropertyContract wxPropertyContract); | |||
| void update(WxBillProperty wxBillProperty); | |||
| void updatePreviewStatus(WxBillProperty record); | |||
| } | |||
| @@ -27,4 +27,6 @@ public interface WxBillRentMapper extends CommonMapper<WxBillRent, Long> { | |||
| void deletePreviewBill(WxRentContract wxRentContract); | |||
| void update(WxBillRent record); | |||
| void updatePreviewStatus(WxBillRent record); | |||
| } | |||
| @@ -43,4 +43,6 @@ public interface WxPropertyContractMapper extends CommonMapper<WxPropertyContrac | |||
| long queryOweCount(WxPropertyContract wxPropertyContract); | |||
| void updateStatusByRentContractId(WxPropertyContract wxPropertyContract); | |||
| WxPropertyContract findOneByRentId(WxRentContract wxRentContract); | |||
| } | |||
| @@ -1,11 +1,13 @@ | |||
| package com.iformall.service; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxBillRent; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| @@ -68,7 +70,7 @@ public interface WxRentContractService { | |||
| void updateApplyStatus(WxRentContract wxRentContract); | |||
| void buildRent(WxMerchant wxMerchant, Long userId); | |||
| List<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract); | |||
| void buildDeposit(WxMerchant wxMerchant, Long userId); | |||
| @@ -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); | |||
| } | |||
| @@ -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<WxBillProperty> 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<Map<String, Object>> 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<WxPropertyContract> list = wxPropertyContractMapper.findList(wxPropertyContract); | |||
| if (list.size() > 0) { | |||
| wxPropertyContract = list.get(0); | |||
| public List<WxBillProperty> buildProperty(WxMerchant wxMerchant,WxPropertyContract propertyContract) { | |||
| List<WxBillProperty> result = new ArrayList<>(); | |||
| WxPropertyContract wxPropertyContract; | |||
| if(propertyContract == null){ | |||
| //根据商户ID找出合同 | |||
| wxPropertyContract = new WxPropertyContract(); | |||
| wxPropertyContract.setMerchantId(wxMerchant.getId()); | |||
| List<WxPropertyContract> 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<String, Object> params = new HashMap<>(); | |||
| params.put("tenantId", record.getTenantId()); | |||
| params.put("rentShopType", record.getRentShopType()); | |||
| return wxPropertyContractMapper.getRentContractList(params); | |||
| List<WxRentContract> 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<WxBillProperty> billList = buildProperty(new WxMerchant(),propertyContract); | |||
| wxRentContract.setReviewBillPropertyPList(billList); | |||
| } | |||
| } | |||
| } | |||
| return contractList; | |||
| } | |||
| @Override | |||
| @@ -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<WxBillRent> 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<WxBillRent> 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<WxBillRent> 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<WxBillRent> buildRent(WxMerchant wxMerchant, Long userId,WxRentContract rentContract) { | |||
| List<WxBillRent> rentList = new ArrayList<>(); | |||
| //根据商户ID找出合同 | |||
| WxRentContract wxRentContract = new WxRentContract(); | |||
| wxRentContract.setMerchantId(wxMerchant.getId()); | |||
| List<WxRentContract> 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<WxRentContract> 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<WxBillRent> 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<WxRentContract> getRentContractList(WxRentContract rentContract, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.getRentContractList(rentContract)); | |||
| PageInfo<WxRentContract> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxRentContractMapper.getRentContractList(rentContract)); | |||
| return pageInfo; | |||
| } | |||
| public Map<String, Object> updateStatus(WxRentContract record) { | |||
| @@ -925,16 +931,22 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| record.getPrice() > 0) { | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| wxBillRent.setMerchantId(record.getMerchantId()); | |||
| List<Map<String, Object>> billRentList = wxBillRentMapper.queryBillRentList(wxBillRent); | |||
| if (billRentList.size() == 0) { | |||
| //发预览账单改为正式 | |||
| WxBillRent billRent = new WxBillRent(); | |||
| billRent.setRentContractId(id); | |||
| billRent.setIsPreview(EnumIsPreview.YES.getCode()); | |||
| wxBillRentMapper.updatePreviewStatus(billRent); | |||
| // List<Map<String, Object>> 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, "操作成功"); | |||
| } | |||
| @@ -138,4 +138,8 @@ | |||
| <update id="update" parameterType="com.iformall.domain.po.WxBillProperty"> | |||
| update wx_bill_property set receive_pay = #{receivePay} where id = #{id} | |||
| </update> | |||
| <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxBillRent"> | |||
| update wx_bill_rent set is_preview = #{isPreview} where rent_contract_id = #{rentContractId} | |||
| </update> | |||
| </mapper> | |||
| @@ -133,4 +133,8 @@ | |||
| <update id="update" parameterType="com.iformall.domain.po.WxBillRent"> | |||
| update wx_bill_rent set receive_pay = #{receivePay} where id = #{id} | |||
| </update> | |||
| <update id="updatePreviewStatus" parameterType="com.iformall.domain.po.WxBillRent"> | |||
| update wx_bill_rent set is_preview = #{isPreview} where rent_contract_id = #{rentContractId} | |||
| </update> | |||
| </mapper> | |||
| @@ -201,4 +201,8 @@ | |||
| <if test=" null != id ">and r.id = #{id}</if> | |||
| <if test=" null != rentContractId ">and r.rent_contract_id = #{rentContractId}</if> | |||
| </select> | |||
| <select id="findOneByRentId" parameterType="com.iformall.domain.po.WxRentContract" resultType="com.iformall.domain.po.WxPropertyContract"> | |||
| select * from wx_property_contract where rent_contract_id =#{id} order by createtime desc limit 1 | |||
| </select> | |||
| </mapper> | |||