From 2eb1b225b5ac1e9453929ef7677bbf15ec7cb3b0 Mon Sep 17 00:00:00 2001 From: winter Date: Wed, 26 Jun 2024 21:37:33 +0800 Subject: [PATCH] fix --- .../WxPropertyContractController.java | 2 +- .../contract/WxRentContractController.java | 4 +- .../iformall/schedule/ContractSchedule.java | 4 +- .../iformall/domain/po/WxBillRentManage.java | 4 + .../mapper/WxBillRentManageMapper.java | 2 + .../service/WxBillDepositService.java | 2 + .../service/WxBillPropertyDepositService.java | 2 + .../service/WxBillPropertyService.java | 3 + .../service/WxBillRentManageService.java | 2 + .../iformall/service/WxBillRentService.java | 4 +- .../service/WxPropertyContractService.java | 2 +- .../service/WxRentContractService.java | 2 +- .../service/helper/WxBillAllHelper.java | 102 +++++++++++++++--- .../service/impl/WxBillBaseService.java | 14 +++ .../impl/WxBillDepositServiceImpl.java | 36 +++++++ .../WxBillPropertyDepositServiceImpl.java | 38 +++++++ .../impl/WxBillPropertyServiceImpl.java | 36 +++++++ .../impl/WxBillRentManageServiceImpl.java | 37 +++++++ .../service/impl/WxBillRentServiceImpl.java | 47 +++++--- .../service/impl/WxFlowServiceImpl.java | 4 +- .../impl/WxPropertyContractServiceImpl.java | 4 +- .../impl/WxRentContractServiceImpl.java | 16 ++- .../java/com/iformall/utils/Constant.java | 1 + .../mapper/WxBillRentManageMapper.xml | 14 ++- 24 files changed, 333 insertions(+), 49 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 2c896a305..3f61dacf7 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java @@ -273,7 +273,7 @@ public class WxPropertyContractController extends WxContractBaseController { @SystemControllerLog(description = "物业合同-终止合同") public ResultData endContract(@RequestBody WxPropertyContract proertyContract) { proertyContract.updateTenantInfo(getTenantInfo()); - wxPropertyContractService.endContract(proertyContract); + wxPropertyContractService.endContract(proertyContract,this.getUser()); return new ResultData(proertyContract); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index 05b53968d..71783fc36 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -479,13 +479,13 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); } wxRentContract.updateTenantInfo(contract); - wxRentContractService.endContract(wxRentContract); + wxRentContractService.endContract(wxRentContract,this.getUser()); //租金+物业的终止 if(contract.getOperationType().intValue() == EnumContractOperationType.WHOLE.getCode().intValue()) { WxPropertyContract wpc = new WxPropertyContract(); wpc.setId(wxRentContract.getPropertyId()); wpc.setEndContractTime(wxRentContract.getEndContractTime()); - wxPropertyContractService.endContract(wpc); + wxPropertyContractService.endContract(wpc,this.getUser()); } return new ResultData(); } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java index 3994dc7dc..f3a244797 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/ContractSchedule.java @@ -101,7 +101,7 @@ public class ContractSchedule { List contractList = wxRentContractService.findToEndContractList(record); for (WxRentContract rent:contractList) { try { - wxRentContractService.endContract(rent); + wxRentContractService.endContract(rent,null); }catch(Exception e) { log.error("rentcontract outDate error.",e); } @@ -123,7 +123,7 @@ public class ContractSchedule { List contractList = wxPropertyContractService.findToEndContractList(record); for (WxPropertyContract rent:contractList) { try { - wxPropertyContractService.endContract(rent); + wxPropertyContractService.endContract(rent,null); }catch(Exception e) { log.error("rentcontract outDate error.",e); } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxBillRentManage.java b/mallinkService/src/main/java/com/iformall/domain/po/WxBillRentManage.java index 296d5d36f..c4e5844e3 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxBillRentManage.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxBillRentManage.java @@ -59,6 +59,9 @@ public class WxBillRentManage extends WxBillBaseEntity { @io.swagger.annotations.ApiModelProperty(value = "付款截图", name = "applyUpdateTime") private Date applyUpdateTime; + @io.swagger.annotations.ApiModelProperty(value = "预览账单0否1是", name = "isPreview") + private Integer isPreview; + @io.swagger.annotations.ApiModelProperty(value="是否删除 是1否0 未到期不显示",name="isDel") private Integer isDel; @@ -137,6 +140,7 @@ public class WxBillRentManage extends WxBillBaseEntity { Date date = new Date(); this.updateTenantInfo(billRent); this.isDel = billRent.getIsDel(); + this.isPreview = billRent.getIsPreview(); this.merchantId = billRent.getMerchantId(); this.userId = billRent.getUserId(); this.shopId = billRent.getShopId(); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillRentManageMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillRentManageMapper.java index 84eb96ea2..29e47df5d 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBillRentManageMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillRentManageMapper.java @@ -45,5 +45,7 @@ public interface WxBillRentManageMapper extends CommonMapper= 今天,并且账单是 WAIT_PAY,NOT_PAID,NOT_EXPIRED,BAD 变为INVALID + * 账单开始时间>= 今天,并且账单是 WAIT_PAY,NOT_PAID,NOT_EXPIRED,BAD 变为INVALID,如果已付了款,需要退回 * 账单开始时间<今天 & 账单结束时间 > 今天: * 账单 WAIT_PAY,NOT_PAID,NOT_EXPIRED,BAD 的,需要计算截止到今天账单总金额是多少钱,更新实际应收金额,并记录日志 * 账单 PAID, 需要计算截止到今天账单总金额是多少钱,更新实际应收金额,并记录日志 @@ -963,32 +964,42 @@ public class WxBillAllHelper { * 那是之前的账单,不处理。 * @param merchant */ - public boolean billEndCalcute(Date endTime,WxBillBaseEntity bill,WxBillAction action) { + public boolean billEndCalcute(Integer decimalSize,Date endTime,WxBillBaseEntity bill,WxBillAction action, boolean isAllReturn) { String endTimeStr = DateUtils.date2String(endTime,DateUtils.DATE_TIME_PATTERN); boolean isPaid = false; if (StringUtils.isNotBlank(bill.getPay()) && new BigDecimal(bill.getPay()).compareTo(new BigDecimal(0)) > 0 ) { isPaid = true; } boolean isUpdate = false; + action.setBillId(bill.getId()); + action.setBillType(bill.getBillType()); + String oldReceivePay = bill.getReceivePay(); if (!bill.getStarttime().before(endTime)) { if (bill.getStatus().intValue() == EnumBillStatus.WAIT_PAY.getCode().intValue() || bill.getStatus().intValue() == EnumBillStatus.NOT_PAID.getCode().intValue() || bill.getStatus().intValue() == EnumBillStatus.NOT_EXPIRED.getCode().intValue() || bill.getStatus().intValue() == EnumBillStatus.BAD.getCode().intValue()) { EnumBillStatus realBillStatus = EnumBillStatus.INVALID; + String newReceivePay = bill.getReceivePay(); if (isPaid) { realBillStatus = EnumBillStatus.STOP_TO_SETTLE; + bill.setReceivePay("0"); + newReceivePay = "0"; } bill.setStatus(realBillStatus.getCode()); + action.setOldMoney(oldReceivePay); + action.setNewMoney(newReceivePay); action.setAction(EnumBillAction.STATUS_CHANGE.getCode()); action.setDetails(EnumBillAction.STATUS_CHANGE.getDescription(null, null, null)+"商户停用,停用日期["+endTimeStr+"]"); - action.setRemark("系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+realBillStatus.getMessage()+"]"); + action.setRemark("系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+realBillStatus.getMessage()+"],应收金额变为0"); isUpdate = true; //如果是已支付,则需退回全部费用 }else if (bill.getStatus().intValue() == EnumBillStatus.PAID.getCode().intValue()) { bill.setReceivePay("0"); bill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); + action.setOldMoney(oldReceivePay); + action.setNewMoney("0"); action.setAction(EnumBillAction.UPDATE_BILL.getCode()); action.setDetails(EnumBillAction.UPDATE_BILL.getDescription(bill.getReceivePay(), "0", null)); - action.setRemark("商户停用,停用日期["+endTimeStr+"],原账单已结清,系统自动更新应收金额为0,待退回费用"); + action.setRemark("商户停用,停用日期["+endTimeStr+"],系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+EnumBillStatus.STOP_TO_SETTLE.getMessage()+"]"); isUpdate = true; }else { //do nothing @@ -996,22 +1007,26 @@ public class WxBillAllHelper { }else if (bill.getStarttime().before(endTime) && bill.getEndtime().after(endTime)){ int realDays = DateUtils.daysBetween(bill.getStarttime(),endTime); int billDays = DateUtils.daysBetween(bill.getStarttime(),bill.getEndtime()); - String newReceivePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(realDays)).divide(new BigDecimal(billDays)).setScale(2,RoundingMode.HALF_UP).toPlainString(); - String oldReceivePay = bill.getReceivePay(); + String newReceivePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(realDays)).divide(new BigDecimal(billDays)).setScale(decimalSize,RoundingMode.HALF_UP).toPlainString(); + if (isAllReturn) { + newReceivePay = "0"; + } + action.setOldMoney(oldReceivePay); + action.setNewMoney(newReceivePay); if (bill.getStatus().intValue() == EnumBillStatus.WAIT_PAY.getCode().intValue() || bill.getStatus().intValue() == EnumBillStatus.NOT_PAID.getCode().intValue() || bill.getStatus().intValue() == EnumBillStatus.NOT_EXPIRED.getCode().intValue() || bill.getStatus().intValue() == EnumBillStatus.BAD.getCode().intValue()) { bill.setReceivePay(newReceivePay); bill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); action.setAction(EnumBillAction.UPDATE_BILL.getCode()); action.setDetails(EnumBillAction.UPDATE_BILL.getDescription(oldReceivePay, newReceivePay, null)); - action.setRemark("商户停用,停用日期["+endTimeStr+"],系统自动更新"); + action.setRemark("商户停用,停用日期["+endTimeStr+"],系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+EnumBillStatus.STOP_TO_SETTLE.getMessage()+"]"); isUpdate = true; }else if (bill.getStatus().intValue() == EnumBillStatus.PAID.getCode().intValue()) { bill.setReceivePay(newReceivePay); bill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); action.setAction(EnumBillAction.UPDATE_BILL.getCode()); action.setDetails(EnumBillAction.UPDATE_BILL.getDescription(oldReceivePay, newReceivePay, null)); - action.setRemark("商户停用,停用日期["+endTimeStr+"],系统自动更新"); + action.setRemark("商户停用,停用日期["+endTimeStr+"],系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+EnumBillStatus.STOP_TO_SETTLE.getMessage()+"]"); isUpdate = true; }else { //do nothing @@ -1019,11 +1034,44 @@ public class WxBillAllHelper { }else { if (bill.getStatus().intValue() == EnumBillStatus.WAIT_PAY.getCode().intValue() || bill.getStatus().intValue() == EnumBillStatus.NOT_PAID.getCode().intValue() || bill.getStatus().intValue() == EnumBillStatus.NOT_EXPIRED.getCode().intValue()) { - bill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); - action.setAction(EnumBillAction.STATUS_CHANGE.getCode()); - action.setDetails(EnumBillAction.STATUS_CHANGE.getDescription(null, null, null)+"商户停用,停用日期["+endTimeStr+"]"); - action.setRemark("系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+EnumBillStatus.STOP_TO_SETTLE.getMessage()+"]"); + if (isAllReturn) { + if (isPaid) { + bill.setReceivePay("0"); + bill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); + action.setOldMoney(oldReceivePay); + action.setNewMoney("0"); + action.setAction(EnumBillAction.UPDATE_BILL.getCode()); + action.setDetails(EnumBillAction.UPDATE_BILL.getDescription(oldReceivePay, "0", null)); + action.setRemark("商户停用,停用日期["+endTimeStr+"],系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+EnumBillStatus.STOP_TO_SETTLE.getMessage()+"]"); + }else { + bill.setReceivePay("0"); + bill.setStatus(EnumBillStatus.INVALID.getCode()); + action.setOldMoney(oldReceivePay); + action.setNewMoney("0"); + action.setAction(EnumBillAction.STATUS_CHANGE.getCode()); + action.setDetails(EnumBillAction.STATUS_CHANGE.getDescription(null, null, null)+"商户停用,停用日期["+endTimeStr+"]"); + action.setRemark("系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+EnumBillStatus.INVALID.getMessage()+"],应收金额变为0"); + } + }else { + bill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); + action.setOldMoney(oldReceivePay); + action.setNewMoney("0"); + action.setAction(EnumBillAction.STATUS_CHANGE.getCode()); + action.setDetails(EnumBillAction.STATUS_CHANGE.getDescription(null, null, null)+"商户停用,停用日期["+endTimeStr+"]"); + action.setRemark("系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+EnumBillStatus.STOP_TO_SETTLE.getMessage()+"]"); + } isUpdate = true; + }else if (bill.getStatus().intValue() == EnumBillStatus.PAID.getCode().intValue()) { + if (isAllReturn) { + bill.setReceivePay("0"); + bill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode()); + action.setOldMoney(oldReceivePay); + action.setNewMoney("0"); + action.setAction(EnumBillAction.UPDATE_BILL.getCode()); + action.setDetails(EnumBillAction.UPDATE_BILL.getDescription(oldReceivePay, "0", null)); + action.setRemark("商户停用,停用日期["+endTimeStr+"],系统自动由["+EnumBillStatus.getEnum(bill.getStatus()).getMessage()+"]变更为["+EnumBillStatus.STOP_TO_SETTLE.getMessage()+"]"); + isUpdate = true; + } }else { //do nothing } @@ -1031,14 +1079,38 @@ public class WxBillAllHelper { return isUpdate; } + private MallUserInfo getSystemUser(TenantEntity tenantEntity) { + MallUserInfo user = new MallUserInfo(); + user.updateTenantInfo(tenantEntity); + user.setId(Constant.SYS_SERVER); + user.setName("SYSTEM"); + user.setPhone("00000000000"); + return user; + } + //租赁合同终止, 租赁押金需全部退回,租金账单,营业管理费,商业管理费账单需重新计算。 - public void rentContractStop(WxRentContract rentContract) { + public void rentContractStop(WxRentContract rentContract,MallUserInfo user) { + if (null == user) { + user = getSystemUser(rentContract); + } + //根据合同查询租金账单,重新计算账单 + wxBillRentService.rentContractStop(rentContract, user); + //营业管理费/商业管理费 + wxBillRentManageService.rentContractStop(rentContract, user); + //租赁押金 + wxBillRentDepositService.rentContractStop(rentContract, user); } //物业合同终止,物业押金需全额退回,物业账单需重新计算 - public void propertyContractStop(WxPropertyContract propertyContract) { - + public void propertyContractStop(WxPropertyContract propertyContract,MallUserInfo user) { + if (null == user) { + user = getSystemUser(propertyContract); + } + //物业账单 + wxBillPropertyService.propertyContractStop(propertyContract, user); + //物业押金 + wxBillPropertyDepositService.propertyContractStop(propertyContract, user); } //终止商户除了租赁账单以外的 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillBaseService.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillBaseService.java index 3afa02ca3..a13db9d28 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillBaseService.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillBaseService.java @@ -53,4 +53,18 @@ public class WxBillBaseService{ wxBillActionService.modifyBill(wxBillAction, bUser); } + protected void addBillAction(WxBillAction wxBillAction, MallUserInfo mallUserInfo) { + //wxBillAction.setBillId(billId); + //wxBillAction.setBillType(billType); + //wxBillAction.setOldMoney(oldMoney); + //wxBillAction.setNewMoney(newMoney); + //wxBillAction.setDetails(billAction.getDescription(oldMoney, newMoney,payWay)); + //wxBillAction.setAction(billAction.getCode()); + //wxBillAction.setPayDate(payDate); + //wxBillAction.setPayWay(payWay); + //wxBillAction.setRemark(remark); + wxBillAction.setUserType(EnumSystemUserType.ADMIN.getCode()); + wxBillActionService.modifyBill(wxBillAction, mallUserInfo); + } + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java index ef147b9ea..7bb592b57 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillDepositServiceImpl.java @@ -39,6 +39,7 @@ import com.iformall.service.WxBillDepositService; import com.iformall.service.WxMerchantService; import com.iformall.service.WxPayAccountBillService; import com.iformall.service.WxShopService; +import com.iformall.service.helper.WxBillAllHelper; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; @@ -91,6 +92,10 @@ public class WxBillDepositServiceImpl extends WxBillBaseService implements WxBil @Autowired WxRentContractMapper wxRentContractMapper; + + @Lazy + @Autowired + WxBillAllHelper wxBillAllHelper; @Override public PageInfo listAsPage(WxBillDeposit record, Integer pageIndex, Integer pageSize) { @@ -568,4 +573,35 @@ public class WxBillDepositServiceImpl extends WxBillBaseService implements WxBil badMoney, badMoney,null,null,dto.getRemark(), user); } + @Override + public void rentContractStop(WxRentContract rentContract, MallUserInfo user) { + WxBillDeposit br = new WxBillDeposit(); + br.setRentContractId(rentContract.getId()); + br.updateTenantInfo(rentContract); + List brList = wxBillDepositMapper.findList(br); + List realRentList = new ArrayList(); + List actionList = new ArrayList(); + if (null != brList && brList.size() > 0 ) { + for (int i = 0 ; i < brList.size() ; i ++ ) { + WxBillDeposit brent = brList.get(i); + WxBillAction action = new WxBillAction(); + boolean isUpdate = wxBillAllHelper.billEndCalcute(rentContract.getDecimalSize(),rentContract.getEndContractTime(), brent, action, true); + if (isUpdate) { + realRentList.add(brent); + actionList.add(action); + } + } + } + + for (int i = 0 ; i < realRentList.size() ; i ++) { + WxBillDeposit rbrent = realRentList.get(i); + wxBillDepositMapper.updateById(rbrent); + } + + for (int i = 0 ; i < actionList.size() ; i ++) { + WxBillAction ba = actionList.get(i); + this.addBillAction(ba, user); + } + } + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java index 798d48798..f13903855 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyDepositServiceImpl.java @@ -12,6 +12,7 @@ import com.iformall.domain.dto.WxBillReceiveUpdateDTO; import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxBillAction; import com.iformall.domain.po.WxBillDeposit; +import com.iformall.domain.po.WxBillProperty; import com.iformall.domain.po.WxBillPropertyDeposit; import com.iformall.domain.po.WxBillRent; import com.iformall.domain.po.WxMerchant; @@ -38,6 +39,7 @@ import com.iformall.service.WxBillPropertyDepositService; import com.iformall.service.WxMerchantService; import com.iformall.service.WxPayAccountBillService; import com.iformall.service.WxShopService; +import com.iformall.service.helper.WxBillAllHelper; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; @@ -50,6 +52,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -84,6 +87,10 @@ public class WxBillPropertyDepositServiceImpl extends WxBillBaseService implemen @Autowired ExcelService excelService; + + @Lazy + @Autowired + WxBillAllHelper wxBillAllHelper; @Override public PageInfo listAsPage(WxBillPropertyDeposit record, Integer pageIndex, Integer pageSize) { @@ -547,5 +554,36 @@ public class WxBillPropertyDepositServiceImpl extends WxBillBaseService implemen badMoney, badMoney,null,null,dto.getRemark(), user); } + @Override + public void propertyContractStop(WxPropertyContract propertyContract, MallUserInfo user) { + WxBillPropertyDeposit br = new WxBillPropertyDeposit(); + br.setPropertyContractId(propertyContract.getId()); + br.updateTenantInfo(propertyContract); + List brList = wxBillPropertyDepositMapper.findList(br); + List realRentList = new ArrayList(); + List actionList = new ArrayList(); + if (null != brList && brList.size() > 0 ) { + for (int i = 0 ; i < brList.size() ; i ++ ) { + WxBillPropertyDeposit brent = brList.get(i); + WxBillAction action = new WxBillAction(); + boolean isUpdate = wxBillAllHelper.billEndCalcute(propertyContract.getDecimalSize(),propertyContract.getEndContractTime(), brent, action, true); + if (isUpdate) { + realRentList.add(brent); + actionList.add(action); + } + } + } + + for (int i = 0 ; i < realRentList.size() ; i ++) { + WxBillPropertyDeposit rbrent = realRentList.get(i); + wxBillPropertyDepositMapper.updateById(rbrent); + } + + for (int i = 0 ; i < actionList.size() ; i ++) { + WxBillAction ba = actionList.get(i); + this.addBillAction(ba, user); + } + } + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java index 97f4eeb94..9b45da5fe 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java @@ -22,6 +22,7 @@ import com.iformall.mapper.WxBillPropertyDepositMapper; import com.iformall.mapper.WxBillPropertyMapper; import com.iformall.mapper.WxPropertyContractMapper; import com.iformall.service.*; +import com.iformall.service.helper.WxBillAllHelper; import com.iformall.utils.DateUtils; import org.apache.commons.collections.CollectionUtils; @@ -76,6 +77,10 @@ public class WxBillPropertyServiceImpl extends WxBillBaseService implements WxBi @Lazy @Autowired WxShopService wxShopService; + + @Lazy + @Autowired + WxBillAllHelper wxBillAllHelper; @Override @@ -637,4 +642,35 @@ public class WxBillPropertyServiceImpl extends WxBillBaseService implements WxBi this.addBillAction(EnumBillAction.BAD, dto.getBillTypeValue(),dto.getId(), badMoney, badMoney,null,null,dto.getRemark(), user); } + + @Override + public void propertyContractStop(WxPropertyContract propertyContract, MallUserInfo user) { + WxBillProperty br = new WxBillProperty(); + br.setPropertyContractId(propertyContract.getId()); + br.updateTenantInfo(propertyContract); + List brList = wxBillPropertyMapper.findList(br); + List realRentList = new ArrayList(); + List actionList = new ArrayList(); + if (null != brList && brList.size() > 0 ) { + for (int i = 0 ; i < brList.size() ; i ++ ) { + WxBillProperty brent = brList.get(i); + WxBillAction action = new WxBillAction(); + boolean isUpdate = wxBillAllHelper.billEndCalcute(propertyContract.getDecimalSize() ,propertyContract.getEndContractTime(), brent, action, false); + if (isUpdate) { + realRentList.add(brent); + actionList.add(action); + } + } + } + + for (int i = 0 ; i < realRentList.size() ; i ++) { + WxBillProperty rbrent = realRentList.get(i); + wxBillPropertyMapper.updateById(rbrent); + } + + for (int i = 0 ; i < actionList.size() ; i ++) { + WxBillAction ba = actionList.get(i); + this.addBillAction(ba, user); + } + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentManageServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentManageServiceImpl.java index f11ea8bfd..51f124ce5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentManageServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentManageServiceImpl.java @@ -32,6 +32,7 @@ import com.iformall.service.WxBillActionService; import com.iformall.service.WxBillRentManageService; import com.iformall.service.WxMerchantService; import com.iformall.service.WxPayAccountBillService; +import com.iformall.service.helper.WxBillAllHelper; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; @@ -78,6 +79,10 @@ public class WxBillRentManageServiceImpl extends WxBillBaseService implements W @Autowired WxRentContractMapper wxRentContractMapper; + + @Lazy + @Autowired + WxBillAllHelper wxBillAllHelper; @Override public PageInfo listAsPage(WxBillRentManage wxBillRentManage, Integer pageIndex, Integer pageSize) { @@ -567,5 +572,37 @@ public class WxBillRentManageServiceImpl extends WxBillBaseService implements W this.addBillAction(EnumBillAction.BAD, dto.getBillTypeValue(),dto.getId(), badMoney, badMoney,null,null,dto.getRemark(), user); } + + @Override + public void rentContractStop(WxRentContract rentContract,MallUserInfo user) { + WxBillRentManage br = new WxBillRentManage(); + br.setRentContractId(rentContract.getId()); + br.updateTenantInfo(rentContract); + br.setIsPreview(EnumIsPreview.NO.getCode()); + List brList = wxBillRentManageMapper.findList(br); + List realRentList = new ArrayList(); + List actionList = new ArrayList(); + if (null != brList && brList.size() > 0 ) { + for (int i = 0 ; i < brList.size() ; i ++ ) { + WxBillRentManage brent = brList.get(i); + WxBillAction action = new WxBillAction(); + boolean isUpdate = wxBillAllHelper.billEndCalcute(rentContract.getDecimalSize(),rentContract.getEndContractTime(), brent, action, false); + if (isUpdate) { + realRentList.add(brent); + actionList.add(action); + } + } + } + + for (int i = 0 ; i < realRentList.size() ; i ++) { + WxBillRentManage rbrent = realRentList.get(i); + wxBillRentManageMapper.updateById(rbrent); + } + + for (int i = 0 ; i < actionList.size() ; i ++) { + WxBillAction ba = actionList.get(i); + this.addBillAction(ba, user); + } + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java index cda3a0f66..61069e79e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java @@ -19,6 +19,7 @@ import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; import com.iformall.service.*; +import com.iformall.service.helper.WxBillAllHelper; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; @@ -74,6 +75,10 @@ public class WxBillRentServiceImpl extends WxBillBaseService implements WxBillRe @Lazy @Autowired WxMerchantService wxMerchantService; + + @Lazy + @Autowired + WxBillAllHelper wxBillAllHelper; @Override public PageInfo listAsPage(WxBillRent record, Integer pageIndex, Integer pageSize) { @@ -733,17 +738,35 @@ public class WxBillRentServiceImpl extends WxBillBaseService implements WxBillRe } @Override - public void rentContractBillStop(WxRentContract rentContract) { - WxBillRent rq = new WxBillRent(); - rq.updateTenantInfo(rentContract); - rq.setRentContractId(rentContract.getId()); - - List rentList = wxBillRentMapper.findList(rq); - if (null != rentList) { - for (int i = 0 ; i < rentList.size() ; i ++) { - - } - } - + public void rentContractStop(WxRentContract rentContract,MallUserInfo user) { + WxBillRent br = new WxBillRent(); + br.setRentContractId(rentContract.getId()); + br.updateTenantInfo(rentContract); + br.setIsPreview(EnumYesOrNo.NO.getCode()); + List brList = wxBillRentMapper.findList(br); + List realRentList = new ArrayList(); + List actionList = new ArrayList(); + if (null != brList && brList.size() > 0 ) { + for (int i = 0 ; i < brList.size() ; i ++ ) { + WxBillRent brent = brList.get(i); + WxBillAction action = new WxBillAction(); + boolean isUpdate = wxBillAllHelper.billEndCalcute(rentContract.getDecimalSize(),rentContract.getEndContractTime(), brent, action, false); + if (isUpdate) { + realRentList.add(brent); + actionList.add(action); + } + } + } + + for (int i = 0 ; i < realRentList.size() ; i ++) { + WxBillRent rbrent = realRentList.get(i); + wxBillRentMapper.updateById(rbrent); + } + + for (int i = 0 ; i < actionList.size() ; i ++) { + WxBillAction ba = actionList.get(i); + this.addBillAction(ba, user); + } } + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java index 1bd9c4c43..a7da9b8d8 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -306,7 +306,7 @@ public class WxFlowServiceImpl implements WxFlowService { //终止租赁合同,同时终止物业合同 Integer endProperty = getIngeter(getVariableByKey(variables,"endProperty")); rent.setEndProperty(endProperty); - wxRentContractService.endContract(rent); + wxRentContractService.endContract(rent,null); } wxRentContractService.updateApplyStatus(rent); }else if(EnumFlowContractType.PROPERTY.getCode().equals(contractType) || EnumFlowContractType.PROPERTY_POINT.getCode().equals(contractType)){ @@ -319,7 +319,7 @@ public class WxFlowServiceImpl implements WxFlowService { wxPropertyContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); //账单失效 - wxPropertyContractService.endContract(wxPropertyContract); + wxPropertyContractService.endContract(wxPropertyContract,null); } wxPropertyContractMapper.updateApplyStatus(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 f695f385f..05254d0e6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -1113,14 +1113,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService } @Override - public void endContract(WxPropertyContract wxPropertyContract) { + public void endContract(WxPropertyContract wxPropertyContract,MallUserInfo userInfo) { wxPropertyContract.setStatus(EnumRentContractStatus.TERMINATE.getCode()); wxPropertyContractMapper.updateStatus(wxPropertyContract); // WxBillProperty wxBillProperty = new WxBillProperty(); // wxBillProperty.setPropertyContractId(wxPropertyContract.getId()); // wxBillPropertyMapper.updateInvalidStatus(wxBillProperty); - wxBillAllHelper.propertyContractStop(wxPropertyContract); + wxBillAllHelper.propertyContractStop(wxPropertyContract,userInfo); } @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 b3f917cc5..ba94b8908 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -545,7 +545,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { //创建预览账单 // List resultList = buildRent(null, record, EnumIsPreview.YES.getCode(),true); // record.setPreviewBillRentList(resultList); - EventUtil.publistRentEvent(this, record); + //EventUtil.publistRentEvent(this, record); return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record); } @@ -1784,7 +1784,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Transactional(rollbackFor = {Exception.class}) @Override - public ResultData endContract(WxRentContract wxRentContract) { + public ResultData endContract(WxRentContract wxRentContract,MallUserInfo userInfo) { WxRentContract contract = wxRentContractMapper.selectById(wxRentContract.getId()); if (contract == null) { @@ -1821,7 +1821,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxBillPropertyMapper.updateInvalidStatusByRent(wxRentContract); } //租赁账单失效 - wxBillAllHelper.rentContractStop(wxRentContract); + wxBillAllHelper.rentContractStop(wxRentContract,userInfo); // WxBillRent wxBillRent = new WxBillRent(); // wxBillRent.setRentContractId(wxRentContract.getId()); // wxBillRent.updateTenantInfo(wxRentContract); @@ -2001,7 +2001,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { wxRentContract.setStatus(EnumRentContractStatus.READY_FOR_PAING.getCode()); } wxRentContractMapper.updateById(wxRentContract); - EventUtil.publistRentEvent(this, wxRentContract); + //EventUtil.publistRentEvent(this, wxRentContract); //建立账单 //自定义账单无单价,为能生成账单,设置该值 if (EnumRentContractType.RENT_BY_CUSTOMIZE.getCode() == record.getType()) { @@ -2020,6 +2020,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { // WxMerchant wxMerchant = new WxMerchant(); // wxMerchant.setId(record.getMerchantId()); // wxMerchant.updateTenantInfo(record); + + //商业管理费,营业管理费 + WxBillRentManage billRentManage = new WxBillRentManage(); + billRentManage.setRentContractId(id); + billRentManage.setIsPreview(EnumIsPreview.NO.getCode()); + billRentManage.updateTenantInfo(record); + wxBillRentManageMapper.updatePreviewStatus(billRentManage); + if(new BigDecimal(record.getDeposit()).compareTo(new BigDecimal(0)) > 0) { //押金 buildDeposit( null, id); diff --git a/mallinkService/src/main/java/com/iformall/utils/Constant.java b/mallinkService/src/main/java/com/iformall/utils/Constant.java index c3b1b2783..d68764015 100644 --- a/mallinkService/src/main/java/com/iformall/utils/Constant.java +++ b/mallinkService/src/main/java/com/iformall/utils/Constant.java @@ -5,6 +5,7 @@ public class Constant { /** 系统管理员ID */ public static final Long SUPER_ADMIN = 1L; // 富茂超管 public static final String FM_SYS_ADMIN = "1"; // 富茂管理员 + public static final Long SYS_SERVER = 999L; //虚拟系统服务用户 public static final int SYS_MENU_MAX = 2000; // 系统菜单最大值 diff --git a/mallinkService/src/main/resources/mapper/WxBillRentManageMapper.xml b/mallinkService/src/main/resources/mapper/WxBillRentManageMapper.xml index 5100f9570..148e56de1 100644 --- a/mallinkService/src/main/resources/mapper/WxBillRentManageMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillRentManageMapper.xml @@ -16,6 +16,7 @@ + @@ -42,9 +43,9 @@ `id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,`last_owe_call_user`, - `createtime`,`expired_day`,`status`,`apply_status`,`apply_pay_img`,`apply_update_time`,`is_del`,`need_pay`,`last_owe_call_time`, - `merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`, - `period`,`shop_info`,`pay_way`,`late_pay_status`,starttime,endtime,freeze,service_charge_pay,manage_fee_type + `createtime`,`expired_day`,`status`,`apply_status`,`apply_pay_img`,`apply_update_time`,`is_del`,`is_preview`,`need_pay`, + `last_owe_call_time`,`merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`late_pay_ratio`,`late_pay_time`, + `late_pay_price`,`period`,`shop_info`,`pay_way`,`late_pay_status`,starttime,endtime,freeze,service_charge_pay,manage_fee_type @@ -65,6 +66,7 @@ and `expired_day` = #{expiredDay} and `status` = #{status} and `apply_status` = #{applyStatus} + and `is_preview` = #{isPreview} and `is_del` = #{isDel} and `need_pay` = #{needPay} and `merchant_id` = #{merchantId} @@ -114,7 +116,7 @@ - 1 = 1 + br.`is_preview` = 0 and br.`id` = #{id} and br.`tenant_id` = #{tenantId} and br.`parent_tenant_id` = #{parentTenantId} @@ -221,6 +223,10 @@ select #{billType} bill_type,#{billTypeName} bill_type_name,br.id as bill_id, br.starttime,br.endtime,br.receive_pay,br.pay,br.merchant_id from wx_bill_rent_manage br + + + update wx_bill_rent_manage set is_preview = #{isPreview} where rent_contract_id = #{rentContractId} +