Skip to content

跨境物流接口:云途物流、三态速递、飞特物流

Notifications You must be signed in to change notification settings

yiier/yii2-cross-border-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cross Border Express for Yii2

跨境物流接口,目前只支持:

  • 云途物流
  • 三态速递
  • 飞特物流
  • 华磊物流
  • 集优物流
  • 万邦物流
  • 速递管家
  • 易仓物流
  • 顺丰国际物流
  • K5物流系统
  • 燕文物流
  • 互联通物流

Latest Stable Version Total Downloads Latest Unstable Version License

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yiier/yii2-cross-border-express "*"

or add

"yiier/yii2-cross-border-express": "*"

to the require section of your composer.json file.

Usage

配置

<?php

$config = [
    // HTTP 请求的超时时间(秒)
    'timeout' => 5.0,

    // 可用的平台配置
    'platforms' => [
       'santai' => [
            'appKey' => 'xxx',
            'token' => 'xxx',
            'userId' => 'xxx'
        ],
        'yuntu' => [
            'account' => 'xxx',
            'secret' => 'xxx',
        ],
        'feite' => [
            'token' => 'xxx',
            'syncPlatformId' => '', // 订单同步平台标识(一般指第三方平台标识,格式类似:scb.logistics.flyt)
            'accountId' => 'xxx',
            'password' => '',
            'printUsername' => '', // 面单接口需要
            'printPassword' => '' // 面单接口需要
        ],
        'hualei' => [
            'host' => '',
            'print_host' => '',
            'customer_id' => '', # 如果customer_id和customer_user_id不为空可不填username及password
            'customer_user_id' => '',
            'username' => '',
            'password' => '',
        ],
        'jiyou' => [
            'host' => '',
            'user_token' => ''
        ],
        'wanb' => [
            "host" => "http://api-sbx.wanbexpress.com",
            "account_no" => "",
            "token" => "",
            "warehouse_code" => "",
            "oss_wan_domain" => "oss-cn-beijing.aliyuncs.com",
            "oss_lan_domain" => "oss-cn-beijing-internal.aliyuncs.com",
            "oss_bucket" => "",
            "oss_access_key_id" => "",
            "oss_access_key_secret" => "",
        ],
        'courierbutler' => [
            "host" => "http://lfn.rtb56.com",
            "app_token" => "",
            "app_key" => "",
        ],
        'eccang' => [
            "appKey" => "",
            "appToken" => "",
            "host" => ""
        ],
        'sfexpress' => [
            "accesscode" => "",
            "username" => "",
            "checkword" => "",
            "platform_code" => "",
        ], 
		'k5' => [
            "host" => "",
            "clientid" => "",
            "token" => "",
        ],
        'yw56' => [
            "host" => '',
            "userId" => '',
            "token" => '',
            "ossBucket" => '',
            "ossAccessKeyId" => '',
            "ossAccessKeySecret" => '',
            "ossLanDomain" => "oss-accelerate-internal.aliyuncs.com",
            "ossWanDomain" => "oss-accelerate.aliyuncs.com",
        ],
        'huiliantong' => [
            'host' => "",
            'userToken' => ''
        ]
    ],
];

$express = new \yiier\crossBorderExpress\Express($config, 'santai');
    

发货

<?php
$expressOrder = new \yiier\crossBorderExpress\contracts\Order();
$expressOrder->customerOrderNo = 'xxx';
$expressOrder->transportCode = 'xxx';

$goods[] = new \yiier\crossBorderExpress\contracts\Goods();
$goods->description = 'xxx';
$goods->cnDescription = 'xxx';
$goods->quantity = 'xxx';
$goods->weight = 'xxx';
$goods->hsCode = 'xxx';
$goods->enMaterial = 'cotton';
$goods->cnMaterial = '';
$goods->worth = 1; // 1美元;
$goods->sku = 'xxx'; // 云途某些渠道需要
        
$expressOrder->goods = $goods;
$expressOrder->evaluate = 1; // 1美元
$expressOrder->taxesNumber = 'xxx'; // 税号
$expressOrder->isRemoteConfirm = 1; // 是否同意收偏远费
$expressOrder->isReturn = 1; // 是否退件
$expressOrder->withBattery = 0; // 是否带电池

$package = new \yiier\crossBorderExpress\contracts\Package();
$package->description = 'xxxx';
$package->quantity = 1;
$package->weight = 'xxx';
$package->declareWorth = 1; // 1美元
$expressOrder->package = $package;


$recipient = new \yiier\crossBorderExpress\contracts\Recipient();
$recipient->countryCode = 'xx';
$recipient->name = 'xx';
$recipient->address = 'xx';
$recipient->city = 'xx';
$recipient->state = 'xx';
$recipient->zip = 'xx';
$recipient->phone = 'xx';
$expressOrder->recipient = $recipient;

$shipper = new \yiier\crossBorderExpress\contracts\Shipper();
$shipper->countryCode = 'CN';
$shipper->name = 'xxx';
$shipper->company = 'xxx';
$shipper->address = 'xxx';
$shipper->city = 'xxx';
$shipper->state = 'xxx';
$shipper->zip = 'xx';
$shipper->phone = 'xxx';
$expressOrder->shipper = $shipper;
    
// 发货
$express->createOrder($expressOrder);

获取物流方式

<?php
$countryCode = 'US';
$item = [];
if (!empty($transports = $express->getTransportsByCountryCode($countryCode))) {
    foreach ($transports as $transport) {
        // 带跟踪号的物流方式
        $item[$transport->code] = [
            'code' => $transport->code,
            'name' => $transport->cnName,
            'is_tracking_no' => (int)$transport->ifTracking,
            'data' => $transport->data,
        ];
    }
}
return $item;

获取打印地址

<?php
$orderNumber = 'xxx';
$express->getPrintUrl($orderNumber);

获取订单详细费用

<?php
$orderNumber = 'xxx';
$express->getOrderFee($orderNumber);

相关链接

About

跨境物流接口:云途物流、三态速递、飞特物流

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages