扩展开发-快递查询扩展

目前已有一号通快递查询、阿里云快递查询扩展

扩展入口文件

文件目录 crmeb\services\express\Express.php 默认一号通快递查询

namespace crmeb\services\express;


use crmeb\basic\BaseManager;
use crmeb\services\AccessTokenServeService;
use think\Container;
use think\facade\Config;

/**
 * Class Express
 * @package crmeb\services\express
 * @mixin \crmeb\services\express\storage\Express
 */
class Express extends BaseManager
{
     //...
}

使用快递查询扩展

use crmeb\services\express\Express;


$express = new Express();

$num = '快递单号';
$com = '快递code码,可以选填';

$res = $express->query($num, $com);

var_dump($res);

切换到阿里云快递查询扩展

use crmeb\services\express\Express;


$express = new Express('aliyun_express');

$num = '快递单号';
$com = '快递code码,可以选填';

$res = $express->query($num, $com);

var_dump($res);

举例增加:腾讯云快递查询扩展

增加 crmeb\services\express\storage\Tencent.php

namespace crmeb\services\express\storage;

use crmeb\services\express\BaseExpress;

/**
*  腾讯快递查询
 * Class Tencent
 * @package crmeb\services\express\storage
 */
class Tencent extends BaseExpress
{

    //查询快递
    public function query(string $no = '', string $type = '')
    {

    }

    //是否开通 如果不需要可以不实现内部逻辑
    public function open()
    {
         return true;
    }

    //电子面单打印 如果不需要可以不实现内部逻辑
    public function dump($data)
    {

    }

    //面单模板 如果不需要可以不实现内部逻辑
    public function temp(string $com)
    {

    }

}

使用腾讯云查询快递扩展

use crmeb\services\express\Express;

//切换扩展
$express = new Express('tencent ');

$num = '快递单号';
$com = '快递code码,可以选填';

$res = $express->query($num, $com);

var_dump($res);

Was this helpful?

0 / 0

发表回复 0