Parcourir la source

测试usps的webhook

lvhao il y a 6 mois
Parent
commit
26acab8f09

+ 35 - 0
core/CoreApp/controllers/Apiexpressv1.php

@@ -0,0 +1,35 @@
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+/**
+ * 这个是快递回执给erp的信息,目前先写在这 不想在写到api那个文件了 
+ */
+class Apiexpressv1 extends Start_Controller{
+    public function __construct(){
+		parent::__construct();
+        $this->load->_model('Model_logic_order','api');
+        $this->load->_model("Model_logic_ding",'logic_ding');
+    }
+    //定义方法的调用规则 获取URI第二段值
+    public function _remap($arg,$arg_array)
+    {
+        if($arg == 'notifyusps')//添加
+        {
+             $this->_notifyusps();
+        }else{
+            $this->_a();
+        }
+    }
+
+    public function _a(){
+        exit('No direct script access allowed');
+    }
+    //usps获取快递回执信息
+    public function _notifyusps(){
+        $str = file_get_contents('PHP://input');
+		$data = json_decode($str, true);
+        $this->logic_ding->sendToDing(json_encode($data,JSON_UNESCAPED_UNICODE));
+        
+        echo "SUCCESS";
+        
+    }
+}

Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
core/CoreApp/core/Lin_Controller.php


+ 33 - 0
core/CoreApp/models/Model_usps.php

@@ -1081,6 +1081,39 @@ function __construct(){
 	    return $list;	
 		
 	}
+	//注册物流轨迹
+	/**
+	 *$order_info  订单信息
+	 */
+	public function sub_logistics($order_info){
+		$data = [
+			"listenerURL"=>"http://1.wepolicy.cn/apiexpressv1/notifyusps",
+			"secret"=>md5($order_info['number']),
+			"adminNotification"=>[
+				[
+					"email"=>"2606071897@qq.com",
+				]
+				],
+				"filterProperties"=>[
+					"MID"=>"902510013",
+					"trackingEventTypes"=>[
+						"ALL"
+					]
+				]
+		];
+		$url = "https://apis.usps.com/subscriptions-tracking/v3/subscriptions";
+		$token = $this->get_token();
+		$header = ['Content-Type: application/json',"Authorization: Bearer ".$token];
+		$res = $this->usps->su_curl($data,$url,$header);
+		$res = json_decode($res, true);
+		$this->logic_ding->sendToDing("usps注册信息监听".json_encode($res,JSON_UNESCAPED_UNICODE));
+		//返回信息异常
+		if(isset($res['error'])){
+			return $res;
+		}else{
+			return $res;
+		}
+	}
 	
 	
 }  //end class