Przeglądaj źródła

添加惠城的转单号获取

lvhao 1 miesiąc temu
rodzic
commit
506da3fd71

+ 49 - 0
core/CoreApp/models/Model_hualei.php

@@ -331,4 +331,53 @@ function __construct(){
 	}
 	//http://123.207.33.169:8089/order/FastRpt/PDF_NEW.aspx?Format=lbl_NL_XIN.frx&PrintType=lab10_10&order_id=5456516打印
 	
+	/**
+	 * 获取华磊的抓单号
+	 */
+	public function getDetail($number_str){
+		$url = "http://123.207.33.169:8082/logistics/api";
+		$ch = curl_init($url);
+		$headers = [
+			'auth'=>'FACFD061CAEC49D048AD9158084D6669',
+			'Content-Type:application/json;charset=UTF-8' ,
+		];
+		$params = [
+			'method'=>"order.selectorderandchildbycode",
+			'content'=>[
+				'order_customerinvoicecode'=>$number_str,
+			]
+		];
+		$params = json_encode($params);
+        $options = [
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_POST => true,
+            CURLOPT_POSTFIELDS => $params,
+            CURLOPT_HTTPHEADER => $headers,
+            CURLOPT_TIMEOUT => 30,  // 添加超时
+            CURLOPT_CONNECTTIMEOUT => 10,
+            // 生产环境应启用SSL验证
+            // CURLOPT_SSL_VERIFYPEER => true,
+            // CURLOPT_SSL_VERIFYHOST => 2,
+        ];
+        
+        curl_setopt_array($ch, $options);
+        $response = curl_exec($ch);
+        
+        // 检查HTTP状态码
+        // $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        // if ($response === false || $httpCode >= 400) {
+        //     $error = curl_error($ch);
+        //     curl_close($ch);
+        //     return [
+        //         "code" => -1,
+        //         "msg" => $error ?: "HTTP $httpCode",
+        //         "http_code" => $httpCode
+        //     ];
+        // }
+        
+        curl_close($ch);
+
+		return json_decode($response,true);
+
+	}
 }  //end class

+ 95 - 0
core/CoreApp/models/Model_job_gethualeiwaybillid.php

@@ -0,0 +1,95 @@
+<?php
+class Model_job_gethualeiwaybillid extends Lin_Model {
+    function __construct(){
+            parent::__construct();
+            $this->load->_model("Model_hualei","hualei");
+            $this->load->_model("Model_fullorder","fullorder");
+            $this->load->_model("Model_fullordersmt","fullordersmt");
+            $this->load->_model("Model_fullordertt","fullordertt");
+            $this->load->_model("Model_fullorderamz","fullorderamz");
+            $this->load->_model("Model_logic_ding","logic_ding");
+    }
+    public function do_job(){
+        $end_time = time() -  5* 3600 * 24;
+        $start_time = time();
+        // 目前只处理惠城的usps 73
+        // 出库时间十天前   waybillid 不能为空
+        $where = "express = 73 and librarytime >= ".$end_time ." and librarytime <= ".$start_time."  ";
+        //$where = "express = 76  and librarytime <= ".$start_time." ";
+        $fields = "id,number,waybill,waybillid,librarytime,express";
+        echo "<pre>";
+        var_dump(date("Y-m-d H:i:s",time()));
+        $this->do_dlz($where,$fields);
+        $this->do_tt($where,$fields);
+        $this->do_amz($where,$fields);
+        $this->do_smt($where,$fields);
+        var_dump(date("Y-m-d H:i:s",time()));
+    }
+    //执行对立站的代码
+    private function do_dlz($where,$fields){
+        $list = $this->fullorder->find_all($where,$fields);
+       
+        foreach($list as $item){
+            if(empty($item['waybillid'])){
+                $this->do_final($item,"fullorder");
+            }else{
+                continue;
+            }
+        }
+    }
+
+    private  function do_tt($where,$fields){
+        $list = $this->fullordertt->find_all($where,$fields);
+        foreach($list as $item){
+            if(empty($item['waybillid'])){
+                $this->do_final($item,"fullordertt");
+            }else{
+                continue;
+            }
+        }
+    }
+
+    private function do_amz($where,$fields){
+        $list = $this->fullorderamz->find_all($where,$fields);
+       
+        foreach($list as $item){
+            if(empty($item['waybillid'])){
+                $this->do_final($item,"fullorderamz");
+            }else{
+                continue;
+            }
+        }
+    }
+    private function do_smt($where,$fields){
+        $list = $this->fullordersmt->find_all($where,$fields);
+       
+        foreach($list as $item){
+            if(empty($item['waybillid'])){
+                $this->do_final($item,"fullordersmt");
+            }else{
+                continue;
+            }
+        }
+    }
+
+    private function do_final($info,$table_name){
+        sleep(1);
+        $res = $this->itsxb->getDetail($info['number']);
+        // var_dump($table_name);
+        // var_dump($res);
+        $res = json_decode($res,true);
+        
+        if(isset($res['msg_code']) && $res['msg_code'] == 200){
+            if(isset($res['data'])){
+                if(isset($res['data']['order_serveinvoicecode'])){
+                    if(!empty($res['data']['order_serveinvoicecode']) && $res['data']['order_serveinvoicecode'] != $info['waybill']){
+               
+                        $this->$table_name->save(['waybillid' => $res['data']['order_serveinvoicecode']],$info['id']);
+                        $this->logic_ding->sendToDing("惠城转单号更新信息【".$info['waybill']."】"."转单号:".$res['data']['deliveryNo']." 平台:".$table_name."订单详细信息:{".json_encode($info)."}");
+                    }
+                }
+            }
+            
+        }
+    }
+}