Exemplo n.º 1
0
 public function order()
 {
     if (IS_POST) {
         if (!check_verify(I('verify'))) {
             $this->error('验证码输入错误');
         }
         $Order = D('Order');
         $order_id = 'NS' . date('YmdHis') . mt_rand(1000, 9999);
         $uid = is_login();
         $site_id = I('site_id', 0, 'intval');
         if ($uid) {
             $result = $Order->inputVisa($order_id, $uid, $site_id);
             $mobile = get_userinfo($uid, 3);
         } else {
             $mobile = I('mobile', '', 'trim');
             /* 调用注册接口注册用户 */
             $User = new UserApi();
             $res = $User->checkMobile($mobile);
             if ($res == 1) {
                 $password = mt_rand(100000, 999999);
                 $uid = $User->register('', $password, '', $mobile);
                 if (0 < $uid) {
                     //注册成功
                     send_sms($mobile, array('mobile' => $mobile, 'password' => $password), 'password');
                     $result = $Order->inputVisa($order_id, $uid, $site_id);
                 }
             } else {
                 $user_info = $User->getinfo($mobile, 3);
                 $result = $Order->inputVisa($order_id, $user_info[0], $site_id);
             }
         }
         if ($result) {
             send_sms($mobile, array('orderid' => $order_id), 'onOrder');
             $this->redirect('checkOrder', array('order_id' => $order_id));
         } else {
             $this->error('订单提交失败');
         }
     } else {
         $visa_id = I('visa_id', 0, 'intval');
         if (empty($visa_id)) {
             $this->error('无效参数');
         }
         // 线路信息
         $map = array('visa_id' => $visa_id);
         $visa_info = M('Visa')->where($map)->find();
         if (empty($visa_info)) {
             $this->error('不存在');
         }
         $this->assign('visa_info', $visa_info);
         $this->display();
     }
 }