✏️ 正在编辑: ColissimoACE.php
路径:
/home/bpioifn/www/pigmentse/modules/colissimo/classes/ColissimoACE.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * 2007-2024 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2024 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_PS_VERSION_')) { exit; } /** * Class ColissimoACE */ class ColissimoACE extends ObjectModel { /** @var int */ public $id_colissimo_ace; /** @var int */ public $ref_order; /** @var string */ public $shipping_number; /** @var array */ public static $definition = [ 'table' => 'colissimo_ace', 'primary' => 'id_colissimo_ace', 'fields' => [ 'ref_order' => ['type' => self::TYPE_INT, 'required' => false], 'shipping_number' => ['type' => self::TYPE_STRING, 'required' => false, 'size' => 64], ], ]; /** * @var array */ protected $webserviceParameters = [ 'objectMethods' => ['add' => 'addWs'], 'objectNodeName' => 'colissimo_ace', 'fields' => [ 'id_order' => [], 'shipping_number' => [], ], ]; /** * @throws PrestaShopDatabaseException * @throws PrestaShopException */ public function addWs() { /** @var Colissimo $module */ $module = Module::getInstanceByName('colissimo'); $module->logger->setChannel('ACE'); if (ColissimoOrder::exists($this->ref_order)) { $order = new Order((int) $this->ref_order); $colissimoLabel = new ColissimoLabel(); $colissimoLabel->id_colissimo_order = (int) ColissimoOrder::getIdByOrderId($this->ref_order); $colissimoLabel->id_colissimo_deposit_slip = 0; $colissimoLabel->shipping_number = pSQL($this->shipping_number); $colissimoLabel->label_format = 'pdf'; $colissimoLabel->return_label = 0; $colissimoLabel->cn23 = 0; $colissimoLabel->coliship = 1; $colissimoLabel->migration = 0; $colissimoLabel->insurance = null; $colissimoLabel->file_deleted = 0; $colissimoLabel->save(true); $orderCarrier = ColissimoOrderCarrier::getByIdOrder($this->ref_order); if (Validate::isLoadedObject($orderCarrier) && !$orderCarrier->tracking_number) { $orderCarrier->tracking_number = pSQL($colissimoLabel->shipping_number); $orderCarrier->save(); $hash = md5($order->reference . $order->secure_key); $link = Context::getContext()->link->getModuleLink( 'colissimo', 'tracking', ['order_reference' => $order->reference, 'hash' => $hash] ); $isoLangOrder = Language::getIsoById($order->id_lang); if (isset($this->module->PNAMailObject[$isoLangOrder])) { $object = $module->PNAMailObject[$isoLangOrder]; } else { $object = $module->PNAMailObject['en']; } ColissimoTools::sendHandlingShipmentMail( $order, sprintf($object, $order->reference), $link ); $module->logger->info('Send tracking mail for shipment ' . $colissimoLabel->shipping_number); } if (Configuration::get('COLISSIMO_USE_SHIPPING_IN_PROGRESS')) { $idShippingInProgressOS = Configuration::get('COLISSIMO_OS_SHIPPING_IN_PROGRESS'); $shippingInProgressOS = new OrderState((int) $idShippingInProgressOS); if (Validate::isLoadedObject($shippingInProgressOS)) { if (!$order->getHistory(Context::getContext()->language->id, (int) $idShippingInProgressOS)) { $history = new OrderHistory(); $history->id_order = (int) $order->id; $history->changeIdOrderState($idShippingInProgressOS, (int) $order->id); try { $history->add(); } catch (Exception $e) { $module->logger->error(sprintf('Cannot change status of order #%d', $order->id)); } } } else { $module->logger->error('Shipping in Progress order state is not valid'); } } $module->logger->info('Label imported successfully.'); return true; } return false; } /** * @param bool $die * @param bool $error_return * @return bool|string */ public function validateFields($die = true, $error_return = false) { if (($id = ColissimoLabel::getLabelIdByShippingNumber($this->shipping_number)) !== 0) { return sprintf('Colissimo label already exists (label ID #%d)', (int) $id); } return true; } }
💾 保存文件
← 返回文件管理器