添加网站文件
This commit is contained in:
52
extend/expressage/Expressage.php
Normal file
52
extend/expressage/Expressage.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Expressage;
|
||||
class Expressage
|
||||
{
|
||||
protected $app;
|
||||
protected $key;
|
||||
protected $debug;
|
||||
|
||||
protected $logistics_info;
|
||||
|
||||
protected $error;
|
||||
|
||||
public function __construct($app, $key, $debug = false)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->key = $key;
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化
|
||||
* @return bool
|
||||
*/
|
||||
public function logisticsFormat()
|
||||
{
|
||||
if (empty($this->logistics_info)) {
|
||||
return false;
|
||||
}
|
||||
$info = $this->logistics_info;
|
||||
foreach ($info as $k => $v) {
|
||||
$info[$k] = array_values($v);
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 电商Sign签名生成
|
||||
* @param data 内容
|
||||
* @param appkey Appkey
|
||||
* @return DataSign签名
|
||||
*/
|
||||
protected function encrypt($data, $appkey)
|
||||
{
|
||||
return urlencode(base64_encode(md5($data . $appkey)));
|
||||
}
|
||||
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
34
extend/expressage/Kd100.php
Normal file
34
extend/expressage/Kd100.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace expressage;
|
||||
|
||||
use Requests;
|
||||
|
||||
class Kd100 extends Expressage
|
||||
{
|
||||
|
||||
public function logistics($code, $number)
|
||||
{
|
||||
$request_data = '{"com":"' . $code . '","num":"' . $number . '","from":"","phone":"","to":"","resultv2":"0","show":"0","order":"desc"}';
|
||||
|
||||
$datas = array(
|
||||
'customer' => $this->app,
|
||||
'sign' => strtoupper(md5($request_data . $this->key . $this->app)),
|
||||
'param' => $request_data,
|
||||
);
|
||||
|
||||
$params = "";
|
||||
foreach ($datas as $k => $v) {
|
||||
$params .= "$k=" . urlencode($v) . "&";
|
||||
}
|
||||
$params = substr($params, 0, -1);
|
||||
$result = Requests::get('http://poll.kuaidi100.com/poll/query.do?' . $params);
|
||||
$result = json_decode($result->body, true);
|
||||
if (isset($result['data'])) {
|
||||
$this->logistics_info = $result['data'];
|
||||
$this->logistics_info;
|
||||
}
|
||||
$this->error = json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
43
extend/expressage/Kdniao.php
Normal file
43
extend/expressage/Kdniao.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace expressage;
|
||||
use app\common\server\ConfigServer;
|
||||
use Requests;
|
||||
|
||||
class Kdniao extends Expressage
|
||||
{
|
||||
|
||||
|
||||
public function logistics($code, $number)
|
||||
{
|
||||
$request_daata = "{'OrderCode':'','ShipperCode':'$code','LogisticCode':'$number'}";
|
||||
|
||||
$datas = array(
|
||||
'EBusinessID' => $this->app,
|
||||
'RequestType' => '1002',
|
||||
'RequestData' => urlencode($request_daata),
|
||||
'DataType' => '2',
|
||||
);
|
||||
|
||||
//快递鸟请求接口类型
|
||||
$request_type = ConfigServer::get('kdniao', 'type', 'free');
|
||||
$search_url = 'https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx';
|
||||
//为付费类型时调整请求指令
|
||||
if ($request_type == 'pay') {
|
||||
$datas['RequestType'] = '8001';
|
||||
}
|
||||
|
||||
$datas['DataSign'] = self::encrypt($request_daata, $this->key);
|
||||
|
||||
$result = Requests::post($search_url,[], $datas);
|
||||
$result = json_decode($result->body,true);
|
||||
|
||||
if(isset($result['Traces'])){
|
||||
$this->logistics_info = $result['Traces'];
|
||||
$this->logistics_info;
|
||||
}
|
||||
$this->error = json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user