public static function getPriceUseCoupon($price = 0, $couponId = 0) { $doctrine = self::$servicelocator->get('doctrine'); $couponModel = new couponModel($doctrine); $couponDetail = $couponModel->findOneBy(array('id' => $couponId)); $newPrice = self::roundCost($price); if (!empty($couponDetail)) { if ($couponDetail->getType() == 0) { $newPrice = self::roundCost($price - $couponDetail->getValue()); } elseif ($couponDetail->getType() == 1) { $newPrice = self::roundCost($price - $price * $couponDetail->getValue() / 100); } } elseif ($couponId == -1) { $newPrice = self::roundCost($price); } return $newPrice; }
static function deleteExpireCoupon() { $doctrine = self::$servicelocator->get('doctrine'); $couponModel = new couponModel($doctrine); $array = $couponModel->delExpireCoupon(); foreach ($array as $coupon) { $coupon->setIsDelete(1); $couponModel->edit($coupon); } }