adesa / smartlabel-client
使用SmartLabel Web服务放置和管理贴纸订单
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2024-09-12 03:03:26 UTC
README
SmartLabel SDK使您能够快速简单地集成Adesa Web服务到您的PHP应用程序中。它允许您计算价格、创建报价、将其转换为订单并上传文件。
- 可用的模板、材料和表面处理列表
- 价格计算
- 创建订单
- 多模型
- 文件传输
- 材料和表面处理的翻译和商业标签
- 生成HTML表单
- 缓存Web服务返回
先决条件
PHP >= 5.3
以及php-soap
扩展
安装
您可以通过以下三种方式安装SDK
- 使用composer命令行工具
$ composer install "adesa/smartlabel-client"
- 在
composer.json
文件中将adesa/smartlabel-client
添加到依赖项
{ "require": { "adesa/smartlabel-client": "*" } }
- 从GitHub下载tarball. 不建议
配置
- 从Adesa获取您的经销商ID以及FTP登录信息。
- 将这些信息添加到配置
.ini
文件或PHP关联数组中
# ./config/smartlabel.ini locale = {fr|en|es|…} localeBasePath = ../locale identifiantRevendeur = {votre identifiant revendeur} [FTP] host = adesaweb.adesa.fr user = {votre login FTP} password = {votre mot de passe FTP}
$config = \Adesa\SmartLabelClient\Config::fromIniFile(__DIR__ . "/../config/smartlabel.ini");
或者
$config = \Adesa\SmartLabelClient\Config::fromArray([ "locale" => "fr-FR", "localeBasPath" => "../locale", "identifiantRevendeur" => "{votre identifiant revendeur}", "ftp" => [ "host" => "adesaweb.adesa.fr", "user" => "{votre identifiant revendeur}" "password" => "{votre mot de passe FTP}" ] ]);
- 通过传递配置实例化
SmartLabel
类
$smartLabel = new \Adesa\SmartLabelClient($config);
用法
不同的模板
Adesa SmartLabel Web服务提供两种模板直径
- 40mm模板
- 76mm模板
此直径对于自动安装尤为重要,因为如果尺寸不正确,则无法适应安装机器。
要获取可用模板的列表,需要调用以下方法
$smartLabel->listeMandrins(); // retourne un tableau d'objet Mandrin
获取材料列表
材料是打印视图的支持材料。Web服务提供以下支持(可能演变)
- 可移除涂层
- 永久涂层
- 自然创作纸张
- 珍珠创作纸张
- 银色亮光聚丙烯
- 白色亮光聚丙烯
- 透明聚丙烯
$matieres = $smartLabel->listeMatieres(); // tableau d'objet Matière $select = "<select name=matieres>"; foreach($matieres as $matiere){ $select.= '<option value="' . $matiere->numero . '">'; $select.= $smartLabel->label($matiere); $select.= '</option>'; } $select.= "</select>";
获取表面处理
表面处理是在打印材料后应用的技术工艺。可用的表面处理取决于选定的材料(可能演变)。Web服务提供以下表面处理
- 亮光漆
- 亮光膜
- 哑光膜
$matiere = $smartLabel->trouverMatiere($_GET['numero_matiere']); // Les finitions disponibles sont fonctions de la matière sélectionnée $finitions = $smartLabel->listeFinitions($matiere); $select = "<select name=finitions>"; foreach($finitions as $finition){ $select.= '<option value="' . $finition->numero . '">'; $select.= $smartLabel->label($finition); $select.= '</option>'; } $select.= "</select>";
请求价格
为了计算标签印刷的价格,首先需要了解制造场景。为此,需要调用以下方法
多模型是指在不同标签上打印不同的视图,而这些标签具有相同的特征:尺寸、材料、表面处理等。
$scenario = $smartLabel->trouverScenario($matiere, $finition);
然后调用demandePrix
方法,该方法接受以下参数
scenario
:通过材料/表面处理组合找到的场景quantite
:总标签数量,包括所有模型hauteur
:标签的高度(不是视图)以毫米为单位largeur
:标签的宽度(不是视图)以毫米为单位poseAutomatique
: sitrue
,则卷材旨在与自动贴标机一起使用。在这种情况下,必须确保使用正确的夹具直径并仔细检查卷材的总直径mandrin
:所使用的夹具每卷标签数量
卷材数量
rotation
:贴标在标签上的视觉方向与卷材滚动方向的关系每系列数量
系列数量
价格查询Web服务创建一个SmartLabel(报价)文件夹,包含以下信息
numero
:文件夹编号prix
:订单购买价格,以欧元(€)计poids
:包裹重量,单位为千克diametre
:卷材直径 (在自动贴标的情况下请务必检查)
创建订单并添加模型
一旦创建文件夹,就是时候下订单了!为此,您只需将“文件夹”对象传递给commander
方法。您可以将外部订单ID作为该方法的参数传递,这将有助于将SmartLabel订单连接到您的ERP /信息系统。
此方法将创建一个SmartLabel订单单,您可以使用它来描述模型及其文件
$bonDeCommande = $smartLabel->commander($dossier, $myOrder->orderID); foreach($myOrder->getAttachments() as $attachment){ $bonDeCommande->ajouterModele($attachment['name'], $attachment['filename']); }
一旦添加了所有模型,您只需完成订单单。
$smartLabel->finaliserBonDeCommande($bonDeCommande);
完成订单单将在Adesa的FTP上放置文件并按XML格式编写制造清单。
跟踪订单进度
SmartLabel订单可能处于四种不同的状态
- 未处理
- 进行中
- 发货
- 文件不合规
当订单处于发货状态时,SmartLabel返回一个跟踪URL,允许您在运输商网站上跟踪包裹,并返回格式为文本的发货信息。
建议设置一个定期任务(例如在crontab
中),以获取所有尚未发货的SmartLabel订单的状态。
// toutes vos commandes d'étiquettes smartlabel dans un tableau associatif // avec pour clé le numéro de dossier $orders = DB::fetchSmartLabelOrders(); $etats = $smartLabel->etatDossiers(array_keys($orders)); // Le tableau $etats est composé d'objets EtatDossier foreach($etats as $numeroDossier => $etat) { $order = $orders[$numeroDossier]; switch($etat->code){ case EtatDossier::LIVRAISON: $order->setState("shipping"); break; case EtatDossier::ERREUR_FICHIER: if(!$order->isInState("error")){ $order->setState("error"); $order->customer->sendErrorMail(); } break; } }