コード例 #1
0
 public function actionIndex()
 {
     $post = $_POST;
     $plan_id = $post['plan'];
     $plan_data = GoodsPlan::model()->findByPk(intval($plan_id));
     $goods_data = Goods::model()->findByPk(intval($plan_data->goods_id));
     $realname = $post['realname'];
     $mobile = $post['mobile'];
     $order_num = $post['order_num'];
     $username = $post['username'];
     $uid = $post['uid'];
     $order_code = $this->get_order_code();
     $plan_price = $plan_data->plan_price;
     $plan_name = $plan_data->plan_name;
     $goods_id = $plan_data->goods_id;
     $total_price = intval($order_num) * $plan_price;
     $goods_name = $goods_data->goods_name;
     $default_thumb = $goods_data->default_thumb;
     $sales_endtime = $goods_data->sales_endtime;
     $is_login = Yii::app()->session['is_login'];
     $uid = Yii::app()->session['uid'];
     $username = Yii::app()->session['username'];
     if (!isset($is_login) && !isset($uid) && $is_login != 1) {
         $this->redirect($this->createUrl('user/login'));
     }
     $status = 1;
     //已下单未支付
     if (empty($plan_id) || empty($uid) || empty($username) || empty($mobile) || empty($order_num) || empty($total_price)) {
         throw new CHttpException(404, '请求非法!!');
     } else {
         $sql = "insert into orders(uid,order_code,username,goods_id,plan_id,order_num,plan_price,total_price,realname,mobile,goods_name,default_thumb,sales_endtime,plan_name,status) values({$uid},{$order_code},{$username},{$goods_id},{$plan_id},{$order_num},{$plan_price},{$total_price},'" . $realname . "',{$mobile},'" . $goods_name . "','" . $default_thumb . "','" . $sales_endtime . "','" . $plan_name . "',{$status})";
         $connection = Yii::app()->db;
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         if ($rowCount == 1) {
             $order_status = 1;
         } else {
             $order_status = 0;
         }
     }
     $this->_seoTitle = '订购成功';
     //发送订购短信
     $sendurl = "http://116.213.72.20/SMSHttpService/send.aspx?username=tongle&password=tongle123&mobile={$username}&content=【上海同乐旅行社】尊敬的客户{$realname} 您预定的产品订单已经生成 订单号:{$order_code};产品名称:{$goods_name};套餐名称:{$plan_name};购买数量:{$order_num};总价:{$total_price}; 请您及时付款,如有任何疑问欢迎拨打4009208581/021-63357992&Extcode=&senddate=&batchID=";
     //$sendurl =  "http://116.213.72.20/SMSHttpService/send.aspx?username=tongle&password=tongle123&mobile=$username&content=【上海同乐旅行社】您的注册验证码是1234,请在60秒内输入完成注册&Extcode=&senddate=&batchID=";
     @file_get_contents($sendurl);
     $this->render('index', array('order_status' => $order_status, 'order_code' => $order_code, 'goods_name' => $goods_name, 'plan_name' => $plan_name, 'plan_price' => $plan_price, 'order_num' => $order_num, 'total_price' => $total_price));
 }
コード例 #2
0
 public function actionBuy($id)
 {
     $goods = Goods::model()->findByPk(intval($id));
     if (false == $goods) {
         throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
     }
     // seo信息
     $this->_seoTitle = $goods->goods_name;
     $goodsplan = GoodsPlan::model()->findAll('goods_id=:goods_id', array('goods_id' => $id));
     $criteria = new CDbCriteria();
     $criteria->select = '*';
     // only select the 'title' column
     $criteria->condition = 'goods_id=:goods_id';
     $criteria->params = array(':goods_id' => $id);
     $criteria->order = 'plan_price asc';
     $goodsplan = GoodsPlan::model()->findAll($criteria);
     // $params is not needed
     //print_r($goodsplan);
     $this->render('buy', array('goods' => $goods, 'goodsplan' => $goodsplan, 'uid' => $uid, 'username' => $username));
 }
コード例 #3
0
 /**
  * 批量操作
  *
  */
 public function actionBatch()
 {
     if ($this->method() == 'GET') {
         $command = trim($_GET['command']);
         $ids = intval($_GET['id']);
     } elseif ($this->method() == 'POST') {
         $command = trim($_POST['command']);
         $ids = $_POST['id'];
     } else {
         $this->message('errorBack', Yii::t('admin', 'Only POST Or GET'));
     }
     empty($ids) && $this->message('error', Yii::t('admin', 'No Select'));
     switch ($command) {
         case 'delete':
             //删除商品
             foreach ((array) $ids as $id) {
                 $goodsModel = GoodsPlan::model()->findByPk($id);
                 if ($goodsModel) {
                     $goodsModel->delete();
                 }
             }
             break;
         case 'show':
             //商品显示
             foreach ((array) $ids as $id) {
                 $goodsModel = GoodsPlan::model()->findByPk($id);
                 if ($goodsModel) {
                     $goodsModel->status = 'Y';
                     $goodsModel->save();
                 }
             }
             break;
         case 'hidden':
             //商品隐藏
             foreach ((array) $ids as $id) {
                 $goodsModel = GoodsPlan::model()->findByPk($id);
                 if ($goodsModel) {
                     $goodsModel->status = 'N';
                     $goodsModel->save();
                 }
             }
             break;
         case 'commend':
             //商品推荐
             foreach ((array) $ids as $id) {
                 $recom_id = intval($_POST['recom_id']);
                 if ($recom_id) {
                     $goodsModel = GoodsPlan::model()->findByPk($id);
                     if ($goodsModel) {
                         $goodsModel->recommend = 'Y';
                         $goodsModel->save();
                     }
                 } else {
                     $this->message('error', Yii::t('admin', 'RecommendPosition is Required'));
                 }
             }
             break;
         case 'unCommend':
             //商品取消推荐
             foreach ((array) $ids as $id) {
                 $goodsModel = GoodsPlan::model()->findByPk($id);
                 if ($goodsModel) {
                     $goodsModel->commend = 'N';
                     $goodsModel->save();
                 }
             }
             break;
         default:
             throw new CHttpException(404, Yii::t('admin', 'Error Operation'));
             break;
     }
     $this->message('success', Yii::t('admin', 'Batch Operate Success'));
 }
コード例 #4
0
ファイル: index.php プロジェクト: redtreelchao/wander-moon
    ?>
"><?php 
    echo $item['goods_name'];
    ?>
</a>
           <p><img src="<?php 
    echo $this->_stylePath;
    ?>
/images/shalou.png" height="12px;"/>&nbsp;<span><?php 
    echo $item['sales_endtime'];
    ?>
结束</span></p>
        </div>
        <div class="right">
        	<span class="price"><?php 
    echo GoodsPlan::getMinPirce($item['id']);
    ?>
</span>元
        </div>
    </div>
    <div class="desc"><?php 
    echo $item['introduce'];
    ?>
</div>
</div>
<?php 
}
?>

<!-- 底部footer开始 -->
<div id="footer">