public String getNotCompleteCashOrder() {
    int notCompleteOrder = 0;
    try {
      BetPlanOrderServiceInterf orderServer =
          ApplicationContextUtils.getService(
              "lotteryBetOrderService", BetPlanOrderServiceInterf.class);
      List<Integer> winStatus = new ArrayList<Integer>();
      List<Integer> orderStatus = new ArrayList<Integer>();
      orderStatus.add(0);
      orderStatus.add(1);
      orderStatus.add(2);
      orderStatus.add(3);

      notCompleteOrder =
          orderServer.queryOrderNumByStatus(
              Integer.parseInt(this.getP_lotteryId()),
              this.getP_termNo_begin(),
              orderStatus,
              winStatus); // 查是否还有需要确认出票处理的订单
    } catch (Exception e) {
      e.printStackTrace();
    }
    this.jsonString = JSONArray.fromObject(notCompleteOrder).toString();
    return "ajaxjson";
  }
  /**
   * Title: betOrderInfoShow<br>
   * Description: <br>
   * (这里用一句话描述这个方法的作用)<br>
   *
   * @return String
   */
  public String betOrderCashInfoShow() {

    try {
      this.initPageParam();
      LotteryManagerInterf termManager =
          ApplicationContextUtils.getService(
              "busLotteryManagerService", LotteryManagerInterf.class);
      List<BusBetOrderDomain> retOrderList = null;
      if (this.page == 0) {
        this.page = 1;
      }
      if (this.perPageNumber == 0) {
        this.perPageNumber = defaultPerPageNumber;
      }
      this.totalNumber =
          termManager.getCanCashOrderInfosCount(this.getP_lotteryId(), this.getP_termNo_begin());
      retOrderList =
          termManager.getCanCashOrderInfoS(
              this.getP_lotteryId(), this.getP_termNo_begin(), this.page, this.perPageNumber);

      this.orderList.setPageNumber(this.page);
      this.orderList.setPerPage(this.perPageNumber);
      this.orderList.setFullListSize(this.totalNumber);
      this.orderList.setList(retOrderList);
    } catch (LotteryException e) {
      e.printStackTrace();
      this.setEx_code(e.getType());
      this.setEx_reason(e.getMessage());
      return ERROR;
    } catch (Exception ex) {
      ex.printStackTrace();
      this.setEx_code(99999);
      this.setEx_reason(ex.getMessage());
      return ERROR;
    }

    return SUCCESS;
  }
  /**
   * Title: betOrderAllCash<br>
   * Description: <br>
   * <br>
   * 全部订单兑奖方法
   *
   * @return String
   */
  @SuppressWarnings("unchecked")
  public String betOrderAllCash() {
    CashResult cashResultBean = new CashResult();
    try {
      HttpServletRequest request = ServletActionContext.getRequest();
      String loginIp = "";
      try {
        loginIp = getIpAddr(request);
      } catch (Exception e) {
        e.printStackTrace();
      }

      Map<String, String> cashNum = new HashMap<String, String>();
      Map<String, String> dbLog = new HashMap<String, String>();
      AdminUser adminUser = (AdminUser) this.getSession().get("tlt.loginuser");
      dbLog.put("userId", String.valueOf(adminUser.getUserId()));
      dbLog.put("userName", String.valueOf(adminUser.getName()));
      dbLog.put("userKey", loginIp);

      cashNum.put("cashTotalNum", "0"); // 兑奖总条数
      cashNum.put("cashCurNum", "0"); // 当前已经兑奖条数
      cashNum.put("cashPersent", "0"); // 当前已经兑奖条数
      this.getSession().put("tlt.cashNum." + this.getP_lotteryId(), cashNum);

      if (StringUtils.isEmpty(this.getP_lotteryId())
          || StringUtils.isEmpty(this.getP_termNo_begin())
          || "0".equals(this.getP_lotteryId())
          || "0".equals(this.getP_termNo_begin())) {
        throw new LotteryException(999999, "兑奖时彩种和彩期不能为空!");
      }

      cashResultBean.setLotteryName(
          LotteryTools.getLotteryName(Integer.parseInt(this.getP_lotteryId())));
      /*
       * 调用兑奖方法兑奖
       */
      CashPrizeInterf cashManager =
          ApplicationContextUtils.getService("busLotteryCashPrizeService", CashPrizeInterf.class);
      // 兑奖
      Map<String, String> cashResult =
          cashManager.cashAutoOrder(
              Integer.parseInt(this.getP_lotteryId()), this.getP_termNo_begin(), cashNum, dbLog);
      /*
       * 统计兑奖结果
       */
      if (cashResult != null) {
        cashResultBean.setTotal_orders(cashResult.get("total_orders"));
        cashResultBean.setTotal_tz_prize(cashResult.get("total_tz_prize"));
        cashResultBean.setSucess_orders(cashResult.get("sucess_orders"));
        cashResultBean.setSucess_tz_prize(cashResult.get("sucess_tz_prize"));
        cashResultBean.setFail_orders(cashResult.get("fail_orders"));
        cashResultBean.setFail_tz_prize(cashResult.get("fail_tz_prize"));
        cashResultBean.setZj_orders(cashResult.get("zj_orders"));
        cashResultBean.setZj_prize(cashResult.get("zj_prize"));
      }
      // 处理追号
      Map<String, String> zhuHaoResult =
          cashManager.dealNotTicketOrder(
              Integer.parseInt(this.getP_lotteryId()), this.getP_termNo_begin(), dbLog);
      /*
       * 统计追号结果
       */
      if (zhuHaoResult != null) {
        cashResultBean.setZh_nextTerm(zhuHaoResult.get("nextTerm"));
        cashResultBean.setZh_total_num(zhuHaoResult.get("total_num"));
        cashResultBean.setZh_sucess_num(zhuHaoResult.get("sucess_num"));
        cashResultBean.setZh_fail_num(zhuHaoResult.get("fail_num"));
        cashResultBean.setZh_sucess_bet_num(zhuHaoResult.get("sucess_bet_num"));
        cashResultBean.setZh_sucess_limit_num(zhuHaoResult.get("sucess_limit_num"));
      }
      // 更新彩期状态
      Map<String, String> upTermResult =
          cashManager.updateCashTermStatus(
              Integer.parseInt(this.getP_lotteryId()), this.getP_termNo_begin(), dbLog);
      if (upTermResult != null) {
        cashResultBean.setOld_term_status(upTermResult.get("old_status"));
        cashResultBean.setNew_term_status(upTermResult.get("new_status"));
      }
    } catch (LotteryException e) {
      e.printStackTrace();
      cashResultBean.setEx_code(e.getType());
      cashResultBean.setEx_reason(e.getMessage());
    } catch (Exception ex) {
      ex.printStackTrace();
      cashResultBean.setEx_code(99999);
      cashResultBean.setEx_reason(ex.getMessage());
    }
    this.jsonString = JSONObject.fromObject(cashResultBean).toString();
    return "ajaxjson";
  }
