You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

436 lines
13KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\ShopBundle\Context\DocumentInterface;
  7. use Lc\ShopBundle\Context\FilterMerchantInterface;
  8. /**
  9. * @ORM\MappedSuperclass()
  10. */
  11. abstract class OrderShop extends AbstractEntity implements FilterMerchantInterface
  12. {
  13. /**
  14. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
  15. * @ORM\JoinColumn(nullable=false)
  16. */
  17. protected $merchant;
  18. /**
  19. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="orders")
  20. */
  21. protected $user;
  22. /**
  23. * @ORM\ManyToOne(targetEntity="App\Entity\Visitor", inversedBy="orders")
  24. */
  25. protected $visitor;
  26. /**
  27. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
  28. */
  29. protected $invoiceAddress;
  30. /**
  31. * @ORM\Column(type="datetime", nullable=true)
  32. */
  33. protected $validationDate;
  34. /**
  35. * @ORM\Column(type="text", nullable=true)
  36. */
  37. protected $comment;
  38. /**
  39. * @ORM\Column(type="boolean", nullable=true)
  40. */
  41. protected $autoPayment;
  42. /**
  43. * @ORM\Column(type="string", length=31, nullable=true)
  44. */
  45. protected $meanPayment;
  46. /**
  47. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderStatusHistoryInterface", mappedBy="orderShop", orphanRemoval=true)
  48. */
  49. protected $orderStatusHistories;
  50. /**
  51. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", mappedBy="orderShop", cascade={"persist", "remove"}, orphanRemoval=true)
  52. */
  53. protected $orderProducts;
  54. /**
  55. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="orderShop", orphanRemoval=true)
  56. */
  57. protected $creditHistories;
  58. /**
  59. * @ORM\Column(type="text", nullable=true)
  60. */
  61. protected $deliveryInfos;
  62. /**
  63. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface")
  64. * @ORM\JoinColumn(nullable=false)
  65. */
  66. protected $orderStatus;
  67. /**
  68. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderReductionCartInterface", mappedBy="orderShop", orphanRemoval=true)
  69. */
  70. protected $orderReductionCarts;
  71. /**
  72. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderReductionCreditInterface", mappedBy="orderShop", orphanRemoval=true)
  73. */
  74. protected $orderReductionCredits;
  75. /**
  76. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\DocumentInterface", inversedBy="orderShops")
  77. */
  78. protected $documents;
  79. public function __construct()
  80. {
  81. $this->orderStatusHistories = new ArrayCollection();
  82. $this->orderProducts = new ArrayCollection();
  83. $this->creditHistories = new ArrayCollection();
  84. $this->orderReductionCarts = new ArrayCollection();
  85. $this->orderReductionCredits = new ArrayCollection();
  86. $this->documents = new ArrayCollection();
  87. }
  88. public function getValidationDate(): ?\DateTimeInterface
  89. {
  90. return $this->validationDate;
  91. }
  92. public function setValidationDate(\DateTimeInterface $validationDate): self
  93. {
  94. $this->validationDate = $validationDate;
  95. return $this;
  96. }
  97. public function getDateCreated()
  98. {
  99. $orderStatusHistory = $this->getOrderStatusHistory('new');
  100. if ($orderStatusHistory) {
  101. return $orderStatusHistory->getCreatedAt();
  102. }
  103. return null;
  104. }
  105. public function getOrderStatusHistory($status)
  106. {
  107. $orderStatusHistories = $this->getOrderStatusHistories();
  108. if (count($orderStatusHistories) > 0) {
  109. foreach ($orderStatusHistories as $orderStatusHistory) {
  110. if ($orderStatusHistory->getOrderStatus() == $status) {
  111. return $orderStatusHistory;
  112. }
  113. }
  114. }
  115. return null;
  116. }
  117. public function getMerchant(): ?Merchant
  118. {
  119. return $this->merchant;
  120. }
  121. public function setMerchant(?Merchant $merchant): self
  122. {
  123. $this->merchant = $merchant;
  124. return $this;
  125. }
  126. public function getUser(): ?User
  127. {
  128. return $this->user;
  129. }
  130. public function setUser(?User $user): self
  131. {
  132. $this->user = $user;
  133. return $this;
  134. }
  135. public function getInvoiceAddress(): ?Address
  136. {
  137. return $this->invoiceAddress;
  138. }
  139. public function setInvoiceAddress(?Address $invoiceAddress): self
  140. {
  141. $this->invoiceAddress = $invoiceAddress;
  142. return $this;
  143. }
  144. public function getComment(): ?string
  145. {
  146. return $this->comment;
  147. }
  148. public function setComment(?string $comment): self
  149. {
  150. $this->comment = $comment;
  151. return $this;
  152. }
  153. public function getAutoPayment(): ?bool
  154. {
  155. return $this->autoPayment;
  156. }
  157. public function setAutoPayment(bool $autoPayment): self
  158. {
  159. $this->autoPayment = $autoPayment;
  160. return $this;
  161. }
  162. public function getMeanPayment(): ?string
  163. {
  164. return $this->meanPayment;
  165. }
  166. public function setMeanPayment(string $meanPayment): self
  167. {
  168. $this->meanPayment = $meanPayment;
  169. return $this;
  170. }
  171. /**
  172. * @return Collection|OrderStatusHistory[]
  173. */
  174. public function getOrderStatusHistories(): Collection
  175. {
  176. return $this->orderStatusHistories;
  177. }
  178. public function addOrderStatusHistory(OrderStatusHistory $orderStatusHistory): self
  179. {
  180. if (!$this->orderStatusHistories->contains($orderStatusHistory)) {
  181. $this->orderStatusHistories[] = $orderStatusHistory;
  182. $orderStatusHistory->setOrderShop($this);
  183. }
  184. return $this;
  185. }
  186. public function removeOrderStatusHistory(OrderStatusHistory $orderStatusHistory): self
  187. {
  188. if ($this->orderStatusHistories->contains($orderStatusHistory)) {
  189. $this->orderStatusHistories->removeElement($orderStatusHistory);
  190. // set the owning side to null (unless already changed)
  191. if ($orderStatusHistory->getOrderShop() === $this) {
  192. $orderStatusHistory->setOrderShop(null);
  193. }
  194. }
  195. return $this;
  196. }
  197. /**
  198. * @return Collection|OrderProduct[]
  199. */
  200. public function getOrderProducts(): Collection
  201. {
  202. return $this->orderProducts;
  203. }
  204. public function addOrderProduct(OrderProduct $orderProduct): self
  205. {
  206. if (!$this->orderProducts->contains($orderProduct)) {
  207. $this->orderProducts[] = $orderProduct;
  208. $orderProduct->setOrderShop($this);
  209. }
  210. return $this;
  211. }
  212. public function removeOrderProduct(OrderProduct $orderProduct): self
  213. {
  214. if ($this->orderProducts->contains($orderProduct)) {
  215. $this->orderProducts->removeElement($orderProduct);
  216. // set the owning side to null (unless already changed)
  217. if ($orderProduct->getOrderShop() === $this) {
  218. $orderProduct->setOrderShop(null);
  219. }
  220. }
  221. return $this;
  222. }
  223. /**
  224. * @return Collection|CreditHistory[]
  225. */
  226. public function getCreditHistories(): Collection
  227. {
  228. return $this->creditHistories;
  229. }
  230. public function addCreditHistory(CreditHistory $creditHistory): self
  231. {
  232. if (!$this->creditHistories->contains($creditHistory)) {
  233. $this->creditHistories[] = $creditHistory;
  234. $creditHistory->setOrderShop($this);
  235. }
  236. return $this;
  237. }
  238. public function removeCreditHistory(CreditHistory $creditHistory): self
  239. {
  240. if ($this->creditHistories->contains($creditHistory)) {
  241. $this->creditHistories->removeElement($creditHistory);
  242. // set the owning side to null (unless already changed)
  243. if ($creditHistory->getOrderShop() === $this) {
  244. $creditHistory->setOrderShop(null);
  245. }
  246. }
  247. return $this;
  248. }
  249. public function getVisitor(): ?Visitor
  250. {
  251. return $this->visitor;
  252. }
  253. public function setVisitor(?Visitor $visitor): self
  254. {
  255. $this->visitor = $visitor;
  256. return $this;
  257. }
  258. public function getDeliveryInfos(): ?string
  259. {
  260. return $this->deliveryInfos;
  261. }
  262. public function setDeliveryInfos(?string $deliveryInfos): self
  263. {
  264. $this->deliveryInfos = $deliveryInfos;
  265. return $this;
  266. }
  267. public function getOrderStatus(): ?OrderStatus
  268. {
  269. return $this->orderStatus;
  270. }
  271. public function setOrderStatusProtected(?OrderStatus $orderStatus): self
  272. {
  273. $this->orderStatus = $orderStatus;
  274. return $this;
  275. }
  276. /**
  277. * @return Collection|OrderReductionCart[]
  278. */
  279. public function getOrderReductionCarts(): Collection
  280. {
  281. return $this->orderReductionCarts;
  282. }
  283. public function addOrderReductionCart(OrderReductionCart $orderReductionCart): self
  284. {
  285. if (!$this->orderReductionCarts->contains($orderReductionCart)) {
  286. $this->orderReductionCarts[] = $orderReductionCart;
  287. $orderReductionCart->setOrderShop($this);
  288. }
  289. return $this;
  290. }
  291. public function removeOrderReductionCart(OrderReductionCart $orderReductionCart): self
  292. {
  293. if ($this->orderReductionCarts->contains($orderReductionCart)) {
  294. $this->orderReductionCarts->removeElement($orderReductionCart);
  295. // set the owning side to null (unless already changed)
  296. if ($orderReductionCart->getOrderShop() === $this) {
  297. $orderReductionCart->setOrderShop(null);
  298. }
  299. }
  300. return $this;
  301. }
  302. /**
  303. * @return Collection|OrderReductionCart[]
  304. */
  305. public function getOrderReductionCredits(): Collection
  306. {
  307. return $this->orderReductionCredits;
  308. }
  309. public function addOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self
  310. {
  311. if (!$this->orderReductionCredits->contains($orderReductionCredit)) {
  312. $this->orderReductionCredits[] = $orderReductionCredit;
  313. $orderReductionCredit->setOrderShop($this);
  314. }
  315. return $this;
  316. }
  317. public function removeOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self
  318. {
  319. if ($this->orderReductionCredits->contains($orderReductionCredit)) {
  320. $this->orderReductionCredits->removeElement($orderReductionCredit);
  321. // set the owning side to null (unless already changed)
  322. if ($orderReductionCredit->getOrderShop() === $this) {
  323. $orderReductionCredit->setOrderShop(null);
  324. }
  325. }
  326. return $this;
  327. }
  328. /**
  329. * @return Collection|Document[]
  330. */
  331. public function getDocuments(): Collection
  332. {
  333. return $this->documents;
  334. }
  335. public function addDocument(Document $document): self
  336. {
  337. if (!$this->documents->contains($document)) {
  338. $this->documents[] = $document;
  339. }
  340. return $this;
  341. }
  342. public function removeDocument(Document $document): self
  343. {
  344. if ($this->documents->contains($document)) {
  345. $this->documents->removeElement($document);
  346. }
  347. return $this;
  348. }
  349. }