public function order()
 {
     if (IS_POST) {
         $Order = D('Order');
         $order_id = 'NS' . date('YmdHis') . mt_rand(1000, 9999);
         $uid = is_login();
         if ($uid) {
             $result = $Order->input($order_id, $uid, 1);
         } 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, '您的密码:' . $password);
                     $result = $Order->input($order_id, $uid, 1);
                 }
             } else {
                 $user_info = $User->getinfo($mobile, 3);
                 $result = $Order->input($order_id, $user_info[0], 1);
             }
         }
         if ($result) {
             $this->redirect('checkOrder', array('order_id' => $order_id));
         } else {
             $this->error('订单提交失败');
         }
     } else {
         $line_id = I('line_id', 0, 'intval');
         $tc_id = I('type_id', 0, 'intval');
         $date = I('date', 0, 'strtotime');
         if (empty($line_id) || empty($tc_id) || empty($date)) {
             $this->error('无效参数');
         }
         // 线路信息
         $line_info = M('Line')->find($line_id);
         // 套餐信息
         $map = array('line_id' => $line_id, 'end_time' => array('egt', strtotime('+' . $line_info['earlier_date'] . 'day')));
         $line_tc = M('LineTc')->where($map)->select();
         if (empty($line_tc)) {
             $this->error('没有报价方案');
         }
         $tc_info = array();
         foreach ($line_tc as $key => $value) {
             if ($value['tc_id'] == $tc_id) {
                 $tc_info = $value;
                 break;
             }
         }
         $ext_time = strtotime('+' . $line_info['earlier_date'] . 'day');
         $tc_str = explode(',', $tc_info['date_price_data']);
         foreach ($tc_str as $value) {
             list($k, $val) = explode('|', $value);
             $k = strtotime($k);
             if ($k <= $ext_time) {
                 continue;
             }
             if ($k == $date) {
                 $tc_info['price_info'] = explode('-', $val);
                 $tc_info['price_info'][] = date('Y-m-d', $k);
                 break;
             }
         }
         if (empty($tc_info['price_info'])) {
             $this->error('没有价格');
         }
         $this->assign('line_info', $line_info);
         $this->assign('line_tc', $line_tc);
         $this->assign('tc_info', $tc_info);
         $this->display();
     }
 }