From a88325e3248eac9be7eaad03c9478f3e7310e5ad Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 13 Apr 2023 11:14:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BF=AB=E9=80=92100?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/CallBackController.php | 11 +++++++ app/Utils/Auth.php | 1 + config/config.php | 6 ++-- config/routes.php | 6 ++++ extend/Kuaidi100/Kuaidi.php | 45 ++++++++++++++------------- hospital-deploy.sh | 6 ++++ 6 files changed, 51 insertions(+), 24 deletions(-) diff --git a/app/Controller/CallBackController.php b/app/Controller/CallBackController.php index c8e7b40..a5214dc 100644 --- a/app/Controller/CallBackController.php +++ b/app/Controller/CallBackController.php @@ -868,4 +868,15 @@ class CallBackController extends AbstractController ); } + // 快递100订阅回调 + public function LogisticsCallBack(): ResponseInterface + { + $request_params = $this->request->all(); + try { + Log::getInstance()->info("处方平台物流回调数据:" . json_encode($request_params, JSON_UNESCAPED_UNICODE)); + dump($request_params); + }catch (\Exception $e){ + + } + } } \ No newline at end of file diff --git a/app/Utils/Auth.php b/app/Utils/Auth.php index abe6880..39f6bf9 100644 --- a/app/Utils/Auth.php +++ b/app/Utils/Auth.php @@ -29,6 +29,7 @@ class Auth "/callback/wxpay/product/refund" => "post", // 微信药品退款回调 "/callback/im" => "post", // im回调 "/callback/platform/logistics" => "post", // 处方平台物流回调 + "/callback/logistics" => "post", // 快递100订阅回调 "/test" => "get", // 测试 ]; } diff --git a/config/config.php b/config/config.php index a2529bf..741bd59 100644 --- a/config/config.php +++ b/config/config.php @@ -96,8 +96,8 @@ return [ "api_url" => env('REG_PLAT_APP_URL', 'https://202.61.88.184:19200/'), ], 'kuaidi100' => [ // 快递100 - "key" => env('REG_PLAT_CLIENT_ID', 'Mpjjgebe8764'), - "customer" => env('REG_PLAT_CLIENT_SECRET', 'EA3A55C09C524BDB72AE31231721B20F'), - "api_url" => env('REG_PLAT_APP_URL', 'https://poll.kuaidi100.com/poll/query.do'), + "key" => env('LOGISTICS_KEY', 'Mpjjgebe8764'), + "customer" => env('LOGISTICS_CUSTOMER', 'EA3A55C09C524BDB72AE31231721B20F'), + "api_url" => env('LOGISTICS_APP_URL', 'https://poll.kuaidi100.com/poll/query.do'), ], ]; diff --git a/config/routes.php b/config/routes.php index 207ec4e..3d3d302 100644 --- a/config/routes.php +++ b/config/routes.php @@ -572,6 +572,12 @@ Router::addGroup('/callback', function () { // 处方平台物流回调 Router::post('/platform/logistics', [CallBackController::class, 'platformLogisticsCallBack']); + + // 快递订阅回调 + Router::addGroup('/logistics', function () { + // 快递订阅查询 + Router::post('', [CallBackController::class, 'LogisticsCallBack']); + }); }); // 用户 diff --git a/extend/Kuaidi100/Kuaidi.php b/extend/Kuaidi100/Kuaidi.php index 23cffa4..1f0fbf3 100644 --- a/extend/Kuaidi100/Kuaidi.php +++ b/extend/Kuaidi100/Kuaidi.php @@ -34,24 +34,39 @@ class Kuaidi } /** - * 封装公共请求 - * @param string $path - * @param array $arg - * @return mixed - * @throws GuzzleException + * 获取签名 + * @param string $params + * @return string */ - protected function httpRequest(string $path, string $arg = []): mixed + protected function getSign(string $params): string { + return md5($params . config("kuaidi100.key") . config("kuaidi100.customer")); + } + + + public function subscribe(string $logistics_no,string $logistics_company_code,string $phone){ + $param = [ + 'company' => $logistics_company_code, // 快递公司编码 + 'number' => $logistics_no, // 快递单号 + 'key' => config("kuaidi100.key"), // 客户授权key + 'parameters' => array ( + 'callbackurl' => 'http://dev.hospital.applets.igandanyiyuan.com/callback/logistics', // 回调地址 + 'resultv2' => '1', // 行政区域解析 + 'phone' => $phone // 手机号 + ) + ]; + $option = [ "json" => [ "schema" => "json", - "param" => json_encode($params, JSON_UNESCAPED_UNICODE), + "param" => json_encode($param, JSON_UNESCAPED_UNICODE), ], + "verify" => false ]; - $arg = array_merge($arg, $option); + $path = "https://poll.kuaidi100.com/poll"; - $response = $this->client->post($path, $arg); + $response = $this->client->post($path, $option); if ($response->getStatusCode() != '200') { // 请求失败 @@ -75,16 +90,4 @@ class Kuaidi return $body['body']; } - /** - * 获取签名 - * @param string $params - * @return string - */ - protected function getSign(string $params): string - { - return md5($params . config("kuaidi100.key") . config("kuaidi100.customer")); - } - - public function - } \ No newline at end of file diff --git a/hospital-deploy.sh b/hospital-deploy.sh index 3b51681..116d0fb 100644 --- a/hospital-deploy.sh +++ b/hospital-deploy.sh @@ -67,6 +67,12 @@ PRE_PLAT_APP_URL=http://49.233.3.200:6304/api/thridapi/ REG_PLAT_CLIENT_ID=09b117f8d1eb4dbfbf565447205ea60f REG_PLAT_CLIENT_SECRET=dcfd9223a3f448b0aae83ce22cdcc015 REG_PLAT_APP_URL=https://202.61.88.184:19200/ + + +# [快递100] +LOGISTICS_KEY=Mpjjgebe8764 +LOGISTICS_CUSTOMER=EA3A55C09C524BDB72AE31231721B20F +LOGISTICS_APP_URL=https://poll.kuaidi100.com/poll/query.do ">.env #nginx_upstrame="/Users/wucongxing/Desktop/test/hospital-upstream.conf"