Example #1
0
  private String getCompanyID(String companycode) throws Exception {
    String companyid = "";
    Object[] cys = StringUtil.split(Params.company, ";").toArray();
    for (int i = 0; i < cys.length; i++) {
      String cy = (String) cys[i];

      Object[] cs = StringUtil.split(cy, ":").toArray();

      String ccode = (String) cs[0];
      String cid = (String) cs[1];

      if (ccode.equals(companycode)) {
        companyid = cid;
        break;
      }
    }

    return companyid;
  }
Example #2
0
  private void delivery(Connection conn) throws Exception {

    String sql =
        "select  a.sheetid,b.tid, upper(ltrim(rtrim(b.companycode))) companycode,"
            + "upper(ltrim(rtrim(b.outsid))) outsid from it_upnote a with(nolock), ns_delivery b with(nolock)"
            + "where a.sheettype=3 and a.sheetid=b.sheetid and a.receiver='"
            + Params.tradecontactid
            + "' and b.iswait=0";
    Vector vdeliveryorder = SQLHelper.multiRowSelect(conn, sql);
    Log.info(username, " 本次要处理的淘宝发货条数为: " + vdeliveryorder.size(), null);
    for (int i = 0; i < vdeliveryorder.size(); i++) {

      Hashtable hto = (Hashtable) vdeliveryorder.get(i);
      String sheetid = hto.get("sheetid") != null ? hto.get("sheetid").toString() : "";
      String orderid = hto.get("tid") != null ? hto.get("tid").toString() : "";
      String post_company = hto.get("companycode") != null ? hto.get("companycode").toString() : "";
      String post_no = hto.get("outsid") != null ? hto.get("outsid").toString() : "";
      // 如果物流公司为空则忽略处理
      if (post_company.trim().equals("")) {
        Log.warn(username, jobName + " 快递公司为空!订单号:" + orderid, null);
        continue;
      }

      // 如果物流公司为空则忽略处理
      if (post_no.trim().equals("")) {
        Log.warn(username, "快递单号为空!订单号:" + orderid, null);
        continue;
      }

      if (!StringUtil.isNumeric(orderid)) {
        sql =
            "insert into IT_UpNoteBak(Owner,SheetID,SheetType,Sender,Receiver,Notetime,HandleTime,Flag) "
                + " select Owner , SheetID , SheetType , Sender , Receiver , Notetime , getdate() , 1 from IT_UpNote "
                + " where SheetID = '"
                + sheetid
                + "' and SheetType = 3";
        SQLHelper.executeSQL(conn, sql);

        sql = "delete from IT_UpNote where SheetID='" + sheetid + "' and sheettype=3";

        SQLHelper.executeSQL(conn, sql);

        Log.warn(username, jobName + ",订单号【" + orderid + "】不全是数字!", null);
        continue;
      }
      if ("1".equals(Params.isJZ)) {
        sql = "select top 1 lbpdc from ns_customerorder where tid='" + orderid + "'";
        String isJz = SQLHelper.strSelect(conn, sql);
        if ("zj".equals(isJz)) { // 家装订单
          // jzSend(post_no,orderid,post_company,conn,sheetid);
          Log.info(username, "家装订单暂时不发货: 订单号: " + orderid, null);
        } else normalSend(post_no, orderid, post_company, conn, sheetid);
      } else normalSend(post_no, orderid, post_company, conn, sheetid);
    }
  }
