|
@@ -47,6 +47,7 @@ import com.sun.org.apache.xpath.internal.operations.Plus;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.bouncycastle.asn1.bc.ObjectStoreData;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -846,24 +847,44 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
|
|
|
}
|
|
|
|
|
|
private int getPayStatus(Long cameraId, Long space){
|
|
|
- //更新相机使用用量
|
|
|
- CameraDetail cameraDetail = cameraDetailService.updateCameraDetailByCameraIdAndSpace(cameraId, space);
|
|
|
- Long totalSpace = cameraDetail.getTotalSpace();
|
|
|
+
|
|
|
+ //查询权益统计容量的方式
|
|
|
+ String unit = SpaceType.GB.code();
|
|
|
+ CameraDetail cameraDetail = cameraDetailService.getByCameraId(cameraId);
|
|
|
+ if(StrUtil.isNotEmpty(cameraDetail.getUnit())){
|
|
|
+ unit = cameraDetail.getUnit();
|
|
|
+ }
|
|
|
+ Long limit = cameraDetail.getTotalSpace();
|
|
|
|
|
|
UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
|
|
|
- if(!ObjectUtils.isEmpty(userIncrement) && userIncrement.getIsExpired().equals(ExpiredStatus.NOT_EXPIRED.code())){
|
|
|
- IncrementType type = incrementTypeService.getById(userIncrement.getIncrementTypeId());
|
|
|
- if(type != null){
|
|
|
- Integer cameraCapacity = type.getCameraCapacity();
|
|
|
- if(cameraCapacity == -1){ //无限容量权益
|
|
|
- return PayStatus.PAY.code();
|
|
|
- }else {
|
|
|
- totalSpace = cameraCapacity *1024 * 1024 * 1024L; //权益设置容量
|
|
|
- }
|
|
|
+ if(Objects.nonNull(userIncrement)){
|
|
|
+ IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
|
|
|
+ switch (SpaceType.get(unit)){
|
|
|
+ case GB:
|
|
|
+ limit = incrementType.getCameraCapacity();
|
|
|
+ if(limit != -1){
|
|
|
+ limit = limit * 1024 * 1024 * 1024;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SP:
|
|
|
+ limit = incrementType.getCameraSpace();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ if(SpaceType.SP.code().equals(unit)){//如果按空间方式统计,则space置为1
|
|
|
+ space = 1L;
|
|
|
+ }
|
|
|
|
|
|
- return totalSpace.compareTo(cameraDetail.getUsedSpace()) == -1 ? PayStatus.NO_CAPACITY.code() : PayStatus.PAY.code();
|
|
|
+ //更新相机使用用量
|
|
|
+ cameraDetail = cameraDetailService.updateCameraDetailByCameraIdAndSpace(cameraId, space);
|
|
|
+ if(limit == -1){
|
|
|
+ return PayStatus.PAY.code();
|
|
|
+ }
|
|
|
+ Long usedSpace = cameraDetail.getUsedSpace();
|
|
|
+ if(usedSpace < limit){
|
|
|
+ return PayStatus.NOT_PAY.code();
|
|
|
+ }
|
|
|
+ return PayStatus.PAY.code();
|
|
|
}
|
|
|
|
|
|
private Object[] updateEditInfo(ScenePlus scenePlus){
|