示例#1
0
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    try {

      Collection messages = new ArrayList();
      MsgObject mt = msgObject;

      String sUserid = msgObject.getUserid();
      String sKeyword = msgObject.getKeyword();
      String sServiceid = msgObject.getServiceid();

      String sMTReturn = mtReturn(sUserid, sServiceid, sKeyword);
      mt.setUsertext(sMTReturn);
      mt.setMsgtype(1);
      messages.add(new MsgObject(mt));
      return messages;
    } catch (Exception e) {
      // TODO: handle exception
      return null;

    } finally {
      ExecuteADVCR.add2queueADV(
          msgObject.getMsgtype(),
          msgObject.getServiceid(),
          msgObject.getUserid(),
          msgObject.getKeyword(),
          msgObject.getRequestid(),
          msgObject.getTTimes(),
          msgObject.getMobileoperator());
    }
  }
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {

    String ismtadd = "1";
    try {
      Collection messages = new ArrayList();

      String infoid = "";
      String sKeyword = msgObject.getKeyword();
      String inv_telco =
          "Hien tai dich vu chua ho tro mang cua ban, moi ban quay lai sau.DTHT 1900571566";

      HashMap _option = new HashMap();
      String options = keyword.getOptions();
      String numberid = "8x51";
      String dtbase = "gateway";
      String last_msg = "MCA tencasy gui 8751.DTHT 1900571566";

      try {
        Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);
        _option = getParametersAsString(options);
        numberid = getString(_option, "numberid", numberid);
        dtbase = getString(_option, "dtbase", dtbase);
        inv_telco = getString(_option, "inv_telco", inv_telco);
        last_msg = getString(_option, "last_msg", last_msg);
        ismtadd = getString(_option, "ismtadd", ismtadd);

      } catch (Exception e) {
        Util.logger.sysLog(2, this.getClass().getName(), "Error: " + e.toString());
        throw new Exception("Wrong config in options");
      }

      /*kiem tra thue bao khach hang*/
      if ("VIETTEL".equalsIgnoreCase(msgObject.getMobileoperator())
          || "VIETEL".equalsIgnoreCase(msgObject.getMobileoperator())) {
        infoid = "viettel";
      } else if (("VMS".equalsIgnoreCase(msgObject.getMobileoperator()))
          || "mobifone".equalsIgnoreCase(msgObject.getMobileoperator())) {
        infoid = "mobifone";
      } else if (("GPC".equalsIgnoreCase(msgObject.getMobileoperator()))
          || ("VINAPHONE".equalsIgnoreCase(msgObject.getMobileoperator()))) {
        infoid = "vinaphone";
      } else if (("GTEL".equalsIgnoreCase(msgObject.getMobileoperator()))
          || ("Beeline".equalsIgnoreCase(msgObject.getMobileoperator()))) {
        infoid = "beeline";
      } else {
        infoid = "other";
      }

      if ("other".equalsIgnoreCase(infoid)) {
        msgObject.setUsertext(inv_telco);
        msgObject.setMsgtype(1);
        messages.add(new MsgObject(msgObject));
        return messages;
      }

      // lay so thue bao nguoi gui
      String userid = msgObject.getUserid();
      /*lay noi dung gui */
      String userText = replaceAllWhiteWithOne(msgObject.getUsertext().toUpperCase());
      String[] sTokens = replaceAllWhiteWithOne(userText).split(" ");
      String serviceid = msgObject.getServiceid();

      /*
       * nc ten bai hat
       */

      if (sTokens.length > 1) {

        String subTokens = "";
        for (int k = 1; k < sTokens.length; k++) {
          subTokens = subTokens + sTokens[k] + " ";
        }

        Util.logger.info("SubTokens : " + subTokens);

        String subTokens2 = subTokens.replace(" ", "");
        String[] resultMusicID = new String[2];
        // 0 la ten bai hat, 1 ma ma bai hat
        resultMusicID = findMusicID(subTokens2, infoid);
        if ("".equalsIgnoreCase(resultMusicID[1])) {
          resultMusicID = findMusicIDlike(subTokens2, infoid);
        }
        // MT1
        if (!"".equalsIgnoreCase(resultMusicID[1])) {
          Random iRandom = new Random();
          int imusic = iRandom.nextInt(10);
          if ("viettel".equalsIgnoreCase(infoid)) {
            if (musicHot_Viettel[imusic].startsWith(resultMusicID[0].trim())) {
              if (imusic == musicHot_Viettel.length) {
                imusic = imusic - 1;
              } else {
                imusic = imusic + 1;
              }
            }
            resultMusicID[1] =
                "De tai "
                    + resultMusicID[0]
                    + " ban soan: B1: Soan DK gui 1221.B2: Soan BH "
                    + resultMusicID[1]
                    + " gui 1221.Bai hat HOT nhat trong thang: "
                    + musicHot_Viettel[imusic];
          } else if ("vinaphone".equalsIgnoreCase(infoid)) {
            if (musicHot_Vinaphone[imusic].startsWith(resultMusicID[0].trim())) {
              if (imusic == musicHot_Vinaphone.length) {
                imusic = imusic - 1;
              } else {
                imusic = imusic + 1;
              }
            }
            resultMusicID[1] =
                "De tai "
                    + resultMusicID[0]
                    + " ban soan: B1: Soan DK gui 9194.B2: Soan TUNE "
                    + resultMusicID[1]
                    + " gui 9194.Bai hat HOT nhat trong thang: "
                    + musicHot_Vinaphone[imusic];
          } else if ("mobifone".equalsIgnoreCase(infoid)) {
            if (musicHot_Mobifone[imusic].startsWith(resultMusicID[0].trim())) {
              if (imusic == musicHot_Mobifone.length) {
                imusic = imusic - 1;
              } else {
                imusic = imusic + 1;
              }
            }
            resultMusicID[1] =
                "De tai "
                    + resultMusicID[0]
                    + " ban soan: B1: Soan DK gui 9224.B2: Soan CHON "
                    + resultMusicID[1]
                    + " gui 9224.Bai hat HOT nhat trong thang: "
                    + musicHot_Mobifone[imusic];
          } else if ("beeline".equalsIgnoreCase(infoid)) {

            // New mang Beeline
            if (musicHot_Beeline[imusic].startsWith(resultMusicID[0].trim())) {
              if (imusic == musicHot_Beeline.length) {
                imusic = imusic - 1;
              } else {
                imusic = imusic + 1;
              }
            }
            resultMusicID[1] =
                "De tai "
                    + resultMusicID[0]
                    + " ban soan: CHON "
                    + resultMusicID[1]
                    + " gui 1221.Bai hat HOT nhat trong thang: "
                    + musicHot_Beeline[imusic];
          }

          if (resultMusicID[1].length() > 160) {
            String[] subString = new String[2];
            subString[0] = resultMusicID[1].substring(0, 159);
            subString[1] = resultMusicID[1].substring(160);
            for (int k = 0; k < 2; k++) {
              if (!"".equalsIgnoreCase(subString[k])) {
                msgObject.setUsertext(subString[k]);
                if (k == 0) {
                  msgObject.setMsgtype(1);
                } else {
                  msgObject.setMsgtype(0);
                }
                msgObject.setContenttype(0);
                DBUtil.sendMT(msgObject);
                Thread.sleep(1000);
              }
            }

          } else {

            msgObject.setUsertext(resultMusicID[1]);
            msgObject.setMsgtype(1);
            msgObject.setContenttype(0);
            // messages.add(new MsgObject(ms//gObject));
            DBUtil.sendMT(msgObject);
            Thread.sleep(1000);
          }

          // tim danh sach bai hat hot
          // Kiem tra so lan gui tin cua khach hang
          int time2send = getUserID(userid, dbcontent, 1);
          String lastid = "";
          if (time2send >= 1) {
            lastid = getMusicID(userid, dbcontent, 1);
          } else {
            // Ghi lai danh sach khach hang da gui
            saverequest(userid, dbcontent, 1);
          }

          // Lay danh sach cac bai hat HOT
          String musichotsend = findListofMusic(userid, infoid, lastid, 1);

          String[] listsendClient = splitString(musichotsend);

          if (!"".equalsIgnoreCase(listsendClient[0])) {
            msgObject.setUsertext(listsendClient[0]);
            msgObject.setMsgtype(0);
            msgObject.setContenttype(0);
            // messages.add(new MsgObject(msgObject));
            DBUtil.sendMT(msgObject);
            Thread.sleep(500);
          }

          // Send MT4 cho khach hang
          String sendtoClient =
              "Ngoai nhung BH ban vua nhan duoc,van con hang ngan BH khac tren "
                  + numberid
                  + ".De tiep tuc nhan duoc ma so BH.Soan:"
                  + last_msg;
          msgObject.setUsertext(sendtoClient);
          msgObject.setMsgtype(0);
          msgObject.setContenttype(0);
          // messages.add(new MsgObject(msgObject));
          DBUtil.sendMT(msgObject);
          Thread.sleep(500);

          return null;

        } else {

          // Bai hat chua co trong he thong.
          // Send MT 1
          String info2Client = "";
          if ("viettel".equalsIgnoreCase(infoid)) {
            info2Client =
                "Bai hat ban thich hien tai chua co trong he thong. De tai bai hat.Buoc1, soan DK gui 1221.Buoc2, soan: BH maso gui 1221. Tang ban ma so BH HOT:";
          } else if ("vinaphone".equalsIgnoreCase(infoid)) {
            info2Client =
                "Bai hat ban thich hien tai chua co trong he thong. De tai bai hat.Buoc1, soan DK gui 9194.Buoc2, soan: TUNE maso gui 9194. Tang ban ma so BH HOT:";
          } else if ("mobifone".equalsIgnoreCase(infoid)) {
            info2Client =
                "Bai hat ban thich hien tai chua co trong he thong. De tai bai hat.Buoc1, soan DK gui 9224.Buoc2, soan: CHON maso gui 9224. Tang ban ma so BH HOT:";
          } else if ("beeline".equalsIgnoreCase(infoid)) {
            info2Client =
                "Bai hat ban thich hien tai chua co trong he thong. De tai bai hat, soan: CHON masobaihat gui 1221. Tang ban ma so BH HOT:";
          }

          msgObject.setUsertext(info2Client);
          msgObject.setMsgtype(1);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);

          // Send MT 2 - 3
          // tim danh sach bai hat hot
          // Kiem tra so lan gui tin cua khach hang
          int time2send = getUserID(userid, dbcontent, 1);
          String lastid = "";
          if (time2send >= 1) {
            lastid = getMusicID(userid, dbcontent, 1);
          } else {
            // Ghi lai danh sach khach hang da gui
            saverequest(userid, dbcontent, 1);
          }

          // Lay danh sach cac bai hat HOT
          String musichotsend = findListofMusic(userid, infoid, lastid, 1);

          String[] listsendClient = splitString(musichotsend);

          if (!"".equalsIgnoreCase(listsendClient[0])) {
            msgObject.setUsertext(listsendClient[0]);
            msgObject.setMsgtype(0);
            msgObject.setContenttype(0);
            // messages.add(new MsgObject(msgObject));
            DBUtil.sendMT(msgObject);
            Thread.sleep(500);
          }

          // Send MT4 cho khach hang
          String sendtoClient =
              "Ngoai nhung BH ban vua nhan duoc, van con hang ngan BH khac tren "
                  + numberid
                  + ".De tiep tuc nhan duoc ma so BH.Soan: "
                  + last_msg;
          msgObject.setUsertext(sendtoClient);
          msgObject.setMsgtype(0);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(500);
          return null;
        }
      } else {

        /* nc */
        // Send MT
        int timesend = getUserID(userid, dbcontent, 0);
        String lastid = "";
        if (timesend >= 1) {
          // Gui lan thu 2
          lastid = getMusicID(userid, dbcontent, 0);
        } else {
          // Ghi lai thong tin ghi nhan khach hang da gui den 6x54
          saverequest(userid, dbcontent, 0);
        }

        String info2Client = "";
        if ("viettel".equalsIgnoreCase(infoid)) {
          info2Client = viettelGuide;
        } else if ("vinaphone".equalsIgnoreCase(infoid)) {
          info2Client = vinaphoneGuide;
        } else if ("mobifone".equalsIgnoreCase(infoid)) {
          info2Client = mobifoneGuide;
        } else if ("beeline".equalsIgnoreCase(infoid)) {
          info2Client = beelineGuide;
        }
        msgObject.setUsertext(info2Client);
        msgObject.setMsgtype(1);
        msgObject.setContenttype(0);
        // messages.add(new MsgObject(msgObject));
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);

        // MT2 - 3
        String musichotsend = findListofMusic(userid, infoid, lastid, 1);

        String[] listsendClient = splitString(musichotsend);

        if (!"".equalsIgnoreCase(listsendClient[0])) {
          msgObject.setUsertext(listsendClient[0]);
          msgObject.setMsgtype(0);
          msgObject.setContenttype(0);
          // messages.add(new MsgObject(msgObject));
          DBUtil.sendMT(msgObject);
          Thread.sleep(500);
        }

        // MT 4
        // Send MT4 cho khach hang
        String sendtoClient =
            "Ngoai nhung BH ban vua nhan duoc, van con hang ngan BH khac tren "
                + numberid
                + ".De tiep tuc nhan duoc ma so BH.Soan: "
                + last_msg;
        msgObject.setUsertext(sendtoClient);
        msgObject.setMsgtype(0);
        msgObject.setContenttype(0);
        // messages.add(new MsgObject(msgObject));
        DBUtil.sendMT(msgObject);
        Thread.sleep(500);
        return null;
      }

    } catch (Exception e) {

      Util.logger.sysLog(2, this.getClass().getName(), "Exception:" + e.getMessage());
      return null;

    } finally {

      if ("1".equalsIgnoreCase(ismtadd))
        ExecuteADVCR.add2queueADV(
            msgObject.getMsgtype(),
            msgObject.getServiceid(),
            msgObject.getUserid(),
            msgObject.getKeyword(),
            msgObject.getRequestid(),
            msgObject.getTTimes(),
            msgObject.getMobileoperator());
    }
  }
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    String ismtadd = "0";
    String isforwardMO = "0";
    try {
      Collection messages = new ArrayList();

      String infoid = "";
      String sKeyword = msgObject.getKeyword();
      String inv_telco =
          "Hien tai dich vu chua ho tro mang cua ban, moi ban quay lai sau.DTHT 1900571566";

      HashMap _option = new HashMap();
      String options = keyword.getOptions();
      try {
        Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);
        _option = getParametersAsString(options);
        ismtadd = getString(_option, "ismtadd", ismtadd);
        isforwardMO = getString(_option, "mo", isforwardMO);

      } catch (Exception e) {
        Util.logger.sysLog(2, this.getClass().getName(), "Error: " + e.toString());
        throw new Exception("Wrong config in options");
      }

      // lay so thue bao nguoi gui
      String userid = msgObject.getUserid();
      /* lay noi dung gui */
      String userText = replaceAllWhiteWithOne(msgObject.getUsertext());
      String[] sTokens = replaceAllWhiteWithOne(userText).split(" ");
      Calendar cal = Calendar.getInstance();
      int day = cal.get(Calendar.DATE);
      int month = cal.get(Calendar.MONTH) + 1;
      int year = cal.get(Calendar.YEAR);
      String date = FormatNumber(day) + "/" + FormatNumber(month) + "/" + year;
      String mt2 =
          "Tang ban 3 game online HOT nhat hien nay.DTHT 1900571566:http://s.mobinet.vn/d/list_gf.htm";

      if (sTokens.length == 1) {
        msgObject.setUsertext(
            "Tin ban gui khong hop le. De tim ban theo nam sinh, soan: N namsinh gui 8251. De tim ban theo noi o va nam sinh, soan T namsinh tinh gui 8251.");
        msgObject.setMsgtype(1);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        return null;
      } else {
        List<String> nick = findBirth(sTokens[1]);
        String nick_example = "";
        if (nick.size() > 0) {
          String allNick = "";
          nick_example = nick.get(0);
          int size = 0;
          for (int i = 0; i < nick.size(); i++) {
            allNick += nick.get(i) + ",";
            size += 1;
            if (size == 5) {
              allNick = allNick.substring(0, allNick.length() - 1);
              break;
            }
          }
          msgObject.setUsertext("Thanh vien sinh nam " + sTokens[1] + ": " + allNick);
          msgObject.setMsgtype(1);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);

          msgObject.setUsertext(
              "De xin SDT cua thanh vien khac, soan: SDT <ma so cua thanh vien do> gui 8551. VD: SDT "
                  + nick_example
                  + " gui 8551. DTHT: 1900571566");
          msgObject.setMsgtype(0);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);

        } else {
          msgObject.setUsertext(
              "Khong tim thay nick nao theo yeu cau cua ban. Ban co the tim theo ngay sinh khac. DTHT: 1900571566");
          msgObject.setMsgtype(1);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);
        }

        return null;
      }

    } catch (Exception e) {

      Util.logger.sysLog(2, this.getClass().getName(), "Exception:" + e.getMessage());
      return null;

    } finally {

      if ("1".equalsIgnoreCase(ismtadd))
        ExecuteADVCR.add2queueADV(
            msgObject.getMsgtype(),
            msgObject.getServiceid(),
            msgObject.getUserid(),
            msgObject.getKeyword(),
            msgObject.getRequestid(),
            msgObject.getTTimes(),
            msgObject.getMobileoperator());
    }
  }
