本文整理汇总了PHP中Kit::getByBarcode方法的典型用法代码示例。如果您正苦于以下问题:PHP Kit::getByBarcode方法的具体用法?PHP Kit::getByBarcode怎么用?PHP Kit::getByBarcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kit
的用法示例。
在下文中一共展示了Kit::getByBarcode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preSave
/**
* (non-PHPdoc)
* @see BaseEntityAbstract::preSave()
*/
public function preSave()
{
if (trim($this->getSerialNo()) === '') {
throw new Exception('You can NOT save a selling Item without a serial number.');
}
if (trim($this->getId()) !== '') {
if (intval($this->getActive()) === 0 && self::countByCriteria('id = ? and active != ?', array($this->getId(), $this->getActive())) > 0) {
//trying to deactivated
$this->_clearKit();
} else {
if (intval($this->getActive()) === 1 && self::countByCriteria('id = ? and serialNo != ?', array($this->getId(), trim($this->getSerialNo()))) > 0) {
//trying to changed serialno
$this->_clearKit()->setKit(null);
}
}
}
if ($this->getOrderItem() instanceof OrderItem) {
$this->setProduct($this->getOrderItem()->getProduct())->setOrder($this->getOrderItem()->getOrder());
}
if (!$this->getKit() instanceof Kit && strpos(trim($this->getSerialNo()), Kit::BARCODE_PREFIX) === 0) {
if (($kit = Kit::getByBarcode(trim($this->getSerialNo()))) instanceof Kit) {
$this->setKit($kit);
}
}
if ($this->getKit() instanceof Kit) {
$kitProduct = $this->getKit()->getProduct();
$orderItemProduct = $this->getOrderItem() instanceof OrderItem ? $this->getOrderItem()->getProduct() : null;
if (!$kitProduct instanceof Product && $orderItemProduct instanceof Product || $kitProduct instanceof Product && !$orderItemProduct instanceof Product || $kitProduct instanceof Product && $orderItemProduct instanceof Product && $kitProduct->getId() !== $orderItemProduct->getId()) {
throw new Exception('The Kit [' . $this->getKit()->getBarcode() . ', SKU: ' . ($kitProduct instanceof Product ? $kitProduct->getSku() : '') . '] is not the same product on this OrderItem[SKU:' . ($orderItemProduct instanceof Product ? $orderItemProduct->getSku() : '') . '].');
}
}
if ($this->getProduct() instanceof Product && intval($this->getProduct()->getIsKit()) === 1) {
if (!$this->getKit() instanceof Kit) {
throw new Exception('The Product(SKU: ' . $this->getProduct()->getSku() . ') is a KIT, but no valid Kit barcode provided(Provided: ' . $this->getSerialNo() . ').');
}
if ($this->getOrderItem()->getOrder() instanceof Order) {
$where = array('kitId = :kitId and orderId = :orderId and active = 1');
$params = array('kitId' => $this->getKit()->getId(), 'orderId' => $this->getOrderItem()->getOrder()->getId());
if (($id = trim($this->getId())) !== '') {
$where[] = 'id != :id';
$params['id'] = $id;
}
if (self::countByCriteria(implode(' AND ', $where), $params) > 0) {
throw new Exception('The KIT[' . $this->getKit()->getBarcode() . '] has been scanned onto this Order(' . $this->getOrderItem()->getOrder()->getOrderNo() . ') already!');
}
}
}
}