Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

OrderShop.php 15KB

4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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="datetime", nullable=true)
  33. */
  34. protected $validationDate;
  35. /**
  36. * @ORM\Column(type="text", nullable=true)
  37. */
  38. protected $comment;
  39. /**
  40. * @ORM\Column(type="boolean", nullable=true)
  41. */
  42. protected $autoPayment;
  43. /**
  44. * @ORM\Column(type="string", length=31, nullable=true)
  45. */
  46. protected $meanPayment;
  47. /**
  48. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderStatusHistoryInterface", mappedBy="orderShop", orphanRemoval=true)
  49. */
  50. protected $orderStatusHistories;
  51. /**
  52. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderPaymentInterface", mappedBy="orderShop", orphanRemoval=true)
  53. */
  54. protected $orderPayments;
  55. /**
  56. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", mappedBy="orderShop", cascade={"persist", "remove"}, orphanRemoval=true)
  57. */
  58. protected $orderProducts;
  59. /**
  60. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="orderShop", orphanRemoval=true)
  61. */
  62. protected $creditHistories;
  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 getComment(): ?string
  163. {
  164. return $this->comment;
  165. }
  166. public function setComment(?string $comment): self
  167. {
  168. $this->comment = $comment;
  169. return $this;
  170. }
  171. public function getAutoPayment(): ?bool
  172. {
  173. return $this->autoPayment;
  174. }
  175. public function setAutoPayment(bool $autoPayment): self
  176. {
  177. $this->autoPayment = $autoPayment;
  178. return $this;
  179. }
  180. public function getMeanPayment(): ?string
  181. {
  182. return $this->meanPayment;
  183. }
  184. public function setMeanPayment(string $meanPayment): self
  185. {
  186. $this->meanPayment = $meanPayment;
  187. return $this;
  188. }
  189. /**
  190. * @return Collection|OrderStatusHistory[]
  191. */
  192. public function getOrderStatusHistories(): Collection
  193. {
  194. return $this->orderStatusHistories;
  195. }
  196. public function addOrderStatusHistory(OrderStatusHistory $orderStatusHistory): self
  197. {
  198. if (!$this->orderStatusHistories->contains($orderStatusHistory)) {
  199. $this->orderStatusHistories[] = $orderStatusHistory;
  200. $orderStatusHistory->setOrderShop($this);
  201. }
  202. return $this;
  203. }
  204. public function removeOrderStatusHistory(OrderStatusHistory $orderStatusHistory): self
  205. {
  206. if ($this->orderStatusHistories->contains($orderStatusHistory)) {
  207. $this->orderStatusHistories->removeElement($orderStatusHistory);
  208. // set the owning side to null (unless already changed)
  209. if ($orderStatusHistory->getOrderShop() === $this) {
  210. $orderStatusHistory->setOrderShop(null);
  211. }
  212. }
  213. return $this;
  214. }
  215. /**
  216. * @return Collection|OrderPayment[]
  217. */
  218. public function getOrderPayments(): Collection
  219. {
  220. return $this->orderPayments;
  221. }
  222. public function addOrderPayment(OrderPayment $orderPayment): self
  223. {
  224. if (!$this->orderPayments->contains($orderPayment)) {
  225. $this->orderPayments[] = $orderPayment;
  226. $orderPayment->setOrderShop($this);
  227. }
  228. return $this;
  229. }
  230. public function removeOrderPayment(OrderPayment $orderPayment): self
  231. {
  232. if ($this->orderPayments->contains($orderPayment)) {
  233. $this->orderPayments->removeElement($orderPayment);
  234. // set the owning side to null (unless already changed)
  235. if ($orderPayment->getOrderShop() === $this) {
  236. $orderPayment->setOrderShop(null);
  237. }
  238. }
  239. return $this;
  240. }
  241. /**
  242. * @return Collection|OrderProduct[]
  243. */
  244. public function getOrderProducts(): Collection
  245. {
  246. return $this->orderProducts;
  247. }
  248. public function addOrderProduct(OrderProduct $orderProduct): self
  249. {
  250. if (!$this->orderProducts->contains($orderProduct)) {
  251. $this->orderProducts[] = $orderProduct;
  252. $orderProduct->setOrderShop($this);
  253. }
  254. return $this;
  255. }
  256. public function removeOrderProduct(OrderProduct $orderProduct): self
  257. {
  258. if ($this->orderProducts->contains($orderProduct)) {
  259. $this->orderProducts->removeElement($orderProduct);
  260. // set the owning side to null (unless already changed)
  261. if ($orderProduct->getOrderShop() === $this) {
  262. $orderProduct->setOrderShop(null);
  263. }
  264. }
  265. return $this;
  266. }
  267. /**
  268. * @return Collection|CreditHistory[]
  269. */
  270. public function getCreditHistories(): Collection
  271. {
  272. return $this->creditHistories;
  273. }
  274. public function addCreditHistory(CreditHistory $creditHistory): self
  275. {
  276. if (!$this->creditHistories->contains($creditHistory)) {
  277. $this->creditHistories[] = $creditHistory;
  278. $creditHistory->setOrderShop($this);
  279. }
  280. return $this;
  281. }
  282. public function removeCreditHistory(CreditHistory $creditHistory): self
  283. {
  284. if ($this->creditHistories->contains($creditHistory)) {
  285. $this->creditHistories->removeElement($creditHistory);
  286. // set the owning side to null (unless already changed)
  287. if ($creditHistory->getOrderShop() === $this) {
  288. $creditHistory->setOrderShop(null);
  289. }
  290. }
  291. return $this;
  292. }
  293. public function getVisitor(): ?Visitor
  294. {
  295. return $this->visitor;
  296. }
  297. public function setVisitor(?Visitor $visitor): self
  298. {
  299. $this->visitor = $visitor;
  300. return $this;
  301. }
  302. public function getDeliveryInfos(): ?string
  303. {
  304. return $this->deliveryInfos;
  305. }
  306. public function setDeliveryInfos(?string $deliveryInfos): self
  307. {
  308. $this->deliveryInfos = $deliveryInfos;
  309. return $this;
  310. }
  311. public function getOrderStatus(): ?OrderStatus
  312. {
  313. return $this->orderStatus;
  314. }
  315. public function setOrderStatusProtected(?OrderStatus $orderStatus): self
  316. {
  317. $this->orderStatus = $orderStatus;
  318. return $this;
  319. }
  320. /**
  321. * @return Collection|OrderReductionCart[]
  322. */
  323. public function getOrderReductionCarts(): Collection
  324. {
  325. return $this->orderReductionCarts;
  326. }
  327. public function addOrderReductionCart(OrderReductionCart $orderReductionCart): self
  328. {
  329. if (!$this->orderReductionCarts->contains($orderReductionCart)) {
  330. $this->orderReductionCarts[] = $orderReductionCart;
  331. $orderReductionCart->setOrderShop($this);
  332. }
  333. return $this;
  334. }
  335. public function removeOrderReductionCart(OrderReductionCart $orderReductionCart): self
  336. {
  337. if ($this->orderReductionCarts->contains($orderReductionCart)) {
  338. $this->orderReductionCarts->removeElement($orderReductionCart);
  339. // set the owning side to null (unless already changed)
  340. if ($orderReductionCart->getOrderShop() === $this) {
  341. $orderReductionCart->setOrderShop(null);
  342. }
  343. }
  344. return $this;
  345. }
  346. /**
  347. * @return Collection|OrderReductionCart[]
  348. */
  349. public function getOrderReductionCredits(): Collection
  350. {
  351. return $this->orderReductionCredits;
  352. }
  353. public function addOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self
  354. {
  355. if (!$this->orderReductionCredits->contains($orderReductionCredit)) {
  356. $this->orderReductionCredits[] = $orderReductionCredit;
  357. $orderReductionCredit->setOrderShop($this);
  358. }
  359. return $this;
  360. }
  361. public function removeOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self
  362. {
  363. if ($this->orderReductionCredits->contains($orderReductionCredit)) {
  364. $this->orderReductionCredits->removeElement($orderReductionCredit);
  365. // set the owning side to null (unless already changed)
  366. if ($orderReductionCredit->getOrderShop() === $this) {
  367. $orderReductionCredit->setOrderShop(null);
  368. }
  369. }
  370. return $this;
  371. }
  372. /**
  373. * @return Collection|Document[]
  374. */
  375. public function getDocuments(): Collection
  376. {
  377. return $this->documents;
  378. }
  379. public function addDocument(Document $document): self
  380. {
  381. if (!$this->documents->contains($document)) {
  382. $this->documents[] = $document;
  383. }
  384. return $this;
  385. }
  386. public function removeDocument(Document $document): self
  387. {
  388. if ($this->documents->contains($document)) {
  389. $this->documents->removeElement($document);
  390. }
  391. return $this;
  392. }
  393. }