示例#4
0
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {

    String ismtadd = "0";
    String isforwardMO = "0";
    try {
      Collection messages = new ArrayList();

      String infoid = "";
      String sKeyword = msgObject.getKeyword();
      String inv_telco =
          "Hien tai dich vu chua ho tro mang cua ban, moi ban quay lai sau.DTHT 1900571566";
      String mt1 =
          "De tai Game theo ma so, soan: GAME maso gui 8751.Cai dat GPRS 3.0 tu dong ve may de co the luot web va choi game,tai nhac,soan tin GPRS gui 8751.";

      HashMap _option = new HashMap();
      String options = keyword.getOptions();
      try {
        Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);
        _option = getParametersAsString(options);
        ismtadd = getString(_option, "ismtadd", ismtadd);
        mt1 = getString(_option, "mt1", mt1);
        isforwardMO = getString(_option, "mo", isforwardMO);

      } catch (Exception e) {
        Util.logger.sysLog(2, this.getClass().getName(), "Error: " + e.toString());
        throw new Exception("Wrong config in options");
      }

      /* kiem tra thue bao khach hang */

      if ("SFONE".equalsIgnoreCase(msgObject.getMobileoperator())) {
        msgObject.setUsertext(inv_telco);
        msgObject.setMsgtype(2);
        messages.add(new MsgObject(msgObject));
        return messages;
      }

      // lay so thue bao nguoi gui
      String userid = msgObject.getUserid();
      /* lay noi dung gui */
      String userText = replaceAllWhiteWithOne(msgObject.getUsertext());
      String[] sTokens = replaceAllWhiteWithOne(userText).split(" ");
      Calendar cal = Calendar.getInstance();
      int day = cal.get(Calendar.DATE);
      int month = cal.get(Calendar.MONTH) + 1;
      int year = cal.get(Calendar.YEAR);
      String date = FormatNumber(day) + "/" + FormatNumber(month) + "/" + year;
      String mt2 =
          "Tang ban 3 game online HOT nhat hien nay.DTHT 1900571566:http://s.mobinet.vn/d/list_gf.htm";

      if (sTokens.length == 1) {
        msgObject.setUsertext(
            "Cam on ban da su dung dich vu.Yeu cau cua ban chua hop le, ban vui long kiem tra lai cu phap hoac lien he tong dai 1900571566 de duoc huong dan su dung dich vu.");
        msgObject.setMsgtype(1);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        msgObject.setUsertext(mt2);
        msgObject.setMsgtype(0);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        return null;
      } else {

        String nick = "";

        if (sTokens[1].length() > 20) {
          msgObject.setUsertext(
              "Nick ban dang ky khong hop le. Vui long chon nick khac hoac goi 1900571566 de duoc huong dan chi tiet.");
          msgObject.setMsgtype(1);
          msgObject.setContenttype(0);
          DBUtil.sendMT(msgObject);
          Thread.sleep(1000);
        } else {

          nick = Getnickbysdt(msgObject.getUserid());

          if (!nick.equalsIgnoreCase("")) {
            msgObject.setUsertext(
                "SDT nay da dky nick "
                    + nick
                    + " tren HNS. De huy nick, soan: HUYN gui 8151. DTHT: 1900571566");
            msgObject.setMsgtype(1);
            msgObject.setContenttype(0);
            DBUtil.sendMT(msgObject);
            Thread.sleep(1000);
          } else {
            nick = Checknick(sTokens[1]);
            if (!nick.equalsIgnoreCase("")) {
              msgObject.setUsertext(
                  "Nick ban chon da co nguoi su dung. Vui long chon nick khac. Chuc ban co nhung giay phut vui ve cung Hop Nhac So tu 8h - 11h hang ngay tren VTV6");
              msgObject.setMsgtype(1);
              msgObject.setContenttype(0);
              DBUtil.sendMT(msgObject);
              Thread.sleep(1000);
            } else {
              msgObject.setUsertext(
                  "Nick cua ban da chuyen sang che do cho duyet. Xin vui long cho. DTHT: 1900571566");
              msgObject.setMsgtype(1);
              msgObject.setContenttype(0);
              DBUtil.sendMT(msgObject);
              Thread.sleep(1000);
              // insert vao bang queue
              savenickqueue(msgObject.getUserid(), sTokens[1], msgObject.getRequestid() + "");
            }
          }
        }

        // mt2
        msgObject.setUsertext(
            "Cac bai hat Hot tren iMbox:"
                + findListofMusic(date)
                + " Lien he 1900571566 de duoc ho tro");
        msgObject.setMsgtype(0);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        msgObject.setUsertext(
            "Game Lam vuon hap dan, soi dong,thoai mai chat chit, dang ky ngay tai day:http://funzone.vn/lamvuon/sub_icom.php");
        msgObject.setMsgtype(0);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
        return null;
      }

    } catch (Exception e) {

      Util.logger.sysLog(2, this.getClass().getName(), "Exception:" + e.getMessage());
      return null;

    } finally {

      if ("1".equalsIgnoreCase(ismtadd))
        ExecuteADVCR.add2queueADV(
            msgObject.getMsgtype(),
            msgObject.getServiceid(),
            msgObject.getUserid(),
            msgObject.getKeyword(),
            msgObject.getRequestid(),
            msgObject.getTTimes(),
            msgObject.getMobileoperator());
    }
  }