Example #3
0
  public void run() {

    Properties prop = StringUtil.getStringProperties(this.getExecuteobj().getParams());

    url = prop.getProperty("url");
    tradecontactid = prop.getProperty("tradecontactid");
    username = prop.getProperty("username");
    app_id = prop.getProperty("app_id");
    secret = prop.getProperty("secret");
    session = prop.getProperty("session");
    System.out.println(url);
    System.out.println(tradecontactid);
    System.out.println(username);
    System.out.println(app_id);
    System.out.println(secret);
    System.out.println(session);
    try {

      updateJobFlag(1);

      synStock();

      UpdateTimerJob();

      Log.info(
          jobName,
          "执行作业成功 ["
              + this.getExecuteobj().getActivetimes()
              + "] ["
              + this.getExecuteobj().getNotes()
              + "] 下次处理时间: "
              + this.datetimeformat.format(this.getExecuteobj().getNextactive()));

    } catch (Exception e) {
      try {
        if (this.getExecuteobj().getSkip() == 1) {
          UpdateTimerJob();
        } else UpdateTimerJob(Log.getErrorMessage(e));

        if (this.getConnection() != null && !this.getConnection().getAutoCommit())
          this.getConnection().rollback();

        if (this.getExtconnection() != null && !this.getExtconnection().getAutoCommit())
          this.getExtconnection().rollback();

      } catch (Exception e1) {
        Log.error(jobName, "回滚事务失败");
      }
      Log.error(jobName, "错误信息:" + Log.getErrorMessage(e));

      Log.error(
          jobName,
          "执行作业失败 ["
              + this.getExecuteobj().getActivetimes()
              + "] ["
              + this.getExecuteobj().getNotes()
              + "] \r\n  "
              + Log.getErrorMessage(e));

    } finally {
      try {
        updateJobFlag(0);
      } catch (Exception e) {
        Log.error(jobName, "更新处理标志失败");
      }

      try {
        if (this.getConnection() != null) this.getConnection().close();
        if (this.getExtconnection() != null) this.getExtconnection().close();

      } catch (Exception e) {
        Log.error(jobName, "关闭数据库连接失败");
      }
    }
  }
