コード例 #1
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);
      }
    }
  }
コード例 #2
0
  private void normalSend(
      String post_no, String orderid, String post_company, Connection conn, String sheetid) {
    try {

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

      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 = 3";
          SQLHelper.executeSQL(conn, sql);

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

          SQLHelper.executeSQL(conn, sql);
          conn.commit();
          conn.setAutoCommit(true);
        } catch (SQLException 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.getSubCode().equals("isv.logistics-offline-service-error:B04")) {
          // 已经同步发货状态或退货成功了
          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.info(username, "订单: " + orderid + ", sheetid: " + sheetid + ",状态异常,已备份到备份表", null);
        }
        if (rsp.getSubCode().equals("isv.logistics-offline-service-error:P38")) {
          // 已经同步发货状态或退货成功了
          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.info(
              username,
              "订单: " + orderid + ", sheetid: " + sheetid + ",状态异常,,拆单校验未通过.已备份到备份表",
              null);
        }
        if (rsp.getSubCode().equals("isv.logistics-offline-service-error:S01")) {
          // 已经同步发货状态或退货成功了
          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.info(username, "订单: " + orderid + ", sheetid: " + sheetid + ",状态异常,已备份到备份表", null);
        }
        if (rsp.getSubCode().indexOf("ORDER_NOT_FOUND_ERROR") != -1) {
          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.error(username, jobName + ",订单号: " + orderid + ", 无法找到!", null);
        }
        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 = 3";
          SQLHelper.executeSQL(conn, sql);

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

          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 = 3";
          SQLHelper.executeSQL(conn, sql);

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

          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);
          for (Iterator it = sublist.iterator(); it.hasNext(); ) {
            String oid = (String) it.next();
            subtids = oid + "," + subtids;
          }
          subtids =
              (subtids != null && subtids != "" ? subtids.substring(0, subtids.length() - 1) : "");

          subreq.setSubTid(subtids);

          LogisticsOfflineSendResponse subrsp = client.execute(subreq, Params.authcode);

          if (subrsp.isSuccess()) {
            Log.info(
                jobName,
                "处理订单【"
                    + orderid
                    + "】,子订单【"
                    + subtids
                    + "】发货成功,快递公司【"
                    + post_company
                    + "】,快递单号【"
                    + post_no
                    + "】");
          }

          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.info(
              username,
              "物流订单不存在或订单已经被拆单,订单【"
                  + orderid
                  + "】,快递公司【"
                  + post_company
                  + "】,快递单号【"
                  + post_no
                  + "】",
              null);
        } 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 = 3";
            SQLHelper.executeSQL(conn, sql);

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

            SQLHelper.executeSQL(conn, sql);

          } else {
            String cc = "";
            String memo = "";
            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; // 把错误的运单号对应的订单号修改一下,让后面修改后的快递信息能正确写入sheettype=3
              orderid += "运单号不符合规则或已经被使用";
              memo += "运单号不符合规则或已经被使用";
            }

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

          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.info(
              jobName,
              "运单号不符合规则或已经被使用,订单【"
                  + orderid
                  + "】,快递公司【"
                  + post_company
                  + "】,快递单号【"
                  + post_no
                  + "】");
        } else {
          Log.info(
              username,
              "处理订单【"
                  + orderid
                  + "】发货失败,快递公司【"
                  + post_company
                  + "】,快递单号【"
                  + post_no
                  + "】"
                  + "错误信息:"
                  + rsp.getSubMsg()
                  + rsp.getMsg(),
              null);
          String errmsg = rsp.getSubMsg();
          Pattern par = Pattern.compile("This ban will last for (\\d{1,9}) more seconds");
          Matcher m = par.matcher(errmsg);
          if (m.find()) {
            long delayTime = Long.parseLong(m.group(1)) * 1000L;
            long now = System.currentTimeMillis();
            while (System.currentTimeMillis() < now + delayTime) {
              Thread.sleep(1000L);
            }
          }
        }
      }

    } catch (ApiException e) {

      Log.error(
          username,
          "处理订单【"
              + orderid
              + "】发货失败,快递公司【"
              + post_company
              + "】,快递单号【"
              + post_no
              + "】,错误信息:"
              + e.getMessage(),
          null);
    } catch (Exception e) {
      Log.error(username, "同步发货状态出错了, 错误信息: " + e.getMessage(), null);
    }
  }