| @@ -92,6 +92,29 @@ public class WxBillProperty implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime") | |||
| private Date updatetime; | |||
| @io.swagger.annotations.ApiModelProperty(value="开始时间",name="starttime") | |||
| private Date starttime; | |||
| @io.swagger.annotations.ApiModelProperty(value="结束时间",name="endtime") | |||
| private Date endtime; | |||
| public Date getStarttime() { | |||
| return starttime; | |||
| } | |||
| public void setStarttime(Date starttime) { | |||
| this.starttime = starttime; | |||
| } | |||
| public Date getEndtime() { | |||
| return endtime; | |||
| } | |||
| public void setEndtime(Date endtime) { | |||
| this.endtime = endtime; | |||
| } | |||
| public Long getPropertyContractId() { | |||
| return propertyContractId; | |||
| } | |||
| @@ -92,6 +92,28 @@ public class WxBillPropertyDeposit implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime") | |||
| private Date updatetime; | |||
| @io.swagger.annotations.ApiModelProperty(value="开始时间",name="starttime") | |||
| private Date starttime; | |||
| @io.swagger.annotations.ApiModelProperty(value="结束时间",name="endtime") | |||
| private Date endtime; | |||
| public Date getStarttime() { | |||
| return starttime; | |||
| } | |||
| public void setStarttime(Date starttime) { | |||
| this.starttime = starttime; | |||
| } | |||
| public Date getEndtime() { | |||
| return endtime; | |||
| } | |||
| public void setEndtime(Date endtime) { | |||
| this.endtime = endtime; | |||
| } | |||
| public Long getPropertyContractId() { | |||
| return propertyContractId; | |||
| } | |||
| @@ -220,6 +220,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| //关联合同 | |||
| if (wxMerchant.getRentContractId() != null) { | |||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(wxMerchant.getRentContractId()); | |||
| if (wxRentContract == null) { | |||
| return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | |||
| } | |||
| wxRentContract.setMerchantId(merchantid); | |||
| wxRentContract.setUpdatetime(new Date()); | |||
| wxRentContract.setStatus(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()); | |||
| @@ -317,7 +320,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| logger.error("db failed: 账户操作失败, e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| return new ResultData(Result.SUCCESS,"操作成功"); | |||
| return new ResultData(Result.SUCCESS, "操作成功"); | |||
| } | |||
| @@ -647,6 +650,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| int extralease = lease % receivePeriod; | |||
| int extracount = extralease > 0 ? 1 : 0; | |||
| int paycount = lease / receivePeriod + extracount; | |||
| int index = paycount - 1; | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| for (int i = 0; i < paycount; i++) { | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| @@ -654,15 +658,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| wxBillRent.setRentContractId(wxRentContract.getId()); | |||
| wxBillRent.setReceivePay(0); | |||
| wxBillRent.setPay(0); | |||
| int needpay = wxRentContract.getPrice() * receivePeriod; | |||
| if (extracount > 0) { | |||
| if (i == paycount - 1) { | |||
| needpay = wxRentContract.getPrice() * extralease; | |||
| } | |||
| } | |||
| wxBillRent.setNeedPay(needpay); | |||
| wxBillRent.setOwe(needpay); | |||
| Date date = new Date(); | |||
| Calendar instance = Calendar.getInstance(); | |||
| @@ -682,8 +677,8 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| instance.setTime(wxBillRent.getReceiveDate()); | |||
| instance.add(Calendar.MONTH, receivePeriod); | |||
| wxBillRent.setEndtime(instance.getTime()); | |||
| if(extracount>0){ | |||
| int needpay = wxRentContract.getPrice() * receivePeriod; | |||
| if (extracount > 0 && i == index) { | |||
| //账单开始时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillRent.getReceiveDate()); | |||
| @@ -694,8 +689,12 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| instance.setTime(wxBillRent.getReceiveDate()); | |||
| instance.add(Calendar.MONTH, extralease); | |||
| wxBillRent.setEndtime(instance.getTime()); | |||
| needpay = wxRentContract.getPrice() * extralease; | |||
| } | |||
| wxBillRent.setNeedPay(needpay); | |||
| wxBillRent.setOwe(needpay); | |||
| //截止收租日在当前时间之前 | |||
| if (wxBillRent.getReceiveDate().before(date)) { | |||
| long day = (time.getTime() - date.getTime()) / (24 * 60 * 60 * 1000); | |||
| @@ -185,6 +185,18 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| Date time = instance.getTime(); | |||
| wxBillDeposit.setReceiveDate(time); | |||
| //账单开始时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillDeposit.getReceiveDate()); | |||
| instance.add(Calendar.DAY_OF_MONTH, 1); | |||
| wxBillDeposit.setStarttime(instance.getTime()); | |||
| //账单结束时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillDeposit.getReceiveDate()); | |||
| instance.add(Calendar.MONTH, wxPropertyContract.getLease()); | |||
| wxBillDeposit.setEndtime(instance.getTime()); | |||
| //截止收租日在当前时间之前 | |||
| if (wxBillDeposit.getReceiveDate().before(date)) { | |||
| long day = (time.getTime() - date.getTime()) / (24 * 60 * 60 * 1000); | |||
| @@ -230,6 +242,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| int extralease =lease%receivePeriod; | |||
| int extracount=extralease>0?1:0; | |||
| int paycount = lease / receivePeriod+extracount; | |||
| int index = paycount-1; | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| for (int i = 0; i < paycount; i++) { | |||
| WxBillProperty wxBillRent = new WxBillProperty(); | |||
| @@ -237,14 +250,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| wxBillRent.setPropertyContractId(wxPropertyContract.getId()); | |||
| wxBillRent.setReceivePay(0); | |||
| wxBillRent.setPay(0); | |||
| int needpay = wxPropertyContract.getPrice()*receivePeriod; | |||
| if(extracount>0){ | |||
| if(i==paycount-1){ | |||
| needpay = wxPropertyContract.getPrice()*extralease; | |||
| } | |||
| } | |||
| wxBillRent.setNeedPay(needpay); | |||
| wxBillRent.setOwe(needpay); | |||
| Date date = new Date(); | |||
| Calendar instance = Calendar.getInstance(); | |||
| @@ -254,6 +259,36 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| Date time = instance.getTime(); | |||
| wxBillRent.setReceiveDate(time); | |||
| //账单开始时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillRent.getReceiveDate()); | |||
| instance.add(Calendar.DAY_OF_MONTH, 1); | |||
| wxBillRent.setStarttime(instance.getTime()); | |||
| //账单结束时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillRent.getReceiveDate()); | |||
| instance.add(Calendar.DAY_OF_MONTH, 1); | |||
| instance.add(Calendar.MONTH, receivePeriod); | |||
| wxBillRent.setEndtime(instance.getTime()); | |||
| int needpay = wxPropertyContract.getPrice()*receivePeriod; | |||
| if (extracount > 0 && i == index) { | |||
| //账单开始时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillRent.getReceiveDate()); | |||
| instance.add(Calendar.DAY_OF_MONTH, 1); | |||
| wxBillRent.setStarttime(instance.getTime()); | |||
| //账单结束时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillRent.getReceiveDate()); | |||
| instance.add(Calendar.DAY_OF_MONTH, 1); | |||
| instance.add(Calendar.MONTH, extralease); | |||
| wxBillRent.setEndtime(instance.getTime()); | |||
| needpay = wxPropertyContract.getPrice() * extralease; | |||
| } | |||
| wxBillRent.setNeedPay(needpay); | |||
| wxBillRent.setOwe(needpay); | |||
| //截止收租日在当前时间之前 | |||
| if (wxBillRent.getReceiveDate().before(date)) { | |||
| @@ -70,12 +70,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| public ResultData getById(Long id) { | |||
| Map<String, Object> result = new HashMap<>(); | |||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); | |||
| if(wxRentContract==null){ | |||
| if (wxRentContract == null) { | |||
| return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | |||
| } | |||
| wxRentContract.setPrice(wxRentContract.getPrice() != null ? wxRentContract.getPrice(): 0); | |||
| wxRentContract.setDeposit(wxRentContract.getDeposit() != null ? wxRentContract.getDeposit(): 0); | |||
| wxRentContract.setPrice(wxRentContract.getPrice() != null ? wxRentContract.getPrice() : 0); | |||
| wxRentContract.setDeposit(wxRentContract.getDeposit() != null ? wxRentContract.getDeposit() : 0); | |||
| result.put("wxRentContract", wxRentContract); | |||
| //关联的商户 | |||
| @@ -121,7 +121,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record); | |||
| } else {//更新租赁合同信息 | |||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getId()); | |||
| if(wxRentContract==null){ | |||
| if (wxRentContract == null) { | |||
| return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | |||
| } | |||
| Calendar instance = Calendar.getInstance(); | |||
| @@ -129,17 +129,17 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| instance.add(Calendar.MONTH, record.getLease()); | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| record.setRentalEndDate(instance.getTime()); | |||
| record.setPrice(record.getPrice() != null ? record.getPrice(): 0); | |||
| record.setDeposit(record.getDeposit() != null ? record.getDeposit(): 0); | |||
| record.setPrice(record.getPrice() != null ? record.getPrice() : 0); | |||
| record.setDeposit(record.getDeposit() != null ? record.getDeposit() : 0); | |||
| record.setUpdatetime(new Date()); | |||
| if(record.getPrice()==0 || record.getDeposit()==0){ | |||
| if (record.getPrice() == 0 || record.getDeposit() == 0) { | |||
| record.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); | |||
| } | |||
| try { | |||
| wxRentContractMapper.updateByPrimaryKeySelective(record); | |||
| //建立账单 | |||
| if (record.getMerchantId() != null && record.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) | |||
| && record.getReceivePeriod() != null && record.getDeposit()>0 && record.getPrice()>0) { | |||
| && record.getReceivePeriod() != null && record.getDeposit() > 0 && record.getPrice() > 0) { | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| wxBillRent.setMerchantId(record.getMerchantId()); | |||
| List<Map<String, Object>> billRentList = wxBillRentMapper.queryBillRentList(wxBillRent); | |||
| @@ -242,9 +242,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| wxRentContract = list.get(0); | |||
| int receivePeriod = wxRentContract.getReceivePeriod().intValue(); | |||
| Integer lease = wxRentContract.getLease(); | |||
| int extralease =lease%receivePeriod; | |||
| int extracount=extralease>0?1:0; | |||
| int paycount = lease / receivePeriod+extracount; | |||
| int extralease = lease % receivePeriod; | |||
| int extracount = extralease > 0 ? 1 : 0; | |||
| int paycount = lease / receivePeriod + extracount; | |||
| int index = paycount - 1; | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| for (int i = 0; i < paycount; i++) { | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| @@ -252,19 +253,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| wxBillRent.setRentContractId(wxRentContract.getId()); | |||
| wxBillRent.setReceivePay(0); | |||
| wxBillRent.setPay(0); | |||
| int needpay = wxRentContract.getPrice()*receivePeriod; | |||
| if(extracount>0){ | |||
| if(i==paycount-1){ | |||
| needpay = wxRentContract.getPrice()*extralease; | |||
| } | |||
| } | |||
| wxBillRent.setNeedPay(needpay); | |||
| wxBillRent.setOwe(needpay); | |||
| int needpay = wxRentContract.getPrice() * receivePeriod; | |||
| Date date = new Date(); | |||
| Calendar instance = Calendar.getInstance(); | |||
| instance.setTime(wxRentContract.getRentalStartDate()); | |||
| instance.add(Calendar.MONTH, receivePeriod* i); | |||
| instance.add(Calendar.MONTH, receivePeriod * i); | |||
| instance.add(Calendar.DAY_OF_MONTH, -1); | |||
| Date time = instance.getTime(); | |||
| wxBillRent.setReceiveDate(time); | |||
| @@ -281,7 +275,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| instance.add(Calendar.MONTH, receivePeriod); | |||
| wxBillRent.setEndtime(instance.getTime()); | |||
| if(extracount>0){ | |||
| if (extracount > 0 && i == index) { | |||
| //账单开始时间 | |||
| instance.clear(); | |||
| instance.setTime(wxBillRent.getReceiveDate()); | |||
| @@ -293,7 +287,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| instance.add(Calendar.DAY_OF_MONTH, 1); | |||
| instance.add(Calendar.MONTH, extralease); | |||
| wxBillRent.setEndtime(instance.getTime()); | |||
| needpay = wxRentContract.getPrice() * extralease; | |||
| } | |||
| wxBillRent.setNeedPay(needpay); | |||
| wxBillRent.setOwe(needpay); | |||
| //截止收租日在当前时间之前 | |||
| if (wxBillRent.getReceiveDate().before(date)) { | |||
| @@ -388,7 +385,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| public ResultData endRentContract(Long id) { | |||
| WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); | |||
| if(wxRentContract==null){ | |||
| if (wxRentContract == null) { | |||
| return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | |||
| } | |||
| wxRentContract.setStatus(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()); | |||
| @@ -407,7 +404,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| @Override | |||
| public ResultData updateMerchant(WxRentContract wxRentContract) { | |||
| WxRentContract record = wxRentContractMapper.selectByPrimaryKey(wxRentContract); | |||
| if(wxRentContract==null){ | |||
| if (wxRentContract == null) { | |||
| return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); | |||
| } | |||
| record.setMerchantId(wxRentContract.getMerchantId()); | |||