示例#1
0
 public function actionLv()
 {
     $model = new VipPaymentModel();
     $_priceList = PriceList::returnPriceList();
     foreach ($_priceList as $l => $p) {
         $priceList[$p] = $l;
     }
     for ($i = 1; $i <= 12; $i++) {
         $mouth[$i] = $i . '个月';
     }
     if (isset($_POST['VipPaymentModel'])) {
         $dateTime = time();
         $model->attributes = $_POST['VipPaymentModel'];
         $model->uid = Yii::app()->session['userInfo']['uid'];
         $model->username = Yii::app()->session['userInfo']['username'];
         $model->created_at = $dateTime;
         $model->orderId = $this->_createOrderSns();
         if ($model->validate()) {
             //校验价格
             $price = $model->payCode;
             $count = $model->count;
             $amount = $price * $count;
             if ($amount != $model->amount) {
                 ShowMessage::error('数据有误!');
             }
             $model->payCode = $priceList[$model->payCode];
             $model->save();
             //ShowMessage::success('添加成功!',Yii::app()->createUrl('vip/index'));
         }
     }
     $this->render('lv', array('model' => $model, 'priceList' => $priceList, 'mouth' => $mouth));
 }