public Set<SaleWorkerCmd> getAfterSaleCanRunCmds(Period period) {
    Set<SaleWorkerCmd> cmds = new HashSet<SaleWorkerCmd>(0);

    PeriodSales singleSale =
        getPeriodManager().getPeriodSales(new PeriodSalesId(period.getId(), SalesMode.SINGLE));
    PeriodSales polySale =
        getPeriodManager().getPeriodSales(new PeriodSalesId(period.getId(), SalesMode.COMPOUND));
    boolean allSaleFinished =
        singleSale.isSaleFinished() && polySale.isSaleFinished(); // 单复式销售流程都完成了

    if (period.isCurrent() && allSaleFinished) {
      List<Period> currentIssues = getPeriodManager().findCurrentPeriods(period.getLotteryType());
      if (currentIssues != null && currentIssues.size() > 1) {
        cmds.add(SaleWorkerCmd.HideIssue);
      }
    } else {
      cmds.add(SaleWorkerCmd.ShowIssue);
    }

    if (!period.isResultUpdate()) {
      cmds.add(SaleWorkerCmd.UpdateResult);
    } else if (!period.isPrizeUpdate()) {
      cmds.add(SaleWorkerCmd.UpdateResult);
    } else if (!period.isPrizeDelived()) {
      cmds.add(SaleWorkerCmd.UpdateResult);
      cmds.add(SaleWorkerCmd.DelivePrize);
    } else if (!period.isFinished()) {
      cmds.add(SaleWorkerCmd.UpdateResult);
      cmds.add(SaleWorkerCmd.DelivePrize);
      if (period.isStarted() && period.isSaleEnded() && allSaleFinished) {
        cmds.add(SaleWorkerCmd.CloseIssue);
      }
    }
    return cmds;
  }
Ejemplo n.º 2
0
  public String index() throws WebDataException {
    this.lotteryType = getLotteryType();
    if (null == this.queryForm) {
      this.queryForm = new PasscountQueryForm();
    }

    if (this.queryForm.getPeriodNumber() == null) {
      periodData = getPeriodDataEntityManagerImpl().getNewestResultPeriodData();
      period = periodEntityManager.getPeriod(periodData.getPeriodId());
    } else {

      period = periodEntityManager.loadPeriod(getLotteryType(), this.queryForm.getPeriodNumber());
      periodData = getPeriodDataEntityManagerImpl().getPeriodData(period.getId());
    }

    if (period == null) throw new WebDataException("期号不存在.");
    if (periodData == null) throw new WebDataException("期数据不存在.");

    periods = periodEntityManager.getDrawPeriodList(getLotteryType(), 20);

    User user = this.getLoginUser();
    if (null != mine && mine) {
      if (null == user) {
        // 先登录
        CookieUtil.addReUrlCookie();
        return GlobalResults.FWD_LOGIN;
      } else {
        this.getQueryForm().setSponsorNames(user.getUserName());
      }
    }

    this.queryForm.setPeriodId(period.getId());
    this.queryForm.setPeriodNumber(period.getPeriodNumber());

    this.pagination =
        queryService.findByCriteriaAndPagination(buildListDetachedCriteria(), this.pagination);

    return "index";
  }
  public String lsbd() {
    if (count == null || count <= 0) {
      count = 50;
    }
    formatNum();
    DetachedCriteria c = DetachedCriteria.forClass(SsqPeriodData.class);
    c.add(Restrictions.isNotNull("result"));
    c.addOrder(Order.desc("id"));
    List<SsqPeriodData> list = periodDataEntityManagerImpl.findByDetachedCriteria(c, 0, count);

    List<Long> periodIdList = new ArrayList<Long>();
    for (SsqPeriodData data : list) {
      periodIdList.add(data.getPeriodId());
      String[] rs = data.getRsultArr();
      if (red1 == null) {
        red1 = rs[0];
        red2 = rs[1];
        red3 = rs[2];
        red4 = rs[3];
        red5 = rs[4];
        red6 = rs[5];
        blue = rs[6];
        data.setPrizePool(7l);
      } else {
        long hits = 0;
        String[] rs1 = (String[]) ArrayUtils.subarray(rs, 0, 6);
        if (ArrayUtils.contains(rs1, red1)) {
          hits++;
        }
        if (ArrayUtils.contains(rs1, red2)) {
          hits++;
        }
        if (ArrayUtils.contains(rs1, red3)) {
          hits++;
        }
        if (ArrayUtils.contains(rs1, red4)) {
          hits++;
        }
        if (ArrayUtils.contains(rs1, red5)) {
          hits++;
        }
        if (ArrayUtils.contains(rs1, red6)) {
          hits++;
        }
        if (blue.equals(rs[6])) {
          hits++;
        }
        data.setPrizePool(hits);
      }
    }
    Collections.sort(
        list,
        new Comparator<SsqPeriodData>() {
          @Override
          public int compare(SsqPeriodData o1, SsqPeriodData o2) {
            if (o1.getPrizePool() < o2.getPrizePool()) {
              return 1;
            }
            return -1;
          }
        });
    c = DetachedCriteria.forClass(Period.class);
    c.add(Restrictions.in("id", periodIdList));
    c.addOrder(Order.desc("id"));
    List<Period> periodList = periodDataEntityManagerImpl.findByDetachedCriteria(c);
    Map<Long, Period> periodMap = new HashMap<Long, Period>();
    for (Period data : periodList) {
      periodMap.put(data.getId(), data);
    }
    Struts2Utils.setAttribute("periodMap", periodMap);
    Struts2Utils.setAttribute("list", list);

    loadForecastAndSkillsNewsList();

    return "lsbd";
  }