<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Customize\Entity;
use Doctrine\ORM\Mapping as ORM;
if (!class_exists('\Customize\Entity\PriceDelivery')) {
/**
* PriceDelivery
* @ORM\Table(name="dtb_price_and_delivery")
* @ORM\Entity(repositoryClass="Customize\Repository\PriceRepository")
*/
class PriceDelivery extends \Eccube\Entity\AbstractEntity
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="quantity", type="string", nullable=true, length=255)
* @ORM\GeneratedValue(strategy="NONE")
*/
private $quantity;
/**
* @var int
*
* @ORM\Column(name="from_quantity", type="integer", nullable=true, options={"unsigned":true})
* @ORM\GeneratedValue(strategy="NONE")
*/
private $from_quantity;
/**
* @var int
*
* @ORM\Column(name="to_quantity", type="integer", nullable=true, options={"unsigned":true})
* @ORM\GeneratedValue(strategy="NONE")
*/
private $to_quantity;
/**
* @var int
*
* @ORM\Column(name="price", type="integer", nullable=true, options={"unsigned":true})
* @ORM\GeneratedValue(strategy="NONE")
*/
private $price;
/**
* @var string
*
* @ORM\Column(name="plan", type="string", nullable=true, length=255)
* @ORM\GeneratedValue(strategy="NONE")
*/
private $plan;
/**
* @var string
*
* @ORM\Column(name="option_ids", type="string", nullable=true, length=255)
* @ORM\GeneratedValue(strategy="NONE")
*/
private $option_ids;
/**
* @var string
*
* @ORM\Column(name="delivery_time_low_session", type="string", nullable=true, length=255)
* @ORM\GeneratedValue(strategy="NONE")
*/
private $delivery_time_low_session;
/**
* @var string
*
* @ORM\Column(name="delivery_time_normal_session", type="string", nullable=true, length=255)
* @ORM\GeneratedValue(strategy="NONE")
*/
private $delivery_time_normal_session;
/**
* @var string
*
* @ORM\Column(name="delivery_time_peak_session", type="string", nullable=true, length=255)
* @ORM\GeneratedValue(strategy="NONE")
*/
private $delivery_time_peak_session;
/**
* @var int
*
* @ORM\Column(name="product_id", type="integer", nullable=false, options={"unsigned":true})
* @ORM\GeneratedValue(strategy="NONE")
*/
private $product_id;
/**
* @var \DateTime
*
* @ORM\Column(name="create_date", type="datetimetz", nullable=true)})
*/
private $create_date;
/**
* @var \DateTime
*
* @ORM\Column(name="update_date", type="datetimetz", nullable=true)})
*/
private $update_date;
public function getFromQuantity(){
return $this->from_quantity;
}
public function getToQuantity(){
return $this->to_quantity;
}
public function setQuantity($quantity)
{
$this->quantity = $quantity;
return $this;
}
public function getQuantity()
{
return $this->quantity;
}
public function getQuantityView()
{
$from = $this->from_quantity ?? '';
$to = $this->to_quantity ?? '';
if ($from == $to) return (string)$from;
return $from . '〜' . $to;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function getId()
{
return $this->id;
}
public function setQuantityFromTo($quantity)
{
// $quantity_arr = explode("-", $quantity);
// $this->from_quantity = trim($quantity_arr[0]);
// $this->to_quantity = count($quantity_arr) > 1 ? (trim($quantity_arr[1]) ? trim($quantity_arr[1]) : null) : trim($quantity_arr[0]);
$format_quantity = str_replace(',', '', $quantity);
preg_match_all('!\d+!', trim($format_quantity), $quantity_number);
$quantity_number = $quantity_number[0];
$from = $quantity_number[0] ?? null;
$to = $quantity_number[1] ?? null;
if($from && strlen($from) === strlen(trim($format_quantity))){
$to = $from;
}
$this->from_quantity = $from;
$this->to_quantity = $to;
return $this;
}
public function getOptionIdArray(){
preg_match_all('!\d+!', trim($this->option_ids), $optionIds);
return $optionIds[0];
}
public function setPlan($plan)
{
$this->plan = $plan;
return $this;
}
public function getPlan()
{
return $this->plan;
}
public function setPrice($price)
{
$format_price = str_replace(',', '', $price);
$format_price = (int)$format_price;
$this->price = $format_price;
return $this;
}
public function getPrice()
{
return $this->price;
}
public function setProductId($product_id)
{
$this->product_id = $product_id;
return $this;
}
public function getProductId()
{
return $this->product_id;
}
public function setOptionIds($option_ids)
{
$this->option_ids = $option_ids;
return $this;
}
public function getOptionIds()
{
return $this->option_ids;
}
public function setDeliveryTimeNormalSession($delivery_time_normal_session)
{
$this->delivery_time_normal_session = $delivery_time_normal_session;
return $this;
}
public function getDeliveryTimeNormalSession()
{
return $this->delivery_time_normal_session;
}
public function setDeliveryTimePeakSession($delivery_time_peak_session)
{
$this->delivery_time_peak_session = $delivery_time_peak_session;
return $this;
}
public function getDeliveryTimePeakSession()
{
return $this->delivery_time_peak_session;
}
public function setDeliveryTimeLowSession($delivery_time_low_session)
{
$this->delivery_time_low_session = $delivery_time_low_session;
return $this;
}
public function getDeliveryTimeLowSession()
{
return $this->delivery_time_low_session;
}
/**
* Set createDate.
*
* @param \DateTime $createDate
*
* @return Campaign
*/
public function setCreateDate($createDate = null)
{
if ($createDate) {
$this->create_date = $createDate;
} else {
$this->create_date = date("Y-m-d H:i:s");
}
return $this;
}
/**
* Get createDate.
*
* @return \DateTime
*/
public function getCreateDate()
{
return $this->create_date;
}
/**
* Set updateDate.
*
* @param \DateTime $updateDate
*
*/
public function setUpdateDate($updateDate = null)
{
if ($updateDate) {
$this->update_date = $updateDate;
} else {
$this->update_date = date("Y-m-d H:i:s");
}
return $this;
}
/**
* Get updateDate.
*
* @return \DateTime
*/
public function getUpdateDate()
{
return $this->update_date;
}
}
}