StatisticsServiceImpl.java 7.62 KB
/**
 * 
 */
package com.bjivt.service.showtime.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.bjivt.dao.showtime.CompetenceDao;
import com.bjivt.dao.showtime.StatisticsDao;
import com.bjivt.entity.showtime.User;
import com.bjivt.entity.vo.StatisticMobile;
import com.bjivt.entity.vo.StatisticsAnchor;
import com.bjivt.entity.vo.StatisticsDecResult;
import com.bjivt.entity.vo.StatisticsIncome;
import com.bjivt.entity.vo.StatisticsResult;
import com.bjivt.entity.vo.StatisticsTwoSeries;
import com.bjivt.entity.vo.StatisticsUser;
import com.bjivt.service.showtime.StatisticsService;
import com.bjivt.util.DateTool;
import com.bjivt.util.Pager;

/**
 * @author ts
 * 2016年7月18日 上午9:52:04
 * 
 */
@Component
public class StatisticsServiceImpl implements StatisticsService {
	@Autowired
	private StatisticsDao statisticsDao;

	/* (non-Javadoc)
	 * @see com.bjivt.service.showtime.StatisticsService#getRegisterUserByMap(java.util.Map)
	 */
	@Override
	public List<StatisticsResult> getRegistUserEveryDayByMap(String startTime,String endTime,String types) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		return statisticsDao.getRegistUserEveryDayByMap(map);
	}

	@Override
	public List<StatisticsResult> getRegistUserTotalByMap(String startTime,String endTime,String types) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		return statisticsDao.getRegistUserTotalByMap(map);
	}

	@Override
	public List<User> getUserListByMap(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return statisticsDao.getUserListByMap(map);
	}

	@Override
	public List<StatisticMobile> findMobileListByPage(StatisticMobile statisticMobile, Pager page) {
		Map<String, Object> map = new HashMap<String, Object>();
		if (page != null) {
			page.setCount(getMobileCountBy(statisticMobile));
		}
	map.put("page", page);
	map.put(statisticMobile.getClass().getSimpleName(), statisticMobile);
	return statisticsDao.findMobileListByMap(map);
	}

	@Override
	public Integer getMobileCountBy(StatisticMobile param) {
		// TODO Auto-generated method stub
		return statisticsDao.getMobileCountBy(param);
	}

	@Override
	public Integer getRegistUserBeforeDayCount(String startTime, String endTime) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		return statisticsDao.getRegistUserBeforeDayCount(map);
	}

	@Override
	public List<StatisticsDecResult> getRetainedUserByMap(String startTime, String types) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("types", types);
		return statisticsDao.getRetainedUserByMap(map);
	}

	@Override
	public List<StatisticsUser> getUserDataByMap(String startTime, String endTime, String orderfield, Integer id,String orderrule, Pager page) {
		Map<String, Object> map = new HashMap<String, Object>();
		
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("orderfield", orderfield);
		map.put("orderrule", orderrule);
		if(page != null){
			int count = statisticsDao.getUserDataCountBy(map);
			page.setCount(count);
			map.put("page", page);
		}
		map.put("id", id);
		
		return statisticsDao.getUserDataByMap(map);
	}

	@Override
	public List<StatisticsResult> getUserVisitTime(String startTime, String endTime, String types, String id) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		map.put("id", id);
		return statisticsDao.getUserVisitTime(map);
	}

	@Override
	public List<StatisticsResult> getUserRecharge(String startTime, String endTime, String types, String id) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		map.put("id", id);
		return statisticsDao.getUserRecharge(map);
	}

	@Override
	public List<StatisticsResult> getUserAnchorTotal(String startTime, String endTime, String types) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		return statisticsDao.getUserAnchorTotal(map);
//		int type = 0;
//		if(StringUtils.isEmpty(types))
//			type=0;
//		else
//			type = Integer.parseInt(types);
//		if(type==0 || type==1){
//			types = "'%Y-%m-%d'";
//			type=0;
//		}else if(type==2){
//			types = "'%Y年第%u周'";
//		}else if(type==3){
//			types = "'%Y年%m月'";
//		}else if(type==4){
//			types = "'%Y'";
//		}
//		StatisticsAnchor sa = new StatisticsAnchor();
//		sa.setStartTime(DateTool.stringToDate(startTime));
//		sa.setEndTime(DateTool.stringToDate(endTime));
//		sa.setTypes(types);
//		sa.setType(type);
//		return statisticsDao.getUserAnchorTotal(startTime, endTime, types);
//		return statisticsDao.getUserAnchorTotal(sa);
	}

	@Override
	public List<StatisticsResult> getUserAnchorDayIncrease(String startTime, String endTime, String types) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		return statisticsDao.getUserAnchorDayIncrease(map);
	}
	/**
	 * 获取主播用户的数据
	 * @see com.bjivt.service.showtime.StatisticsService#getAnchorUserDataList(java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, com.bjivt.util.Pager)
	 */
	@Override
	public List<StatisticsUser> getAnchorUserDataList(String startTime, String endTime, String orderfield, Integer id,
			String orderrule, Pager page) {
		Map<String, Object> map = new HashMap<String, Object>();
		
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("orderfield", orderfield);
		map.put("orderrule", orderrule);
		if(page != null){
			int count = statisticsDao.getAnchorUserDataCount(map);
			page.setCount(count);
			map.put("page", page);
		}
		map.put("id", id);
		
		return statisticsDao.getAnchorUserDataList(map);
	}

	@Override
	public List<StatisticsDecResult> getAnchorUserTimeTotal(String startTime, String endTime, String types, String id) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		map.put("id", id);
		return statisticsDao.getAnchorUserTimeTotal(map);
	}

	@Override
	public List<StatisticsResult> getAnchorByVisitUser(String startTime, String endTime, String types, String id) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		map.put("id", id);
		return statisticsDao.getAnchorByVisitUser(map);
	}

	@Override
	public List<StatisticsTwoSeries> getAnchorVisitUserAndTimeTotal(String startTime, String endTime, String types,
			String id) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		map.put("id", id);
		return statisticsDao.getAnchorVisitUserAndTimeTotal(map);
	}

	@Override
	public List<StatisticsIncome> getIncomeTotal(String startTime, String endTime, String types) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("startTime", startTime);
		map.put("endTime", endTime);
		map.put("types", types);
		return statisticsDao.getIncomeTotal(map);
	}

}