예제 #1
0
 public function print3d()
 {
     $return_array = $this->obj_order->return_array();
     $view = new View('service/print1');
     $view->set('user', $this->_user);
     if ($_POST) {
         include_once WEBROOT . 'application/libraries/recaptchalib.php';
         $privatekey = "6LeEcuASAAAAAAdzMZqxXewlJJhn50HSA4sD9_yG";
         $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["rcf"], $_POST["rrf"]);
         if (!$resp->is_valid) {
             $return_array['msg'] = '验证码错误';
             echo json_encode($return_array);
             return;
         }
         $model_file = $this->obj_session->get('PRINT_3D_MODELSTL');
         if ($model_file == FALSE) {
             $return_array['msg'] = '先上传3D模型文件';
             echo json_encode($return_array);
             return;
         }
         $preview = $this->obj_session->get('PRINT_3D_PREVIEW');
         if ($preview == FALSE) {
             $return_array['msg'] = '先上传预览图';
             echo json_encode($return_array);
             return;
         }
         $name = $this->input->post('name');
         if ($name == FALSE) {
             $return_array['msg'] = '请填写真实姓名!';
             echo json_encode($return_array);
             return;
         }
         $email = $this->input->post('email');
         if ($email == FALSE || !preg_match('/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,3}){1,2})$/', $email)) {
             $return_array['msg'] = '请填写正确的电子邮箱地址!';
             echo json_encode($return_array);
             return;
         }
         $mobile = $this->input->post('mobile');
         if ($mobile == FALSE || !preg_match('/^1[3|4|5|8][0-9]\\d{4,8}$/', $mobile)) {
             $return_array['msg'] = '手机号码格式错误!';
             echo json_encode($return_array);
             return;
         }
         //用户注册
         $r = $this->obj_user_lib->get_user_by_email($email);
         if ($r == FALSE) {
             $reg_data = array('username' => $email, 'email' => $email, 'mobile' => $mobile, 'name' => $name, 'passwd' => $this->obj_user_help->encrypt_passwd($mobile), 'tk' => $this->obj_user_help->create_token($email), 'lastlogin_time' => date('Y-m-d H:i:s'), 'status' => User_Model::STATUS_0);
             //var_dump($reg_data);die();
             $uid = $this->obj_user_lib->add_user($reg_data);
             if ($uid == FALSE) {
                 $return_array['msg'] = '用户信息错误!';
                 echo json_encode($return_array);
                 return;
             }
             $reg_data['id'] = $uid;
             $this->obj_user_help->send_reg_mail($uid, $email, $email);
             $this->_user = $reg_data;
         } else {
             $this->_user = $r;
             if ($this->_user['name'] == FALSE) {
                 $this->obj_user_lib->update_user_name($this->_user['id'], $name);
             }
             if ($this->_user['mobile'] == FALSE) {
                 $this->obj_user_lib->update_user_mobile($this->_user['id'], $mobile);
             }
         }
         $lengh = intval($this->input->post('sizel'));
         $width = intval($this->input->post('sizew'));
         $heigh = intval($this->input->post('sizeh'));
         if ($lengh == FALSE || $lengh < 30) {
             $return_array['msg'] = '最小为30mm!';
             echo json_encode($return_array);
             return;
         }
         if ($width == FALSE || $width < 30) {
             $return_array['msg'] = '最小为30mm!';
             echo json_encode($return_array);
             return;
         }
         if ($heigh == FALSE || $heigh < 30) {
             $return_array['msg'] = '最小为30mm!';
             echo json_encode($return_array);
             return;
         }
         $size = $lengh . '*' . $width . '*' . $heigh;
         $material = $this->input->post('material');
         if (order::get_print_material($material) == FALSE) {
             $return_array['msg'] = '材料数据错误!';
             echo json_encode($return_array);
             return;
         }
         $color = $this->input->post('color');
         if (order::get_print_color($color) == FALSE) {
             $return_array['msg'] = '颜色数据错误!';
             echo json_encode($return_array);
             return;
         }
         $precision = $this->input->post('precision');
         if (order::get_print_precision($precision) == FALSE) {
             $return_array['msg'] = '精度数据错误!';
             echo json_encode($return_array);
             return;
         }
         $quantity = $this->input->post('quantity');
         if ($quantity == false || $quantity < 1) {
             $return_array['msg'] = '请填写数量!';
             echo json_encode($return_array);
             return;
         }
         $message = $this->input->post('message');
         $order_num = $this->obj_order->creat_order_num();
         $order_data = array('order_num' => $order_num, 'uid' => $this->_user['id'], 'name' => $name, 'mobile' => $mobile, 'price' => Order_detail_Model::FRONT_MONEY, 'status' => Order_basic_Model::STATUS_0);
         $order_id = $this->obj_orderbasic->add_order($order_data);
         if ($order_id == FALSE) {
             $return_array['msg'] = '订单数据出错!';
             echo json_encode($return_array);
             return;
         }
         $order_detail_data = array('order_id' => $order_id, 'uid' => $this->_user['id'], 'type' => Order_detail_Model::TYPE_1, 'price' => Order_detail_Model::FRONT_MONEY, 'model' => $model_file['path'], 'model_name' => $model_file['name'], 'preview' => $preview['path'], 'preview_name' => $preview['name'], 'size' => $size, 'material' => $material, 'color' => $color, 'precision' => $precision, 'quantity' => $quantity, 'message' => $message, 'front_money' => Order_detail_Model::FRONT_MONEY, 'status' => Order_basic_Model::STATUS_0);
         $service_id = $this->obj_orderdetail->add_order($order_detail_data);
         if ($service_id == FALSE) {
             $return_array['msg'] = '服务订单数据出错!';
             echo json_encode($return_array);
             return;
         }
         mail::order_create($this->_user['email'], $this->_user['username'], $order_num);
         $userinfo = array('username' => $this->_user['username'], 'email' => $this->_user['email'], 'name' => $name, 'mobile' => $mobile);
         mail::order_create2admin($this->_user, $order_id);
         $this->obj_session->delete('PRINT_3D_PREVIEW', NULL);
         $this->obj_session->delete('PRINT_3D_MODELSTL', NULL);
         $return_array['code'] = 1;
         echo json_encode($return_array);
         return;
     }
     $view->render(TRUE);
 }
예제 #2
0
$color = order::get_print_color($data['color']);
if ($color != '') {
    echo '<img src="' . $color . '" width="30px" height="40px"/>';
}
?>
                                     <?php 
echo $data['color'];
?>
</label>
                                    </td>
                                </tr>
                                <tr>
                                    <th>打印精度:</th>
                                    <td>
                                     <label><?php 
echo order::get_print_precision($data['precision']);
?>
</label>
                                    </td>
                                </tr>
                                <tr>
                                    <th>打印数量:</th>
                                    <td>
                                     <label><?php 
echo $data['quantity'];
?>
</label>
                                    </td>
                                </tr>
                                <tr>
                                    <th>草图:</th>