PHP code example of lensen / base-erp-sdk

1. Go to this page and download the library: Download lensen/base-erp-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lensen / base-erp-sdk example snippets


# 定义 composer 加载路径
!defined('BASE_PATH_PKG') && define('BASE_PATH_PKG', dirname(__DIR__, 1));

use Lensen\BaseErp\Facade\AuthFacade;
use Lensen\BaseErp\Facade\OrderFacade;
use Lensen\BaseErp\Facade\ShippingFacade;

// 1. 设置 API Token(推荐从 .env 读取,无需传参)
AuthFacade::setAuth();
// 或显式传入:
// AuthFacade::setAuth('your-api-token');

// 2. 订单相关
$orders   = OrderFacade::getOrders(['date_from' => strtotime('-1 day'), 'date_to' => time()]);
$logs     = OrderFacade::getJournalList(['last_log_id' => 0]);
$returns  = OrderFacade::getOrderReturns(['date_from' => strtotime('-7 day'), 'date_to' => time()]);
$sources  = OrderFacade::getOrderSources();

// 3. 物流相关
$couriers  = ShippingFacade::getCouriersList(['filter_active' => true]);
$packageId = ShippingFacade::createPackageManual([
    'order_id'       => 12345,
    'courier_code'   => 'DPD',
    'package_number' => 'TRACK-123456789',
    'pickup_date'    => strtotime('today'),
]);