gdinko/econt
Composer 安装命令:
composer require gdinko/econt
包简介
Laravel Econt API Wrapper
README 文档
README
Installation
You can install the package via composer:
composer require gdinko/econt
If you plan to use database for storing nomenclatures:
php artisan migrate
If you need to export configuration file:
php artisan vendor:publish --tag=econt-config
If you need to export migrations:
php artisan vendor:publish --tag=econt-migrations
If you need to export models:
php artisan vendor:publish --tag=econt-models
If you need to export commands:
php artisan vendor:publish --tag=econt-commands
Configuration
ECONT_ENV=test|production #default=test ECONT_API_USER= #default=iasp-dev ECONT_API_PASS= #default=iasp-dev ECONT_API_TEST_BASE_URI= #default=https://demo.econt.com/ee/services ECONT_API_PRODUCTION_BASE_URI= #default=https://ee.econt.com/services ECONT_API_TIMEOUT= #default=5
Usage
Runtime Setup
Econt::setAccount('user', 'pass'); Econt::setBaseUrl('endpoint'); Econt::setTimeout(99); Econt::addAccountToStore('AccountUser', 'AccountPass'); Econt::getAccountFromStore('AccountUser'); Econt::setAccountFromStore('AccountUser');
Multiple Account Support In AppServiceProvider add accounts in boot method
public function boot() { Econt::addAccountToStore( 'AccountUser', 'AccountPass' ); Econt::addAccountToStore( 'AccountUser_XXX', 'AccountPass_XXX' ); }
Methods
//Nomenclatures Econt::getCountries(); Econt::getCities(); Econt::getOffices(); Econt::getStreets(); Econt::getQuarters(); //Labels Econt::createLabel(); Econt::createLabels(); Econt::updateLabel(); Econt::deleteLabels(); //Misc Econt::requestCourier(); Econt::getRequestCourierStatus(); Econt::getShipmentStatuses(); Econt::getClientProfiles(); Econt::paymentReport();
Commands
#sync countries with database (use -h to view options) php artisan econt:sync-countries #sync cities with database (use -h to view options) php artisan econt:sync-cities #create cities map with other carriers in database (use -h to view options) php artisan econt:map-cities #sync offices with database (use -h to view options) php artisan econt:sync-offices #sync querters with database (use -h to view options) php artisan econt:sync-quarters #sync stretts with database (use -h to view options) php artisan econt:sync-streets #sync all nomenclatures with database (use -h to view options) php artisan econt:sync-all #get payments (use -h to view options) php artisan econt:get-payments #get econt api status (use -h to view options) php artisan econt:api-status #track parcels (use -h to view options) php artisan econt:track
Models
CarrierEcontCountry CarrierEcontCity CarrierEcontOffice CarrierEcontStreet CarrierEcontQuarter CarrierEcontPayment CarrierEcontApiStatus CarrierEcontTracking CarrierCityMap
Events
CarrierEcontTrackingEvent CarrierEcontPaymentEvent
Parcels Tracking
- Subscribe to tracking event, you will recieve last tracking info, if tracking command is schduled
Event::listen(function (CarrierEcontTrackingEvent $event) { echo $event->account; dd($event->tracking); });
- Before use of tracking command you need to create your own command and define setUp method
php artisan make:command TrackCarrierEcont
- In app/Console/Commands/TrackCarrierEcont define your logic for parcels to be tracked
use Gdinko\Econt\Commands\TrackCarrierEcontBase; class TrackCarrierEcontSetup extends TrackCarrierEcontBase { protected function setup() { //define parcel selection logic here // $this->parcels = []; } }
- Use the command
php artisan econt:track
Examples
Address Validation
try { $address = new Address([ 'city' => [ 'name' => 'София' ], 'street' => 'България', 'num' => '100' ]); dd(Econt::validateAddress($address)); } catch (EcontValidationException $eve) { echo $eve->getMessage(); echo $eve->getCode(); print_r($eve->getErrors()); } catch (EcontException $ee) { echo $ee->getMessage(); echo $ee->getCode(); print_r($ee->getErrors()); }
Get Nearest Offices to Address
try { $address = new Address([ 'city' => [ 'name' => 'София' ], 'street' => 'България', 'num' => '100' ]); dd(Econt::getNearestOffices($address)); } catch (EcontValidationException $eve) { echo $eve->getMessage(); echo $eve->getCode(); print_r($eve->getErrors()); } catch (EcontException $ee) { echo $ee->getMessage(); echo $ee->getCode(); print_r($ee->getErrors()); }
Calculcate Price
$labelData = [ 'senderClient' => [ 'name' => 'Иван Иванов', 'phones' => [ 0 => '0888888888', ], ], 'senderAddress' => [ 'city' => [ 'country' => [ 'code3' => 'BGR', ], 'name' => 'София', 'postCode' => 1000, ], ], 'senderOfficeCode' => '1127', 'receiverAddress' => [ 'city' => [ 'country' => [ 'code3' => 'BGR', ], 'name' => 'София', 'postCode' => 1000, ], 'street' => 'България', 'num' => '100', ], 'packCount' => 1, 'shipmentType' => ShipmentType::PACK, 'weight' => 3.4, 'shipmentDescription' => 'обувки', 'services' => [ 'cdAmount' => 122.59, 'cdType' => 'get', 'cdCurrency' => 'BGN', 'smsNotification' => true, ], 'payAfterAccept' => false, 'payAfterTest' => false, ]; $label = new Label( $labelData, LabelMode::CALCULATE ); $result = Econt::createLabel($label);
Create Label
$labelData = [ 'senderClient' => [ 'name' => 'Иван Иванов', 'phones' => [ 0 => '0888888888', ], ], 'senderAddress' => [ 'city' => [ 'country' => [ 'code3' => 'BGR', ], 'name' => 'София', 'postCode' => 1000, ], ], 'senderOfficeCode' => '1127', 'receiverClient' => [ 'name' => 'Димитър Димитров', 'phones' => [ 0 => '0876543210', ], ], 'receiverAddress' => [ 'city' => [ 'country' => [ 'code3' => 'BGR', ], 'name' => 'София', 'postCode' => '1000', ], 'street' => 'България', 'num' => 100, ], 'packCount' => 1, 'shipmentType' => ShipmentType::PACK, 'weight' => 3.4, 'shipmentDescription' => 'обувки', 'services' => [ 'cdAmount' => '122.59', 'cdType' => 'get', 'cdCurrency' => 'BGN', 'smsNotification' => true, ], 'payAfterAccept' => false, 'payAfterTest' => false, 'holidayDeliveryDay' => 'workday', ]; $label = new Label( $labelData, LabelMode::CREATE ); $result = Econt::createLabel($label);
Request Courier
try { $curierRequest = [ 'requestTimeFrom' => '2022-05-05 16:00:00', 'requestTimeTo' => '2022-05-05 17:00:00', 'shipmentType' => 'PACK', 'shipmentPackCount' => '1', 'shipmentWeight' => '2', 'senderClient' => [ 'name' => 'Иван Иванов', 'phones' => [ 0 => '0888888888', ], ], 'senderAddress' => [ 'city' => [ 'country' => [ 'code3' => 'BGR', ], 'postCode' => '7012', 'name' => 'Русе', ], 'fullAddress' => 'Алея Младост 7', ], ]; dd( Econt::requestCourier( new Courier($curierRequest) ) ); } catch (EcontValidationException $eve) { echo $eve->getMessage(); echo $eve->getCode(); print_r($eve->getErrors()); } catch (EcontException $ee) { echo $ee->getMessage(); echo $ee->getCode(); print_r($ee->getErrors()); }
Get Payments
try { dd( Econt::paymentReport(new Payment([ 'dateFrom' => '2022-05-01', 'dateTo' => '2022-05-05' ])) ); } catch (EcontValidationException $eve) { echo $eve->getMessage(); echo $eve->getCode(); print_r($eve->getErrors()); } catch (EcontException $ee) { echo $ee->getMessage(); echo $ee->getCode(); print_r($ee->getErrors()); }
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email dinko359@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
gdinko/econt 适用场景与选型建议
gdinko/econt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.15k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2022 年 04 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「econt」 「gdinko」 「econt laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gdinko/econt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gdinko/econt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gdinko/econt 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
统计信息
- 总下载量: 7.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-04-21