diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java index 875bfa1c0..b731aada9 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java @@ -52,4 +52,6 @@ public interface WxRentContractMapper extends CommonMapper void updateInvalidContract(WxRentContract record); List selectRentContractByMerchantId(WxRentContract wxRentContract); + + List selectRentContractByShopId(WxRentContract record); } 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 45b29a9cd..3d20fa73f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -622,6 +622,10 @@ public class WxRentContractServiceImpl implements WxRentContractService { record.setTenantId(wxRentContract.getTenantId()); record.setStatus(EnumRentContractStatus.INVALID.getCode()); wxRentContractMapper.updateInvalidContract(record); + List rentContractList = wxRentContractMapper.selectRentContractByShopId(record); + for (WxRentContract updateContract : rentContractList) { + updateInvalidStatus(updateContract); + } } } else { WxRentContract record = new WxRentContract(); @@ -629,8 +633,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { record.setRentShopType(wxRentContract.getRentShopType()); record.setStatus(EnumRentContractStatus.INVALID.getCode()); wxRentContractMapper.updateRentInvalidStatus(record); + List rentContractList = wxRentContractMapper.select(record); + for (WxRentContract updateContract : rentContractList) { + updateInvalidStatus(updateContract); + } } - updateInvalidStatus(wxRentContract); + } @Override @@ -660,42 +668,34 @@ public class WxRentContractServiceImpl implements WxRentContractService { return new ResultData(Result.SUCCESS, "操作成功"); } - public void updateInvalidStatus(WxRentContract wxRentContract) { - WxRentContract record = new WxRentContract(); - record.setTenantId(wxRentContract.getTenantId()); - record.setStatus(EnumRentContractStatus.INVALID.getCode()); + public void updateInvalidStatus(WxRentContract record) { + Long id = record.getId(); //审核流程中止 - 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); + 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); } } diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 7453c3f99..e43336c0d 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -235,6 +235,11 @@ select count(*) from wx_rent_contract where tenant_id=#{tenantId} and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and status in (2,3,4) + + update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and id in(select r.id from ( select id from wx_rent_contract where json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"'))