Example #1
0
  @Override
  public String execute() throws Exception {
    UserGoldLogService userGoldLogService =
        ServiceCacheFactory.getServiceCache().getService(UserGoldLogService.class);
    if (isCommit.equals("T")) {
      String searchUserId = super.searchUser();

      // 搜索玩家的时候出错了,返回
      if (super.getErroDescrip() != null) {
        return SUCCESS;
      }
      IPage<Object> list =
          userGoldLogService.findPageLogListByCondition(
              searchUserId,
              super.getStartDate(),
              super.getEndDate(),
              searchCategory,
              searchType,
              super.getToPage(),
              super.getPageSize());
      count =
          userGoldLogService.countAll(1, searchUserId, super.getStartDate(), super.getEndDate());
      useCount =
          userGoldLogService.countAll(2, searchUserId, super.getStartDate(), super.getEndDate());

      if (list != null) {
        List<Object> ll = (List<Object>) list.getData();
        for (int i = 0; i < ll.size(); i++) {
          Object[] arr = (Object[]) ll.get(i);
          UserGoldLog log = new UserGoldLog();
          log.setUserId(arr[0].toString());
          log.setUserName(arr[1].toString());
          log.setLodoId(Integer.valueOf(arr[2].toString()));
          log.setUserLevel(Integer.valueOf(arr[3].toString()));
          log.setCategory(Integer.valueOf(arr[4].toString()));
          log.setType(Integer.valueOf(arr[5].toString()));
          log.setChangeNum(Integer.valueOf(arr[6].toString()));
          log.setTime(
              new Timestamp(
                  DateUtil.stringtoDate(arr[7].toString(), DateUtil.FORMAT_ONE).getTime()));
          userGoldLogList.add(log);
        }
        super.setTotalPage(list.getTotalPage());
        super.setTotalSize(list.getTotalSize());
      }
    }

    return SUCCESS;
  }
  @Override
  public String execute() throws Exception {
    UserLoginLogService userLoginLogService =
        ServiceCacheFactory.getServiceCache().getService(UserLoginLogService.class);
    UserGoldLogService userGoldLogService =
        ServiceCacheFactory.getServiceCache().getService(UserGoldLogService.class);

    // {4,2} 等级为0-5区间时,活跃天数大于或等于4的为小户, 活跃天数大于或等于2小于4为中户,活跃天数小于2的为大户。

    List<Object> activeDaysList =
        userLoginLogService.findUserIdAndLevelIntervalIndexAndActiveDaysList();

    Map<String, Map<Integer, Integer>> userIdAndLevelIntervalIndexAndConsumeNumMap =
        userGoldLogService.findUserIdAndLevelIntervalIndexAndConsumeNumMap();

    Integer levelIntervalIndex;
    String userId;
    Integer activeDays;
    // 0小户 1中户 2大户
    Integer userConsumeType;
    String key;
    Integer consumeNum;
    if (activeDaysList != null && activeDaysList.size() > 0) {
      for (int i = 0; i < activeDaysList.size(); i++) {
        userId = ((Object[]) activeDaysList.get(i))[0].toString();
        levelIntervalIndex = Integer.valueOf(((Object[]) activeDaysList.get(i))[1].toString());
        activeDays = Integer.valueOf(((Object[]) activeDaysList.get(i))[2].toString());

        if (userIdAndLevelIntervalIndexAndConsumeNumMap.get(userId) != null
            && userIdAndLevelIntervalIndexAndConsumeNumMap.get(userId).get(levelIntervalIndex)
                != null) {
          consumeNum =
              userIdAndLevelIntervalIndexAndConsumeNumMap.get(userId).get(levelIntervalIndex);
        } else {
          consumeNum = 0;
        }

        if (activeDays >= activeDaysInterval[levelIntervalIndex][0]) {
          userConsumeType = 0;
        } else if (activeDays >= activeDaysInterval[levelIntervalIndex][1]) {
          userConsumeType = 1;
        } else {
          userConsumeType = 2;
        }
        key = levelIntervalIndex + "-" + userConsumeType;
        if (statsMap.get(key) != null) {
          statsMap.put(
              key,
              (Integer.valueOf(statsMap.get(key).split("-")[0]) + 1)
                  + "-"
                  + (Integer.valueOf(statsMap.get(key).split("-")[1]) + consumeNum));
        } else {
          statsMap.put(key, "1-" + consumeNum);
        }
        //				System.out.println(statsMap);
        //				System.out.println();
      }
    }

    return SUCCESS;
  }
  @Override
  public void execute(Date date) throws Exception {
    LogSystem.info("VIP 玩家元宝统计 Collector开始");
    UserGoldLogService userGoldLogService =
        ServiceCacheFactory.getServiceCache().getService(UserGoldLogService.class);
    UserService userService = ServiceCacheFactory.getServiceCache().getService(UserService.class);
    VipUserDiamondStatsService vipUserDiamondStatsService =
        ServiceCacheFactory.getServiceCache().getService(VipUserDiamondStatsService.class);

    String[] dates = DateUtil.getOneDayStrArr(SystemStatsDate.YESTERDAY);
    List<Object> tempList = userService.findVipUser();
    List<String> userList = new ArrayList<String>();
    for (int i = 0; i < tempList.size(); i++) {
      Object objArr = (Object) tempList.get(i);
      Character[] cc = (Character[]) objArr;
      StringBuilder sb = new StringBuilder();
      for (int j = 0; j < cc.length; j++) {
        Character c = cc[j];
        sb.append(c);
      }
      userList.add(sb.toString());
    }
    int actityCount = userService.findActityVipUser(dates, userList);
    Map<Integer, Integer> map1 =
        userGoldLogService.findEveryTypeAmountVIP(UserGoldLogCategory.RECEIVE, dates, userList);
    Map<Integer, Integer> map2 =
        userGoldLogService.findEveryTypeAmountVIP(UserGoldLogCategory.CONSUME, dates, userList);
    List<VipUserDiamondStats> resultList = new ArrayList<VipUserDiamondStats>();

    Iterator<Integer> key1 = map1.keySet().iterator();
    while (key1.hasNext()) {
      Integer k = key1.next();
      Integer value = map1.get(k);
      VipUserDiamondStats stats = new VipUserDiamondStats();
      stats.setSysNum(CustomerContextHolder.getSystemNum());
      stats.setDate(DateUtil.getSomeDaysDiffDate(SystemStatsDate.YESTERDAY));
      stats.setCount(tempList.size());
      stats.setType(k);
      stats.setCaterory(UserGoldLogCategory.RECEIVE);
      stats.setDiamond(value);
      stats.setActityCount(actityCount);

      resultList.add(stats);
    }
    Iterator<Integer> key2 = map2.keySet().iterator();
    while (key2.hasNext()) {
      Integer k = key2.next();
      Integer value = map2.get(k);
      VipUserDiamondStats stats = new VipUserDiamondStats();
      stats.setSysNum(CustomerContextHolder.getSystemNum());
      stats.setDate(DateUtil.getSomeDaysDiffDate(SystemStatsDate.YESTERDAY));
      stats.setCount(tempList.size());
      stats.setType(k);
      stats.setDiamond(value);
      stats.setCaterory(UserGoldLogCategory.CONSUME);
      stats.setActityCount(actityCount);

      resultList.add(stats);
    }
    vipUserDiamondStatsService.saveBatch(resultList);
    LogSystem.info("VIP 玩家元宝统计 Collector结束");
  }