Przeglądaj źródła

封存解封相机容量

lyhzzz 2 lat temu
rodzic
commit
921e556ae6

+ 2 - 0
src/main/java/com/fdkankan/ucenter/service/ICameraDetailService.java

@@ -44,4 +44,6 @@ public interface ICameraDetailService extends IService<CameraDetail> {
     void uploadUserCameraInfo(Long id, String cameraVersion, String appVersion);
 
     List<CameraExcelVo> getListByUserAndTypeEx(Long cameraId);
+
+    void updateSpaceByCameraId(Long cameraId, Long cameraDetailSpace);
 }

+ 8 - 0
src/main/java/com/fdkankan/ucenter/service/impl/CameraDetailServiceImpl.java

@@ -206,4 +206,12 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
     public List<CameraExcelVo> getListByUserAndTypeEx(Long userId) {
         return this.getBaseMapper().getListByUserAndTypeEx(userId);
     }
+
+    @Override
+    public void updateSpaceByCameraId(Long cameraId, Long cameraDetailSpace) {
+        LambdaUpdateWrapper<CameraDetail> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(CameraDetail::getCameraId,cameraId)
+                .set(CameraDetail::getUsedSpace,cameraDetailSpace);
+        this.update(wrapper);
+    }
 }

+ 10 - 3
src/main/java/com/fdkankan/ucenter/service/impl/SceneProServiceImpl.java

@@ -278,18 +278,23 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         List<Long> lockedIds = new ArrayList<>();
         Long beyondSpace =  0L;
         Long accumulateSpace = 0L;
+        Long cameraDetailSpace = 0L;
         if(payStatus == 1){ //解封
             beyondSpace =  totalSpace - usedSpace;
-            getSceneLockedIds(lockedIds,sceneVos,beyondSpace,accumulateSpace);
+            Long space = getSceneLockedIds(lockedIds, sceneVos, beyondSpace, accumulateSpace);
+            cameraDetailSpace  = usedSpace + space;
         }else {
             beyondSpace =  usedSpace - totalSpace;
             Collections.reverse(sceneVos);
-            getSceneLockedIds(lockedIds,sceneVos, beyondSpace, accumulateSpace);
+            Long space = getSceneLockedIds(lockedIds,sceneVos, beyondSpace, accumulateSpace);
+            cameraDetailSpace  = usedSpace -space;
         }
+        cameraDetailService.updateSpaceByCameraId(cameraId,cameraDetailSpace);
         lockOrUnLockScenes(lockedIds,payStatus);
     }
 
-    private void getSceneLockedIds(List<Long> lockedIds ,List<SimpleSceneVo> list,Long beyondSpace,Long accumulateSpace){
+    private Long getSceneLockedIds(List<Long> lockedIds ,List<SimpleSceneVo> list,Long beyondSpace,Long accumulateSpace){
+        Long space = 0L;
         if (list != null && list.size() > 0){
             for (SimpleSceneVo scenePro : list){
                 if(scenePro.getSpace() > beyondSpace){
@@ -299,9 +304,11 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
                 if (accumulateSpace > beyondSpace){
                     break;
                 }
+                space += scenePro.getSpace();
                 lockedIds.add(scenePro.getId());
             }
         }
+        return space;
     }