示例#5
0
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    try {
      Collection messages = new ArrayList();
      String sUserid = msgObject.getUserid();
      String sKeyword = msgObject.getKeyword();
      String sServiceid = msgObject.getServiceid();
      String sUsertext = msgObject.getUsertext();

      sUsertext = replaceAllWhiteWithOne(sUsertext);
      HashMap _option = new HashMap();
      String options = keyword.getOptions();
      _option = getParametersAsString(options);
      Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);
      String stime = "7h thu 3";
      stime = getString(_option, "stime", stime);
      String[] sTokens = sUsertext.split(" ");
      String[] kq1 = getPhien();
      String sBeginDate = "";
      String sEndDate = "";
      String sSanpham = "xxxx";

      int iPhien = 0;

      if ("SFONE".equalsIgnoreCase(msgObject.getMobileoperator().toUpperCase())) {
        msgObject.setUsertext(
            "Hien tai dich vu chua ho tro mang cua ban.Vui long quay tro lai sau.DTHT 1900571566");
        msgObject.setMsgtype(2);
        messages.add(new MsgObject(msgObject));
        return messages;
      }
      if (kq1[0].equalsIgnoreCase("")) {
        msgObject.setUsertext(
            "Chuong trinh chua bat dau.Hay quay lai vao chuong trinh lan sau vao "
                + stime
                + " hang tuan tren VOV giao thong 91MHz.DTHT:1900571566.");
        msgObject.setMsgtype(1);
        messages.add(new MsgObject(msgObject));
        return messages;
      }
      HashMap bgia = new HashMap();

      iPhien = Integer.parseInt(kq1[0]);
      Util.logger.info("iPhien" + iPhien);
      sBeginDate = String2Date(kq1[1]);
      sEndDate = String2Date(kq1[2]);
      sSanpham = kq1[3];
      if (sTokens.length == 1) {
        msgObject.setUsertext(
            "Tin nhan sai cu phap.Soan tin "
                + keyword.getKeyword()
                + " giaSP gui "
                + keyword.getServiceid()
                + " de tham gia chuong trinh Dau gia nguoc.DTHT:1900571566");
        msgObject.setMsgtype(1);
        messages.add(new MsgObject(msgObject));

      } else {

        String sMTReturn = "";
        sMTReturn = mtReturn(sKeyword, sServiceid, sUserid, sUsertext, iPhien, sSanpham);
        msgObject.setUsertext(sMTReturn);
        msgObject.setMsgtype(1);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);

        String[] gw_old = getWinnerKQ(iPhien);
        String[] gw = getWinner(iPhien);
        Util.logger.info("user old:" + gw_old[0] + ",price: " + gw_old[1]);
        Util.logger.info("gw[0]:" + gw[0] + "gw[1]:" + gw[1] + "gw[2]:" + gw[2]);
        if (!gw_old[1].equalsIgnoreCase("-1")) {
          Util.logger.info("Co nguoi thang cu");
          String text =
              "Gia cua ban chon khong con la duy nhat va thap nhat.Nhanh tay dat gia de gianh quyen mua "
                  + sSanpham
                  + " voi gia thap nhat";
          String giff_telco = "";
          if (!gw_old[1].equalsIgnoreCase(gw[1])) {
            if (!gw[0].equalsIgnoreCase("-1")) {
              Util.logger.info("Co nguoi thang moi , thay the nguoi thag cu");
              try {
                giff_telco = getMobileOperatorNew(gw_old[0], 2);
                Util.logger.info("operator giff:" + giff_telco);
                sendGifMsg(
                    msgObject.getServiceid(),
                    gw_old[0],
                    giff_telco,
                    msgObject.getKeyword(),
                    text,
                    msgObject.getRequestid(),
                    0);
              } catch (Exception ex3) {
                Util.logger.error("Khong gui duoc tin cho nguoi thang cu");
              }
              updateWinner(sKeyword, sServiceid, gw[2], gw[1], iPhien);

            } else {
              try {
                giff_telco = getMobileOperatorNew(gw_old[0], 2);
                Util.logger.info("operator giff:" + giff_telco);
                sendGifMsg(
                    msgObject.getServiceid(),
                    gw_old[0],
                    giff_telco,
                    msgObject.getKeyword(),
                    text,
                    msgObject.getRequestid(),
                    0);
              } catch (Exception ex3) {
                Util.logger.error("Khong gui duoc tin cho nguoi thang cu");
              }
              Util.logger.info("Hien tai khong co ai thang");
              deleteWinner(iPhien);
            }
          }

        } else if (!gw[0].equalsIgnoreCase("-1")) {
          Util.logger.info("Co nguoi thang moi");
          saveWinner(sKeyword, sServiceid, sUserid, gw[1], iPhien);
        } else Util.logger.info("Hien tai khong co ai thang");
        return null;
      }

      return messages;

    } catch (Exception ex) {
      Util.logger.error("Error:" + ex.toString());
      return null;
    } finally {

      ExecuteADVCR.add2queueADV(
          msgObject.getMsgtype(),
          msgObject.getServiceid(),
          msgObject.getUserid(),
          msgObject.getKeyword(),
          msgObject.getRequestid(),
          msgObject.getTTimes(),
          msgObject.getMobileoperator());
    }
  }
