Пример #1
0
 @Override
 public void setLuckyNum(String issue, String luckyNum) {
   if (agentCommConfig != null) {
     int i = 0;
     int len = agentCommConfig.getAgent().getIssues().getIssue().length;
     for (; i < len; i++) {
       // Verify if it's the desired issue!
       Issue iss = agentCommConfig.getAgent().getIssues().getIssue(i);
       if (issue.trim().equalsIgnoreCase(iss.getIssueNumber())) {
         iss.setBonusCode(luckyNum);
         iss.setStatus("5");
         break;
       }
     }
     if (i >= len) {
       log.error(
           "In setLuckyNum: maybe set the wrong issue number,pls check the configure file!\n "
               + "The issue set is:"
               + issue);
     }
   }
 }
Пример #2
0
  @Override
  public void processAgentMockAction(HttpServletRequest req, HttpServletResponse resp)
      throws Exception {
    InputStream in = null;
    ByteArrayOutputStream out = null;
    String transType = null;
    String xmlMsg = null;

    String contentType = req.getContentType();
    if (contentType != null && contentType.contains("zip")) {
      try {
        in = req.getInputStream();
        out = new ByteArrayOutputStream();
        byte[] bytes = new byte[1024];
        int count = -1;
        while ((count = in.read(bytes)) != -1) {
          out.write(bytes, 0, count);
        }
        byte[] b = out.toByteArray();
        String paramString = new String(b, "GBK");
        log.warn("Receive request from Keno: " + paramString);
        if (StringUtil.isBlank(paramString)) {
          log.error("Request from keno is illegal: " + paramString);
          resp.getWriter().println("ÇëÇóÄÚÈÝΪ¿Õ£¡");
          return;
        }
        transType = getParameter(paramString, "transType");
        xmlMsg = getParameter(paramString, "transMessage");
      } catch (Exception e) {
      } finally {
        in.close();
        if (out != null) {
          out.close();
        }
      }

    } else {
      transType = req.getParameter("transType");
      xmlMsg = req.getParameter("transMessage");
    }

    boolean success = false;

    if (StringUtil.isEmpty(xmlMsg) || transType == null) {
      success = false;
    } else {
      // process action!
      int transTypeCode = Integer.parseInt(transType);
      HengPengCommandAdaptor executeCommand = null;
      if (transTypeCode == HengPengCommandAdaptorFactory.BOOK_TICKETS) {
        executeCommand =
            HengPengCommandAdaptorFactory.getAdaptor(HengPengCommandAdaptorFactory.BOOK_TICKETS);
      } else if (transTypeCode == HengPengCommandAdaptorFactory.GET_ISSUE) {
        // Should identify the get issue or get lucky number!
        executeCommand =
            HengPengCommandAdaptorFactory.getAdaptor(HengPengCommandAdaptorFactory.GET_ISSUE);
      } else if (transTypeCode == HengPengCommandAdaptorFactory.QUERY_TICKETS) {
        executeCommand =
            HengPengCommandAdaptorFactory.getAdaptor(HengPengCommandAdaptorFactory.QUERY_TICKETS);
      } else if (transTypeCode == HengPengCommandAdaptorFactory.GET_AWARD_TICKETS) {
        executeCommand =
            HengPengCommandAdaptorFactory.getAdaptor(
                HengPengCommandAdaptorFactory.GET_AWARD_TICKETS);
      }

      if (executeCommand != null) {
        executeCommand.setXmlMsg(xmlMsg);
        executeCommand.setAgentCommConfig(agentCommConfig);
        if (executeCommand.doCommCommand()) {
          resp.setContentType(CONTENT_TYPE);
          PrintWriter pw = resp.getWriter();
          String res =
              "transType="
                  + ResponsMap.get(transType)
                  + "&transMessage="
                  + executeCommand.getResponseMsg();
          pw.println(res);
          pw.close();
          success = true;
          return;
        }
      }
    }

    if (!success) {
      resp.setContentType(CONTENT_TYPE);
      resp.getWriter()
          .println(
              "ÇëÇó²ÎÊý´íÎó,»òÅäÖôíÎó¡£ transType{"
                  + transType
                  + "}, transMessage{"
                  + xmlMsg
                  + "}...");
      return;
    }
  }