Example #4
0
  @Override
  public void run() {
    logger.info(name + " is running...");
    String resource = "com.success.lottery.ticket.service.TicketRouter";
    if ("true"
        .equalsIgnoreCase(
            AutoProperties.getString("ticketSender.loadWhenStart", "false", resource).trim())) {
      logger.debug("TicketSender will load the to send ticket from database when start.");
      loadSendTicketWhenStart();
      logger.debug("TicketSender load the to send ticket from database completed when start.");
    }

    BetTicketServiceInterf lotteryBetTicketService =
        ApplicationContextUtils.getService("lotteryBetTicketService", BetTicketServiceInterf.class);
    // LotteryTermServiceInterf lotteryTermService =
    // ApplicationContextUtils.getService("lotteryTermService", LotteryTermServiceInterf.class);
    List<Integer> ticketStatus = new ArrayList<Integer>();
    ticketStatus.add(Integer.valueOf(0));
    ticketStatus.add(Integer.valueOf(3));
    ticketStatus.add(Integer.valueOf(4));
    ticketStatus.add(Integer.valueOf(5));

    while (!isStop) {
      try {
        List<BetTicketDomain> ticketes =
            lotteryBetTicketService.getTicketes(
                ticketStatus,
                "printStation='" + station + "'",
                AutoProperties.getInt("ticketSender.queryLimit", 1000, resource));

        List<String> ticketSequences = new ArrayList<String>();
        List<TicketLogInfo> logInfo = new ArrayList<TicketLogInfo>();
        if (ticketes != null && ticketes.size() > 0) {
          ticketCount = ticketCount + ticketes.size();
          for (BetTicketDomain ticket : ticketes) {
            logger.debug("TicketSender get a ticket(" + ticket.getTicketSequence() + ").");
            TicketLogInfo info = new TicketLogInfo();
            info.setName("TICKETSENDER");
            info.setInTime(System.currentTimeMillis());
            info.setProcessorName(this.getName());
            info.setTicketSequence(ticket.getTicketSequence());
            info.setOrderId(ticket.getOrderId());

            if (TicketDispatch.contains(ticket)) {
              logger.debug(
                  "TicketSender get the ticket("
                      + ticket.getTicketSequence()
                      + ") was already sent to the queue.");
              sendFail++;
              continue;
            } else {
              // 转换投注串格式
              String printCode =
                  EHandSplitTools.betCodeToPrintCode(
                      ticket.getLotteryId(),
                      ticket.getPlayType(),
                      ticket.getBetType(),
                      ticket.getBetCode());
              // 转换投注方式
              int printType =
                  EHandSplitTools.betTypeToPrintType(
                      ticket.getLotteryId(), ticket.getPlayType(), ticket.getBetType());
              logger.debug(
                  "TicketSender convert a ticket("
                      + ticket.getTicketSequence()
                      + ") betType from:"
                      + ticket.getBetType()
                      + " to:"
                      + printType
                      + " betCode from:"
                      + ticket.getBetCode()
                      + " to:"
                      + printCode);
              info.setRemark(
                  "convert betType from:"
                      + ticket.getBetType()
                      + " to:"
                      + printType
                      + " betCode from:"
                      + ticket.getBetCode()
                      + " to:"
                      + printCode);
              ticket.setBetType(printType);
              ticket.setBetCode(printCode);

              String rs = null;
              if ((rs = TicketDispatch.dispatch(ticket)) == null) {
                logger.debug(
                    "TicketSender send the ticket("
                        + ticket.getTicketSequence()
                        + ") to the queue success.");
                ticketSequences.add(ticket.getTicketSequence());
                info.addRemark("dispatch", "success");
                logInfo.add(info);
              } else {
                logger.debug(
                    "TicketSender send the ticket("
                        + ticket.getTicketSequence()
                        + ") to the queue failed:"
                        + rs
                        + ".");
                sendFail++;
              }
            }
          }
          String rs = null;
          if (ticketSequences.size() > 0) {
            try {
              int rc = 0;
              if ((rc =
                      lotteryBetTicketService.updateBetTicketesStatus(
                          ticketSequences, 1, ticketStatus))
                  == 0) {
                rs = "NoRowsUpdate";
                logger.debug(
                    "TicketSender update the ticketes("
                        + ticketSequences.toString()
                        + ") ticketStauts = 1 failed:"
                        + rs);
                sendFail = sendFail + ticketSequences.size();
              } else {
                logger.debug(
                    "TicketSender update "
                        + rc
                        + " ticketes("
                        + ticketSequences.toString()
                        + ") ticketStauts = 1 success.");
                sendSucc = sendSucc + ticketSequences.size();
                for (TicketLogInfo info : logInfo) {
                  info.setResult(rs);
                  info.setOutTime(System.currentTimeMillis());
                  TicketLogger.getInstance("TICKET").log(info);
                }
              }
            } catch (Exception e) {
              logger.error(
                  "TicketSender update the ticketes("
                      + ticketSequences.toString()
                      + ") ticketStatus = 1 occur exception:"
                      + e);
              if (logger.isDebugEnabled()) {
                e.printStackTrace();
              }
              sendFail = sendFail + ticketSequences.size();
              rs = e.toString();
            }
          }
        }
        int count = ticketSequences == null ? 0 : ticketSequences.size();
        logger.debug(
            "TicketSender get "
                + count
                + " ticketes, sleep "
                + AutoProperties.getInt("ticketSender.interval", 200, resource)
                + "ms.");
        try {
          Thread.sleep(AutoProperties.getInt("ticketSender.interval", 200, resource));
        } catch (Exception e) {
        }
      } catch (Exception e) {
        logger.error("TicketSender occur unknow exception:" + e);
        if (logger.isDebugEnabled()) {
          e.printStackTrace();
        }
        try {
          Thread.sleep(AutoProperties.getInt("ticketSender.interval", 200, resource));
        } catch (Exception e1) {
        }
      }
    }
    isExit = true;
    logger.info(name + " is shutdown!");
  }
