app/Customize/Entity/PriceDelivery.php line 26

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of EC-CUBE
  4. *
  5. * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6. *
  7. * http://www.ec-cube.co.jp/
  8. *
  9. * For the full copyright and license information, please view the LICENSE
  10. * file that was distributed with this source code.
  11. */
  12. namespace Customize\Entity;
  13. use Doctrine\ORM\Mapping as ORM;
  14. if (!class_exists('\Customize\Entity\PriceDelivery')) {
  15. /**
  16. * PriceDelivery
  17. * @ORM\Table(name="dtb_price_and_delivery")
  18. * @ORM\Entity(repositoryClass="Customize\Repository\PriceRepository")
  19. */
  20. class PriceDelivery extends \Eccube\Entity\AbstractEntity
  21. {
  22. /**
  23. * @var integer
  24. *
  25. * @ORM\Column(name="id", type="integer", options={"unsigned":true})
  26. * @ORM\Id
  27. * @ORM\GeneratedValue(strategy="IDENTITY")
  28. */
  29. private $id;
  30. /**
  31. * @var string
  32. *
  33. * @ORM\Column(name="quantity", type="string", nullable=true, length=255)
  34. * @ORM\GeneratedValue(strategy="NONE")
  35. */
  36. private $quantity;
  37. /**
  38. * @var int
  39. *
  40. * @ORM\Column(name="from_quantity", type="integer", nullable=true, options={"unsigned":true})
  41. * @ORM\GeneratedValue(strategy="NONE")
  42. */
  43. private $from_quantity;
  44. /**
  45. * @var int
  46. *
  47. * @ORM\Column(name="to_quantity", type="integer", nullable=true, options={"unsigned":true})
  48. * @ORM\GeneratedValue(strategy="NONE")
  49. */
  50. private $to_quantity;
  51. /**
  52. * @var int
  53. *
  54. * @ORM\Column(name="price", type="integer", nullable=true, options={"unsigned":true})
  55. * @ORM\GeneratedValue(strategy="NONE")
  56. */
  57. private $price;
  58. /**
  59. * @var string
  60. *
  61. * @ORM\Column(name="plan", type="string", nullable=true, length=255)
  62. * @ORM\GeneratedValue(strategy="NONE")
  63. */
  64. private $plan;
  65. /**
  66. * @var string
  67. *
  68. * @ORM\Column(name="option_ids", type="string", nullable=true, length=255)
  69. * @ORM\GeneratedValue(strategy="NONE")
  70. */
  71. private $option_ids;
  72. /**
  73. * @var string
  74. *
  75. * @ORM\Column(name="delivery_time_low_session", type="string", nullable=true, length=255)
  76. * @ORM\GeneratedValue(strategy="NONE")
  77. */
  78. private $delivery_time_low_session;
  79. /**
  80. * @var string
  81. *
  82. * @ORM\Column(name="delivery_time_normal_session", type="string", nullable=true, length=255)
  83. * @ORM\GeneratedValue(strategy="NONE")
  84. */
  85. private $delivery_time_normal_session;
  86. /**
  87. * @var string
  88. *
  89. * @ORM\Column(name="delivery_time_peak_session", type="string", nullable=true, length=255)
  90. * @ORM\GeneratedValue(strategy="NONE")
  91. */
  92. private $delivery_time_peak_session;
  93. /**
  94. * @var int
  95. *
  96. * @ORM\Column(name="product_id", type="integer", nullable=false, options={"unsigned":true})
  97. * @ORM\GeneratedValue(strategy="NONE")
  98. */
  99. private $product_id;
  100. /**
  101. * @var \DateTime
  102. *
  103. * @ORM\Column(name="create_date", type="datetimetz", nullable=true)})
  104. */
  105. private $create_date;
  106. /**
  107. * @var \DateTime
  108. *
  109. * @ORM\Column(name="update_date", type="datetimetz", nullable=true)})
  110. */
  111. private $update_date;
  112. public function getFromQuantity(){
  113. return $this->from_quantity;
  114. }
  115. public function getToQuantity(){
  116. return $this->to_quantity;
  117. }
  118. public function setQuantity($quantity)
  119. {
  120. $this->quantity = $quantity;
  121. return $this;
  122. }
  123. public function getQuantity()
  124. {
  125. return $this->quantity;
  126. }
  127. public function getQuantityView()
  128. {
  129. $from = $this->from_quantity ?? '';
  130. $to = $this->to_quantity ?? '';
  131. if ($from == $to) return (string)$from;
  132. return $from . '〜' . $to;
  133. }
  134. public function setId($id)
  135. {
  136. $this->id = $id;
  137. return $this;
  138. }
  139. public function getId()
  140. {
  141. return $this->id;
  142. }
  143. public function setQuantityFromTo($quantity)
  144. {
  145. // $quantity_arr = explode("-", $quantity);
  146. // $this->from_quantity = trim($quantity_arr[0]);
  147. // $this->to_quantity = count($quantity_arr) > 1 ? (trim($quantity_arr[1]) ? trim($quantity_arr[1]) : null) : trim($quantity_arr[0]);
  148. $format_quantity = str_replace(',', '', $quantity);
  149. preg_match_all('!\d+!', trim($format_quantity), $quantity_number);
  150. $quantity_number = $quantity_number[0];
  151. $from = $quantity_number[0] ?? null;
  152. $to = $quantity_number[1] ?? null;
  153. if($from && strlen($from) === strlen(trim($format_quantity))){
  154. $to = $from;
  155. }
  156. $this->from_quantity = $from;
  157. $this->to_quantity = $to;
  158. return $this;
  159. }
  160. public function getOptionIdArray(){
  161. preg_match_all('!\d+!', trim($this->option_ids), $optionIds);
  162. return $optionIds[0];
  163. }
  164. public function setPlan($plan)
  165. {
  166. $this->plan = $plan;
  167. return $this;
  168. }
  169. public function getPlan()
  170. {
  171. return $this->plan;
  172. }
  173. public function setPrice($price)
  174. {
  175. $format_price = str_replace(',', '', $price);
  176. $format_price = (int)$format_price;
  177. $this->price = $format_price;
  178. return $this;
  179. }
  180. public function getPrice()
  181. {
  182. return $this->price;
  183. }
  184. public function setProductId($product_id)
  185. {
  186. $this->product_id = $product_id;
  187. return $this;
  188. }
  189. public function getProductId()
  190. {
  191. return $this->product_id;
  192. }
  193. public function setOptionIds($option_ids)
  194. {
  195. $this->option_ids = $option_ids;
  196. return $this;
  197. }
  198. public function getOptionIds()
  199. {
  200. return $this->option_ids;
  201. }
  202. public function setDeliveryTimeNormalSession($delivery_time_normal_session)
  203. {
  204. $this->delivery_time_normal_session = $delivery_time_normal_session;
  205. return $this;
  206. }
  207. public function getDeliveryTimeNormalSession()
  208. {
  209. return $this->delivery_time_normal_session;
  210. }
  211. public function setDeliveryTimePeakSession($delivery_time_peak_session)
  212. {
  213. $this->delivery_time_peak_session = $delivery_time_peak_session;
  214. return $this;
  215. }
  216. public function getDeliveryTimePeakSession()
  217. {
  218. return $this->delivery_time_peak_session;
  219. }
  220. public function setDeliveryTimeLowSession($delivery_time_low_session)
  221. {
  222. $this->delivery_time_low_session = $delivery_time_low_session;
  223. return $this;
  224. }
  225. public function getDeliveryTimeLowSession()
  226. {
  227. return $this->delivery_time_low_session;
  228. }
  229. /**
  230. * Set createDate.
  231. *
  232. * @param \DateTime $createDate
  233. *
  234. * @return Campaign
  235. */
  236. public function setCreateDate($createDate = null)
  237. {
  238. if ($createDate) {
  239. $this->create_date = $createDate;
  240. } else {
  241. $this->create_date = date("Y-m-d H:i:s");
  242. }
  243. return $this;
  244. }
  245. /**
  246. * Get createDate.
  247. *
  248. * @return \DateTime
  249. */
  250. public function getCreateDate()
  251. {
  252. return $this->create_date;
  253. }
  254. /**
  255. * Set updateDate.
  256. *
  257. * @param \DateTime $updateDate
  258. *
  259. */
  260. public function setUpdateDate($updateDate = null)
  261. {
  262. if ($updateDate) {
  263. $this->update_date = $updateDate;
  264. } else {
  265. $this->update_date = date("Y-m-d H:i:s");
  266. }
  267. return $this;
  268. }
  269. /**
  270. * Get updateDate.
  271. *
  272. * @return \DateTime
  273. */
  274. public function getUpdateDate()
  275. {
  276. return $this->update_date;
  277. }
  278. }
  279. }