sch-group/pickpoint

俄罗斯PickPoint快递服务API连接器

v4.2 2021-12-03 13:35 UTC

README

PICKPOINT PHP SDK API

https://pickpoint.ru/sales/api/

@ainurecm telegram

composer require sch-group/pickpoint

示例

初始化

$config = [
 'host' => '',
 'login' => '',
 'password' => '',
 'ikn' => '',
];    

$pickPointConf = new PickPointConf($config['host'], $config['login'], $config['password'], $config['ikn']);

$defaultPackageSize = new PackageSize(20, 20,20); // может быть null

$senderDestination = new SenderDestination('Москва', 'Московская обл.'); // Адрес отправителя

$client = new PickPointConnector($pickPointConf, $senderDestination, $defaultPackageSize);
 
 
Так же можно добавить кэширование, для ускорения запроса на авторизацию 
$redisCacheConf = [
 'host' => '127.0.0.1',
 'port' => 6379
];

$client = new PickPointConnector($pickPointConf, $senderDestination, $defaultPackageSize, $redisCacheConf);

 

获取快递柜数组

$points = $client->getPoints(); // get postamats list

配送费用

$receiverDestination = new ReceiverDestination('Санкт-Петербург', 'Ленинградская обл.');

$prices = $client->calculatePrices($receiverDestination); // вернет массив с ценами и тарифами

$tariffPrice = $client->calculateObjectedPrices($receiverDestination); // Вернет объект с ценами

$commonStandardPrice = $tariffPrice->getStandardCommonPrice(); // получить общую цену с тарифом стандарт

创建发货

$invoice = new Invoice();
$invoice->setSenderCode('order: 123456');
$invoice->setPostamatNumber('5602-009');
$invoice->setDescription('Custom zakaz');
$invoice->setRecipientName('Саша');
$invoice->setMobilePhone('+79274269590');
$invoice->setEmail('kek@mail.ru');
$invoice->setGettingType('sc'); // courier or sc
$invoice->setSum(500.00);
$invoice->setDeliveryMode('standard'); // stanadard or priority
$packageSize = new PackageSize(20, 20, 20);
$invoice->setPackageSize($packageSize);

$product = new Product('number 234', 'Test', 2, 100);

$address = new Address();
$address->setCityName('Казань');
$address->setPhoneNumber('+79274269590');
$invoice->setClientReturnAddress($address);
$response = $client->createShipment($invoice);

打印标签

$invoice = $client->createShipmentWithInvoice($invoice);
$invoiceNumber = $invoice->getInvoiceNumber();
$pdfByteCode = $client->printLabel(array($invoiceNumber));

创建清单并打印

$invoice = $client->createShipmentWithInvoice($invoice);
$invoiceNumber = $invoice->getInvoiceNumber();

$reestr = $client->makeReceipt(array($invoiceNumber));
$pdfByteCode = $client->rintReceipt($reestr[0]);

同时创建清单和打印

$invoice = $client->createShipmentWithInvoice($invoice);
$invoiceNumber = $invoice->getInvoiceNumber();
$pdfByteCode = $client->makeReceiptAndPrint(array($invoiceNumber));

从清单中删除发票

 $remove = $client->removeInvoiceFromReceipt($invoiceNumber);

检查发货状态

$invoiceNumber = $invoice->getInvoiceNumber();
$status = $client->getStatus($invoiceNumber);
$status->getState();
$status->getStateText();

获取所有状态

$states = $client->getStates();

取消发货

$senderCode = $invoice->getSenderCode(); // order id
$cancelResponse = $client->cancelInvoice($invoiceNumber);
или 
$cancelResponse = $client->cancelInvoice('', $senderCode); // отмена с собственным id заказа

发货信息

$response = $client->shipmentInfo($invoiceNumber);
$response = $client->shipmentInfo('', $senderCode);

调用快递员

$senderDestination = new SenderDestination('Москва', 'Московская обл.', '', 992); 

$courierCall = new CourierCall(
    $senderDestination->getCity(),
    $senderDestination->getCityId(),
    $senderDestination->getAddress(),
   'Тестов Тест',
    '+79274269594',
    new \DateTime('tomorrow + 1 day'),
    12 * 60, // from 12:00,
    17 * 60, // to 17:00
    1, // 1 заказ,
    1, // 10 кг
    'Это тестовый вызов, пожалуйста не приезжайте'
 );

$callCourier = $client->callCourier($courierCall);
$courierOrderNumber = $callCourier->getCallOrderNumber();

取消调用快递员


$cancelResponse = $client->cancelCourierCall($courierOrderNumber);

发货变更历史

$response = $client->getInvoicesTrackHistory([$invoiceNumber]);

$states = $client->getInvoiceStatesTrackHistory($invoiceNumber);

$lastSates = $client->getInvoicesLastStates([$invoiceNumber]);

更新发货字段

$updateInvoice->setInvoiceNumber($invoice->getInvoiceNumber());
$updateInvoice->setRecipientName("Кек чебурек");
$updateInvoice->setSum(20.32);
$updateInvoice->setMobilePhone('+745642411');
$response = $client->updateShipment($updateInvoice);