Example #5
0
  public synchronized void loadSendTicketWhenStart() {
    try {
      BetTicketServiceInterf lotteryBetTicketService =
          ApplicationContextUtils.getService(
              "lotteryBetTicketService", BetTicketServiceInterf.class);
      List<Integer> ticketStatus = new ArrayList<Integer>();
      ticketStatus.add(1);
      ticketStatus.add(3);
      ticketStatus.add(4);

      List<BetTicketDomain> ticketes =
          lotteryBetTicketService.getTicketes(ticketStatus, "printStation='" + station + "'", 0);
      for (BetTicketDomain ticket : ticketes) {
        logger.debug(
            "TicketSender load a ticket("
                + ticket.getTicketSequence()
                + ") from database when start load.");

        // 转换投注串格式
        String printCode =
            EHandSplitTools.betCodeToPrintCode(
                ticket.getLotteryId(),
                ticket.getPlayType(),
                ticket.getBetType(),
                ticket.getBetCode());
        // 转换投注方式
        int printType =
            EHandSplitTools.betTypeToPrintType(
                ticket.getLotteryId(), ticket.getPlayType(), ticket.getBetType());
        logger.debug(
            "TicketSender convert a ticket("
                + ticket.getTicketSequence()
                + ") betType from:"
                + ticket.getBetType()
                + " to:"
                + printType
                + " betCode from:"
                + ticket.getBetCode()
                + " to:"
                + printCode);
        ticket.setBetType(printType);
        ticket.setBetCode(printCode);

        String rs = TicketDispatch.dispatch(ticket);
        if (rs == null) {
          logger.debug(
              "TicketSender put the ticket("
                  + ticket.getTicketSequence()
                  + ") into the SendTicketQueue success when start load.");
        } else {
          logger.debug(
              "TicketSender put the ticket("
                  + ticket.getTicketSequence()
                  + ") into the SendTicketQueue failed:"
                  + rs
                  + " when start load.");
        }
      }
    } catch (Exception e) {
      logger.error("TicketSender occur unknow exception when start load:" + e);
    }
  }