public function index() { $gets = I('get.'); $product_id = $gets['product_id']; $member_id = session('home_member_id'); /* 获取所选商品信息 */ $map['id'] = $product_id; $product_info = get_info($this->product_table, $map); $product_type = $product_info['type']; if (!$product_type) { $this->error('产品类型错误'); } if (intval($product_type)) { // 文件上传插件第二次加载页面时的报错 /* 确定要加载的第一步的页面 */ session('buy_first_view', $this->first_step_view[$product_type]); } $temp['0'] = $product_info; /* 获取格式为 id=>title 的语言分类数组 */ $language_text = id_and_text(get_language_cache()); /* 获取格式为 id=>title 的领域分类数组 */ $industry_text = id_and_text(get_industry_cache()); /* 获取格式为 id=>title 的属性分类数组 */ $ability_text = id_and_text(get_ability_cache()); /* 获取所有属性,并将键值转换为子数组的ID */ $ability_all = array_id_key(get_ability_cache()); /* 获取所有行业,并将键值转换为子数组的ID */ $industry_all = array_id_key(get_industry_cache()); $temp = int_to_string($temp, array("language_id" => $language_text, "to_language_id" => $language_text)); /* 将二维数组还原成一维数组 */ $product_info = $temp[0]; /* 将行业ID转换为包含title的数组 */ $product_info['industry_id_arr'] = int_to_arr(json_decode($product_info['industry_id'], true), $industry_all); /* 将属性ID转换为包含title的数组 */ $product_info['ability_id_arr'] = int_to_arr(json_decode($product_info['ability_id'], true), $ability_all); // print_r($product_info); $address_result = get_address_info($member_id); $data['address_result'] = $address_result; $data['product_info'] = $product_info; $this->assign($data); // 根据数据表中的字段获取地址信息 $area = get_area_cache(); $data['area'] = $area; // dump($data['product_info']);die; $this->assign('data', $data); /* 按照所传产品类型确定第一步加载的页面 */ $this->display(session('buy_first_view')); }
/** * 查看订单详情 * @author 李东 * @date 2015-06-30 */ public function detail() { $order_id = I('get.id'); if (!$order_id) { $this->error('错误操作'); } $map['order_id'] = $order_id; $order_info = get_info(D($this->model), $map); if ($order_info['order_status'] == 1) { redirect(U('/Home/Buy/confirm_quote/', array('order_id' => $order_id))); } $files = get_result($this->files_complete, array('order_id' => $order_id)); // print_r($files);exit; $order_info['files'] = $files; /*获取格式为 id=>title 的语言分类数组*/ $language_text = id_and_text(get_language_cache()); /*获取格式为 id=>title 的领域分类数组*/ $industry_text = id_and_text(get_industry_cache()); /*获取格式为 id=>title 的属性分类数组*/ $ability_text = id_and_text(get_ability_cache()); /*获取格式为 id=>title 的产品分类数组*/ $product_type = id_and_text($this->product_type); /*暂时将一维数组转化为二维数组*/ $temp[] = $order_info; $temp = int_to_string($temp, array("order_status" => $this->order_status, 'is_need_invoice' => array('0' => '否', '1' => '是'), 'product_type' => $product_type, 'pay_type' => array('0' => '余额支付', '1' => '支付宝支付'), "product_language_id" => $language_text, "product_to_language_id" => $language_text)); /*将Json中所有ID转换成文字字符串*/ $temp = json_to_chars($temp, array('product_industry_id' => $industry_text, 'product_ability_id' => $ability_text)); $order_info = $temp[0]; /*将二维数组还原成一维数组*/ /*获取买家信息*/ $buyer_info = get_info('member', array('id' => $order_info['member_id'])); /*获取下单地址信息*/ $user_address = get_area_pid($order_info['address_path'] . $order_info['address_id']); /*获取发票信息*/ if ($order_info['is_need_invoice'] == 1) { $invoice = get_address_detail($order_info['address_id']); } $address_text = ''; foreach ($user_address as $row) { $address_text .= $row['title'] . ' '; } $buyer_info['address_text'] = $address_text; $map = array(); $map['order_id'] = $order_id; $order_result = get_result('order_history', $map); $order_result = int_to_string($order_result, array('order_status' => $this->order_status)); if ($order_info['order_status'] == 4) { /*如果订单状态为待退款状态,查询退款原因描述*/ $map['order_id'] = $order_id; $refund_result = get_result(D($this->refund_model), $map); // print_r($refund_result);exit; foreach ($refund_result as $k => $row) { if ($row['type'] == 1) { /*如果是下单用户的信息,查询是否上传凭证文件*/ $refund_result[$k]['ask_name'] = $row['username']; $files = get_result($this->refund_files, array('refund_id' => $row['id'])); $files = get_file_type($files); $refund_result[$k]['files'] = $files; } elseif ($row['type']) { $refund_result[$k]['ask_name'] = $row['shop_title']; } } } $data['invoice'] = $invoice; $data['info'] = $order_info; $data['result'] = $order_result; $data['buyer_info'] = $buyer_info; $data['refund_result'] = $refund_result; $this->assign($data); $this->display(); }
public function servece() { $this->header(); //店铺内页主要模块信息 // //获取用户的评价等信息 $comments = $this->get_shop_comments(); //店铺的评价信息 // //店铺的服务信息 // $shop_servece = $this->get_servece_language(10);//店铺的服务,2表示查询两个 // $data['shop_servece'] = $shop_servece; $shop_id = I('get.shop_id'); $status = true; if (intval($shop_id) <= 0 and empty(I("post."))) { /*判断参数是否符合规则*/ $result = array('status' => '0', 'msg' => '错误请求'); $status = false; } if ($status) { //获取用户的评价等信息 $comments = $this->get_shop_comments(); //店铺的评价信息 /*如果前置条件符合,执行以下操作*/ /*查询店铺信息*/ $shop_info = get_info($this->table, array('id' => $shop_id)); /*获取语言信息*/ $language = get_language_cache(); /*获取技能信息*/ $ability = list_to_tree(get_ability_cache()); /*获取行业信息*/ $industry = get_industry_cache(); /*获取数组键值为语言ID的新数组*/ foreach ($language as $val) { $language_id_key[$val['id']] = $val; } /*处理擅长语言*/ $good_at = json_decode($shop_info['good_at'], true); foreach ($good_at as $k => $v) { $good_at_new[$k]['id'] = $v; $good_at_new[$k]['title'] = $language_id_key[$v]['title']; } $shop_info['good_at_arr'] = $good_at_new; /*处理店铺logo*/ if (is_file($shop_info['logo'])) { $shop_info['logo'] = __ROOT__ . '/' . $shop_info['logo']; } else { $shop_info['logo'] = __ROOT__ . '/Public/Home/img/company_img.jpg'; } /*处理数字值,将数字转化为文字*/ $temp[0] = $shop_info; $temp = int_to_string($temp, array('type' => $this->seller_type)); $shop_info = $temp[0]; /*查询店铺所属商品*/ $map['status'] = 1; $map['shop_id'] = $shop_id; $map['assess'] = 1; /*默认排序条件*/ $order = ' recommend desc,sort desc,id desc'; $product_result = get_result(D($this->product_model), $map, '', $order); /*获取格式为 id=>title 的语言分类数组*/ $language_text = id_and_text(get_language_cache()); /*获取格式为 id=>title 的等级分类数组*/ $level_text = id_and_text(get_product_level_cache()); /*获取格式为 id=>title 的产品分类数组*/ $product_type = id_and_text($this->product_type); $product_result = int_to_string($product_result, array('level_id' => $level_text, "type" => $product_type, "language_id" => $language_text, "to_language_id" => $language_text)); /*将json格式ID转为逗号分隔的Title*/ /*获取格式为 id=>title 的领域分类数组*/ $industry_text = id_and_text(get_industry_cache()); /*获取格式为 id=>title 的属性分类数组*/ $ability_text = id_and_text(get_ability_cache()); /*将Json中所有ID转换成文字字符串*/ $product_result = json_to_chars($product_result, array('industry_id' => $industry_text, 'ability_id' => $ability_text)); //print_r($product_result); $data['shop_info'] = $shop_info; $data['product_result'] = $product_result; /*查询店铺所属商品*/ $shop_id = I('get.shop_id'); $map['status'] = 1; $map['shop_id'] = $shop_id; /*默认排序条件*/ $all_product = get_result(D($this->product_model), $map); /*获取格式为 id=>title 的语言分类数组*/ $language_text = id_and_text(get_language_cache()); /*获取格式为 id=>title 的等级分类数组*/ $level_text = id_and_text(get_product_level_cache()); /*获取格式为 id=>title 的产品分类数组*/ $product_type = id_and_text($this->product_type); $all_product = int_to_string($all_product, array('level_id' => $level_text, "type" => $product_type, "language_id" => $language_text, "to_language_id" => $language_text)); /*将json格式ID转为逗号分隔的Title*/ /*获取格式为 id=>title 的领域分类数组*/ $industry_text = id_and_text(get_industry_cache()); /*获取格式为 id=>title 的属性分类数组*/ $ability_text = id_and_text(get_ability_cache()); /*将Json中所有ID转换成文字字符串*/ $all_product = json_to_chars($all_product, array('industry_id' => $industry_text, 'ability_id' => $ability_text)); $data['all_product'] = json_encode($all_product); //店铺的过往经历 /********************************TODO:最近浏览**************************************************/ $view_shops = cookie('view_shops'); // print_r($view_shops); // echo '<br/>'; // cookie('view_shops',$view_shops); $view_shops[$shop_info['id']] = json_encode($shop_info); cookie('view_shops', $view_shops); // echo '<pre />'; // print_r(cookie('view_shops')); /*************************************************************************************/ $this->assign($data); $this->assign($comments); if (IS_AJAX) { $this->display('comments_ajax'); } else { $this->display('list'); } } else { /*如果前置条件不符合,执行以下操作*/ $this->error($result['msg']); } }
/** * 商品更新 * 添加商品/修改商品的方法 * * @author 李东 * @date 2015-07-01 */ public function update($shop_id) { if (IS_POST) { $posts = I('post.'); if (intval($posts['id']) > 0) { $map['id'] = $posts['id']; $map['shop_id'] = session('home_shop_id'); //按照登录店铺的ID来查看 $info = get_info($this->table, $map); if (!$info) { return array('status' => 0, 'msg' => '操作失败'); } } /* 定义添加验证规则 */ $rules = array(array('title', 'require', '名称不能为空'), array('type', 'require', '请选择类型'), array('language_id', 'require', '请选择源语言'), array('to_language_id', 'require', '请选择目标语言'), array('short_description', 'require', '简介不能为空'), array('price', 'require', '请填写价格'), array('level_id', 'require', '请选择等级')); if (empty($posts['industry_id'])) { return array('status' => '0', 'msg' => '请设置行业'); } if ($posts['language_id'] == $posts['to_language_id']) { return array('status' => '0', 'msg' => '源语言不能与目标语言相同'); } if (is_numeric($posts['price'])) { if (floatval($posts['price']) <= 0) { return array('status' => '0', 'msg' => '价额应大于0'); } } if (empty($posts['start_time']) || $posts['start_time'] == '0000-00-00 00:00:00') { return array('status' => '0', 'msg' => '请填写开始时间'); } if (empty($posts['expired_time']) || $posts['expired_time'] == '0000-00-00 00:00:00') { return array('status' => '0', 'msg' => '请填写结束时间'); } /*判断添加的产品是否在服务范围内*/ $status = $this->check_type($shop_id, $posts['language_id'], $posts['to_language_id']); if (!empty($status)) { return $status; } if ($posts['start_time'] > $posts['expired_time']) { return array('status' => 0, 'msg' => '结束时间必须大于开始时间'); } $industry_id = json_encode($posts['industry_id']); $language = id_and_text(get_language_cache()); $title = $language[$posts['language_id']] . '翻译成' . $language[$posts['to_language_id']]; $_POST = array('id' => $posts['id'], 'title' => $title, 'language_id' => $posts['language_id'], 'to_language_id' => $posts['to_language_id'], 'short_description' => $posts['short_description'], 'description' => $posts['description'], 'price' => $posts['price'], 'keywords' => $posts['keywords'], 'industry_id' => $industry_id, 'type' => $posts['type'], 'ability_id' => json_encode($posts['ability_3']), 'level_id' => $posts['level_id'], 'start_time' => $posts['start_time'], 'expired_time' => $posts['expired_time'], 'description' => $posts['description'], 'shop_id' => session("home_shop_id"), 'invoice' => $posts['invoice'], 'status' => 1, 'assess' => 1); $result = update_data($this->table, $rules); /* 判断执行操作是否成功 */ if (is_numeric($result)) { // $price=$this->get_min_price(); // if($posts['price']<=$price){ // $_POST=null; // $_POST['id']=session('home_shop_id'); // $_POST['min_price']=$posts['price']; // } //当用户添加商品成功时,更新店铺表 $sql .= "UPDATE sr_shop SET have_product=1 WHERE id=" . session('home_shop_id'); $Model = M(); $result2 = $Model->execute($sql); $price = $this->get_min_price(); if ($posts['price'] <= $price) { $_POST = null; $_POST['id'] = session('home_shop_id'); $_POST['min_price'] = $posts['price']; } else { $_POST = null; $_POST['id'] = session('home_shop_id'); $_POST['min_price'] = $price; } /*更新店铺最低价*/ update_data($this->shop_table); F($this->category_cache, null); /* 操作成功清除缓存 */ return array('status' => '1', 'msg' => '操作成功', 'url' => U('index')); // $this->success('操作成功',U('index',array('pid'=>intval(I('post.pid'))))); } else { return array('status' => '0', 'msg' => $result); // $this->error($result); } } else { return array('status' => '0', 'msg' => '违法操作', 'url' => U('index')); // $this->error('违法操作',U('index')); } }
/** * 获取热销商品 * @param int $shop_id 店铺ID * @return array 查询处理后的结果集 * @author 李东 * @date 2015-07-25 */ function get_hot_product($shop_id) { $map['shop_id'] = $shop_id; $map['status'] = 1; $limit = 9; $order = ' id desc '; $result = get_result('products', $map, '', $order, $limit); /*获取格式为 id=>title 的语言分类数组*/ $language_text = id_and_text(get_language_cache()); /*获取格式为 id=>title 的等级分类数组*/ $level_text = id_and_text(get_product_level_cache()); /*获取格式为 id=>title 的产品分类数组*/ $product_type = id_and_text(list_to_tree(get_ability_cache())); /*获取缓存的分类属性转换为树状*/ $result = int_to_string($result, array('level_id' => $level_text, "type" => $product_type, "language_id" => $language_text, "to_language_id" => $language_text)); /*将json格式ID转为逗号分隔的Title*/ /*获取格式为 id=>title 的领域分类数组*/ $industry_text = id_and_text(get_industry_cache()); /*获取格式为 id=>title 的属性分类数组*/ $ability_text = id_and_text(get_ability_cache()); /*将Json中所有ID转换成文字字符串*/ $result = json_to_chars($result, array('industry_id' => $industry_text, 'ability_id' => $ability_text)); return $result; }