選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

451 行
14KB

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