Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #4

Merged
merged 45 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f874e18
Merge pull request #8 from icowan/master
forecho Jun 30, 2020
0118645
Merge pull request #10 from icowan/master
forecho Jul 6, 2020
5cbc9ac
Merge pull request #11 from icowan/master
forecho Jul 9, 2020
2912fe6
Merge pull request #12 from icowan/master
forecho Jul 9, 2020
02085b5
Merge pull request #13 from icowan/master
forecho Jul 10, 2020
5b80371
Merge pull request #14 from icowan/master
forecho Jul 19, 2020
a8c0baf
Merge pull request #15 from icowan/master
forecho Jul 20, 2020
2bef2bb
Merge pull request #16 from icowan/master
forecho Jul 21, 2020
cf3962e
Merge pull request #17 from icowan/master
forecho Aug 4, 2020
5412b8c
Merge pull request #18 from icowan/master
forecho Aug 4, 2020
d8d0b3d
Merge pull request #19 from icowan/master
forecho Aug 6, 2020
1da5723
Merge pull request #20 from icowan/master
forecho Aug 10, 2020
9c0558a
Merge pull request #21 from icowan/master
forecho Aug 25, 2020
ed358f6
Merge pull request #22 from icowan/master
forecho Sep 20, 2020
86aa195
Merge pull request #23 from icowan/master
forecho Sep 22, 2020
8f37573
Merge pull request #24 from icowan/master
forecho Sep 23, 2020
2258098
Merge pull request #25 from icowan/master
forecho Sep 24, 2020
424b4a9
Merge pull request #26 from icowan/master
forecho Sep 24, 2020
97d7dba
Merge pull request #27 from icowan/master
icowan Sep 29, 2020
4cd1574
Merge pull request #28 from icowan/master
icowan Oct 23, 2020
5251ac2
Merge pull request #29 from icowan/master
icowan Nov 19, 2020
a07f92c
Merge pull request #30 from icowan/master
icowan Nov 24, 2020
6e4d7a0
Merge pull request #31 from icowan/master
icowan Nov 25, 2020
62f20d9
Merge pull request #32 from icowan/master
icowan Nov 26, 2020
0f06a6d
增加K5物流系统
liushuai Dec 21, 2020
cec4fb0
Merge pull request #33 from liushuai/feat-k5
icowan Dec 21, 2020
51b95d7
增加K5系统常量
liushuai Dec 22, 2020
a1ca67e
Merge pull request #34 from liushuai/feat-k5
icowan Dec 22, 2020
65cdf84
修改K5names 以及代码错行
liushuai Dec 22, 2020
443a3ce
Merge pull request #35 from liushuai/feat-k5
icowan Dec 22, 2020
e9b69e9
修改 K5杰航测试用例
liushuai Dec 22, 2020
94c5f02
Merge pull request #36 from liushuai/feat-k5
icowan Dec 22, 2020
6a5de8a
去掉 无效字段
liushuai Dec 22, 2020
d5d4985
Merge pull request #37 from liushuai/feat-k5
icowan Dec 23, 2020
60c8881
修改K5系统 面单打印
Dec 24, 2020
b00e1f9
Merge pull request #38 from liushuai/feat-k5
icowan Dec 24, 2020
bfe5dad
Merge pull request #39 from liushuai/feat-k5
icowan Dec 25, 2020
508b7cf
飞特物流 返回unauthorized_client 错误的时候一般是因为token过期导致 所以强行清除一下
Dec 25, 2020
e1ac460
纵横物流 增加获取跟踪号 方法
Dec 31, 2020
d055968
Merge pull request #40 from liushuai/feat-k5
icowan Dec 31, 2020
38179ea
修改 k5川日提交物流报错
liushuai Feb 4, 2021
2e948f3
Merge branch 'feat-k5' of https://github.com/liushuai/yii2-cross-bord…
liushuai Feb 4, 2021
601fbae
Merge pull request #41 from liushuai/feat-k5
icowan Feb 4, 2021
aa709a2
修改k5适配 八爪鱼物流
liushuai Mar 19, 2021
a099019
Merge pull request #42 from liushuai/feat-k5
forecho Mar 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Cross Border Express for Yii2
- 速递管家
- 易仓物流
- 顺丰国际物流
- K5物流系统

[![Latest Stable Version](https://poser.pugx.org/yiier/yii2-cross-border-express/v/stable)](https://packagist.org/packages/yiier/yii2-cross-border-express)
[![Total Downloads](https://poser.pugx.org/yiier/yii2-cross-border-express/downloads)](https://packagist.org/packages/yiier/yii2-cross-border-express)
Expand Down Expand Up @@ -108,7 +109,12 @@ $config = [
"username" => "",
"checkword" => "",
"platform_code" => "",
]
],
'k5' => [
"host" => "",
"clientid" => "",
"token" => "",
],
],
];

Expand Down
39 changes: 37 additions & 2 deletions src/platforms/CourierbutlerPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,37 @@ public function getClient()
return $client;
}


/**
* @param string $refrence_no 客户参考号
* @return string
* @throws ExpressException
*/
public function getTracingNumber(string $refrence_no): string
{


$this->body["serviceMethod"] = "gettrackingnumber";
$this->body["paramsJson"] = json_encode([
'reference_no'=>$refrence_no
], true);
try {
$result = $this->client->post($this->host . "/webservice/PublicService.asmx/ServiceInterfaceUTF8", [
'form_params' => $this->body,
])->getBody();
$data = $this->parseResult($result);
//var_dump($data);exit;
return $data['shipping_method_no']?$data['shipping_method_no']:'';
} catch (ExpressException $exception) {
throw new ExpressException(sprintf("获取转单号失败: %s", $exception->getMessage()));
}

return "";
}




/**
* @param string $countryCode
* @return array|Transport[]
Expand All @@ -59,7 +90,8 @@ public function createOrder(Order $order): OrderResult
$orderResult = new OrderResult();
$orderResult->data = json_encode($resData, true);
$orderResult->expressNumber = !empty($resData["refrence_no"]) ? $resData["refrence_no"] : "";
$orderResult->expressTrackingNumber = !empty($resData["shipping_method_no"]) ? $resData["shipping_method_no"] : "";
$orderResult->expressTrackingNumber = !empty($resData["shipping_method_no"]) ? $resData["shipping_method_no"] : "";;
$orderResult->expressAgentNumber = !empty($resData["shipping_method_no"]) ? $resData["shipping_method_no"] : "";
return $orderResult;
} catch (ExpressException $exception) {
throw new ExpressException(sprintf("创建包裹失败: %s", $exception->getMessage()));
Expand Down Expand Up @@ -129,7 +161,10 @@ public function getOrderAllFee(array $query = []): array
protected function parseResult(string $result)
{
$res = json_decode($result, true);
if ($res["success"] == 1) {
if(!is_array($res)) {
throw new ExpressException('接口返回数据异常');
}
if (isset($res["success"]) && $res["success"] == 1) {
return $res["data"];
} else {
throw new ExpressException($res["cnmessage"]);
Expand Down
6 changes: 6 additions & 0 deletions src/platforms/FeitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public function getPrintUrl(string $orderNumber, array $params = []): string
$response = $this->client->post($api, $body);

$result = json_decode($response->getBody(), true);

// 返回unauthorized_client 错误的时候一般是因为token过期导致 所以强行清除一下
if($result['Status'] === 0 && $result['ErrCode'] === 'unauthorized_client') {
$cache = \Yii::$app->cache;
$cache->delete(self::CACHE_KEY_FEITE_ACCESS_TOKEN);
}

try {
$b64 = $result['Data']['Label'];
Expand Down
Loading