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.

500 satır
15KB

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