Commit f058ed92 by felix

添加cache功能

parent c87b7a79
......@@ -52,6 +52,7 @@ class House extends Tospur_House{
}else{
$wpdb->query("COMMIT");
echo "<h4>新房房源修改成功</h4>";
w3tc_pgcache_flush_url(home_url() . '/?page=detail&hid=' . $_POST['houseId']);
}
}else{
$insert_tospur_house_array["status"] = 0;
......
......@@ -11,6 +11,8 @@ class TCSyncView {
TCSync::organization_sync();
break;
case 2:
$w3_objectcache = w3_instance('W3_ObjectCache');
$w3_objectcache->flush();
TCSync::other_sync();
break;
}
......
......@@ -65,8 +65,8 @@ class RentHouse extends Tospur_House{
}else{
$wpdb->query("COMMIT");
echo "<h4>租房房源修改成功</h4>";
w3tc_pgcache_flush_url(home_url() . '/?page=detail&hid=' . $_POST['houseId']);
}
}else {
$insert_tospur_house_array["status"] = 0;
$insert_tospur_house_array["approval"] = 1;
......
......@@ -65,8 +65,8 @@ class SecHandHouse extends Tospur_House{
}else{
$wpdb->query("COMMIT");
echo "<h4>二手房房源修改成功</h4>";
w3tc_pgcache_flush_url(home_url() . '/?page=detail&hid=' . $_POST['houseId']);
}
}else {
$insert_tospur_house_array["status"] = 0;
$insert_tospur_house_array["approval"] = 1;
......@@ -104,7 +104,6 @@ class SecHandHouse extends Tospur_House{
$context["photoType"] = SearchDao::searchPhotoType();
$context["house_type"] = 1;
Timber::render("secHandHouse.html",$context);
}
public static function secHouseData_insert($params)
......
......@@ -15,7 +15,7 @@
</select>
</span>
<span>
<select id="baseAreaId" name="baseAreaId" class="form-control" style="width: 90px;">
<select id="baseAreaId" name="baseAreaId" class="form-control" style="width: 100px;">
<option value = "-1">区域</option>
{% if district %}
{% for item in district %}
......@@ -25,7 +25,7 @@
</select>
</span>
<span>
<select id="basePlateId" name="basePlateId" class="form-control" style="width: 90px;">
<select id="basePlateId" name="basePlateId" class="form-control" style="width: 100px;">
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
......@@ -281,7 +281,7 @@
{% elseif house_type== 2 %}
<div class="col-xs-4">
<label for="rent" class="control-label">租金:</label>
<p class="col-xs-7">
<p class="col-xs-6">
<input name="rent" id="rent" type="text" value="{{result.rent}}" class="form-control">
</p>
<p class="col-xs-2" style="margin-top: 10px">&nbsp;元/月</p>
......@@ -378,7 +378,7 @@
{% if not houseId %}
<div class="row form-group">
<div class="col-xs- ">
<div class="col-xs-4">
<label for="owner_name" class="control-label">业主姓名:</label>
<p class="col-xs-7">
<input name="owner_name" id="owner_name" type="text" value="" class="form-control">
......
<div id="preview">
<div class="row">
<div class="col-md-2">
<label for="traffic" style="margin-left: 30px">主力房源:</label>
</div>
<label style="float: left;margin-top: 25px;margin-left: 15px;">主力房源:</label>
<div class="col-md-10">
{% set exists_ids = "" %}
{% for item in mainImage %}
......
......@@ -13,7 +13,7 @@
</select>
</span>
<span>
<select id="baseAreaId" name="baseAreaId" class="form-control" style="width: 90px;">
<select id="baseAreaId" name="baseAreaId" class="form-control" style="width: 100px;">
<option value = "-1">区域</option>
{% if district %}
{% for item in district %}
......@@ -23,7 +23,7 @@
</select>
</span>
<span>
<select id="basePlateId" name="basePlateId" class="form-control" style="width: 90px;">
<select id="basePlateId" name="basePlateId" class="form-control" style="width: 100px;">
<option value = "-1">板块</option>
{% if district %}
{% for item in plate %}
......
......@@ -5,13 +5,19 @@
<meta charset="utf-8">
<title>{{title}}</title>
<style>
.form-horizontal label.control-label{
#adminmenuwrap {
position: fixed;
}
.form-horizontal {
width: 1500px;
}
.form-horizontal label.control-label {
text-align: left;
float: left;
margin-right: 10px;
width: 65px;
}
.form-horizontal span select{
.form-horizontal span select {
display: inline;
}
</style>
......@@ -41,15 +47,13 @@
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="info">
{% if (house_type==1 or house_type == 2)%}
{% include 'houseInfo.html' %}
{% else %}
{% include 'newHouseInfo.html' %}
{% endif %}
</div>
<div role="tabpanel" class="tab-pane active" id="info">
{% if (house_type==1 or house_type == 2)%}
{% include 'houseInfo.html' %}
{% else %}
{% include 'newHouseInfo.html' %}
{% endif %}
</div>
<div role="tabpanel" class="tab-pane" id="mainHouse">
<br/>
{% include 'mainHouse.html' %}
......@@ -71,8 +75,8 @@
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
</div>
<div class="col-xs-2">
<div class="row" style="position: fixed;">
<div class="col-xs-2" style="position: relative;height: 28px;">
<div class="row" style="position: absolute;">
{% if canEdit %}
{% if houseId %}
{% if canApproval %}
......@@ -95,7 +99,6 @@
<input type="submit" id="submit" class="button action">
{% endif %}
</div>
</div>
</div>
</form>
......
......@@ -5,6 +5,12 @@
<meta charset="utf-8">
<title>{{title}}</title>
<style>
#adminmenuwrap {
position: fixed;
}
.form-horizontal {
width: 1500px;
}
.form-horizontal label.control-label{
text-align: left;
float: left;
......@@ -60,8 +66,8 @@
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
</div>
<div class="col-xs-2">
<div class="row" style="position: fixed;">
<div class="col-xs-2" style="position: relative;height: 28px;">
<div class="row" style="position: absolute;">
{% if canEdit %}
{% if (result.status != 2 and result.status != 3) %}
{% if houseId %}
......
......@@ -6,6 +6,12 @@
<meta charset="utf-8">
<title>{{title}}</title>
<style>
#adminmenuwrap {
position: fixed;
}
.form-horizontal {
width: 1500px;
}
.form-horizontal label.control-label{
text-align: left;
float: left;
......@@ -64,8 +70,8 @@
<input type="text" name="houseId" value="{{houseId}}" hidden="hidden">
{% endif %}
</div>
<div class="col-xs-2">
<div class="row" style="position: fixed;">
<div class="col-xs-2" style="position: relative;height: 28px;">
<div class="row" style="position: absolute;">
{% if canEdit %}
{% if (result.status != 2 and result.status != 3) %}
{% if houseId %}
......
......@@ -5,6 +5,26 @@ require_once(PLUGIN_DIR . 'Tools/Image.php');
class SearchDao
{
public static function get_dic_ojbectCache($id)
{
$w3_objectcache = w3_instance('W3_ObjectCache');
$get_objectcache = $w3_objectcache->get($id, 'dic');
if ($get_objectcache) {
DBManager::getLog()->info("get object cache " . $id);
return $get_objectcache;
} else {
return false;
}
}
public static function set_dic_ojbectCache($id, $result)
{
$w3_objectcache = w3_instance('W3_ObjectCache');
$w3_objectcache->set($id, $result, 'dic');
DBManager::getLog()->info("set object cache " . $id);
return $w3_objectcache->get($id, 'dic');
}
public static function ajax_searchCity()
{
wp_send_json(SearchDao::searchCity($_GET["cityId"], $_GET['districtId']));
......@@ -16,21 +36,28 @@ class SearchDao
$selectName = "cityId as id,cityName as value";
$where = " where 1=1 ";
$groupBy = " group by cityId";
$id = "citys";
$params = array();
if ($cityId != NULL && $districtId == NULL) {
$selectName = "districtId as id,districtName as value";
$where .= " and cityId = %d";
$params[] = $cityId;
$groupBy = " group by districtId";
$id = "citys_" . $cityId;
} else if ($cityId != NULL && $districtId != NULL) {
$selectName = "plateId as id,plateName as value";
$where .= " and cityId = %d and districtId = %d";
$params[] = $cityId;
$params[] = $districtId;
$groupBy = "";
$id = "citys_" . $cityId . "_" . $districtId;
}
$result = DBManager::get_results($wpdb->prepare('select ' . $selectName . ' from ' . Config::DIC_CITY_TABLE . $where . $groupBy, $params));
return $result;
$data = SearchDao::get_dic_ojbectCache($id);
if (!$data) {
$result = DBManager::get_results($wpdb->prepare('select ' . $selectName . ' from ' . Config::DIC_CITY_TABLE . $where . $groupBy, $params));
$data = SearchDao::set_dic_ojbectCache($id, $result);
}
return $data;
}
public static function ajax_searchArea()
......@@ -42,11 +69,17 @@ class SearchDao
{
global $wpdb;
$where = " where 1=1";
if (isset($_GET['cityId'])) {
$id = "area";
if ($cityId) {
$where .= " and cityId = %d";
$id .= "_" . $cityId;
}
$result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_AREA_TABLE . $where, $cityId));
return $result;
$data = SearchDao::get_dic_ojbectCache($id);
if (!$data) {
$result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_AREA_TABLE . $where, $cityId));
$data = SearchDao::set_dic_ojbectCache($id, $result);
}
return $data;
}
public static function ajax_searchBuildProperty()
......@@ -56,9 +89,13 @@ class SearchDao
public static function searchBuildProperty()
{
global $wpdb;
$result = DBManager::get_results('select value as id,literal as value from ' . Config::DIC_BUILDPROPERTY_TABLE);
return $result;
$id = "buildproperty";
$data = SearchDao::get_dic_ojbectCache($id);
if (!$data) {
$result = DBManager::get_results('select value as id,literal as value from ' . Config::DIC_BUILDPROPERTY_TABLE);
$data = SearchDao::set_dic_ojbectCache($id, $result);
}
return $data;
}
public static function ajax_searchRoom()
......@@ -68,8 +105,13 @@ class SearchDao
public static function searchRoom()
{
$result = DBManager::get_results('select value as id,literal as value from ' . Config::DIC_ROOM_TABLE);
return $result;
$id = "room";
$data = SearchDao::get_dic_ojbectCache($id);
if (!$data) {
$result = DBManager::get_results('select value as id,literal as value from ' . Config::DIC_ROOM_TABLE);
$data = SearchDao::set_dic_ojbectCache($id, $result);
}
return $data;
}
public static function ajax_searchUnitPriceRange()
......@@ -81,11 +123,17 @@ class SearchDao
{
global $wpdb;
$where = " where 1=1";
if (isset($cityId)) {
$id = "unitpricerange";
if ($cityId) {
$where .= " and cityId = %d";
$id .= "_" . $cityId;
}
$result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_UNITPRICERANGE_TABLE . $where, $cityId));
return $result;
$data = SearchDao::get_dic_ojbectCache($id);
if (!$data) {
$result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_UNITPRICERANGE_TABLE . $where, $cityId));
$data = SearchDao::set_dic_ojbectCache($id, $result);
}
return $data;
}
public static function ajax_searchTotalPrice()
......@@ -97,11 +145,17 @@ class SearchDao
{
global $wpdb;
$where = " where 1=1";
$id = "totalprice";
if ($cityId) {
$where .= " and cityId = " . $cityId;
$id .= "_" . $cityId;
}
$result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_TOTALPRICE_TABLE . $where, $cityId));
return $result;
$data = SearchDao::get_dic_ojbectCache($id);
if (!$data) {
$result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_TOTALPRICE_TABLE . $where, $cityId));
$data = SearchDao::set_dic_ojbectCache($id, $result);
}
return $data;
}
public static function ajax_searchRentalPrice()
......@@ -113,11 +167,17 @@ class SearchDao
{
global $wpdb;
$where = " where 1=1";
$id = "rentalprice";
if ($cityId) {
$where .= " and cityId = " . $cityId;
$id .= "_" . $cityId;
}
$result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_RENTALPRICE_TABLE . $where, $cityId));
return $result;
$data = SearchDao::get_dic_ojbectCache($id);
if (!$data) {
$result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_RENTALPRICE_TABLE . $where, $cityId));
$data = SearchDao::set_dic_ojbectCache($id, $result);
}
return $data;
}
public static function ajax_searchOrganization()
......@@ -147,143 +207,144 @@ class SearchDao
}
}
public static function ajax_searchHouse()
{
$house_result = SearchDao::searchHouse(
array(
'cityId' => $_POST['cityId'],
'districtId' => $_POST['districtId'],
'plateId' => $_POST['plateId'],
'buildPropertyId' => $_POST['buildPropertyId'],
'roomId' => $_POST['roomId'],
'acreage' => $_POST['acreage'],
'unitPrice'=> $_POST['unitPrice'],
'totalPrice' => $_POST['totalPrice'],
'rentalPrice' => $_POST['rentalPrice'],
'searchText' => $_POST['searchText'],
'houseType' => $_POST['houseType'],
'feature' => $_POST['feature'],
'userType' => $_POST['userType'],
'userId' => $_POST['userId'],
'index' => $_POST['index']
)
);
$array = SearchDao::get_house_list($house_result);
wp_send_json($array);
}
public static function searchHouse($array)
{
global $wpdb;
$params = array();
$addSql = null;
$addWhereSql = null;
$orderbySql = null;
if ($array['houseType'] == 0) {
$addSql = " left join (select buildproperty_id,house_area,image_id,house_id as bph_id from ".Config::A_DISTRICT_AREA_TABLE.") ada on th.id = ada.bph_id".
" left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on ada.buildproperty_id = dbp.bp_value";
$orderbySql = " group by th.id order by th.creattime DESC";
}else if ($array['houseType'] == 1) {
$addSql = " left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on if(th.buildproperty_id>5,5,buildproperty_id) = dbp.bp_value";
if ($array['feature'] > -1) {
$addSql .= " left join (select house_id,tag_id from ".Config::A_HOUSE_TAG_TABLE.") aht on th.id = aht.house_id";
$addWhereSql = " and tag_id = ".$array['feature'];
}
$orderbySql = " order by th.creattime DESC";
}else if($array['houseType'] == 2){
$addSql = " left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on th.buildproperty_id = dbp.bp_value";
$orderbySql = " order by th.creattime DESC";
}
$sql = "select th.id,th.house_type,th.name,th.latest_news,th.address,th.average_price,th.community_name,th.covered_area,th.total_price,th.decoration,th.rent,".
"ti.path,dr.literal,th.house_number,dbp.bp_literal,th.owner_name,th.owner_phone,(SELECT GROUP_CONCAT(left(tt.name,3)) from ".Config::A_HOUSE_TAG_TABLE." aht".
" LEFT JOIN ".Config::TOSPUR_TAG_TABLE." tt on tt.id = aht.tag_id".
" where aht.house_id = th.id) as tags from ".Config::TOSPUR_HOUSE_TABLE." th".
$addSql.
" left join ".Config::DIC_CITY_TABLE." dc on th.plate_id = dc.plateId".
" left join (select id as rid,value as r_value,literal from ".Config::DIC_ROOM_TABLE.") dr on th.room_id = dr.r_value".
" left join (select id as image_id,path from ".Config::TOSPUR_IMAGE_TABLE.") ti on ti.image_id = th.frontCover_id".
" where 1=1 and th.status = 1 ";
if ($array['cityId'] > -1) {
$params[] = $array['cityId'];
$sql = $sql . " and cityId=%d";
}
if ($array['districtId'] > -1) {
$params[] = $array['districtId'];
$sql = $sql . " and districtId=%d";
}
if ($array['plateId'] > -1) {
$params[] = $array['plateId'];
$sql = $sql . " and plateId=%d";
}
if ($array['buildPropertyId'] > -1) {
$params[] = $array['buildPropertyId'];
if ($array['houseType'] == 0) {
$sql = $sql . " and ada.buildproperty_id=%d";
}else{
$sql = $sql . " and th.buildproperty_id=%d";
}
}
if ($array['roomId'] > -1) {
$params[] = $array['roomId'];
$sql = $sql . " and room_id=%d";
}
if ($array['acreage'] > -1) {
$areaArray = explode("-", $array['acreage']);
$params[] = $areaArray[0];
$params[] = $areaArray[1];
if ($array['houseType'] == 0) {
$sql = $sql . " and ada.house_area between %d and %d";
}else{
$sql = $sql . " and covered_area between %d and %d";
}
}
if ($array['unitPrice'] > -1) {
$priceArray = explode("-", $array['unitPrice']);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql . " and average_price between %d and %d";
}
public static function ajax_searchHouse()
{
$house_result = SearchDao::searchHouse(
array(
'cityId' => $_POST['cityId'],
'districtId' => $_POST['districtId'],
'plateId' => $_POST['plateId'],
'buildPropertyId' => $_POST['buildPropertyId'],
'roomId' => $_POST['roomId'],
'acreage' => $_POST['acreage'],
'unitPrice' => $_POST['unitPrice'],
'totalPrice' => $_POST['totalPrice'],
'rentalPrice' => $_POST['rentalPrice'],
'searchText' => $_POST['searchText'],
'houseType' => $_POST['houseType'],
'feature' => $_POST['feature'],
'userType' => $_POST['userType'],
'userId' => $_POST['userId'],
'index' => $_POST['index']
)
);
$array = SearchDao::get_house_list($house_result);
wp_send_json($array);
exit;
}
public static function searchHouse($array)
{
global $wpdb;
$params = array();
$addSql = null;
$addWhereSql = null;
$orderbySql = null;
if ($array['houseType'] == 0) {
$addSql = " left join (select buildproperty_id,house_area,image_id,house_id as bph_id from " . Config::A_DISTRICT_AREA_TABLE . ") ada on th.id = ada.bph_id" .
" left join (select value as bp_value,literal as bp_literal from " . Config::DIC_BUILDPROPERTY_TABLE . ") dbp on ada.buildproperty_id = dbp.bp_value";
$orderbySql = " group by th.id order by th.creattime DESC";
} else if ($array['houseType'] == 1) {
$addSql = " left join (select value as bp_value,literal as bp_literal from " . Config::DIC_BUILDPROPERTY_TABLE . ") dbp on th.buildproperty_id = dbp.bp_value";
if ($array['feature'] > -1) {
$addSql .= " left join (select house_id,tag_id from " . Config::A_HOUSE_TAG_TABLE . ") aht on th.id = aht.house_id";
$addWhereSql = " and tag_id = " . $array['feature'];
}
$orderbySql = " order by th.creattime DESC";
} else if ($array['houseType'] == 2) {
$addSql = " left join (select value as bp_value,literal as bp_literal from " . Config::DIC_BUILDPROPERTY_TABLE . ") dbp on th.buildproperty_id = dbp.bp_value";
$orderbySql = " order by th.creattime DESC";
}
$sql = "select th.id,th.house_type,th.name,th.latest_news,th.address,th.average_price,th.community_name,th.covered_area,th.total_price,th.decoration,th.rent," .
"ti.path,dr.literal,th.house_number,dbp.bp_literal,th.owner_name,th.owner_phone,(SELECT GROUP_CONCAT(left(tt.name,3)) from " . Config::A_HOUSE_TAG_TABLE . " aht" .
" LEFT JOIN " . Config::TOSPUR_TAG_TABLE . " tt on tt.id = aht.tag_id" .
" where aht.house_id = th.id) as tags from " . Config::TOSPUR_HOUSE_TABLE . " th" .
$addSql .
" left join " . Config::DIC_CITY_TABLE . " dc on th.plate_id = dc.plateId" .
" left join (select id as rid,value as r_value,literal from " . Config::DIC_ROOM_TABLE . ") dr on th.room_id = dr.r_value" .
" left join (select id as image_id,path from " . Config::TOSPUR_IMAGE_TABLE . ") ti on ti.image_id = th.frontCover_id" .
" where 1=1 and th.status = 1 ";
if ($array['cityId'] > -1) {
$params[] = $array['cityId'];
$sql = $sql . " and cityId=%d";
}
if ($array['districtId'] > -1) {
$params[] = $array['districtId'];
$sql = $sql . " and districtId=%d";
}
if ($array['plateId'] > -1) {
$params[] = $array['plateId'];
$sql = $sql . " and plateId=%d";
}
if ($array['buildPropertyId'] > -1) {
$params[] = $array['buildPropertyId'];
if ($array['houseType'] == 0) {
$sql = $sql . " and ada.buildproperty_id=%d";
} else {
$sql = $sql . " and th.buildproperty_id=%d";
}
}
if ($array['roomId'] > -1) {
$params[] = $array['roomId'];
$sql = $sql . " and room_id=%d";
}
if ($array['acreage'] > -1) {
$areaArray = explode("-", $array['acreage']);
$params[] = $areaArray[0];
$params[] = $areaArray[1];
if ($array['houseType'] == 0) {
$sql = $sql . " and ada.house_area between %d and %d";
} else {
$sql = $sql . " and covered_area between %d and %d";
}
}
if ($array['unitPrice'] > -1) {
$priceArray = explode("-", $array['unitPrice']);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql . " and average_price between %d and %d";
}
if ($array['totalPrice'] > -1) {
$priceArray = explode("-", $array['totalPrice']);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql . " and total_price/10000 between %d and %d";
}
if ($array['rentalPrice'] > -1) {
$priceArray = explode("-", $array['rentalPrice']);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql . " and rent between %d and %d";
}
if ($array['houseType'] > -1) {
$params[] = $array['houseType'];
$sql = $sql . " and house_type = %d";
}
if ($array['userType'] > -1 && $array['userId'] > -1) {
$params[] = $array['userType'];
$params[] = $array['userId'];
$sql = $sql . " and id in (select house_id from ".Config::A_HOUSE_USER_TABLE." where user_type = %d and user_id = %d)";
}
if ($array['searchText'] != null) {
$params[] = '%'.$array['searchText'].'%';
$params[] = '%'.$array['searchText'].'%';
$sql = $sql . " and (name like '%s' or address like '%s')";
}
if($addWhereSql){
$sql = $sql . $addWhereSql;
}
$sql = $sql . $orderbySql;
if ($array['index'] > -1) {
$params[] = $array['index'];
$sql = $sql . " limit %d,10";
}
$result = DBManager::get_results($wpdb->prepare($sql, $params));
return $result;
}
$sql = $sql . " and total_price between %d and %d";
}
if ($array['rentalPrice'] > -1) {
$priceArray = explode("-", $array['rentalPrice']);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql . " and rent between %d and %d";
}
if ($array['houseType'] > -1) {
$params[] = $array['houseType'];
$sql = $sql . " and house_type = %d";
}
if ($array['userType'] > -1 && $array['userId'] > -1) {
$params[] = $array['userType'];
$params[] = $array['userId'];
$sql = $sql . " and id in (select house_id from " . Config::A_HOUSE_USER_TABLE . " where user_type = %d and user_id = %d)";
}
if ($array['searchText'] != null) {
$params[] = '%' . $array['searchText'] . '%';
$params[] = '%' . $array['searchText'] . '%';
$sql = $sql . " and (name like '%s' or address like '%s')";
}
if ($addWhereSql) {
$sql = $sql . $addWhereSql;
}
$sql = $sql . $orderbySql;
if ($array['index'] > -1) {
$params[] = $array['index'];
$sql = $sql . " limit %d,10";
}
$result = DBManager::get_results($wpdb->prepare($sql, $params));
return $result;
}
public static function ajax_searchPhotoType()
{
......@@ -296,62 +357,65 @@ class SearchDao
$result = DBManager::get_results('select id,photo_name as value from ' . Config::DIC_PHOTOTYPE_TABLE);
return $result;
}
public static function ajax_searchConsultant(){
wp_send_json(SearchDao::searchConsultant($_GET["organizationId"],$_GET["consultantName"]));
public static function ajax_searchConsultant()
{
wp_send_json(SearchDao::searchConsultant($_GET["organizationId"], $_GET["consultantName"]));
}
public static function searchConsultant($organizationId = NULL,$consultantName = NULL){
public static function searchConsultant($organizationId = NULL, $consultantName = NULL)
{
global $wpdb;
$sql = "select tc.id,tc.name,tc.subsidiaryId,imageUrl,tor.Name as branchName from ".Config::TOSPUR_CONSULTANT." tc
LEFT JOIN ".Config::TOSPUR_ORGANIZATION_TABLE." tor on tc.subsidiaryId = tor.Id
$sql = "select tc.id,tc.name,tc.subsidiaryId,imageUrl,tor.Name as branchName from " . Config::TOSPUR_CONSULTANT . " tc
LEFT JOIN " . Config::TOSPUR_ORGANIZATION_TABLE . " tor on tc.subsidiaryId = tor.Id
where 1=1";
$params = array();
if($organizationId!=NULL && $organizationId != -1 ){
if ($organizationId != -1) {
$params[] = $organizationId;
$sql = $sql." and subsidiaryId=%d";
$sql = $sql . " and subsidiaryId=%d";
}
if($consultantName != NULL){
$params[] = '%'.$consultantName.'%';
$sql = $sql." and tc.name like %s";
if ($consultantName != NULL) {
$params[] = '%' . $consultantName . '%';
$sql = $sql . " and tc.name like %s";
}
$result = DBManager::get_results($wpdb->prepare($sql,$params));
$result = DBManager::get_results($wpdb->prepare($sql, $params));
return $result;
}
public static function get_house_list($house_result)
{
$array = array();
if ($house_result) {
$array['code'] = 2000;
$house_ids = array();
foreach ($house_result as $key => $value) {
$house_id = $value->id;
$house_ids[] = $house_id;
if($value->path){
$value->path = home_url() . Image::getImage($value->path,'small');
}
}
$array['result'] = $house_result;
} else {
$array['code'] = 2001;
}
return $array;
}
public static function searchFeatureByHouse($hid){
global $wpdb;
$featureSql ="select tag_id,name from ".Config::A_HOUSE_TAG_TABLE." aht
LEFT JOIN (select id as tid,name ,type from ".Config::TOSPUR_TAG_TABLE.") tt on aht.tag_id = tt.tid where aht.house_id = %d and type = 1";
$feature = DBManager::get_results($wpdb->prepare($featureSql,$hid));
return $feature;
}
public static function searchFeature()
{
$sql = 'select id,name as value from '.Config::TOSPUR_TAG_TABLE.' where type = 1;';
return DBManager::get_results($sql);
}
public static function get_house_list($house_result)
{
$array = array();
if ($house_result) {
$array['code'] = 2000;
$house_ids = array();
foreach ($house_result as $key => $value) {
$house_id = $value->id;
$house_ids[] = $house_id;
if ($value->path) {
$value->path = home_url() . Image::getImage($value->path, 'small');
}
}
$array['result'] = $house_result;
} else {
$array['code'] = 2001;
}
return $array;
}
public static function searchFeatureByHouse($hid)
{
global $wpdb;
$featureSql = "select tag_id,name from " . Config::A_HOUSE_TAG_TABLE . " aht
LEFT JOIN (select id as tid,name ,type from " . Config::TOSPUR_TAG_TABLE . ") tt on aht.tag_id = tt.tid where aht.house_id = %d and type = 1";
$feature = DBManager::get_results($wpdb->prepare($featureSql, $hid));
return $feature;
}
public static function searchFeature()
{
$sql = 'select id,name as value from ' . Config::TOSPUR_TAG_TABLE . ' where type = 1;';
return DBManager::get_results($sql);
}
public static function ajax_searchTagOrFeature()
{
......@@ -364,128 +428,130 @@ class SearchDao
return DBManager::get_results($sql);
}
public static function getDetailInfo($hid,$type = NULL){
public static function getDetailInfo($hid, $type = NULL)
{
global $wpdb;
$sql = "select *,dr.literal as room,db.literal as buildproperty from ".Config::TOSPUR_HOUSE_TABLE." th
left JOIN ".Config::DIC_ROOM_TABLE." dr on th.room_id = dr.id
left JOIN ".Config::DIC_BUILDPROPERTY_TABLE." db on th.buildproperty_id = db.value
$sql = "select *,dr.literal as room,db.literal as buildproperty from " . Config::TOSPUR_HOUSE_TABLE . " th
left JOIN " . Config::DIC_ROOM_TABLE . " dr on th.room_id = dr.id
left JOIN " . Config::DIC_BUILDPROPERTY_TABLE . " db on th.buildproperty_id = db.value
where th.id = %d";
$result = DBManager::get_row($wpdb->prepare($sql,$hid));
$result = DBManager::get_row($wpdb->prepare($sql, $hid));
$context = array();
$context['result'] = $result;
$houseType = $result->house_type;
$context['cityName'] = SearchDao::getCityNameWithId($result->city_id);
$consultantLimit = 1;
if($houseType == 0){
if ($houseType == 0) {
$consultantLimit = 5;
$mainImagesSql = "SELECT ti.id,ada.buildproperty_id,db.literal as type,ada.house_area as area,ti.path FROM ".Config::A_DISTRICT_AREA_TABLE." ada
LEFT JOIN ".Config::DIC_BUILDPROPERTY_TABLE." db on db.value = ada.buildproperty_id
LEFT JOIN ".Config::TOSPUR_IMAGE_TABLE." ti on ti.id = ada.image_id
$mainImagesSql = "SELECT ti.id,ada.buildproperty_id,db.literal as type,ada.house_area as area,ti.path FROM " . Config::A_DISTRICT_AREA_TABLE . " ada
LEFT JOIN " . Config::DIC_BUILDPROPERTY_TABLE . " db on db.value = ada.buildproperty_id
LEFT JOIN " . Config::TOSPUR_IMAGE_TABLE . " ti on ti.id = ada.image_id
where ada.house_id = %d";
$mainImage = DBManager::get_results($wpdb->prepare($mainImagesSql,$hid));
$mainImage = DBManager::get_results($wpdb->prepare($mainImagesSql, $hid));
foreach($mainImage as $key => $value){
foreach ($mainImage as $key => $value) {
$path = $value->path;
$value->path = Image::getImage($path,'big');
$value->smallPath = Image::getImage($path,'small');
$value->path = Image::getImage($path, 'big');
$value->smallPath = Image::getImage($path, 'small');
}
$context['mainImage'] = $mainImage;
$recommendSql = "select th.id,th.name,th.average_price,th.latest_news,th.address,ti.path,dr.literal,(SELECT GROUP_CONCAT(left(tt.name,3)) from ".Config::A_HOUSE_TAG_TABLE." aht
LEFT JOIN ".Config::TOSPUR_TAG_TABLE." tt on tt.id = aht.tag_id
where aht.house_id = th.id) as tags from ".Config::TOSPUR_HOUSE_TABLE." th
LEFT JOIN ".Config::TOSPUR_IMAGE_TABLE." ti on th.frontCover_id = ti.id
LEFT JOIN ".Config::DIC_ROOM_TABLE." dr on dr.value = th.room_id
where th.id in(select recommend_id from ".Config::A_HOUSE_RECOMMEND_TABLE." where house_id = %d);";
}else{
$recommendSql = "select th.id,th.name,th.community_name,ti.path,db.literal,th.rent,th.decoration,th.covered_area,th.total_price,(SELECT GROUP_CONCAT(left(tt.name,3)) from ".Config::A_HOUSE_TAG_TABLE." aht
LEFT JOIN ".Config::TOSPUR_TAG_TABLE." tt on tt.id = aht.tag_id
where aht.house_id = th.id) as tags from ".Config::TOSPUR_HOUSE_TABLE." th
LEFT JOIN ".Config::DIC_BUILDPROPERTY_TABLE." db on db.value = if(th.buildproperty_id>5,5,buildproperty_id)
LEFT JOIN ".Config::TOSPUR_IMAGE_TABLE." ti on th.frontCover_id = ti.id
where th.id in(select recommend_id from ".Config::A_HOUSE_RECOMMEND_TABLE." where house_id = %d);";
}
$recommends = DBManager::get_results($wpdb->prepare($recommendSql,$hid));
foreach($recommends as $key => $value){
$value->path = Image::getImage($value->path,'small');
$recommendSql = "select th.id,th.name,th.average_price,th.latest_news,th.address,ti.path,dr.literal,(SELECT GROUP_CONCAT(left(tt.name,3)) from " . Config::A_HOUSE_TAG_TABLE . " aht
LEFT JOIN " . Config::TOSPUR_TAG_TABLE . " tt on tt.id = aht.tag_id
where aht.house_id = th.id) as tags from " . Config::TOSPUR_HOUSE_TABLE . " th
LEFT JOIN " . Config::TOSPUR_IMAGE_TABLE . " ti on th.frontCover_id = ti.id
LEFT JOIN " . Config::DIC_ROOM_TABLE . " dr on dr.value = th.room_id
where th.id in(select recommend_id from " . Config::A_HOUSE_RECOMMEND_TABLE . " where house_id = %d);";
} else {
$recommendSql = "select th.id,th.name,th.community_name,ti.path,dr.value,th.rent,th.decoration,th.covered_area,th.total_price,(SELECT GROUP_CONCAT(left(tt.name,3)) from " . Config::A_HOUSE_TAG_TABLE . " aht
LEFT JOIN " . Config::TOSPUR_TAG_TABLE . " tt on tt.id = aht.tag_id
where aht.house_id = th.id) as tags from " . Config::TOSPUR_HOUSE_TABLE . " th
LEFT JOIN " . Config::DIC_ROOM_TABLE . " dr on dr.id = th.room_id
LEFT JOIN " . Config::TOSPUR_IMAGE_TABLE . " ti on th.frontCover_id = ti.id
where th.id in(select recommend_id from " . Config::A_HOUSE_RECOMMEND_TABLE . " where house_id = %d);";
}
$recommends = DBManager::get_results($wpdb->prepare($recommendSql, $hid));
foreach ($recommends as $key => $value) {
$value->path = Image::getImage($value->path, 'small');
}
$context['recommends'] = $recommends;
$consultantSql = "select id,name,mobile,imageUrl,subsidiaryId,s.average_score from ".Config::TOSPUR_CONSULTANT." c
$consultantSql = "select id,name,mobile,imageUrl,subsidiaryId,s.average_score from " . Config::TOSPUR_CONSULTANT . " c
LEFT JOIN (select consultant_id,sum(score)/count(score) as average_score
from ".Config::TOSPUR_CONSULTANT_SCORE_TABLE."
from " . Config::TOSPUR_CONSULTANT_SCORE_TABLE . "
where valid=1 group by consultant_id) s on c.id = s.consultant_id
where id in(select user_id from ".Config::A_HOUSE_USER_TABLE." where user_type = 1 and house_id = %d) limit {$consultantLimit};";
$consultant = DBManager::get_results($wpdb->prepare($consultantSql,$hid));
where id in(select user_id from " . Config::A_HOUSE_USER_TABLE . " where user_type = 1 and house_id = %d) limit {$consultantLimit};";
$consultant = DBManager::get_results($wpdb->prepare($consultantSql, $hid));
$context['consultant'] = $consultant;
if($type == 'edit'){
if ($type == 'edit') {
$imagesSql = 'select * from a_house_image ahi
LEFT JOIN tospur_image ti on ti.id = ahi.image_id
where ahi.house_id = %d and ahi.image_id not in (select image_id from '.Config::A_DISTRICT_AREA_TABLE.' where house_id = %d);';
}else{
$imagesSql = 'select * from '.Config::TOSPUR_IMAGE_TABLE.' ti
LEFT JOIN '.Config::A_HOUSE_IMAGE_TABLE.' ahi on ti.id = ahi.image_id
where ahi.house_id = %d and ahi.image_id not in (select image_id from ' . Config::A_DISTRICT_AREA_TABLE . ' where house_id = %d);';
} else {
$imagesSql = 'select * from ' . Config::TOSPUR_IMAGE_TABLE . ' ti
LEFT JOIN ' . Config::A_HOUSE_IMAGE_TABLE . ' ahi on ti.id = ahi.image_id
WHERE ahi.house_id = %d order by image_type;';
}
$images = DBManager::get_results($wpdb->prepare($imagesSql,$hid,$hid));
foreach($images as $key => $value){
$images = DBManager::get_results($wpdb->prepare($imagesSql, $hid, $hid));
foreach ($images as $key => $value) {
$path = $value->path;
$value->path = Image::getImage($path,'big');
$context['normalImages'][]->path = Image::getImage($path,'normal');
$value->path = Image::getImage($path, 'big');
$context['normalImages'][]->path = Image::getImage($path, 'normal');
}
$context['images'] = $images;
return $context;
}
public static function searchHouseTag($houseId){
public static function searchHouseTag($houseId)
{
global $wpdb;
$sql = "select tt.name from ".Config::A_HOUSE_TAG_TABLE." aht
LEFT JOIN ".Config::TOSPUR_TAG_TABLE." tt on aht.tag_id = tt.id
$sql = "select tt.name from " . Config::A_HOUSE_TAG_TABLE . " aht
LEFT JOIN " . Config::TOSPUR_TAG_TABLE . " tt on aht.tag_id = tt.id
where aht.house_id = %d and type = 0;";
$results = DBManager::get_results($wpdb->prepare($sql,$houseId));
$results = DBManager::get_results($wpdb->prepare($sql, $houseId));
$tags = array();
foreach($results as $item){
$tags[] =$item->name;
foreach ($results as $item) {
$tags[] = $item->name;
}
return implode(",",$tags);
return implode(",", $tags);
}
public static function searchStatusType($statusType,$canShow = null,$currentStatus = null,$currentApproval = null){
public static function searchStatusType($statusType, $canShow = null, $currentStatus = null, $currentApproval = null)
{
global $wpdb;
$sql="select status_id as id,status_name as value from ".Config::TOSPUR_STATUS_TABLE." where status_type = %d ";
$sql = "select status_id as id,status_name as value from " . Config::TOSPUR_STATUS_TABLE . " where status_type = %d ";
//控制进入详细后可选的状态
if(isset($canShow)){
$sql .= " and canShow = ".$canShow;
if (isset($canShow)) {
$sql .= " and canShow = " . $canShow;
}
if(isset($currentStatus)){
if (isset($currentStatus)) {
//房源为无效时当置业顾问提交后,status变为未审核,approval为重激活,要使此类房源进去后状态仍只有重激活
if( $currentApproval == 5 && $currentStatus == 0 ){
if ($currentApproval == 5 && $currentStatus == 0) {
$sql .= " and status_id = 5";
}
//无效只显示重激活
if($currentStatus == 4){
if ($currentStatus == 4) {
$sql .= " and status_id = 5";
}
}
$results = DBManager::get_results($wpdb->prepare($sql,$statusType));
$results = DBManager::get_results($wpdb->prepare($sql, $statusType));
return $results;
}
public static function searchFeatureOld($hid, $type){
public static function searchFeatureOld($hid, $type)
{
global $wpdb;
$params[] = $hid;
$params[] = $type;
$featureSql ="select tag_id,name from a_house_tag aht
LEFT JOIN (select id as tid,name ,type from ".Config::TOSPUR_TAG_TABLE.") tt on aht.tag_id = tt.tid where aht.house_id = %d and tt.type = %d";
$feature = DBManager::get_results($wpdb->prepare($featureSql,$params));
$featureSql = "select tag_id,name from a_house_tag aht
LEFT JOIN (select id as tid,name ,type from " . Config::TOSPUR_TAG_TABLE . ") tt on aht.tag_id = tt.tid where aht.house_id = %d and tt.type = %d";
$feature = DBManager::get_results($wpdb->prepare($featureSql, $params));
return $feature;
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@
$context = array();
$context['theme'] = get_template_directory_uri();
require_once(WP_PLUGIN_DIR . "/tospur/Dao/SearchDao.php");
$default_city_id = get_option('default_city_id');
$cityId = ($default_city_id) ? $default_city_id : 2;
......@@ -27,11 +26,12 @@ $context['select']['plate'] = json_encode($plateArray);
$context['select']['buildProperty'] = SearchDao::searchBuildProperty();
$context['select']['room'] = json_encode(SearchDao::searchRoom());
$context['select']['feature'] = json_encode(SearchDao::searchTagOrFeature(1));
$context['select']['unitPriceRange'] = SearchDao::searchUnitPriceRange($cityId);
if ($houseType == 2) {
$context['select']['rentalPrice'] = SearchDao::searchRentalPrice($cityId);
} else {
if ($houseType == 0) {
$context['select']['unitPrice'] = SearchDao::searchUnitPriceRange($cityId);
} else if ($houseType == 1) {
$context['select']['totalPrice'] = SearchDao::searchTotalPrice($cityId);
} else {
$context['select']['rentalPrice'] = SearchDao::searchRentalPrice($cityId);
}
$context['select']['area'] = json_encode(SearchDao::searchArea($cityId));
......
......@@ -57,6 +57,7 @@
'</span></p></li>');
$('#carousel_indicator').append('<li/>');
});
sliderTap = true;
}
carousel.find("#carousel_scroller ul li").css({"width":carouselWidth});
......
......@@ -55,6 +55,7 @@
'</span></p></li>');
$('#carousel_indicator').append('<li/>');
});
sliderTap = true;
}
carousel.find("#carousel_scroller ul li").css({"width":carouselWidth});
......
......@@ -59,21 +59,30 @@
<div class="btn-group">
<a class="btn">价格<span></span></a>
<div id="price_wrapper" class="dropdown-menu">
{% if select.totalPrice %}
{% if select.unitPrice %}
<div type="unitPrice" id="unitPrice_scroller">
<a href="#" class="active">不限</a>
{% for item in select.unitPrice %}
<a data-id="{{item.value}}">{{item.value}}</a>
{% endfor %}
</div>
{% elseif select.totalPrice %}
<div type="totalPrice" id="totalPrice_scroller">
<a href="#" class="active">不限</a>
{% for item in select.totalPrice %}
<a data-id="{{item.value}}">{{item.value}}</a>
<a data-id="{{item.value}}">{{item.value}}</a>
{% endfor %}
</div>
{% endif %}
{% if select.rentalPrice %}
{% elseif select.rentalPrice %}
<div type="rentalPrice" id="rentalPrice_scroller">
<a href="#" class="active">不限</a>
{% for item in select.rentalPrice %}
<a data-id="{{item.value}}">{{item.value}}</a>
<a data-id="{{item.value}}">{{item.value}}</a>
{% endfor %}
</div>
{% else %}
<div id="price_scroller">
</div>
{% endif %}
</div>
</div>
......@@ -343,7 +352,11 @@
});
function searchNameAndAddress(){
searchData.index = 0;
searchData.searchText = $('#searchText').val();
var searchText = $('#searchText').val();
if (searchText.trim() == '') {
searchText = '';
}
searchData.searchText = searchText;
scroller.html('');
ajax_get_house('{{ url }}', loading, searchData, scroller);
}
......@@ -352,6 +365,7 @@
cityId: {{ cityId }},
districtId: -1,
plateId: -1,
unitPrice: -1,
totalPrice: -1,
rentalPrice: -1,
buildPropertyId: -1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment