This commit is contained in:
张良(004796)
2024-03-07 17:07:31 +08:00
parent 0a1b918738
commit bda5acb21b

View File

@@ -147,20 +147,24 @@ public class RoomService {
public Long canCallTime(Room room) { public Long canCallTime(Room room) {
try { try {
Long callId = room.getCallUserData().getId(); Long userId = room.getCallUserData().getId();
Account account = accountService.getByUserId(callId); Account account = accountService.getByUserId(userId);
if(account == null){ if(account == null){
return 0L; return 0L;
} }
RoomData roomData = room.getRoomData(); RoomData roomData = room.getRoomData();
long blockAmount = roomData.getPayCoin() + roomData.getPayIncome(); long blockAmount = roomData.getPayCoin() + roomData.getPayIncome();
long totalAmount = account.getCoin()+account.getIncomeCoin() + blockAmount; long totalAmount = account.getCoin()+account.getIncomeCoin() + blockAmount;
long totalSecond = (totalAmount / roomData.getCallPrice()) / 60; long totalSecond = (totalAmount / roomData.getCallPrice()) * 60;
long useTime = 0; long useTime = 0;
if(roomData.getBeginTime() != null){ if(roomData.getBeginTime() != null){
useTime = DateUtil.currentSeconds() - roomData.getBeginTime(); useTime = DateUtil.currentSeconds() - roomData.getBeginTime();
} }
return totalSecond - useTime; long canCallTime = totalSecond - useTime;
if(canCallTime < 0){
return 0L;
}
return canCallTime;
}catch (Exception e){ }catch (Exception e){
log.error("计算可通话时间失败!",e); log.error("计算可通话时间失败!",e);
return 0L; return 0L;