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