Example #4
0
  @Override
  public void run() {
    Properties prop = StringUtil.getStringProperties(this.getExecuteobj().getParams());
    pageSize = prop.getProperty("pageSize");
    url = prop.getProperty("url");
    tradecontactid = prop.getProperty("tradecontactid");
    username = prop.getProperty("username");

    try {
      // 检查未入订单
      updateJobFlag(1);
      checkWaitStockOutOrders();
      // 检查取消订单
      checkCancleOrders();

      UpdateTimerJob();

      Log.info(
          jobName,
          "执行作业成功 ["
              + this.getExecuteobj().getActivetimes()
              + "] ["
              + this.getExecuteobj().getNotes()
              + "] 下次处理时间: "
              + this.datetimeformat.format(this.getExecuteobj().getNextactive()));

    } catch (Exception e) {
      try {

        if (this.getExecuteobj().getSkip() == 1) {
          UpdateTimerJob();
        } else UpdateTimerJob(Log.getErrorMessage(e));

        updateJobFlag(0);

        if (this.getConnection() != null && !this.getConnection().getAutoCommit())
          this.getConnection().rollback();

        if (this.getExtconnection() != null && !this.getExtconnection().getAutoCommit())
          this.getExtconnection().rollback();

      } catch (Exception e1) {
        Log.error(jobName, "回滚事务失败");
      }
      Log.error(jobName, "错误信息:" + Log.getErrorMessage(e));

      Log.error(
          jobName,
          "执行作业失败 ["
              + this.getExecuteobj().getActivetimes()
              + "] ["
              + this.getExecuteobj().getNotes()
              + "] \r\n  "
              + Log.getErrorMessage(e));

    } finally {
      try {
        updateJobFlag(0);
      } catch (Exception e) {
        Log.error(jobName, "更新处理标志失败");
      }

      try {
        if (this.getConnection() != null) this.getConnection().close();
        if (this.getExtconnection() != null) this.getExtconnection().close();

      } catch (Exception e) {
        Log.error(jobName, "关闭数据库连接失败");
      }
    }
  }
  public void run() {
    Properties proper = StringUtil.getStringProperties(this.getExecuteobj().getParams());
    tid = proper.getProperty("tid");
    tradecontactid = proper.getProperty("tradecontactid");
    url = proper.getProperty("url");
    appkey = proper.getProperty("appkey");
    appsecret = proper.getProperty("appsecret");
    authcode = proper.getProperty("authcode");
    sellernick = proper.getProperty("sellernick");
    try {
      updateJobFlag(1);
      String sql = "select isnull(value,0) from config where name='等待付款订单是否进系统'";
      if ("1".equals(this.getDao().strSelect(sql))) ;
      waitbuyerpayisin = true;

      TaobaoClient client = new DefaultTaobaoClient(url, appkey, appsecret, "xml");
      TradeGetRequest req = new TradeGetRequest();
      req.setFields("tid,modified,status,orders.outer_sku_id,orders.num");
      req.setTid(Long.parseLong(tid));
      TradeGetResponse response = client.execute(req, authcode);

      if (response.getTrade() == null) {
        return;
      }

      Trade td = response.getTrade();

      if (td.getStatus().equals("WAIT_SELLER_SEND_GOODS")) {

        if (!OrderManager.isCheck(
            "检查淘宝订单", this.getDao().getConnection(), String.valueOf(td.getTid()))) {
          if (!OrderManager.TidLastModifyIntfExists(
              "检查淘宝订单",
              this.getDao().getConnection(),
              String.valueOf(td.getTid()),
              td.getModified())) {
            OrderUtils.createInterOrder(
                this.getDao().getConnection(), td, Params.tradecontactid, Params.username, true);
            for (Iterator ito = td.getOrders().iterator(); ito.hasNext(); ) {
              Order o = (Order) ito.next();
              String sku = o.getOuterSkuId();

              StockManager.deleteWaitPayStock(
                  jobName,
                  this.getDao().getConnection(),
                  Params.tradecontactid,
                  String.valueOf(td.getTid()),
                  sku);
              StockManager.addSynReduceStore(
                  jobName,
                  this.getDao().getConnection(),
                  Params.tradecontactid,
                  td.getStatus(),
                  String.valueOf(td.getTid()),
                  sku,
                  -o.getNum(),
                  false);
            }
          }
        }

        // 等待买家付款时记录锁定库存
      } else if (td.getStatus().equals("WAIT_BUYER_PAY")
          || td.getStatus().equals("TRADE_NO_CREATE_PAY")) {
        if (waitbuyerpayisin) {
          if (!OrderManager.TidLastModifyIntfExists(
              "检查淘宝订单",
              this.getDao().getConnection(),
              String.valueOf(td.getTid()),
              td.getModified())) {
            OrderUtils.createInterOrder(
                this.getDao().getConnection(), td, Params.tradecontactid, Params.username, false);
          }
        }
        for (Iterator ito = td.getOrders().iterator(); ito.hasNext(); ) {
          Order o = (Order) ito.next();
          String sku = o.getOuterSkuId();
          StockManager.addWaitPayStock(
              jobName,
              this.getDao().getConnection(),
              Params.tradecontactid,
              String.valueOf(td.getTid()),
              sku,
              o.getNum());
          StockManager.addSynReduceStore(
              jobName,
              this.getDao().getConnection(),
              Params.tradecontactid,
              td.getStatus(),
              String.valueOf(td.getTid()),
              sku,
              -o.getNum(),
              false);
        }

        // 付款以后用户退款成功,交易自动关闭
        // 释放库存,数量为负数
      } else if (td.getStatus().equals("TRADE_CLOSED")) {
        OrderManager.CancelOrderByCID(
            jobName, this.getDao().getConnection(), String.valueOf(td.getTid()));
        for (Iterator ito = td.getOrders().iterator(); ito.hasNext(); ) {
          Order o = (Order) ito.next();
          String sku = o.getOuterSkuId();
          StockManager.deleteWaitPayStock(
              jobName,
              this.getDao().getConnection(),
              Params.tradecontactid,
              String.valueOf(td.getTid()),
              sku);
          // StockManager.addSynReduceStore(jobName, this.getDao().getConnection(),
          // Params.tradecontactid, td.getStatus(),String.valueOf(td.getTid()),sku,
          // o.getNum(),false);
        }

        // 付款以前,卖家或买家主动关闭交易
        // 释放等待买家付款时锁定的库存
      } else if (td.getStatus().equals("TRADE_CLOSED_BY_TAOBAO")) {

        if (waitbuyerpayisin) {

          if (!OrderManager.TidLastModifyIntfExists(
              "检查淘宝订单",
              this.getDao().getConnection(),
              String.valueOf(td.getTid()),
              td.getModified())) {
            OrderUtils.createInterOrder(
                this.getDao().getConnection(), td, Params.tradecontactid, Params.username, false);
          }
        }

        for (Iterator ito = td.getOrders().iterator(); ito.hasNext(); ) {
          Order o = (Order) ito.next();
          String sku = o.getOuterSkuId();

          StockManager.deleteWaitPayStock(
              jobName,
              this.getDao().getConnection(),
              Params.tradecontactid,
              String.valueOf(td.getTid()),
              sku);

          if (StockManager.WaitPayStockExists(
              jobName,
              this.getDao().getConnection(),
              Params.tradecontactid,
              String.valueOf(td.getTid()),
              sku)) // 有获取到等待买家付款状态时才加库存
          {

            StockManager.addSynReduceStore(
                jobName,
                this.getDao().getConnection(),
                Params.tradecontactid,
                td.getStatus(),
                String.valueOf(td.getTid()),
                sku,
                o.getNum(),
                false);
          }
        }

      } else if (td.getStatus().equals("TRADE_FINISHED")) {

        for (Iterator ito = td.getOrders().iterator(); ito.hasNext(); ) {
          Order o = (Order) ito.next();
          String sku = o.getOuterSkuId();

          StockManager.deleteWaitPayStock(
              jobName,
              this.getDao().getConnection(),
              Params.tradecontactid,
              String.valueOf(td.getTid()),
              sku);

          // 更新结束时间

          OrderUtils.updateFinishedStatus(
              this.getDao().getConnection(), Params.tradecontactid, td.getTid(), td.getEndTime());
        }
      }

      // if(Params.isc)
      // {
      // 处理退货
      for (Iterator oit = td.getOrders().iterator(); oit.hasNext(); ) {
        Order o = (Order) oit.next();
        // Log.info("订单号:"+String.valueOf(td.getTid())+" 退货ID:"+String.valueOf(o.getRefundId()));
        if (o.getRefundId() > 0) {
          OrderUtils.getRefund(
              jobName,
              this.getDao().getConnection(),
              Params.url,
              Params.appkey,
              Params.appsecret,
              Params.authcode,
              Params.tradecontactid,
              td,
              o,
              String.valueOf(td.getTid()),
              o.getRefundId());
        }
      }

      updateJobFlag(0);
      Log.info(
          jobName,
          "执行作业成功 ["
              + this.getExecuteobj().getActivetimes()
              + "] ["
              + this.getExecuteobj().getNotes()
              + "] 下次处理时间: "
              + this.datetimeformat.format(this.getExecuteobj().getNextactive()));

    } catch (Exception e) {
      try {

        if (this.getDao().getConnection() != null
            && !this.getDao().getConnection().getAutoCommit()) {
          this.getDao().getConnection().rollback();
          this.getDao().getConnection().setAutoCommit(true);
        }

      } catch (Exception e1) {
        Log.error(jobName, "回滚事务失败");
        Log.error(jobName, e1.getMessage());
      }

      try {
        if (this.getExecuteobj().getSkip() == 1) {
          UpdateTimerJob();
        } else UpdateTimerJob(Log.getErrorMessage(e));
      } catch (Exception ex) {
        Log.error(jobName, "更新任务信息失败");
        Log.error(jobName, ex.getMessage());
      }
      Log.error(jobName, "错误信息:" + Log.getErrorMessage(e));

      Log.error(
          jobName,
          "执行作业失败 ["
              + this.getExecuteobj().getActivetimes()
              + "] ["
              + this.getExecuteobj().getNotes()
              + "] \r\n  "
              + Log.getErrorMessage(e));
    } finally {

      try {
        updateJobFlag(0);
      } catch (Exception e) {
        Log.error(jobName, e.getMessage());
        Log.error(jobName, "更新处理标志失败");
        TimerRunner.modifiedErrVect(this.getExecuteobj().getId());
      }

      try {
        if (this.getDao().getConnection() != null) {
          this.getDao().getConnection().setAutoCommit(true);
          this.getDao().getConnection().close();
        }

      } catch (Exception e) {
        Log.error(jobName, "关闭数据库连接失败");
      }
    }
  }
