/** * 店铺评论添加 * 1.验证用户评论信息是否都填写完整,不完整给出提示, * 2.验证用户评论的订单是否处于可评论状态,不可评论给出提示, * 3.验证用户是否已经评论过,已经评论过给出提示, * * 开启事务 * 4.将评论信息以及计算出的综合评分记录到评论表 * 5.点星级信息以及评价总数更新到店铺信息表 * 6.将订单评论状态改为已评论 * 7.将订单历史记录表数据更新 * 4、5、6、7都成功,提交事务,否则回滚事务 * */ public function comment() { if (IS_POST) { $posts = I('post.'); $product_id = $posts['product_id']; $order_id = $posts['order_id']; $member_id = session('home_member_id'); $type = $posts['type']; if (!in_array(intval($type), array(1, 2, 3))) { $tips_msg = array('status' => '0', 'msg' => '请选择给该店铺好/中/差评'); goto export; } if (!$posts['speed_star_num']) { $tips_msg = array('status' => '0', 'msg' => '请为本次服务速度打分'); goto export; } if (!$posts['quality_star_num']) { $tips_msg = array('status' => '0', 'msg' => '请为本次服务质量打分'); goto export; } if (!$posts['serve_star_num']) { $tips_msg = array('status' => '0', 'msg' => '请为本次服务打分'); goto export; } if (!$posts['content']) { $tips_msg = array('status' => '0', 'msg' => '请填写评价内容'); goto export; } $map['id'] = $order_id; $map['status'] = 3; $order_info = get_info($this->table, $map); if (!$order_info) { /*判断订单是否是存在*/ $tips_msg = array('status' => '0', 'msg' => '订单不存在或不能评论', 'url' => U('index')); goto export; } if ($member_id != $order_info['member_id']) { /*判断用户评论的是否是自己的订单*/ $tips_msg = array('status' => '0', 'msg' => '只能评论自己的订单', 'url' => U('index')); goto export; } if ($order_info['is_comment'] > 0) { /*判断是否已经评论过*/ $tips_msg = array('status' => '0', 'msg' => '订单已经评论过', 'url' => U('index')); goto export; } /*计算单条评价综合评分*/ $star_num = round(($posts['speed_star_num'] + $posts['quality_star_num'] + $posts['serve_star_num']) / 3, 1); /*开启事务*/ $Model = M(); $Model->startTrans(); $posts['content'] = get_word_search($posts['content']); $_POST = array('order_id' => $order_id, 'product_id' => $order_info['product_id'], 'shop_id' => $order_info['shop_id'], 'content' => $posts['content'], 'member_id' => $member_id, 'type' => $type, 'speed_star_num' => $posts['speed_star_num'], 'quality_star_num' => $posts['quality_star_num'], 'serve_star_num' => $posts['serve_star_num'], 'star_num' => $star_num); $res = update_data($this->comment); /*店铺表评论数增加1,统计平均星级并更新*/ $map = null; $map['id'] = $order_info['shop_id']; $shop_info = get_info($this->shop_table, $map); $comment_num = $shop_info['comment_num'] + 1; /*计算平均速度星级*/ $speed_star_num = ($shop_info['speed_star_num'] * $shop_info['comment_num'] + $posts['speed_star_num']) / $comment_num; /*计算平均质量星级*/ $quality_star_num = ($shop_info['quality_star_num'] * $shop_info['comment_num'] + $posts['quality_star_num']) / $comment_num; /*计算平均服务星级*/ $serve_star_num = ($shop_info['serve_star_num'] * $shop_info['comment_num'] + $posts['serve_star_num']) / $comment_num; /*计算平均综合星级*/ $new_star_num = round(($shop_info['star_num'] * $shop_info['comment_num'] + $star_num) / $comment_num, 1); $_POST = array('id' => $order_info['shop_id'], 'speed_star_num' => $speed_star_num, 'quality_star_num' => $quality_star_num, 'serve_star_num' => $serve_star_num, 'star_num' => $new_star_num, 'comment_num' => $comment_num); $res2 = update_data($this->shop_table); /*将订单评论状态改为已评论状态*/ $_POST = array('id' => $order_id, 'is_comment' => 1); $res3 = update_data($this->table); /*将订单状态信息跟新到历史记录表中*/ $_POST = array('order_id' => $order_id, 'order_status' => '7', 'description' => '评价订单成功'); $res4 = update_data($this->history_table); if (is_numeric($res) && is_numeric($res2) && is_numeric($res3) && is_numeric($res4)) { /*都执行成功提交事务*/ $Model->commit(); if (!empty($posts['save_path'])) { /*如果上传了图片则将图片更新到评论图片信息表中*/ multi_file_upload($posts['save_path'], 'Uploads/Orders/comment', $this->comment_image, 'comment_id', $res, 'save_path'); } $cache_name = 'shop_comment_count_' . $order_info['shop_id']; F($cache_name, null); $tips_msg = array('status' => '1', 'msg' => '评论添加成功', 'url' => U('index')); } else { /*其中之一执行失败则回滚事务*/ $Model->rollback(); $tips_msg = array('status' => '0', 'msg' => '评论添加失败', 'url' => U('index')); } export: if ($tips_msg['status'] == 1) { $this->success($tips_msg['msg'], $tips_msg['url']); } else { $this->error($tips_msg['msg'], $tips_msg['url']); } } else { $gets = I('get.'); $order_id = $gets['order_id']; $map['id'] = $order_id; $map['status'] = 3; $order_info = get_info($this->table, $map); if ($order_info['is_comment'] > 0) { /*判断是否已经评论过*/ $tips_msg = array('status' => '0', 'msg' => '订单已经评论过', 'url' => U('index')); $status = true; } $coment_count = get_shops_comment_count($order_info['shop_id']); if ($status) { $this->error($tips_msg['msg'], $tips_msg['url']); } $data['order_id'] = $order_id; /*@liuqiao 改*/ if (I('get.type')) { $map = array('type' => I('get.type')); } else { $map = array('type' => array(in, array(1, 2, 3))); } $comments = $this->get_shop_comments(); //dump($comments); $this->assign($comments); //$data['goods_results']=get_result('comment',$map);//查出该产品的所有评价 $data['coment_count'] = $coment_count; $data['type'] = I('get.type'); $this->assign($data); $this->display(); } }
/** *店铺管理 * 个人译者和翻译公司的店铺管理有所不同,需要做一定的判断处理 *流程分析 * 1、店铺的申请 * 按照用户登录的类型店铺的申请分为个人译者店铺的申请和翻译公司店铺的申请 * 个人译者的店铺申请所上传的资料是身份证、学历证书、资质证书 * 公司翻译的店铺申请所上传的资料是营业执照、税务登记、资质证书 * 2、店铺的审核 * 店铺上传资料之后就会由后台审核,审核的过程中商铺可以修改上传的资质 * 3、店铺申请成功 * 店铺申请成功之后店铺的资料只能修改店铺介绍 *@author 刘浩 <qq:372980503> *@time 2015-07-20 **/ public function index() { if (IS_POST) { //不考虑app端的 $posts = I("post."); //$type = session('type'); //$shop_id = session('home_shop_id'); //重新获取店铺信息 $member_id = session("home_member_id"); $info = get_info(D('ShopMemberView'), array("member.id" => $member_id)); $type = $info["type"]; $shop_id = $info["shop_id"]; if ($type == 3 or $type == 2) { $_POST['id'] = $shop_id; if ($type == 3) { $_POST['type'] = 2; //翻译公司 $title_msg = "公司名称不能为空"; $content_msg = "公司介绍不能为空!"; $license_msg = "营业执照正面不能为空!"; $license_msg_1 = "营业执照反面不能为空!"; $tax_msg = "税务登记证不能为空!"; } else { if ($type == 2) { $_POST['type'] = 1; //个人译者 $title_msg = "店铺名称不能为空"; $content_msg = "店铺介绍不能为空!"; $license_msg = "身份证正面不能为空!"; $license_msg_1 = "身份证反面不能为空!"; $tax_msg = "学历证书不能为空!"; } } if (empty($shop_id)) { $_POST["member_id"] = session("home_member_id"); } $_POST['status'] = 0; //表示正在审核 $_POST['operate_type1'] = $_POST['operate_type']; $_POST['operate_type'] = json_encode($_POST['operate_type']); $_POST['translate_type'] = json_encode($_POST['servece_type']); $_POST['description_now'] = htmlspecialchars($_POST['content']); //判断店铺名称是否重名 if (!empty($_POST['title'])) { if ($shop_id) { $map = array("title" => array("eq", $_POST['title']), "id" => array("neq", $shop_id)); } else { $map = array("title" => array("eq", $_POST['title'])); } $match_result = get_info($this->table, $map); if ($match_result) { $this->error('店铺名称已经被占用,请重新取名!!'); } } //判断店铺是否已审核通过 //$info = get_info($this->table,array("id"=>$shop_id)); if ($info['shop_status'] == 1) { $this->error('您的店铺已经审核通过,不可再次修改!'); } else { if ($info['shop_status'] == 2) { $this->error('您的店铺已被冻结,无法进行修改!'); } } //验证资质证书 if (empty($_POST["image1"]) and empty($_POST["image"])) { $_POST["images"] = ""; } else { $_POST["images"] = 1; } //验证信息的正确性 $rules = array(array('title', 'require', $title_msg, 1), array('operate_type1', 'checkArray', '业务范围不能为空', 1, 'function'), array('servece_type', 'checkArray', '服务类别不能为空', 1, 'function'), array('translate_num', 'require', '日翻译量不能为空', 1), array('translate_year', 'require', '翻译年限不能为空!', 1), array('translate_year', 'number', '翻译年限必须为数字!'), array('shop_license', 'require', $license_msg, 1), array('shop_license_1', 'require', $license_msg_1, 1), array('shop_tax', 'require', $tax_msg, 1), array('images', 'require', '翻译资质证书不能为空', 1), array('content', 'require', $content_msg)); /*@刘巧 判断用户店铺名是否符合规范*/ $_POST['title'] = get_word_search($_POST['title']); //组织上传信息 /* unset($_POST); $_POST = array( 'id'=>$shop_id, 'title'=>$parameters['title'], 'type'=>$type, 'short_description'=>$parameters['content'], 'status'=>3, 'operate_type'=>json_encode($parameters['operate_type']), 'translate_type'=>json_encode($parameters['servece_type']), 'translate_year'=>$parameters['translate_year'], 'traslate_num'=>$parameters['translate_num'], ); */ $result = update_data($this->table, $rules); if (is_numeric($result)) { //将店铺的营业执照存入对应的文件夹,对应的字段 if (is_numeric($posts['shop_license'])) { multi_file_upload($posts['shop_license'], 'Uploads/Shop/license', $this->table, 'id', $result, 'shop_license'); } if (is_numeric($posts['shop_license_1'])) { multi_file_upload($posts['shop_license_1'], 'Uploads/Shop/license', $this->table, 'id', $result, 'shop_license_1'); } //将店铺的税务登记证或者是个人译者的学历证书图片存入之地呢的文件夹和对应的字段 if (is_numeric($posts['shop_tax'])) { multi_file_upload($posts['shop_tax'], 'Uploads/Shop/license', $this->table, 'id', $result, 'shop_tax'); } //将店铺的翻译资质存入到shop_image if ($posts['image']) { multi_file_upload(array_unique($posts['image']), 'Uploads/Shop/license', $this->shop_image, 'shop_id', $result, 'image'); } $content = C('SHOPZILIAO'); $account = session('home_member_tel'); $status = send_code($content, $account); $this->success('提交成功'); } else { $this->error($result); } } else { $this->error("您还未开店或者不是公司账号"); } } else { $member_id = session('home_member_id'); //获取业务范围缓存 $operate_type = get_operate_cache(); //指的是翻译、审稿、校对、母语审稿、同声传译、陪同翻译 //定义服务类别 $servece_type = array('中译外', '外译外', '外译中'); //这个是固定的,后台不能做出修改的 //判断用户是否开店 //使用member_id查找店铺列表中是否存在status是1或3的店铺,如果没有就显示让其上传资料,上传资料的时候分为两种一种是翻译公司一种是个人译者 //如果是开店的就显示其上传的认证信息 //如果是没有开店的就显示店铺申请的信息 $info = get_info(D('MemberShopView'), array('shop.member_id' => $member_id)); $data['operate_type'] = $operate_type; $data['servece_type'] = $servece_type; if ($info) { //开了店的或者是正在审核中的店铺 $info['operate_type'] = json_decode($info['operate_type']); $info['translate_type'] = json_decode($info['translate_type']); $data['info'] = $info; //获取资质证书 $shop_image = get_result("shop_image", array("shop_id" => $info["shop_id"])); $data['shop_image'] = $shop_image; $this->assign($data); if ($info['shop_status'] == 1 or $info['shop_status'] == 2) { //表示店铺审核通过或冻结 $this->display('index2'); } else { //表示店铺正在审核的 $this->display('index'); } } else { if (session("type") < 2) { $this->redirect('User/Index/index'); } else { $this->assign($data); $this->display('index'); } } /* $ParameterArray['data']['operate_type'] = $operate_type; $ParameterArray['data']['servece_type'] = $servece_type; $this->ReturnParameter($ParameterArray); */ } }