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 8c5f3d466..9b331e5f6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -13,7 +13,10 @@ import com.iformall.domain.po.*; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; -import com.iformall.service.*; +import com.iformall.service.WxFlowRecordService; +import com.iformall.service.WxFlowService; +import com.iformall.service.WxMerchantService; +import com.iformall.service.WxRentContractService; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; import org.apache.commons.collections.map.HashedMap; @@ -30,6 +33,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; @@ -605,6 +609,46 @@ public class WxRentContractServiceImpl implements WxRentContractService { record.setStatus(EnumRentContractStatus.INVALID.getCode()); wxRentContractMapper.updateRentInvalidStatus(record); } + updateInvalidStatus(wxRentContract); + } + + public void updateInvalidStatus(WxRentContract wxRentContract) { + WxRentContract record = new WxRentContract(); + record.setTenantId(wxRentContract.getTenantId()); + record.setStatus(EnumRentContractStatus.INVALID.getCode()); + //审核流程中止 + List collect = wxRentContractMapper.select(record).stream() + .map(r -> r.getId()).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(collect)) { + for (Long id : collect) { + try { + logger.info("合同id:{},开始停止...", id); + //结束审批流 by luozukai + List tasks = taskService.createTaskQuery().processDefinitionKey(WxFlowServiceImpl.getFlowKeyByType(1)) + .processVariableValueEquals("businessId", id).list(); + if (!CollectionUtils.isEmpty(tasks)) { + for (Task task : tasks) { + logger.info("合同id:{},taskid:{}", id, task.getId()); + runtimeService.deleteProcessInstance(task.getProcessInstanceId(), "合同作废"); + } + } + // 修改合同审核状态 + WxRentContract rentContract = record; + rentContract.setId(id); + rentContract.setApplyStatus(EnumRentContractAppStatus.CANCLE.getCode()); + updateApplyStatus(rentContract); + + // 保存审批历史入 + WxFlowRecord updateRecord = new WxFlowRecord(); + updateRecord.setBusinessId(id); + updateRecord.setStatus(EnumFlowRecordStatus.CANCLE.getCode()); + updateRecord.setBusinessType(1); + wxFlowRecordService.saveOrUpdate(updateRecord); + } catch (Exception e) { + logger.error("deleteProcessInstance error", e); + } + } + } } @Override @@ -1040,40 +1084,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { int allCount = wxRentContractMapper.selectCount(wxRentContract); resultData.put("allCount", allCount); - //审核流程中止 - List collect = wxRentContractMapper.getRentInvalidList(wxRentContract).stream() - .map(r -> r.getId()).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(collect)) { - for (Long id:collect) { - try { - logger.info("合同id:{},开始停止...",id); - //结束审批流 by luozukai - List tasks = taskService.createTaskQuery().processDefinitionKey(WxFlowServiceImpl.getFlowKeyByType(1)) - .processVariableValueEquals("businessId",id).list(); - if (!CollectionUtils.isEmpty(tasks)) { - for (Task task:tasks) { - logger.info("合同id:{},taskid:{}",id,task.getId()); - runtimeService.deleteProcessInstance(task.getProcessInstanceId(), "合同作废"); - } - } - // 修改合同审核状态 - WxRentContract rentContract = new WxRentContract(); - rentContract.setId(id); - rentContract.setApplyStatus(EnumRentContractAppStatus.CANCLE.getCode()); - updateApplyStatus(rentContract); - - // 保存审批历史入 - WxFlowRecord updateRecord = new WxFlowRecord(); - updateRecord.setBusinessId(id); - updateRecord.setStatus(EnumFlowRecordStatus.CANCLE.getCode()); - updateRecord.setBusinessType(1); - wxFlowRecordService.saveOrUpdate(updateRecord); - }catch (Exception e){ - logger.error("deleteProcessInstance error",e); - } - } - } - //待签约 wxRentContract.setStatus(EnumRentContractStatus.WAIT_SIGN.getCode()); int waitSignCount = wxRentContractMapper.queryRentContractWaitSignStatus(wxRentContract); diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 74cddb199..871c498b3 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -214,7 +214,7 @@ resultType="com.iformall.domain.po.WxRentContract"> select id from wx_rent_contract where shop_id in ( select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE tenant_id = #{tenantId} and status in(2,3,4) - )s) and status in(0,1) and status!=7 and tenant_id=#{tenantId} + )s) and status in(0,1) and status!=7 and tenant_id=#{tenantId} and apply_status=1