Пример #1
0
 static function _createBirthdayCoupon($controller, $member, $couponConf)
 {
     $coupon = new Coupon();
     $coupon->setCouponType('product');
     $coupon->setDiscountPercentage($couponConf['discount_percentage']);
     $coupon->setIsAllProducts(TRUE);
     $startDate = Helper_Date::formatSqlDatetime(strtotime(date('F Y', $controller->now)));
     $endDate = Helper_Date::formatSqlDatetime(strtotime(date('F Y', $controller->now) . ' +1 month'));
     $coupon->setStartDate($startDate);
     $coupon->setExpiryDate($endDate);
     $coupon->setNumOfUsage(1);
     $curYear = date('Y', $controller->now);
     $couponCode = 'BIRTHDAY-' . $member->getEmail() . "-{$curYear}";
     $coupon->setCouponCode($couponCode);
     $name = $member->getFirstName();
     $nyears = $curYear - date('Y', strtotime($member->getDateOfBirth()));
     $th = Helper_Math::getTh($nyears);
     $coupon->setTitle("{$name}'s {$nyears}{$th} Birthday");
     return $coupon;
 }