當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Coupon::model方法代碼示例

本文整理匯總了PHP中Coupon::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Coupon::model方法的具體用法?PHP Coupon::model怎麽用?PHP Coupon::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Coupon的用法示例。


在下文中一共展示了Coupon::model方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadModel

 public function loadModel($id)
 {
     if (($model = Coupon::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:7,代碼來源:CouponBackendController.php

示例2: deleteOldItems

 public function deleteOldItems($model, $itemsPk)
 {
     $criteria = new CDbCriteria();
     $criteria->addNotInCondition('coupon_id', $itemsPk);
     $criteria->addCondition("listing_id= {$model->primaryKey}");
     Coupon::model()->deleteAll($criteria);
 }
開發者ID:yasirgit,項目名稱:hotmall,代碼行數:7,代碼來源:CouponManager.php

示例3: loadModel

 public function loadModel($id)
 {
     $model = Coupon::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
開發者ID:tierous,項目名稱:yiirisma,代碼行數:8,代碼來源:CouponController.php

示例4: loadModel

 public function loadModel($id)
 {
     $model = Coupon::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('CouponModule.coupon', 'Page not found!'));
     }
     return $model;
 }
開發者ID:yupe,項目名稱:yupe,代碼行數:8,代碼來源:CouponBackendController.php

示例5: registerCoupon

 function registerCoupon($code)
 {
     $coupon = Coupon::model()->findByPk($code);
     if (!$coupon) {
         return false;
     }
     echo "Coupon registered. {$coupon->description}";
     return $coupon->delete();
 }
開發者ID:moohwaan,項目名稱:yii-application-cookbook-2nd-edition-code,代碼行數:9,代碼來源:CouponTest.php

示例6: check

 public function check()
 {
     if (Yii::app()->cart->isEmpty()) {
         $this->clear();
         return;
     }
     $price = Yii::app()->cart->getCost();
     foreach ($this->coupons as $code) {
         /* @var $coupon Coupon */
         $coupon = Coupon::model()->getCouponByCode($code);
         if (!$coupon->getIsAvailable($price)) {
             $this->remove($code);
         }
     }
 }
開發者ID:RonLab1987,項目名稱:43berega,代碼行數:15,代碼來源:CouponManager.php

示例7: actionCoupon

 public function actionCoupon($id = '')
 {
     $id = $this->checkCorrectness($id);
     if ($id != 0) {
         $coupon = Coupon::model()->getFrontendCoupon($id);
     } else {
         $coupon = null;
     }
     if ($coupon == null) {
         $this->render('missing_coupon');
         return null;
     }
     Yii::app()->user->setLastCouponId($id);
     ViewsTrack::addCouponView($id);
     $listing = Listing::model()->getFrontendListing($coupon->listing_id);
     // render normal listing
     $this->render('coupon_detail', array('coupon' => $coupon, 'listing' => $listing, 'listingId' => $listing->listing_id));
 }
開發者ID:yasirgit,項目名稱:hotmall,代碼行數:18,代碼來源:ListingController.php

示例8: actionIndex

 /**
  *
  */
 public function actionIndex()
 {
     $positions = Yii::app()->cart->getPositions();
     $order = new Order(Order::SCENARIO_USER);
     if (Yii::app()->getUser()->isAuthenticated()) {
         $user = Yii::app()->getUser()->getProfile();
         $order->name = $user->getFullName();
         $order->email = $user->email;
         $order->city = $user->location;
     }
     $coupons = [];
     if (Yii::app()->hasModule('coupon')) {
         $couponCodes = Yii::app()->cart->couponManager->coupons;
         foreach ($couponCodes as $code) {
             $coupons[] = Coupon::model()->getCouponByCode($code);
         }
     }
     $deliveryTypes = Delivery::model()->published()->findAll();
     $this->render('index', ['positions' => $positions, 'order' => $order, 'coupons' => $coupons, 'deliveryTypes' => $deliveryTypes]);
 }
開發者ID:alextravin,項目名稱:yupe,代碼行數:23,代碼來源:CartController.php

示例9: actionRestrank

 /**
  * 福袋領取單
  * GET /api/activity/luckybag/rank
  */
 public function actionRestrank()
 {
     $this->checkRestAuth();
     // 活動
     $criteria = new CDbCriteria();
     $criteria->compare('code', '2015ACODEFORGREETINGFROMWEIXIN');
     $criteria->compare('archived', 1);
     $activities = Activity::model()->findAll($criteria);
     if (count($activities) == 0) {
         return $this->sendResponse(400, "no code");
     }
     // 已領的獎品
     $criteria = new CDbCriteria();
     $criteria->compare('activity_id', $activities[0]->id);
     $criteria->compare('archived', 1);
     $criteria->addCondition('open_id IS NOT NULL');
     $criteria->order = 'achieved_time desc';
     $criteria->limit = 100;
     $prizes = Coupon::model()->findAll($criteria);
     $openIds = array();
     foreach ($prizes as $prize) {
         array_push($openIds, $prize->open_id);
     }
     // 獲獎人
     $criteria = new CDbCriteria();
     $criteria->addInCondition('open_id', $openIds);
     $result = Luckybag::model()->findAll($criteria);
     $winners = $this->JSONArrayMapper($result);
     /*
             $idx = 0;
             foreach ($winners as $winner) {
                 foreach ($prizes as $prize) {
                     if ($winner['openId'] == $prize->open_id) {
                         $winners[$idx]['prize'] = $prize->code;
                     }
                 }
                 $idx++;
             }*/
     echo CJSON::encode($winners);
 }
開發者ID:aer123456,項目名稱:yougou,代碼行數:44,代碼來源:LuckybagController.php

示例10: repMails

 public function repMails($email, $id)
 {
     //получаю шаблон письма
     $sms = Mails::model()->findByPk(1);
     if ($sms) {
         //вставляю  тело
         $html = $sms['body'];
         //тема
         $subject = $sms['theme'];
         //нахожу нужный купон
         $coupon = Coupon::model()->findByPk($id);
         //название купона
         $product = $coupon['title'];
         //скидка
         $sale = $coupon['discount'];
         //цен до скидки
         $before = $coupon['discountPrice'] . " рублей";
         if ($before == 0) {
             $before = "Не ограничена";
             $after = "Не ограничена";
         } else {
             //цена после скидки
             $after = round($before - $sale * $before / 100, 2);
             $after .= " рублей";
         }
         //ссылка на купон
         $link = $_SERVER['HTTP_HOST'] . Yii::app()->createUrl("/coupon", array('id' => $coupon['id'], 'title' => $coupon['title']));
         $link = "<a href='http://" . $link . "'>" . $link . "</a>";
         //подставляю в шаблон
         $html = str_replace('[product]', $product, $html);
         $html = str_replace('[before]', $before, $html);
         $html = str_replace('[after]', $after, $html);
         $html = str_replace('[sale]', $sale, $html);
         $html = str_replace('[link]', $link, $html);
         //отправляем письмо
         $this->sendMail($email, $subject, $html);
     }
 }
開發者ID:kirians,項目名稱:sf,代碼行數:38,代碼來源:Vladimir_Yii_ModerationController.php

示例11: saveOrderCoupon

 /**
  * 保存優惠券信息
  */
 protected function saveOrderCoupon($order_id, $couponInfo)
 {
     if (empty($couponInfo)) {
         return false;
     }
     if ($couponInfo['type'] == 'A') {
         return false;
     }
     //A(固定券碼 暫不保存數據)
     $couponInfo = Coupon::model()->findByAttributes(array('coupon_sn' => $couponInfo['coupon_sn']));
     if (empty($couponInfo)) {
         throw new Exception("優惠券不存在!", 1);
     }
     $couponInfo->order_id = $order_id;
     $couponInfo->use_time = time();
     $flag = $couponInfo->save();
     if (empty($flag)) {
         throw new Exception("優惠券保存失敗!", 1);
     }
     return true;
 }
開發者ID:conghua1013,項目名稱:yii,代碼行數:24,代碼來源:Cart.php

示例12: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     Yii::app()->clientScript->registerPackage('discount-edit');
     $id = null;
     if (isset($_GET['id'])) {
         $id = (int) $_GET['id'];
     } elseif (isset($_POST['Discount']['id'])) {
         $id = (int) $_POST['Discount']['id'];
     }
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $coupons = $model->coupons;
     if (isset($_POST['Discount'])) {
         if (!isset($_POST['Coupon'])) {
             $model->addError('status', Yii::t('errors', 'В предложении должен быть хотябы один купон'));
         } else {
             $data = $_POST['Coupon'];
             $coupons = array();
             foreach ($data as $c) {
                 $coupon = null;
                 if (isset($c['id']) && $c['id'] > 0) {
                     $coupon = Coupon::model()->findByPk($c['id']);
                     if (isset($c['delete'])) {
                         $coupon->delete();
                     }
                 }
                 if (!isset($c['delete'])) {
                     if ($coupon === null) {
                         $coupon = new Coupon();
                     }
                     $coupon->attributes = $c;
                     $coupons[] = $coupon;
                 }
             }
         }
         $model->attributes = $_POST['Discount'];
         if (!$model->hasErrors() && $model->save()) {
             $fail = false;
             foreach ($coupons as $coupon) {
                 $coupon->discount_id = $model->id;
                 if (!$coupon->save()) {
                     $fail = true;
                 }
             }
             if (!$fail) {
                 if (isset($_POST['Cats'])) {
                     $cats = array_map('intval', explode(',', $_POST['Cats']));
                     //Normalize
                     $dicats = DiscountCategory::model()->findAllByAttributes(array('discount_id' => $model->id));
                     foreach ($dicats as $i => $d) {
                         if (FALSE !== ($k = array_search($d->category_id, $cats))) {
                             unset($cats[$k]);
                             unset($dicats[$i]);
                         } else {
                             $d->delete();
                         }
                     }
                     if (!empty($cats)) {
                         $cats = Category::model()->findAllByAttributes(array('id' => $cats));
                         foreach ($cats as $c) {
                             $DC = new DiscountCategory();
                             $DC->discount_id = $model->id;
                             $DC->category_id = $c->id;
                             if (!$DC->save()) {
                                 echo CHtml::errorSummary($DC);
                             }
                         }
                     }
                 }
                 if (isset($_POST['Region'])) {
                     $cats = array_map('intval', explode(',', $_POST['Region']));
                     //Normalize
                     $dicats = DiscountRange::model()->findAllByAttributes(array('discount_id' => $model->id));
                     foreach ($dicats as $i => $d) {
                         if (FALSE !== ($k = array_search($d->category_id, $cats))) {
                             unset($cats[$k]);
                             unset($dicats[$i]);
                         } else {
                             $d->delete();
                         }
                     }
                     if (!empty($cats)) {
                         $cats = City::model()->findAllByAttributes(array('id' => $cats));
                         foreach ($cats as $c) {
                             $DC = new DiscountRange();
                             $DC->discount_id = $model->id;
                             $DC->city_id = $c->id;
                             if (!$DC->save()) {
                                 echo CHtml::errorSummary($DC);
                             }
                         }
                     }
                 }
                 $this->redirect('/business/discount');
             }
//.........這裏部分代碼省略.........
開發者ID:BGCX067,項目名稱:facecom-svn-to-git,代碼行數:101,代碼來源:DiscountController.php

示例13: isActiveCouponsExists

 public function isActiveCouponsExists()
 {
     return Coupon::model()->active()->count() > 0 ? true : false;
 }
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:4,代碼來源:Coupon.php

示例14: array

                <th>наименование программы</th>
                <th width="100">Стоимость</th>
            </tr>
            </thead>

            <tfoot>
            <tr>
                <td colspan="2" class="cart-table__td-promo">
                    <div class="cart-table__promo" 
                         data-add-url="<?php 
echo Yii::app()->createUrl("/subscription/order/addCoupon", array('subscriptionId' => $subscription->id));
?>
">
                        
                        <?php 
if (Coupon::model()->isActiveCouponsExists()) {
    ?>
                        <span class="form-control-input form-control-input_type_2">
                            <input id="coupon" placeholder="Введите промо-код (если есть)" type="text" value="<?php 
    if (!empty($subscription->coupon)) {
        echo $subscription->coupon->code;
    }
    ?>
" class="coupon" maxlength="10" />
                        </span>
                        <button class="btn_ok" id="coupon-apply"></button>
                        <i class="icn icn_checkbox"></i>  
                        <div class="promo-error"></div>
                        <?php 
}
?>
開發者ID:kuzmina-mariya,項目名稱:happy-end,代碼行數:31,代碼來源:cart_good.php

示例15: getValidCoupons

 /**
  * Фильтрует переданные коды купонов и возвращает объекты купонов
  * @param $codes - массив кодов купонов
  * @return Coupon[] - массив объектов-купонов
  */
 public function getValidCoupons($codes)
 {
     if ($this->_validCoupons !== null) {
         return $this->_validCoupons;
     }
     $productsTotalPrice = $this->getProductsCost();
     $validCoupons = [];
     /* @var $coupon Coupon */
     /* проверим купоны на валидность */
     foreach ($codes as $code) {
         $coupon = Coupon::model()->getCouponByCode($code);
         if (null !== $coupon && $coupon->getIsAvailable($productsTotalPrice)) {
             $validCoupons[] = $coupon;
         }
     }
     return $validCoupons;
 }
開發者ID:syrexby,項目名稱:domovoishop.by,代碼行數:22,代碼來源:Order.php


注:本文中的Coupon::model方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。