diff --git a/pom.xml b/pom.xml index 6d6c306..2954025 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ mysql mysql-connector-java - 5.1.49 + 8.0.26 runtime diff --git a/src/main/java/com/lh/mapper/CrowdfundingMapper.java b/src/main/java/com/lh/mapper/CrowdfundingMapper.java index 31a3136..9f22d46 100644 --- a/src/main/java/com/lh/mapper/CrowdfundingMapper.java +++ b/src/main/java/com/lh/mapper/CrowdfundingMapper.java @@ -19,6 +19,8 @@ public interface CrowdfundingMapper { //当前众筹数量+1 void updateNowNumber(); + //当前众筹数量-1 + void updateMinusNowNumber(); //修改状态 void updateStatus(Integer status); diff --git a/src/main/java/com/lh/service/CrowdfundingServiceImpl.java b/src/main/java/com/lh/service/CrowdfundingServiceImpl.java index 1916d36..1e4121b 100644 --- a/src/main/java/com/lh/service/CrowdfundingServiceImpl.java +++ b/src/main/java/com/lh/service/CrowdfundingServiceImpl.java @@ -15,12 +15,15 @@ public class CrowdfundingServiceImpl implements CrowdfundingService { @Autowired private CrowdfundingMapper crowdfundingMapper; @Override + @Transactional(rollbackFor = Exception.class) public CrowdfundingInfo loadPage() { - CrowdfundingInfo crowdfundingInfoList = crowdfundingMapper.loadPage(); - //如果当前进度大于等于目标人数,将status变更为0 - if (crowdfundingInfoList != null && crowdfundingInfoList.getNowNumber() >= crowdfundingInfoList.getTargetNumber()) { + CrowdfundingInfo crowdfundingInfoList1 = crowdfundingMapper.loadPage(); + if (crowdfundingInfoList1 != null && crowdfundingInfoList1.getNowNumber() >= crowdfundingInfoList1.getTargetNumber()) { + crowdfundingMapper.updateStatus(1); + }else { crowdfundingMapper.updateStatus(0); } + CrowdfundingInfo crowdfundingInfoList = crowdfundingMapper.loadPage(); List participants = crowdfundingMapper.queryCrowdUser(null); if (crowdfundingInfoList != null) { crowdfundingInfoList.setParticipantList(participants); @@ -79,6 +82,7 @@ public class CrowdfundingServiceImpl implements CrowdfundingService { } @Override + @Transactional(rollbackFor = Exception.class) public void deleteCrowdUser(String jwcode) throws MyException { if (CollectionUtils.isEmpty(crowdfundingMapper.queryCrowdUser(new Participant(null,jwcode,null,null)))) { throw new MyException("删除失败,用户不存在"); @@ -86,6 +90,7 @@ public class CrowdfundingServiceImpl implements CrowdfundingService { List participants = crowdfundingMapper.queryCrowdUser(new Participant(null, jwcode, null, null)); Participant participant = participants.get(0); crowdfundingMapper.saveDeleteCrowdUser(participant); + crowdfundingMapper.updateMinusNowNumber(); crowdfundingMapper.deleteCrowdUser(jwcode); } diff --git a/src/main/resources/com/lh/mapper/CrowdfundingMapper.xml b/src/main/resources/com/lh/mapper/CrowdfundingMapper.xml index d78b394..98a62d2 100644 --- a/src/main/resources/com/lh/mapper/CrowdfundingMapper.xml +++ b/src/main/resources/com/lh/mapper/CrowdfundingMapper.xml @@ -19,6 +19,9 @@ update crowdfundinginfo set status=#{status} + + update crowdfundinginfo set now_number=now_number-1 + delete from participants where jwcode=#{jwcode}