当前位置: 首页>>代码示例>>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;未经允许,请勿转载。