/** * 取得官網顯示價格 * * 2015-03-03 * 1. 滿額贈模式 * -> 累計 * -> 不累計(單次) * -> 商品獨自計算 * -> 滿額贈不可和折扣並用 * * ======== flow ========= * * 如果不允許網路顯示,直接返回 null * * 如果網路售價合法[大於等於 100,且小於原始售價] * 返回網路售價 * * 若否 * 存在活動且活動折扣 < 1 * 返回原始售價 * 活動折扣金額 * 若否 * 返回 null * * ======= End Flow ======= * * @return integer | boolean */ public function getPromotionPrice($price = null) { if (!$this->isAllowWeb) { return null; } if ($this->productTl && $this->productTl->getPrice() >= 100 && $this->productTl->isValid()) { return $this->productTl->getPrice(); } // 如果本商品屬於促銷活動,且該促銷活動有效 if ($this->promotion && $this->promotion->isValid()) { $displayPrice = $this->webPrice && $this->webPrice >= 100 ? $this->webPrice : $this->price; // 根據贈送金額是否大於0判斷是否為滿額贈活動 if ($this->promotion->getGift() > 0) { // 售價若大於滿額贈門檻 if ($displayPrice >= $this->promotion->getThread()) { return $this->promotion->getIsStack() ? $displayPrice - $this->promotion->getGift() * floor($displayPrice / $this->promotion->getThread()) : $displayPrice - $this->promotion->getGift(); } } if ($this->promotion->getDiscount() < 1) { return $displayPrice * $this->promotion->getDiscount(); } } if ($this->webPrice && $this->webPrice >= 100) { return $this->webPrice; } if ($price) { return $this->price; } }