コード例 #1
0
  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;
  }
コード例 #2
0
 /**
  * 设置全部结束
  *
  * @return
  * @throws WebDataException
  */
 public String setIssueClose() {
   Map<String, Object> map = new HashMap<String, Object>();
   try {
     AdminUser adminUser = getAdminUser();
     if (null == adminUser) {
       throw new WebDataException("你还没有登录!");
     }
     if (this.id == null) {
       throw new DataException("期号ID不能为空.");
     }
     kenoService.updateIssueState(this.getId(), IssueState.ISSUE_SATE_FINISH);
     I issueData = kenoService.findIssueDataById(this.getId());
     // 同传统彩的期实体传数据
     Period period = new Period();
     period.setId(issueData.getId());
     period.setPeriodNumber(issueData.getPeriodNumber());
     // 记录操作日志
     eventLogManager.saveSimpleEventLog(
         period, getLottery(), adminUser, EventLogType.CloseIssue, "期号为ID:" + this.getId());
     map.put("success", true);
     map.put("msg", "期号设置结束成功");
   } catch (DataException e) {
     e.printStackTrace();
     map.put("success", false);
     map.put("msg", e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     map.put("success", false);
     map.put("msg", "期号设置结束发生异常!");
   }
   Struts2Utils.renderJson(map);
   return null;
 }
コード例 #3
0
  public Set<SaleWorkerCmd> getCanRunCmds(Period period) {
    Set<SaleWorkerCmd> cmds = new HashSet<SaleWorkerCmd>(0);
    if (period.isOnSale()) cmds.add(SaleWorkerCmd.PauseSale);
    else if (period.isPaused()) cmds.add(SaleWorkerCmd.ResumeSale);
    if (period.isStarted()) cmds.addAll(getAfterSaleCanRunCmds(period));

    if (period.isFinished()) cmds.addAll(getAfterFinishCanRunCmds(period));

    return cmds;
  }
コード例 #4
0
 /**
  * 更新开奖号码
  *
  * @return
  * @throws WebDataException
  */
 public String updateResults() throws WebDataException {
   AdminUser adminUser = getAdminUser();
   if (null == adminUser) {
     throw new WebDataException("你还没有登录!");
   }
   if (issueData != null && issueData.getId() != null) {
     if (!StringUtils.isBlank(issueData.getResults())) {
       String results = issueData.getResults().trim();
       boolean result = false;
       if (Lottery.KLSF.equals(getLottery())) {
         result =
             results.matches(
                 "\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2}");
       } else if (Lottery.EL11TO5.equals(getLottery())
           || Lottery.SDEL11TO5.equals(getLottery())
           || Lottery.XJEL11TO5.equals(getLottery())) {
         result = results.matches("\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2}");
       } else if (Lottery.SSC.equals(getLottery())) {
         result = results.matches("\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2}");
       } else if (Lottery.QYH.equals(getLottery())) {
         result = results.matches("\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2},\\d{1,2}");
       }
       if (!result) {
         addActionError("开奖号码格式不正确!");
         return error();
       }
       kenoService.updateResults(issueData);
       addActionMessage("操作成功.");
       I issueDataTemp = kenoService.findIssueDataById(issueData.getId());
       // 同传统彩的期实体传数据
       Period period = new Period();
       period.setId(issueDataTemp.getId());
       period.setPeriodNumber(issueDataTemp.getPeriodNumber());
       // 记录操作日志
       eventLogManager.saveSimpleEventLog(
           period,
           getLottery(),
           adminUser,
           EventLogType.SetResult,
           "期ID为" + issueData.getId() + "开奖号码为" + results + "期实体为" + issueData.toString());
     }
   }
   return "save";
 }
コード例 #5
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";
  }
コード例 #6
0
  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";
  }