正在显示
5 个修改的文件
包含
59 行增加
和
39 行删除
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | namespace api\home\controller; | 2 | namespace api\home\controller; |
3 | 3 | ||
4 | use cmf\controller\RestBaseController; | 4 | use cmf\controller\RestBaseController; |
5 | +use think\Db; | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * @title 欢迎页 | 8 | * @title 欢迎页 |
@@ -35,4 +36,29 @@ class IndexController extends RestBaseController | @@ -35,4 +36,29 @@ class IndexController extends RestBaseController | ||
35 | $this->success("恭喜您,API访问成功!", $data); | 36 | $this->success("恭喜您,API访问成功!", $data); |
36 | } | 37 | } |
37 | 38 | ||
39 | + | ||
40 | + /** | ||
41 | + * 接收快递鸟推送快递信息 | ||
42 | + */ | ||
43 | + public function test(){ | ||
44 | + $param=input('param.'); | ||
45 | + $param['RequestData']=htmlspecialchars_decode($param['RequestData']); | ||
46 | + $arr=json_decode($param['RequestData'],true); | ||
47 | + foreach ($arr['Data'] as $k=>$v){ | ||
48 | + $sta=Db::name('zj_kd_order')->where(['kd_num'=>$v['LogisticCode'],'kd_type'=>$v['ShipperCode']])->find(); | ||
49 | + if (empty($sta)){ | ||
50 | + Db::name('zj_kd_order')->insert(['kd_num'=>$v['LogisticCode'],'kd_type'=>$v['ShipperCode'],'text'=>json_encode($v['Traces'])]); | ||
51 | + }else{ | ||
52 | + Db::name('zj_kd_order')->where(['kd_num'=>$v['LogisticCode'],'kd_type'=>$v['ShipperCode']])->update(['text'=>json_encode($v['Traces'])]); | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + $return['EBusinessID']='1385929'; | ||
57 | + $return['UpdateTime']=date('Y-m-d H:i:s'); | ||
58 | + $return['Success']=true; | ||
59 | + $return['Reason']=''; | ||
60 | + return $return; | ||
61 | + } | ||
62 | + | ||
63 | + | ||
38 | } | 64 | } |
@@ -22,36 +22,46 @@ | @@ -22,36 +22,46 @@ | ||
22 | namespace app\kdnapi\controller; | 22 | namespace app\kdnapi\controller; |
23 | 23 | ||
24 | 24 | ||
25 | +use think\Controller; | ||
25 | use think\Db; | 26 | use think\Db; |
26 | 27 | ||
27 | -class KdnApiController | 28 | +class KdnApiController extends Controller |
28 | { | 29 | { |
30 | + | ||
31 | + public function aa(){ | ||
32 | + return $this->orderTracesSubByJson('77'); | ||
33 | + } | ||
34 | + | ||
29 | /** | 35 | /** |
30 | * Json方式 物流信息订阅 | 36 | * Json方式 物流信息订阅 |
31 | */ | 37 | */ |
32 | - public function orderTracesSubByJson(){ | ||
33 | - $requestData="{'OrderCode': 'SF201608081055208281',". | ||
34 | - "'ShipperCode':'SF',". | ||
35 | - "'LogisticCode':'3100707578976',". | ||
36 | - "'PayType':1,". | ||
37 | - "'ExpType':1,". | ||
38 | - "'IsNotice':0,". | ||
39 | - "'Cost':1.0,". | ||
40 | - "'OtherCost':1.0,". | 38 | + public function orderTracesSubByJson($id){ |
39 | + $arr1=Db::name('zj_order')->alias('o')->join('zj_kd k','o.kid=k.id','left')->where('o.id',$id) | ||
40 | + ->field('o.*,k.code')->find(); | ||
41 | + $arr2=Db::name('zj_system')->find(); | ||
42 | + | ||
43 | + | ||
44 | + $requestData="{'OrderCode': '',". | ||
45 | + "'ShipperCode':'". $arr1['code'] ."',". | ||
46 | + "'LogisticCode':".$arr1['kd_num'].",". | ||
47 | + "'PayType':'',". | ||
48 | + "'ExpType':'',". | ||
49 | + "'IsNotice':'',". | ||
50 | + "'Cost':'',". | ||
51 | + "'OtherCost':'',". | ||
41 | "'Sender':". | 52 | "'Sender':". |
42 | "{". | 53 | "{". |
43 | - "'Company':'LV','Name':'Taylor','Mobile':'15018442396','ProvinceName':'上海','CityName':'上海','ExpAreaName':'青浦区','Address':'明珠路73号'},". | 54 | + "'Name':'". $arr2['name'] ."','Mobile':'". $arr2['fmobile'] ."','ProvinceName':'". $arr2['province'] ."','CityName':'". $arr2['city'] ."','ExpAreaName':'". $arr2['county'] ."','Address':'". $arr2['place'] ."'},". |
44 | "'Receiver':". | 55 | "'Receiver':". |
45 | "{". | 56 | "{". |
46 | - "'Company':'GCCUI','Name':'Yann','Mobile':'15018442396','ProvinceName':'北京','CityName':'北京','ExpAreaName':'朝阳区','Address':'三里屯街道雅秀大厦'},". | 57 | + "'Name':'". $arr1['name'] ."','Mobile':'". $arr1['mobile'] ."','ProvinceName':'". $arr1['province'] ."','CityName':'". $arr1['city'] ."','ExpAreaName':'". $arr1['county'] ."','Address':'". $arr1['place'] ."'},". |
47 | "'Commodity':". | 58 | "'Commodity':". |
48 | "[{". | 59 | "[{". |
49 | - "'GoodsName':'鞋子','Goodsquantity':1,'GoodsWeight':1.0}],". | ||
50 | - "'Weight':1.0,". | ||
51 | - "'Quantity':1,". | ||
52 | - "'Volume':0.0,". | ||
53 | - "'Remark':'小心轻放'}"; | ||
54 | - | 60 | + "'GoodsName':'','Goodsquantity':'','GoodsWeight':''}],". |
61 | + "'Weight':'',". | ||
62 | + "'Quantity':'',". | ||
63 | + "'Volume':'',". | ||
64 | + "'Remark':''}"; | ||
55 | 65 | ||
56 | $datas = array( | 66 | $datas = array( |
57 | 'EBusinessID' => config('EBusinessID'), | 67 | 'EBusinessID' => config('EBusinessID'), |
@@ -116,16 +126,4 @@ class KdnApiController | @@ -116,16 +126,4 @@ class KdnApiController | ||
116 | private function encrypt($data, $appkey) { | 126 | private function encrypt($data, $appkey) { |
117 | return urlencode(base64_encode(md5($data.$appkey))); | 127 | return urlencode(base64_encode(md5($data.$appkey))); |
118 | } | 128 | } |
119 | - | ||
120 | - /** | ||
121 | - * 推送接口 | ||
122 | - */ | ||
123 | - public function kdApi(){ | ||
124 | - $request = request(); | ||
125 | - $param='2'; | ||
126 | - if ($request->param()){ | ||
127 | - $param=input('param.'); | ||
128 | - } | ||
129 | - Db::name('zj_kd_order')->insert(['text'=>$param]); | ||
130 | - } | ||
131 | } | 129 | } |
@@ -6,14 +6,10 @@ return [ | @@ -6,14 +6,10 @@ return [ | ||
6 | 'MchId' => '1263633001', | 6 | 'MchId' => '1263633001', |
7 | 'EBusinessID' => '1385929', | 7 | 'EBusinessID' => '1385929', |
8 | 'AppKey' => 'a30c2b36-2f16-4a39-9c75-323feddb415f', | 8 | 'AppKey' => 'a30c2b36-2f16-4a39-9c75-323feddb415f', |
9 | - 'ReqURL' => 'http://testapi.kdniao.cc:8081/api/dist', | 9 | + 'ReqURL' => 'http://testapi.kdniao.cc:8081/api/dist' |
10 | ]; | 10 | ]; |
11 | 11 | ||
12 | -//电商ID | ||
13 | -defined('EBusinessID') or define('EBusinessID','1385929'); | ||
14 | -//电商加密私钥,快递鸟提供,注意保管,不要泄漏 | ||
15 | -defined('AppKey') or define('AppKey','a30c2b36-2f16-4a39-9c75-323feddb415f'); | ||
16 | //测试请求url | 12 | //测试请求url |
17 | -defined('ReqURL') or define('ReqURL','http://testapi.kdniao.cc:8081/api/dist'); | 13 | +//http://testapi.kdniao.cc:8081/api/dist |
18 | //正式请求url | 14 | //正式请求url |
19 | -//defined('ReqURL') or define('ReqURL', 'http://api.kdniao.cc/api/dist'); | ||
15 | +//http://api.kdniao.cc/api/dist |
-
请 注册 或 登录 后发表评论