示例#6
0
  @Override
  protected Collection getMessages(MsgObject msgObject, Keyword keyword) throws Exception {
    HashMap _option = new HashMap();
    String options = keyword.getOptions();
    Collection messages = new ArrayList();
    String dtbase = "gateway";
    String operator = msgObject.getMobileoperator();
    try {
      Util.logger.sysLog(2, this.getClass().getName(), "options: " + options);

      _option = getParametersAsString(options);
      dtbase = getString(_option, "dtbase", dtbase);

      String info = msgObject.getUsertext();
      String mt = "";

      mt = getContent(info);
      if (!mt.equalsIgnoreCase("")) {
        String[] mtsplit = mt.split("###");
        String total = "";
        String index = "";
        String ismore = "";
        int intindex = 0;
        for (int j = 0; j < mtsplit.length; j++) {
          if (!"".equalsIgnoreCase(mtsplit[j])) {

            msgObject.setUsertext(mtsplit[j]);
            if (j == 0) {
              msgObject.setMsgtype(1);

            } else msgObject.setMsgtype(0);

            msgObject.setContenttype(0);
            total = mtsplit.length + "";
            intindex = j + 1;
            index = intindex + "";
            if (j == mtsplit.length - 1) {
              ismore = 0 + "";
            } else ismore = 1 + "";

            DBUtil.sendMT(msgObject);
            Thread.sleep(1000);
          }
        }
      } else {
        msgObject.setUsertext("Ban nhan tin sai cu phap. DTHT 1900571566");
        msgObject.setMsgtype(1);
        msgObject.setContenttype(0);
        DBUtil.sendMT(msgObject);
        Thread.sleep(1000);
      }
      return null;
    } catch (Exception e) {

      Util.logger.sysLog(2, this.getClass().getName(), "Exception: " + e.getMessage());
      return null;

    } finally {

      ExecuteADVCR.add2queueADV(
          msgObject.getMsgtype(),
          msgObject.getServiceid(),
          msgObject.getUserid(),
          msgObject.getKeyword(),
          msgObject.getRequestid(),
          msgObject.getTTimes(),
          msgObject.getMobileoperator());
    }
  }