diff --git a/mallinkAdmin/src/main/resources/processes/endBillflow.bpmn20.xml b/mallinkAdmin/src/main/resources/processes/endBillflow.bpmn20.xml index 1d756edd8..e44520472 100644 --- a/mallinkAdmin/src/main/resources/processes/endBillflow.bpmn20.xml +++ b/mallinkAdmin/src/main/resources/processes/endBillflow.bpmn20.xml @@ -1,7 +1,7 @@ - 终止合同审批流程 + 账单审批流程 初审 diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxBillAction.java b/mallinkService/src/main/java/com/iformall/domain/po/WxBillAction.java index ac7fcebbe..c856cd0e2 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxBillAction.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxBillAction.java @@ -70,6 +70,28 @@ public class WxBillAction implements Serializable { @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updatetime") private Date updatetime; + @Transient + private Integer oldPrice; + + @Transient + private Integer newPrice; + + public Integer getOldPrice() { + return oldPrice; + } + + public void setOldPrice(Integer oldPrice) { + this.oldPrice = oldPrice; + } + + public Integer getNewPrice() { + return newPrice; + } + + public void setNewPrice(Integer newPrice) { + this.newPrice = newPrice; + } + public String getTenantId() { return tenantId; } diff --git a/mallinkService/src/main/java/com/iformall/service/WxBillActionService.java b/mallinkService/src/main/java/com/iformall/service/WxBillActionService.java index 6a96d2a76..f6bc6777d 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxBillActionService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxBillActionService.java @@ -1,6 +1,7 @@ package com.iformall.service; import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxBillAction; /** @@ -12,4 +13,6 @@ public interface WxBillActionService { int save(WxBillAction action); + int modifyBill(WxBillAction wxBillAction, MallUserInfo mallUserInfo); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillActionServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillActionServiceImpl.java index 8aaca8106..46924591b 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillActionServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillActionServiceImpl.java @@ -3,7 +3,9 @@ package com.iformall.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.iformall.common.IdWorker; +import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.WxBillAction; +import com.iformall.enums.EnumBillAction; import com.iformall.mapper.WxBillActionMapper; import com.iformall.service.WxBillActionService; import org.slf4j.Logger; @@ -11,6 +13,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.Date; /** @@ -38,4 +41,26 @@ public class WxBillActionServiceImpl implements WxBillActionService { action.setUpdatetime(date); return wxBillActionMapper.insertSelective(action); } + + + @Override + public int modifyBill(WxBillAction action, MallUserInfo user) { + final IdWorker idWorker = IdWorker.get(); + WxBillAction wxBillAction = new WxBillAction(); + wxBillAction.setId(idWorker.nextId()); + wxBillAction.setBillId(action.getBillId()); + String oldPrice = new BigDecimal(action.getOldPrice()).divide(new BigDecimal(100)).toPlainString(); + String newPrice = new BigDecimal(action.getOldPrice()).divide(new BigDecimal(100)).toPlainString(); + wxBillAction.setDetails(oldPrice + "元变更成" + newPrice + "元"); + wxBillAction.setAction(EnumBillAction.UPDATE_BILL.getCode()); + wxBillAction.setUserId(user.getId()); + wxBillAction.setUserName(user.getName()); + wxBillAction.setPhone(user.getPhone()); + wxBillAction.setTenantId(user.getTenantId()); + Date date = new Date(); + action.setCreatetime(date); + action.setUpdatetime(date); + return wxBillActionMapper.insertSelective(action); + } + } 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 3c21b0625..a6ebc7065 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -1,8 +1,5 @@ package com.iformall.service.impl; -import java.lang.reflect.Field; -import java.text.SimpleDateFormat; -import java.util.*; import com.alibaba.druid.support.json.JSONUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -21,6 +18,7 @@ import com.iformall.utils.Constant; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.map.HashedMap; import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; import org.flowable.bpmn.model.BpmnModel; import org.flowable.engine.*; import org.flowable.engine.runtime.Execution; @@ -35,9 +33,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; + import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.io.OutputStream; +import java.lang.reflect.Field; +import java.text.SimpleDateFormat; +import java.util.*; /** * @author luozukai @@ -76,6 +78,18 @@ public class WxFlowServiceImpl implements WxFlowService { private WxMerchantService wxMerchantService; @Autowired private MqBaseProducer mqBaseProducer; + @Autowired + private WxBillActionService wxBillActionService; + @Autowired + private WxBillPropertyDepositMapper wxBillPropertyDepositMapper; + @Autowired + private WxBillDepositMapper wxBillDepositMapper; + @Autowired + private WxBillDailyMapper wxBillDailyMapper; + @Autowired + private WxBillOtherMapper wxBillOtherMapper; + @Autowired + private WxBillOtherDepositMapper wxBillOtherDepositMapper; /** * 获取流程key,1合同 2账单 @@ -181,14 +195,100 @@ public class WxFlowServiceImpl implements WxFlowService { } wxPropertyContractMapper.updateApplyStatus(wxPropertyContract); } - }else if(2 == flowType){ //账单审批 + } else if (2 == flowType) { if(EnumRentContractAppStatus.FINISH.getCode().intValue() == applyStatus.intValue()) { - //todo:审批完成 - + //账单审批 + Integer billType = (Integer) getVariableByKey(variables, "billType"); + Integer oldPrice = (Integer) getVariableByKey(variables, "oldPrice"); + Integer newPrice = (Integer) getVariableByKey(variables, "newPrice"); + Date updateDate = new Date(); + MallUserInfo mallUserInfo = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute("userSession"); + if (billType.equals(EnumBillTypeParam.RENT.getCode())) { + //租赁账单更新 + WxBillRent wxBillRent = new WxBillRent(); + wxBillRent.setId(businessId); + wxBillRent.setReceivePay(newPrice); + wxBillRent.setUpdatetime(updateDate); + wxBillRentMapper.updateByPrimaryKeySelective(wxBillRent); + //账单日志 + addBillAction(oldPrice, newPrice, mallUserInfo); + } else if (billType.equals(EnumBillTypeParam.RENT_DEPOSIT.getCode())) { + //租赁押金账单更新 + WxBillDeposit wxBillDeposit = new WxBillDeposit(); + wxBillDeposit.setId(businessId); + wxBillDeposit.setReceivePay(newPrice); + wxBillDeposit.setUpdatetime(updateDate); + wxBillDepositMapper.updateByPrimaryKeySelective(wxBillDeposit); + //账单日志 + addBillAction(oldPrice, newPrice, mallUserInfo); + } else if (billType.equals(EnumBillTypeParam.PROPERTY.getCode())) { + //物业账单更新 + WxBillProperty wxBillProperty = new WxBillProperty(); + wxBillProperty.setId(businessId); + wxBillProperty.setReceivePay(newPrice); + wxBillProperty.setUpdatetime(updateDate); + wxBillPropertyMapper.updateByPrimaryKeySelective(wxBillProperty); + //账单日志 + addBillAction(oldPrice, newPrice, mallUserInfo); + } else if (billType.equals(EnumBillTypeParam.PROPERTY_DEPOSIT.getCode())) { + //物业押金账单更新 + WxBillPropertyDeposit wxBillPropertyDeposit = new WxBillPropertyDeposit(); + wxBillPropertyDeposit.setId(businessId); + wxBillPropertyDeposit.setReceivePay(newPrice); + wxBillPropertyDeposit.setUpdatetime(updateDate); + wxBillPropertyDepositMapper.updateByPrimaryKeySelective(wxBillPropertyDeposit); + //账单日志 + addBillAction(oldPrice, newPrice, mallUserInfo); + } else if (billType.equals(EnumBillTypeParam.WATER.getCode())) { + //水费账单更新 + updateDailyBill(businessId, newPrice, updateDate); + //账单日志 + addBillAction(oldPrice, newPrice, mallUserInfo); + } else if (billType.equals(EnumBillTypeParam.POWER.getCode())) { + //电费账单更新 + updateDailyBill(businessId, newPrice, updateDate); + //账单日志 + addBillAction(oldPrice, newPrice, mallUserInfo); + } else if (billType.equals(EnumBillTypeParam.ROUTINE.getCode())) { + //其他费用账单更新 + WxBillOther wxBillOther = new WxBillOther(); + wxBillOther.setId(businessId); + wxBillOther.setReceivePay(newPrice); + wxBillOther.setUpdatetime(updateDate); + wxBillOtherMapper.updateByPrimaryKeySelective(wxBillOther); + //账单日志 + addBillAction(oldPrice, newPrice, mallUserInfo); + } else if (billType.equals(EnumBillTypeParam.ATHER_DEPOSIT.getCode())) { + //其他押金账单更新 + WxBillOtherDeposit wxBillOtherDeposit = new WxBillOtherDeposit(); + wxBillOtherDeposit.setId(businessId); + wxBillOtherDeposit.setReceivePay(newPrice); + wxBillOtherDeposit.setUpdatetime(updateDate); + wxBillOtherDepositMapper.updateByPrimaryKeySelective(wxBillOtherDeposit); + //账单日志 + addBillAction(oldPrice, newPrice, mallUserInfo); + } else { + logger.info("未找到账单类型"); + } } } } + public void updateDailyBill(Long businessId, Integer newPrice, Date updateDate) { + WxBillDaily wxBillDaily = new WxBillDaily(); + wxBillDaily.setId(businessId); + wxBillDaily.setReceivePay(newPrice); + wxBillDaily.setUpdatetime(updateDate); + wxBillDailyMapper.updateByPrimaryKeySelective(wxBillDaily); + } + + public void addBillAction(Integer oldPrice, Integer newPrice, MallUserInfo mallUserInfo) { + WxBillAction wxBillAction = new WxBillAction(); + wxBillAction.setOldPrice(oldPrice); + wxBillAction.setNewPrice(newPrice); + wxBillActionService.modifyBill(wxBillAction, mallUserInfo); + } + public Map mallUserInfoToMap(MallUserInfo userInfo){ try { Map map = new HashMap<>(); @@ -224,7 +324,7 @@ public class WxFlowServiceImpl implements WxFlowService { // map info,设置发起人等信息 MallUserInfo starterInfo = this.mallUserInfoService.getById(userId); map.put("starter", mallUserInfoToMap(starterInfo)); - map.put("startTime",new Date().getTime()); + map.put("startTime", System.currentTimeMillis()); map.put("businessId",businessId+""); map.put("flowType",flowType); map.put("taskAssignee",taskAssignee); @@ -907,5 +1007,4 @@ public class WxFlowServiceImpl implements WxFlowService { } - }