/**
  * 统计销售总量跟中奖金额
  *
  * @return
  * @throws WebDataException
  */
 public String stat() throws WebDataException {
   AdminUser adminUser = getAdminUser();
   if (null == adminUser) {
     throw new WebDataException("你还没有登录!");
   }
   String startDate = "";
   String endDate = "";
   if (StringUtils.isNotBlank(queryForm.getStartDate())) {
     startDate = queryForm.getStartDate();
   }
   if (StringUtils.isNotBlank(queryForm.getEndDate())) {
     endDate = queryForm.getEndDate();
   }
   List list = kenoService.moneyAnalye(startDate, endDate);
   HashMap result = new HashMap();
   if (null != list && list.size() > 0) {
     result.put("totalSales", (BigDecimal) list.get(0));
     result.put("totalHits", (BigDecimal) list.get(1));
     result.put("success", true);
   } else {
     result.put("totalSales", "0");
     result.put("totalHits", "0");
     result.put("success", false);
   }
   Struts2Utils.renderJson(result);
   return null;
 }
  /**
   * 期号管理
   *
   * @return
   * @throws WebDataException
   */
  public String list() throws WebDataException {
    AdminUser adminUser = getAdminUser();
    if (null == adminUser) {
      throw new WebDataException("你还没有登录!");
    }
    Class<I> cls = kenoService.getIssueDataClass();
    XDetachedCriteria criteria = new XDetachedCriteria(cls, "s");
    if (queryForm != null) {
      if (StringUtils.isNotBlank(queryForm.getPeriodNumber()))
        criteria.add(Restrictions.eq("s.periodNumber", queryForm.getPeriodNumber()));

      if (queryForm.getIssueState() != null)
        criteria.add(Restrictions.eq("s.state", queryForm.getIssueState()));
    }
    criteria.addOrder(Order.desc("s.id"));
    pagination = kenoService.findByCriteriaAndPagination(criteria, pagination);
    pause = kenoService.findPauseOrStart();
    return SUCCESS;
  }
  public String scheme() throws WebDataException {
    AdminUser adminUser = getAdminUser();
    if (null == adminUser) {
      throw new WebDataException("你还没有登录!");
    }
    Class<S> cls = kenoService.getSchemeClass();
    if (queryForm != null) {
      if (StringUtils.isNotBlank(queryForm.getPeriodNumber()))
        criteria.add(Restrictions.eq("s.periodNumber", queryForm.getPeriodNumber()));

      if (queryForm.getState() != null)
        criteria.add(Restrictions.eq("s.state", queryForm.getState()));
      if (queryForm.getTicketState() != null)
        criteria.add(Restrictions.eq("s.schemePrintState", queryForm.getTicketState()));

      if (queryForm.getPrizeSended() != null)
        criteria.add(Restrictions.eq("s.cut", queryForm.getPrizeSended()));

      if (queryForm.getWon() != null) criteria.add(Restrictions.eq("s.won", queryForm.getWon()));

      if (StringUtils.isNotBlank(queryForm.getSponsorNames())) {
        String[] arr = queryForm.getSponsorNames().trim().split(",");
        if (arr.length == 1) {
          criteria.add(Restrictions.eq("s.sponsorName", arr[0]));
        } else if (arr.length == 2) {
          criteria.add(
              Restrictions.or(
                  Restrictions.eq("s.sponsorName", arr[0]),
                  Restrictions.eq("s.sponsorName", arr[1])));
        } else {
          criteria.add(Restrictions.in("s.sponsorName", arr));
        }
      }

      if (StringUtils.isNotBlank(queryForm.getSchemeNumbers())) {
        String[] arr = queryForm.getSchemeNumbers().trim().split(",");
        List<Long> idList = new ArrayList<Long>();
        for (String s : arr) {
          Long id = getLottery().getSchemeId(s);
          if (id != null) idList.add(id);
        }
        if (idList.size() == 1) {
          criteria.add(Restrictions.eq("s.id", idList.get(0)));
        } else if (idList.size() == 2) {
          criteria.add(
              Restrictions.or(
                  Restrictions.eq("s.id", idList.get(0)), Restrictions.eq("s.id", idList.get(1))));
        } else if (idList.size() > 2) {
          criteria.add(Restrictions.in("s.id", idList));
        }
      }
    }
    criteria.addOrder(Order.desc("s.id"));
    pagination = kenoService.findByCriteriaAndPagination(criteria, pagination);
    return "scheme";
  }
  /**
   * 追号管理
   *
   * @return
   * @throws WebDataException
   */
  public String chase() throws WebDataException {
    AdminUser adminUser = getAdminUser();
    if (null == adminUser) {
      throw new WebDataException("你还没有登录!");
    }
    //		Class<C> cls = kenoService.getChasePlanClass();
    XDetachedCriteria criteria = new XDetachedCriteria(ChasePlan.class, "s");
    if (queryForm != null) {
      if (StringUtils.isNotBlank(queryForm.getFirstPeriodNumber())) {
        I issueData = kenoService.findByIssueNumber(queryForm.getFirstPeriodNumber());
        if (issueData != null) {
          criteria.add(Restrictions.eq("s.firstPeriodId", issueData.getId()));
        }
      }

      if (queryForm.getChaseState() != null)
        criteria.add(Restrictions.eq("s.state", queryForm.getChaseState()));

      if (queryForm.getWon() != null) criteria.add(Restrictions.eq("s.won", queryForm.getWon()));

      if (queryForm.getWonStop() != null)
        criteria.add(Restrictions.eq("s.wonStop", queryForm.getWonStop()));

      if (StringUtils.isNotBlank(queryForm.getPeriodNumber())) {
        I issueData = kenoService.findByIssueNumber(queryForm.getPeriodNumber());
        if (issueData != null) {
          criteria.add(Restrictions.eq("s.curPeriodId", issueData.getId()));
        }
      }

      if (StringUtils.isNotBlank(queryForm.getSponsorNames())) {
        String[] arr = queryForm.getSponsorNames().trim().split(",");
        if (arr.length == 1) {
          criteria.add(Restrictions.eq("s.userName", arr[0]));
        } else if (arr.length == 2) {
          criteria.add(
              Restrictions.or(
                  Restrictions.eq("s.userName", arr[0]), Restrictions.eq("s.userName", arr[1])));
        } else {
          criteria.add(Restrictions.in("s.userName", arr));
        }
      }
    }
    pagination = kenoService.findByCriteriaAndPagination(criteria, pagination);
    return "chase";
  }