/** *相册/视频管理 * 显示店铺的视频和照片 *@author 刘浩 <*****@*****.**> *@time 2015-07-07 **/ public function index() { if (session('home_shop_id')) { if (IS_POST) { //接收用户传值 $title = I('post.title'); $img_path = I('post.img_path'); //验证用户名不能大于20个字 if (strlen($img_path) > 20) { $this->error('字数不能大于20!'); } //验证标题不能为空 /*if(empty($title)){ $this->error('标题不能为空!'); }*/ if (empty($img_path)) { $this->error('请上传图片或视频!'); } //将视频和图片分类 //$map["id"]=$img_path; if (is_array($img_path)) { $map = array("id" => array("in", implode(",", $img_path))); } $result = get_result("file", $map); if (empty($result)) { $this->error('图片或视频上传失败!'); } $img_path = array(); foreach ($result as $key => $row) { $ext = array("flv", "mp4", "f4v"); if (in_array($row["ext"], $ext)) { $type = 4; } else { $type = 1; } //生成视频缩略图 if ($type == 4) { $makeImage = "Uploads/shop/VideoAlbum/" . uniqid() . ".jpg"; //视频路径 $input = $_SERVER["DOCUMENT_ROOT"] . __ROOT__ . "/" . $row["save_path"]; //视频缩略图路径 $output = $_SERVER["DOCUMENT_ROOT"] . __ROOT__ . "/" . $makeImage; makeVideoImage($input, $output); } /*$_POST = array( 'title'=>$title, 'pid'=>session('home_shop_id'), 'type'=>$type, 'cover'=>$makeImage, );*/ $data_array[$row["id"]] = array('title' => $_POST["filename_" . $row["id"]], 'pid' => session('home_shop_id'), 'type' => $type, 'cover' => $makeImage); $img_path[] = $row["id"]; //$result = update_data($this->table,$rules); } $result = multi_file_uploads($img_path, 'Uploads/shop/VideoAlbum', $this->table, $data_array, 'img_path'); if ($result['success'] == count($img_path)) { //multi_file_upload($img_path,'Uploads/shop/VideoAlbum',$this->table,'id',$result,'img_path'); $this->success('提交成功!!', U('User/VideoAlbum/index')); } else { $this->error('提交失败!!', U('User/VideoAlbum/index')); } } else { $shop_id = session('home_shop_id'); $map['pid'] = $shop_id; $map['type'] = array('in', array(1, 4)); //表示表中的视频和店铺图片 //将店铺的图片和视频缩略图显示出来 $shop_resource = $this->page($this->table, $map); $data['shop_resource'] = $shop_resource; $data['p'] = $_GET['p']; $this->assign($data); $this->display(); } } else { $this->error('您的店铺尚未开通!!', U('Home/Index/index')); } }
/** * 下订单 * 判断是否是POST提交 * 如果是POST提交则进行下单操作 * 否则 提示错误 * * * @author 李东 * @date 2015-07-09 */ public function add_order() { if (IS_POST) { $posts = I('post.'); // print_r($posts);exit; /* 获取当前登录的用户的ID */ $member_id = session('home_member_id'); $rules = array(array('qty', '/^[1-9]\\d*(\\.\\d+)?$/', '数量必须大于1', 'regex')); // 默认情况下用正则进行验证 if (!$posts['agree']) { $tips_msg = array('status' => '0', 'msg' => '请同意保密协议'); goto export; /* 直接跳转到输出位置 */ } /* 如果需要发票,判断发票信息是否填写 */ if ($posts['need_invoice']) { if (empty(trim($posts['invoice']))) { $tips_msg = array('status' => '0', 'msg' => '请填写发票抬头'); goto export; } if (intval($posts['address_id']) < 1) { $tips_msg = array('status' => '0', 'msg' => '请选择发票寄送地址'); goto export; } } $product_info = get_info($this->product_table, array('id' => $posts['product_id'])); $shop_id = $product_info['shop_id']; /* 获取店铺ID */ $product_type = $product_info['type']; /* 获取产品类型 */ $address_path = ''; $area_detail = ''; $product_title = $product_info['title']; /*获取产品title*/ $product_description = array(); if (empty($posts['expected_start_time']) || empty($posts['expected_end_time'])) { $tips_msg = array('status' => '0', 'msg' => '请填写完整预约服务时间'); goto export; } if ($posts['expected_start_time'] >= $posts['expected_end_time']) { $tips_msg = array('status' => '0', 'msg' => '结束时间必须大于开始时间'); goto export; } if ($product_type == 37) { /* 判断是否填写了详细信息 */ if (empty(trim($posts['area_detail']))) { $tips_msg = array('status' => '0', 'msg' => '请填写详细地址'); goto export; } elseif (empty($posts['addpath'])) { $tips_msg = array('status' => '0', 'msg' => '请选择服务地址'); goto export; } else { /* 选择服务地址的path */ $address_path = $posts['addpath'] . $posts['area']; $area_detail = $posts['area_detail']; } } else { if (!$posts['language_sbt']) { $tips_msg = array('status' => '0', 'msg' => '请选择翻译模式'); goto export; } /* 判断文件用途 */ if ($posts['ability_id'] == 'other') { $description = $posts['ability_other']; $product_description['ability_other'] = $description; } elseif (is_numeric($posts['ability_id'])) { $product_description['ability_id'] = $posts['ability_id']; } else { $tips_msg = array('status' => '0', 'msg' => '请选择服务领域或文件领域'); goto export; } } /* 判断专业领域 */ if ($posts['industry_id'] == 'other') { $description = $posts['industry_other']; $product_description['industry_other'] = $description; } elseif (is_numeric($posts['industry_id'])) { $product_description['industry_id'] = $posts['industry_id']; } else { $tips_msg = array('status' => '0', 'msg' => '请选择服务领域或文件领域'); goto export; } $expired_time = date('Y-m-d H-i-s', time() + intval(C('TIME_LEFT')) * 24 * 3600); /* 计算失效时间 */ /* 判断音频翻译是否填网址或者上传文件 */ if ($product_type != 37) { if (empty($posts['save_path']) && !$posts['files_url']) { $tips_msg = array('status' => '0', 'msg' => '请上传要翻译的文件'); goto export; } } /* 计算数量(千字/小时) */ $qty = floatval($posts['qty']); $total_price = $qty * $product_info['price']; /* 计算总价 */ $order_num = get_order_num(intval($shop_id), intval($member_id)); // dump($address_path);die; $_POST = array('title' => $product_title, 'order_num' => $order_num, 'member_id' => $member_id, 'shop_id' => $posts['shop_id'], 'product_id' => $posts['product_id'], 'qty' => $qty, 'product_type' => $product_type, 'total_price' => $total_price, 'status' => '1', 'expired_time' => $expired_time, 'description' => $posts['description'], 'product_description' => json_encode($product_description), 'address_id' => $posts['address_id'], 'requirements' => $posts['language_sbt'], 'is_need_invoice' => $posts['need_invoice'], 'step' => 1, 'address_path' => $address_path, 'area_detail' => $area_detail, 'expected_start_time' => $posts['expected_start_time'], 'expected_end_time' => $posts['expected_end_time'], 'invoice' => $posts['invoice'], 'address_id' => $posts['address_id'], 'files_url' => $posts['files_url'], 'is_confirm_price' => '1'); /* 开启事务 */ $Model = M(); $Model->startTrans(); $result1 = update_data($this->table, $rules); if (is_numeric($result1)) { $_POST = array('order_id' => $result1, 'order_status' => 1, 'description' => '下单成功'); $result2 = update_data($this->history_table); if (!empty($posts['save_path'])) { /* 判断是否提交了文件 */ //multi_file_upload($posts['save_path'],'Uploads/UserFiles/'.$member_id,'files','order_id',$result1,'save_path'); $data_array = array(); foreach ($posts['save_path'] as $val) { if (!empty(intval($val))) { $data_array[$val] = array("title" => $posts["filename_" . $val], "order_id" => $result1, "member_id" => $member_id, "shop_id" => $posts['shop_id'], "description" => $posts['description']); } } multi_file_uploads($posts['save_path'], 'Uploads/UserFiles/' . $member_id, 'files', $data_array, 'save_path'); } /*发送订单消息*/ $result3 = order_msg_send($member_id, $result1, $order_num, $shop_id); if (is_numeric($result1) && is_numeric($result2) && is_numeric($result3)) { /*提交事务*/ $Model->commit(); /*@刘巧 给订单用户发送短信 */ $shop_info = get_info('shop', array('shop_id' => $posts['shop_id']), array('title')); $content = C('ORDSUCCESS'); $content2 = C('MESSAGE_SHOP'); $content = str_replace("(0)", $total_price, $content); //替换金额; $content = str_replace("(1)", $shop_info['title'], $content); //替换商家电铺字符串 $content2 = str_replace("(0)", $total_price, $content2); //替换订单用户字符串 $content2 = str_replace("(2)", session('username'), $content2); //替换订单用户字符串 $account = session('home_member_tel'); $stauts1 = send_code($content, $account); /*@liuqiao 给商家用户发送短信*/ $stauts2 = send_code($content1, $account1); $tips_msg = array('status' => '1', 'msg' => '下单成功', 'order_id' => $result1); } else { /*事务回滚*/ $Model->rollback(); $tips_msg = array('status' => '0', 'msg' => '下单失败'); } } else { $tips_msg = array('status' => '0', 'msg' => $result1); } } else { $tips_msg = array('status' => '0', 'msg' => '错误请求'); } export: /*判断需要展示的web提示信息*/ if ($tips_msg['status']) { $this->success($tips_msg['msg'], U('/Home/Buy/confirm_quote', array('order_id' => $tips_msg['order_id']))); } else { $this->error($tips_msg['msg']); } }
/** * 商家上传完成翻译的文件 * * @author 李东 * @date 2015-07-14 */ public function upload_completeFiles() { if (IS_POST) { $posts = I('post.'); $order_id = $posts['order_id']; $member_id = session('home_member_id'); if (!empty($posts['save_path'])) { $map['id'] = $order_id; $order_info = get_info($this->table, $map); if (!$order_info) { $tips_msg = array('status' => '0', 'msg' => '订单不存在'); goto export; } /*开启事务*/ $Model = M(); $Model->startTrans(); $_POST = array('id' => $order_id, 'step' => 4, 'status' => 6); /*将订单更新为翻译完成状态*/ $res = update_data($this->table); /*将订单状态记录添加到订单历史记录表中*/ $_POST = array('order_id' => $order_id, 'order_status' => '6', 'description' => '商家提交翻译完成文件'); $res2 = update_data($this->history_table); if (is_numeric($res) && is_numeric($res2)) { /*事务提交*/ $Model->commit(); /* 判断是否提交了文件 */ $data_array = array(); foreach ($posts['save_path'] as $val) { if (!empty(intval($val))) { $data_array[$val] = array("title" => $posts["filename_" . $val], "order_id" => $order_id); } } multi_file_uploads($posts['save_path'], 'Uploads/UserFiles/' . $member_id, 'files_complete', $data_array, 'save_path'); //multi_file_upload($posts['save_path'],'Uploads/UserFiles/'.$member_id,'files_complete','order_id',$order_id,'save_path'); $tips_msg = array('status' => '1', 'msg' => '上传成功'); } else { /*事务回滚*/ $Model->rollback(); $tips_msg = array('status' => '0', 'msg' => '上传失败'); } } else { $tips_msg = array('status' => '0', 'msg' => '请先上传文件'); } } else { $tips_msg = array('status' => '0', 'msg' => '请求错误'); } export: if ($tips_msg['status'] == 1) { $this->success($tips_msg['msg']); } else { $this->error($tips_msg['msg']); } }