Example #6
0
  /** 修改物流公司和运单号 已经发过货的订单才能进行此操作 api : taobao.logistics.consign.resend 免费 */
  private void resend(Connection conn) throws Exception {

    String sql =
        "select  a.sheetid,b.tid, upper(ltrim(rtrim(b.companycode))) companycode,"
            + " upper(ltrim(rtrim(b.outsid))) outsid from it_upnote a with(nolock), ns_delivery b with(nolock)"
            + "where a.sheettype=4 and a.sheetid=b.sheetid and a.receiver='"
            + Params.tradecontactid
            + "' and b.iswait=0";
    Vector vdeliveryorder = SQLHelper.multiRowSelect(conn, sql);
    for (int i = 0; i < vdeliveryorder.size(); i++) {
      String orderid = "";
      try {
        Hashtable hto = (Hashtable) vdeliveryorder.get(i);
        String sheetid = hto.get("sheetid") != null ? hto.get("sheetid").toString() : "";
        orderid = hto.get("tid") != null ? hto.get("tid").toString() : "";
        String post_company =
            hto.get("companycode") != null ? hto.get("companycode").toString().trim() : "";
        String post_no =
            hto.get("outsid").toString() != null ? hto.get("outsid").toString().trim() : "";

        // 如果物流公司为空则忽略处理
        if (post_company.trim().equals("")) {
          Log.warn(username, jobName + " 快递公司为空!订单号:" + orderid + "");
          continue;
        }

        // 如果物流公司为空则忽略处理
        if (post_no.trim().equals("")) {
          Log.warn(username, jobName + "快递单号为空!订单号:" + orderid + "");
          continue;
        }

        if (!StringUtil.isNumeric(orderid)) {
          sql =
              "insert into IT_UpNoteBak(Owner,SheetID,SheetType,Sender,Receiver,Notetime,HandleTime,Flag) "
                  + " select Owner , SheetID , SheetType , Sender , Receiver , Notetime , getdate() , 1 from IT_UpNote "
                  + " where SheetID = '"
                  + sheetid
                  + "' and SheetType = 4";
          SQLHelper.executeSQL(conn, sql);

          sql = "delete from IT_UpNote where SheetID='" + sheetid + "' and sheettype=4";

          SQLHelper.executeSQL(conn, sql);

          Log.warn(username, jobName + " 订单号【" + orderid + "】不全是数字!");
          continue;
        }

        TaobaoClient client = new DefaultTaobaoClient(Params.url, Params.appkey, Params.appsecret);
        LogisticsConsignResendRequest req = new LogisticsConsignResendRequest();
        req.setOutSid(post_no);
        req.setTid(TranTid(orderid));
        req.setCompanyCode(post_company);
        LogisticsConsignResendResponse rsp = client.execute(req, Params.authcode);

        if (rsp.isSuccess()) {

          try {
            conn.setAutoCommit(false);

            sql =
                "insert into IT_UpNoteBak(Owner,SheetID,SheetType,Sender,Receiver,Notetime,HandleTime,Flag) "
                    + " select Owner , SheetID , SheetType , Sender , Receiver , Notetime , getdate() , 1 from IT_UpNote "
                    + " where SheetID = '"
                    + sheetid
                    + "' and SheetType = 4";
            SQLHelper.executeSQL(conn, sql);

            sql = "delete from IT_UpNote where SheetID='" + sheetid + "' and sheettype=4";

            SQLHelper.executeSQL(conn, sql);
            conn.commit();
            conn.setAutoCommit(true);
          } catch (Exception sqle) {
            if (!conn.getAutoCommit())
              try {
                conn.rollback();
              } catch (Exception e1) {
              }
            try {
              conn.setAutoCommit(true);
            } catch (Exception e1) {
            }
            // throw new JSQLException(sql, sqle);
          }
          Log.info(
              username,
              "处理订单【" + orderid + "】发货成功,快递公司【" + post_company + "】,快递单号【" + post_no + "】",
              null);
        } else {

          if (rsp.getSubMsg().indexOf("不能重复发货") >= 0 || rsp.getSubMsg().indexOf("发货类型不匹配") >= 0) {
            sql =
                "insert into IT_UpNoteBak(Owner,SheetID,SheetType,Sender,Receiver,Notetime,HandleTime,Flag) "
                    + " select Owner , SheetID , SheetType , Sender , Receiver , Notetime , getdate() , 1 from IT_UpNote "
                    + " where SheetID = '"
                    + sheetid
                    + "' and SheetType = 4";
            SQLHelper.executeSQL(conn, sql);

            sql = "delete from IT_UpNote where SheetID='" + sheetid + "' and sheettype=4";

            SQLHelper.executeSQL(conn, sql);
            Log.info(
                username,
                "订单【" + orderid + "】不能重复发货,快递公司【" + post_company + "】,快递单号【" + post_no + "】",
                null);
          } else if (rsp.getSubMsg().indexOf("订单未发货") >= 0) {
            sql =
                "insert into IT_UpNoteBak(Owner,SheetID,SheetType,Sender,Receiver,Notetime,HandleTime,Flag) "
                    + " select Owner , SheetID , SheetType , Sender , Receiver , Notetime , getdate() , 1 from IT_UpNote "
                    + " where SheetID = '"
                    + sheetid
                    + "' and SheetType = 4";
            SQLHelper.executeSQL(conn, sql);

            sql = "delete from IT_UpNote where SheetID='" + sheetid + "' and sheettype=4";

            SQLHelper.executeSQL(conn, sql);
            Log.info(
                username,
                "订单【" + orderid + "】可能未发货,或已经退货,快递公司【" + post_company + "】,快递单号【" + post_no + "】",
                null);
          } else if ((rsp.getSubMsg().indexOf("没有权限进行发货") >= 0)
              || rsp.getSubMsg().indexOf("没有权限发货") >= 0
              || rsp.getSubMsg().indexOf("当前订单状态不支持修改") >= 0) {
            sql =
                "insert into IT_UpNoteBak(Owner,SheetID,SheetType,Sender,Receiver,Notetime,HandleTime,Flag) "
                    + " select Owner , SheetID , SheetType , Sender , Receiver , Notetime , getdate() , 1 from IT_UpNote "
                    + " where SheetID = '"
                    + sheetid
                    + "' and SheetType = 4";
            SQLHelper.executeSQL(conn, sql);

            sql = "delete from IT_UpNote where SheetID='" + sheetid + "' and sheettype=4";

            SQLHelper.executeSQL(conn, sql);
            Log.info(
                username,
                "没有权限发货,订单【" + orderid + "】,快递公司【" + post_company + "】,快递单号【" + post_no + "】",
                null);

          } else if (rsp.getSubMsg().indexOf("物流订单不存在") >= 0
              || rsp.getSubMsg().indexOf("订单已经被拆单") >= 0
              || rsp.getSubMsg().indexOf("当前操作的订单是拆单订单") >= 0) {
            TaobaoClient subclient =
                new DefaultTaobaoClient(Params.url, Params.appkey, Params.appsecret);
            LogisticsOfflineSendRequest subreq = new LogisticsOfflineSendRequest();
            subreq.setOutSid(post_no);
            subreq.setTid(TranTid(orderid));
            subreq.setCompanyCode(post_company);
            subreq.setIsSplit(1L);
            String subtids = "";

            sql =
                "select oid from customerorderitem a with(nolock),customerorder b with(nolock),"
                    + "customerdelive c with(nolock) where a.sheetid=b.sheetid and a.sheetid=c.refsheetid "
                    + "and c.customersheetid='"
                    + orderid
                    + "' and c.delivery='"
                    + post_company
                    + "' "
                    + "and c.deliverysheetid='"
                    + post_no
                    + "'";
            List sublist = SQLHelper.multiRowListSelect(conn, sql);
            if (sublist.size() > 0) {
              for (Iterator it = sublist.iterator(); it.hasNext(); ) {
                String oid = (String) it.next();
                subtids = oid + "," + subtids;
              }

              subtids = subtids.substring(0, subtids.length() - 1);

              subreq.setSubTid(subtids);

              LogisticsOfflineSendResponse subrsp = client.execute(subreq, Params.authcode);
              if (subrsp.isSuccess()) {
                Log.info(
                    username,
                    "处理订单【"
                        + orderid
                        + "】,子订单【"
                        + subtids
                        + "】发货成功,快递公司【"
                        + post_company
                        + "】,快递单号【"
                        + post_no
                        + "】",
                    null);
              }
            }

            sql =
                "insert into IT_UpNoteBak(Owner,SheetID,SheetType,Sender,Receiver,Notetime,HandleTime,Flag) "
                    + " select Owner , SheetID , SheetType , Sender , Receiver , Notetime , getdate() , 1 from IT_UpNote "
                    + " where SheetID = '"
                    + sheetid
                    + "' and SheetType = 4";
            SQLHelper.executeSQL(conn, sql);

            sql = "delete from IT_UpNote where SheetID='" + sheetid + "' and sheettype=4";

            SQLHelper.executeSQL(conn, sql);
            Log.info(
                jobName,
                "物流订单不存在或订单已经被拆,订单【"
                    + orderid
                    + "】,快递公司【"
                    + post_company
                    + "】,快递单号【"
                    + post_no
                    + "】");
          } else if (rsp.getSubMsg().indexOf("运单号不符合规则或已经被使用") >= 0) {
            // 公司内部自提发货处理
            if ((post_no.toUpperCase().indexOf("1111111") >= 0)
                || (post_no.toUpperCase().indexOf("YJ") >= 0)) {
              sql =
                  "insert into IT_UpNoteBak(Owner,SheetID,SheetType,Sender,Receiver,Notetime,HandleTime,Flag) "
                      + " select Owner , SheetID , SheetType , Sender , Receiver , Notetime , getdate() , 1 from IT_UpNote "
                      + " where SheetID = '"
                      + sheetid
                      + "' and SheetType = 4";
              SQLHelper.executeSQL(conn, sql);

              sql = "delete from IT_UpNote where SheetID='" + sheetid + "' and sheettype=4";

              SQLHelper.executeSQL(conn, sql);
            } else {
              String cc = "";
              if (post_no.toUpperCase().indexOf("EH") == 0) {
                cc = "EMS";
              } else if (post_no.toUpperCase().indexOf("101") == 0) {
                cc = "SF";
              } else if (post_no.toUpperCase().indexOf("368") == 0) {
                cc = "STO";
              } else if (post_no.toUpperCase().indexOf("W") == 0) {
                cc = "YTO";
              } else cc = post_company;

              sql =
                  "update ns_delivery set companycode='"
                      + cc
                      + "' where SheetID = '"
                      + sheetid
                      + "'";
              SQLHelper.executeSQL(conn, sql);
            }

            Log.info(
                username,
                "运单号不符合规则或已经被使用,订单【"
                    + orderid
                    + "】,快递公司【"
                    + post_company
                    + "】,快递单号【"
                    + post_no
                    + "】",
                null);
          } else if (rsp.getSubMsg().indexOf("该订单不支持修改") >= 0) {
            sql =
                "insert into IT_UpNoteBak(Owner,SheetID,SheetType,Sender,Receiver,Notetime,HandleTime,Flag) "
                    + " select Owner , SheetID , SheetType , Sender , Receiver , Notetime , getdate() , 1 from IT_UpNote "
                    + " where SheetID = '"
                    + sheetid
                    + "' and SheetType = 4";
            SQLHelper.executeSQL(conn, sql);

            sql = "delete from IT_UpNote where SheetID='" + sheetid + "' and sheettype=4";

            SQLHelper.executeSQL(conn, sql);
            Log.info(
                jobName,
                "处理订单【"
                    + orderid
                    + "】发货失败,快递公司【"
                    + post_company
                    + "】,快递单号【"
                    + post_no
                    + "】"
                    + "错误信息:"
                    + rsp.getSubMsg()
                    + rsp.getMsg());
          } else
            Log.info(
                username,
                "处理订单【"
                    + orderid
                    + "】发货失败,快递公司【"
                    + post_company
                    + "】,快递单号【"
                    + post_no
                    + "】"
                    + "错误信息:"
                    + rsp.getSubMsg()
                    + rsp.getMsg(),
                null);
        }
      } catch (Exception ex) {
        if (conn != null && !conn.getAutoCommit()) conn.rollback();
        Log.info(username, "修改发货信息作业出错,订单号: " + orderid + ",错误信息: " + ex.getMessage(), null);
      }
    }
  }