Example #1
0
 /**
  * 商品编辑
  * 如果是表单提交更新数据
  * 否则查询出要编辑的商品,在页面中展示高商品的信息
  *
  * @author					李东
  * @date					2015-07-03
  */
 public function edit()
 {
     if (IS_POST) {
         $shop_id = session('home_shop_id');
         $result = $this->update($shop_id);
         $this->appOut($result, $this->apptype, 0);
         //    		if($result['status'] == 1){
         //    			$this->success($result['msg'],$result['url']);
         //    		}else{
         //    			$this->error($result['msg'],$result['url']);
         //    		}
     } else {
         $gets = I('get.');
         $id = $gets['id'];
         $map['id'] = $id;
         $info = get_info(D($this->model), $map);
         /*获取格式为 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[] = $info;
         $temp = int_to_string($temp, array("language_id" => $language_text, "to_language_id" => $language_text));
         /*将Json中所有ID转换成文字字符串*/
         $temp = json_to_chars($temp, array('industry_id' => $industry_text, 'ability_id' => $ability_text));
         $info = $temp[0];
         /*将二维数组还原成一维数组*/
         $ability_ids = json_decode($info['ability_id'], true);
         $industry_ids = json_decode($info['industry_id'], true);
         //     		print_r($info);exit;
         $data['info'] = $info;
         $data['ability_ids'] = $ability_ids;
         $data['industry_ids'] = $industry_ids;
         $data['product_level'] = get_product_level_cache();
         $data['product_type'] = $this->product_type;
         $data['ability'] = list_to_tree(get_ability_cache());
         $data['industry'] = list_to_tree(get_industry_cache());
         $data['language'] = get_language_cache();
         $tips_msg = array('status' => 1, 'info' => $data);
         $this->appOut($tips_msg, $this->apptype, 1, 'operate');
         //    		$this->assign($data);
         //    		$this->display('operate');
     }
 }
 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']);
     }
 }
Example #3
0
/**
 * 获取热销商品
 * @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;
}