作者 徐治堂
1 个管道 的构建 通过 耗费 3 秒

快递接入成功

... ... @@ -9,6 +9,6 @@ return [
// 应用调试模式
'app_debug' => true,
// 应用Trace
'app_trace' => true,
'app_trace' => false,
];
\ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@
namespace api\home\controller;
use cmf\controller\RestBaseController;
use think\Db;
/**
* @title 欢迎页
... ... @@ -35,4 +36,29 @@ class IndexController extends RestBaseController
$this->success("恭喜您,API访问成功!", $data);
}
/**
* 接收快递鸟推送快递信息
*/
public function test(){
$param=input('param.');
$param['RequestData']=htmlspecialchars_decode($param['RequestData']);
$arr=json_decode($param['RequestData'],true);
foreach ($arr['Data'] as $k=>$v){
$sta=Db::name('zj_kd_order')->where(['kd_num'=>$v['LogisticCode'],'kd_type'=>$v['ShipperCode']])->find();
if (empty($sta)){
Db::name('zj_kd_order')->insert(['kd_num'=>$v['LogisticCode'],'kd_type'=>$v['ShipperCode'],'text'=>json_encode($v['Traces'])]);
}else{
Db::name('zj_kd_order')->where(['kd_num'=>$v['LogisticCode'],'kd_type'=>$v['ShipperCode']])->update(['text'=>json_encode($v['Traces'])]);
}
}
$return['EBusinessID']='1385929';
$return['UpdateTime']=date('Y-m-d H:i:s');
$return['Success']=true;
$return['Reason']='';
return $return;
}
}
... ...
... ... @@ -13,6 +13,6 @@ return [
// 应用调试模式
'app_debug' => true,
// 应用Trace
'app_trace' => true,
'app_trace' => false,
];
\ No newline at end of file
... ...
... ... @@ -22,36 +22,46 @@
namespace app\kdnapi\controller;
use think\Controller;
use think\Db;
class KdnApiController
class KdnApiController extends Controller
{
public function aa(){
return $this->orderTracesSubByJson('77');
}
/**
* Json方式 物流信息订阅
*/
public function orderTracesSubByJson(){
$requestData="{'OrderCode': 'SF201608081055208281',".
"'ShipperCode':'SF',".
"'LogisticCode':'3100707578976',".
"'PayType':1,".
"'ExpType':1,".
"'IsNotice':0,".
"'Cost':1.0,".
"'OtherCost':1.0,".
public function orderTracesSubByJson($id){
$arr1=Db::name('zj_order')->alias('o')->join('zj_kd k','o.kid=k.id','left')->where('o.id',$id)
->field('o.*,k.code')->find();
$arr2=Db::name('zj_system')->find();
$requestData="{'OrderCode': '',".
"'ShipperCode':'". $arr1['code'] ."',".
"'LogisticCode':".$arr1['kd_num'].",".
"'PayType':'',".
"'ExpType':'',".
"'IsNotice':'',".
"'Cost':'',".
"'OtherCost':'',".
"'Sender':".
"{".
"'Company':'LV','Name':'Taylor','Mobile':'15018442396','ProvinceName':'上海','CityName':'上海','ExpAreaName':'青浦区','Address':'明珠路73号'},".
"'Name':'". $arr2['name'] ."','Mobile':'". $arr2['fmobile'] ."','ProvinceName':'". $arr2['province'] ."','CityName':'". $arr2['city'] ."','ExpAreaName':'". $arr2['county'] ."','Address':'". $arr2['place'] ."'},".
"'Receiver':".
"{".
"'Company':'GCCUI','Name':'Yann','Mobile':'15018442396','ProvinceName':'北京','CityName':'北京','ExpAreaName':'朝阳区','Address':'三里屯街道雅秀大厦'},".
"'Name':'". $arr1['name'] ."','Mobile':'". $arr1['mobile'] ."','ProvinceName':'". $arr1['province'] ."','CityName':'". $arr1['city'] ."','ExpAreaName':'". $arr1['county'] ."','Address':'". $arr1['place'] ."'},".
"'Commodity':".
"[{".
"'GoodsName':'鞋子','Goodsquantity':1,'GoodsWeight':1.0}],".
"'Weight':1.0,".
"'Quantity':1,".
"'Volume':0.0,".
"'Remark':'小心轻放'}";
"'GoodsName':'','Goodsquantity':'','GoodsWeight':''}],".
"'Weight':'',".
"'Quantity':'',".
"'Volume':'',".
"'Remark':''}";
$datas = array(
'EBusinessID' => config('EBusinessID'),
... ... @@ -116,16 +126,4 @@ class KdnApiController
private function encrypt($data, $appkey) {
return urlencode(base64_encode(md5($data.$appkey)));
}
/**
* 推送接口
*/
public function kdApi(){
$request = request();
$param='2';
if ($request->param()){
$param=input('param.');
}
Db::name('zj_kd_order')->insert(['text'=>$param]);
}
}
\ No newline at end of file
... ...
... ... @@ -6,14 +6,10 @@ return [
'MchId' => '1263633001',
'EBusinessID' => '1385929',
'AppKey' => 'a30c2b36-2f16-4a39-9c75-323feddb415f',
'ReqURL' => 'http://testapi.kdniao.cc:8081/api/dist',
'ReqURL' => 'http://testapi.kdniao.cc:8081/api/dist'
];
//电商ID
defined('EBusinessID') or define('EBusinessID','1385929');
//电商加密私钥,快递鸟提供,注意保管,不要泄漏
defined('AppKey') or define('AppKey','a30c2b36-2f16-4a39-9c75-323feddb415f');
//测试请求url
defined('ReqURL') or define('ReqURL','http://testapi.kdniao.cc:8081/api/dist');
//http://testapi.kdniao.cc:8081/api/dist
//正式请求url
//defined('ReqURL') or define('ReqURL', 'http://api.kdniao.cc/api/dist');
\ No newline at end of file
//http://api.kdniao.cc/api/dist
\ No newline at end of file
... ...