package com.platform.modules.live.utils;

import java.util.Date;

import com.platform.common.utils.DateUtils;

public class CalculateSceneCountUtils {
	
	public static final int radix = 50;
	
	/**
	 * 获取从1到10的随机数
	 * @param min 最小值
	 * @param max 最大值
	 * @return
	 */
	public static int getRandom(int min, int max){
	    int s = (int)(min+Math.random()*(max-min+1));
	    return s;
	}

	/**
	 * 计算现场显示浏览量
	 * @param views 计算前的值
	 * @return
	 */
	public static int CalculateSceneViewsUtils(int views,Date date){
		if(date==null){
			return getRandom(1, 10);
		}
		int days = CalculateTimeDifference.CalculateHoursDifference(date, new Date());
		days = days <= 0 ? 1 : days;
	    long totalViews = Math.round(views * radix * ((days <= 2) ? 1 : 2)/days) + getRandom(1, 10);
		return (int)totalViews;
	}
	
	public static void main(String[] args) {
		System.out.println(CalculateSceneViewsUtils(1, DateUtils.stringToDate("2019-03-21 19:19:35", DateUtils.DATE_TIME_PATTERN)));
	}
}
