Exemplo n.º 1
0
 public function validataTracnumber($orderid, $expressid)
 {
     $sqlstr = 'select expressid from wh_orderid_expressid_map where orderid=' . "'{$orderid}'";
     $result = $this->dbconn->query($sqlstr);
     $checkresult = 0;
     $haveone = FALSE;
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // 处理一个订单多个跟踪号的情况
         while ($row = mysql_fetch_assoc($result)) {
             $haveone = TRUE;
             $tempar = explode('和', $row['expressid']);
             //var_dump($tempar);exit;
             //print_r($expressid);exit;
             $checkresult = 1;
             foreach ($tempar as $exval) {
                 if (!in_array($exval, $expressid)) {
                     $checkresult = 0;
                     break;
                 }
             }
             if ($checkresult == 0) {
                 continue;
             } else {
                 break;
             }
         }
     } else {
         while ($row = mysql_fetch_assoc($result)) {
             $haveone = TRUE;
             // if( $row['expressid'] == $expressid ){
             if (strpos($expressid, sprintf('%s', $row['expressid'])) !== false) {
                 if (strlen($expressid) != $row['expressid']) {
                     // 判断为联邦快递
                     $offset = strpos($expressid, sprintf('%s', $row['expressid']));
                     // 偏移量
                     $cutlen = strlen($expressid) - strlen($row['expressid']);
                     // 前后缀长之和
                     $formatedtrid = substr($expressid, $offset, strlen($expressid) - $cutlen);
                     $expressid = $formatedtrid;
                     $expressid = $row['expressid'];
                     // 2013/7/10 修改 涂兴隆
                 }
                 // 验证成功
                 $sql_updata = 'update wh_orderid_expressid_map set checked =1 where orderid=' . "'{$orderid}'";
                 // echo $sql_updata;exit;
                 $this->dbconn->query($sql_updata);
                 $checkresult = 1;
                 break;
             }
         }
     }
     if (!$haveone) {
         self::$errCode = 0;
         self::$errMsg = '跟踪号未录入!';
         return FALSE;
     }
     //echo $checkresult;exit;
     if ($checkresult == 1) {
         //验证成功
         $upres = $this->updataExpressId($expressid, $orderid, 1);
         if (!$upres) {
             self::$errCode = 0;
             self::$errMsg = '验证失败';
             return FALSE;
         } else {
             self::$errCode = 1;
             self::$errMsg = '成功';
             return TRUE;
         }
     } else {
         self::$errCode = 0;
         self::$errMsg = '复核失败,请检查包裹!';
         return FALSE;
     }
 }