|
@@ -244,10 +244,6 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
log.info("lockOrUnLockBySpace---cameraId:{},payStatus:{},totalSpace:{},useSpace{}",
|
|
log.info("lockOrUnLockBySpace---cameraId:{},payStatus:{},totalSpace:{},useSpace{}",
|
|
cameraId,payStatus,totalSpace,cameraDetail.getUsedSpace());
|
|
cameraId,payStatus,totalSpace,cameraDetail.getUsedSpace());
|
|
if(payStatus == 1){ //解封,判断用户权益,用户会员权益无限容量
|
|
if(payStatus == 1){ //解封,判断用户权益,用户会员权益无限容量
|
|
- if (totalSpace != -1 && totalSpace <= cameraDetail.getUsedSpace()) {
|
|
|
|
- // 总容量小于已使用容量,不予解封
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
wrapper.orderByAsc(ScenePro::getCreateTime);
|
|
wrapper.orderByAsc(ScenePro::getCreateTime);
|
|
plusWr.orderByAsc(ScenePlus::getCreateTime);
|
|
plusWr.orderByAsc(ScenePlus::getCreateTime);
|
|
wrapper.eq(ScenePro::getPayStatus,-2);
|
|
wrapper.eq(ScenePro::getPayStatus,-2);
|
|
@@ -271,20 +267,26 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
List<ScenePro> list = this.list(wrapper);
|
|
List<ScenePro> list = this.list(wrapper);
|
|
List<ScenePlus> plusList = scenePlusService.list(plusWr);
|
|
List<ScenePlus> plusList = scenePlusService.list(plusWr);
|
|
|
|
|
|
- Long beyondSpace = Math.abs(cameraDetail.getUsedSpace() - totalSpace);
|
|
|
|
- if(totalSpace == -1){
|
|
|
|
- beyondSpace = Long.MAX_VALUE;
|
|
|
|
|
|
+ List<Long> lockedIds = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ if(totalSpace == -1 && payStatus == 1){
|
|
|
|
+ List<Long> collect = list.stream().map(ScenePro::getId).collect(Collectors.toList());
|
|
|
|
+ List<Long> collect2 = plusList.stream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
|
|
+ lockedIds.addAll(collect);
|
|
|
|
+ lockedIds.addAll(collect2);
|
|
|
|
+ lockOrUnLockScenes(lockedIds,payStatus); // 无限容量 全部解封
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Long beyondSpace = 0L;
|
|
Long accumulateSpace = 0L;
|
|
Long accumulateSpace = 0L;
|
|
- List<Long> lockedIds = new ArrayList<>();
|
|
|
|
if(payStatus == 1){
|
|
if(payStatus == 1){
|
|
- Long doSpace = getScenePlusLockedIds(lockedIds, plusList, beyondSpace, accumulateSpace);
|
|
|
|
- beyondSpace -= doSpace;
|
|
|
|
|
|
+ beyondSpace = totalSpace - cameraDetail.getTotalSpace();
|
|
|
|
+ getScenePlusLockedIds(lockedIds, plusList, beyondSpace, accumulateSpace);
|
|
getSceneLockedIds(lockedIds,list,beyondSpace,accumulateSpace);
|
|
getSceneLockedIds(lockedIds,list,beyondSpace,accumulateSpace);
|
|
}else {
|
|
}else {
|
|
- Long doSpace = getSceneLockedIds(lockedIds, list, beyondSpace, accumulateSpace);
|
|
|
|
- beyondSpace -= doSpace;
|
|
|
|
|
|
+ beyondSpace = cameraDetail.getUsedSpace() - totalSpace;
|
|
|
|
+ getSceneLockedIds(lockedIds, list, beyondSpace, accumulateSpace);
|
|
getScenePlusLockedIds(lockedIds,plusList,beyondSpace,accumulateSpace);
|
|
getScenePlusLockedIds(lockedIds,plusList,beyondSpace,accumulateSpace);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -293,19 +295,18 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- private Long getSceneLockedIds(List<Long> lockedIds ,List<ScenePro> list,Long beyondSpace,Long accumulateSpace){
|
|
|
|
|
|
+ private void getSceneLockedIds(List<Long> lockedIds ,List<ScenePro> list,Long beyondSpace,Long accumulateSpace){
|
|
if (list != null && list.size() > 0){
|
|
if (list != null && list.size() > 0){
|
|
for (ScenePro scenePro : list){
|
|
for (ScenePro scenePro : list){
|
|
accumulateSpace += scenePro.getSpace();
|
|
accumulateSpace += scenePro.getSpace();
|
|
if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
- return accumulateSpace - scenePro.getSpace();
|
|
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
lockedIds.add(scenePro.getId());
|
|
lockedIds.add(scenePro.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return accumulateSpace;
|
|
|
|
}
|
|
}
|
|
- private Long getScenePlusLockedIds(List<Long> lockedIds , List<ScenePlus> list, Long beyondSpace, Long accumulateSpace){
|
|
|
|
|
|
+ private void getScenePlusLockedIds(List<Long> lockedIds , List<ScenePlus> list, Long beyondSpace, Long accumulateSpace){
|
|
if (list != null && list.size() > 0){
|
|
if (list != null && list.size() > 0){
|
|
List<Long> plusIds = list.parallelStream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
List<Long> plusIds = list.parallelStream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
HashMap<Long, ScenePlusExt> byPlusIds = scenePlusExtService.getByPlusIds(plusIds);
|
|
HashMap<Long, ScenePlusExt> byPlusIds = scenePlusExtService.getByPlusIds(plusIds);
|
|
@@ -313,12 +314,11 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
ScenePlusExt scenePlusExt = byPlusIds.get(scenePlus.getId());
|
|
ScenePlusExt scenePlusExt = byPlusIds.get(scenePlus.getId());
|
|
accumulateSpace += scenePlusExt.getSpace();
|
|
accumulateSpace += scenePlusExt.getSpace();
|
|
if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
- return accumulateSpace - scenePlusExt.getSpace();
|
|
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
lockedIds.add(scenePlus.getId());
|
|
lockedIds.add(scenePlus.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return accumulateSpace;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|