Commit 7754a36b by shz

TospurDao

parent e2d78274
...@@ -141,30 +141,6 @@ class TospurDao ...@@ -141,30 +141,6 @@ class TospurDao
'where cityid = ' . $city_id . ' LIMIT ' . $index . ',20;'; 'where cityid = ' . $city_id . ' LIMIT ' . $index . ',20;';
return $wpdb->get_results($consultant_sql); return $wpdb->get_results($consultant_sql);
} }
public static function search_house_image($house_ids)
{
$string = '(' . implode(',', array_map('intval', $house_ids)) . ')';
$sql = 'select * from (select ahi.house_id,ti.path,ti.image_type,case ti.image_type ' .
'when 1 then 1 ' .
'when 5 then 1 ' .
'ELSE 2 ' .
'end as type from ' . Config::A_HOUSE_IMAGE_TABLE . ' ahi ' .
'left join ' . Config::TOSPUR_IMAGE_TABLE . ' ti on ahi.image_id = ti.id ' .
'where house_id in ' . $string . ' order by type) as image group by house_id;';
global $wpdb;
return $wpdb->get_results($sql);
}
public static function search_house_tag($house_ids)
{
$string = '(' . implode(',', array_map('intval', $house_ids)) . ')';
$sql = 'select aht.house_id,tt.name from ' . Config::A_HOUSE_TAG_TABLE . ' aht' .
' left join ' . Config::TOSPUR_TAG_TABLE . ' tt on aht.tag_id = tt.id' .
' where house_id in ' . $string;
global $wpdb;
return $wpdb->get_results($sql);
}
} }
?> ?>
\ No newline at end of file
...@@ -13,9 +13,10 @@ add_action('init', 'tospur_init'); ...@@ -13,9 +13,10 @@ add_action('init', 'tospur_init');
function tospur_init() function tospur_init()
{ {
require_once(PLUGIN_DIR . 'Config.php'); require_once(PLUGIN_DIR . 'Config.php');
require_once(PLUGIN_DIR . 'Tools/TCSync.php'); require_once(PLUGIN_DIR . 'Tools/TCSync.php');
require_once(PLUGIN_DIR . 'Tools/Image.php'); require_once(PLUGIN_DIR . 'Tools/Image.php');
require_once(PLUGIN_DIR . 'Dao/SearchDao.php'); require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
require_once(PLUGIN_DIR . 'Dao/TospurDao.php');
require_once(PLUGIN_DIR . 'Admin/House.php'); require_once(PLUGIN_DIR . 'Admin/House.php');
require_once(PLUGIN_DIR . 'Admin/newHouseList.php'); require_once(PLUGIN_DIR . 'Admin/newHouseList.php');
require_once(PLUGIN_DIR . 'Admin/secHandHouse.php'); require_once(PLUGIN_DIR . 'Admin/secHandHouse.php');
...@@ -111,7 +112,7 @@ function valid_consultant_score() ...@@ -111,7 +112,7 @@ function valid_consultant_score()
$score_id = $_POST['id']; $score_id = $_POST['id'];
$valid = $_POST['valid']; $valid = $_POST['valid'];
if (isset($score_id) && isset($valid)) { if (isset($score_id) && isset($valid)) {
$result = dao::update_consultant_score($score_id, $valid); $result = TospurDao::update_consultant_score($score_id, $valid);
$array = array(); $array = array();
if ($result) { if ($result) {
$array['code'] = 2000; $array['code'] = 2000;
...@@ -126,7 +127,7 @@ function update_consultant() ...@@ -126,7 +127,7 @@ function update_consultant()
$house_id = $_POST['id']; $house_id = $_POST['id'];
$consultant_id = $_POST['consultant_id']; $consultant_id = $_POST['consultant_id'];
if (isset($consultant_id) && isset($house_id)) { if (isset($consultant_id) && isset($house_id)) {
$result = dao::update_view_house_consultant($house_id, $consultant_id); $result = TospurDao::update_view_house_consultant($house_id, $consultant_id);
$array = array(); $array = array();
if ($result) { if ($result) {
$array['code'] = 2000; $array['code'] = 2000;
......
<?php
require_once('const.php');
class dao
{
//insert 预约看房
public static function insert_view_house($house_id, $user_id, $date, $index, $time, $consultant_id)
{
$insert_view_house_array = array(
'house_id' => $house_id,
'user_id' => $user_id,
'date' => $date,
'time_index' => $index,
'time' => $time,
'consultant_id' => $consultant_id,
'handle' => 0
);
global $wpdb;
$result = $wpdb->insert(tospur_view_house_table, $insert_view_house_array);
return $result;
}
public static function update_view_house($id)
{
global $wpdb;
$result = $wpdb->update(tospur_view_house_table, array(
'handle' => 1,
'handle_date' => current_time('Y-m-d H:i:s')
), array(
'id' => $id
));
return $result;
}
public static function update_view_house_consultant($house_id, $consultant_id)
{
global $wpdb;
$result = $wpdb->update(tospur_view_house_table, array(
'consultant_id' => $consultant_id
), array(
'id' => $house_id
));
return $result;
}
//search 预约看房 user_id
public static function search_view_house_by_user_id($user_id)
{
global $wpdb;
$sql = 'select v.house_id,v.date,v.time,v.consultant_id,v.handle,h.name from ' . tospur_view_house_table . ' v ' .
'left join ' . tospur_house_table . ' h on v.house_id = h.id ' .
'where v.user_id = ' . $user_id . ' order by v.date desc';
return $wpdb->get_results($sql);
}
//search 预约看房 consultant_id
public static function search_view_house_by_consultant_id($consultant_id)
{
global $wpdb;
$sql = 'select v.id,v.house_id,v.date,v.time,v.user_id,v.handle,h.name from ' . tospur_view_house_table . ' v ' .
'left join ' . tospur_house_table . ' h on v.house_id = h.id ' .
'where v.consultant_id = ' . $consultant_id . ' order by v.date desc';
return $wpdb->get_results($sql);
}
//insert 置业顾问评分
public static function insert_consultant_score($consultant_id, $user_id, $score, $valid = 1)
{
$insert_consultant_score_array = array(
'consultant_id' => $consultant_id,
'user_id' => $user_id,
'score' => $score,
'valid' => $valid
);
global $wpdb;
$result = $wpdb->insert(tospur_consultant_score_table, $insert_consultant_score_array);
return $result;
}
//search 置业顾问信息
public static function search_consultant_info($consultant_id)
{
global $wpdb;
$sql = 'select c.*,u.display_name,s.average_score from ' . tospur_consultant_table . ' c ' .
'left join ' . wp_users_table . ' u on c.id = u.ID ' .
'left join (select consultant_id,sum(score)/count(score) as average_score from ' . tospur_consultant_score_table . ' group by consultant_id) s ' .
'on c.id = s.consultant_id where c.id = ' . $consultant_id;
return $wpdb->get_row($sql);
}
public static function update_consultant_score($score_id, $valid)
{
global $wpdb;
$result = $wpdb->update(tospur_consultant_score_table, array(
'valid' => $valid
), array(
'id' => $score_id
));
return $result;
}
public static function search_tospur_verify($phone, $code)
{
global $wpdb;
$sql = 'select code from ' . tospur_verify_table . ' where phone = ' . $phone . ' and status = 0 ' .
'and create_time > NOW() - INTERVAL 30 MINUTE ' .
'order by create_time desc limit 1';
return $wpdb->get_var($sql);
}
public static function insert_tospur_verify($phone, $code)
{
$insert_tospur_verify_array = array(
'phone' => $phone,
'code' => $code,
'create_time' => current_time('Y-m-d H:i:s'),
'status' => 0
);
global $wpdb;
$result = $wpdb->insert(tospur_verify_table, $insert_tospur_verify_array);
return $result;
}
public static function update_tospur_verify($phone)
{
global $wpdb;
$wpdb->update(tospur_verify_table, array(
'status' => 1
), array(
'phone' => $phone
));
}
public static function search_consultant_by_city($city_id, $index)
{
global $wpdb;
$consultant_sql = 'select c.*,u.display_name,s.average_score from ' . tospur_consultant_table . ' c ' .
'left join ' . wp_users_table . ' u on c.id = u.ID ' .
'left join (select consultant_id,sum(score)/count(score) as average_score from ' . tospur_consultant_score_table . ' where valid=1 group by consultant_id) s on c.id = s.consultant_id ' .
'where cityid = ' . $city_id . ' LIMIT ' . $index . ',20;';
return $wpdb->get_results($consultant_sql);
}
public static function search_house_image($house_ids)
{
$string = '(' . implode(',', array_map('intval', $house_ids)) . ')';
$sql = 'select * from (select ahi.house_id,ti.path,ti.image_type,case ti.image_type ' .
'when 1 then 1 ' .
'when 5 then 1 ' .
'ELSE 2 ' .
'end as type from ' . a_house_image_table . ' ahi ' .
'left join ' . tospur_image_table . ' ti on ahi.image_id = ti.id ' .
'where house_id in ' . $string . ' order by type) as image group by house_id;';
global $wpdb;
return $wpdb->get_results($sql);
}
public static function search_house_tag($house_ids)
{
$string = '(' . implode(',', array_map('intval', $house_ids)) . ')';
$sql = 'select aht.house_id,tt.name from ' . a_house_tag_table . ' aht' .
' left join ' . tospur_tag_table . ' tt on aht.tag_id = tt.id' .
' where house_id in ' . $string;
global $wpdb;
return $wpdb->get_results($sql);
}
}
?>
\ No newline at end of file
...@@ -14,10 +14,10 @@ if ($_POST) { ...@@ -14,10 +14,10 @@ if ($_POST) {
} else if (!$password) { } else if (!$password) {
$context['error'] = '请输入新密码'; $context['error'] = '请输入新密码';
} else { } else {
$search_code = dao::search_tospur_verify($phone, $code); $search_code = TospurDao::search_tospur_verify($phone, $code);
if ($code == $search_code) { if ($code == $search_code) {
wp_set_password($password, $user->data->ID); wp_set_password($password, $user->data->ID);
dao::update_tospur_verify($phone); TospurDao::update_tospur_verify($phone);
$context['error'] = '成功修改密码'; $context['error'] = '成功修改密码';
} else { } else {
$context['error'] = '验证码错误'; $context['error'] = '验证码错误';
......
<?php <?php
require_once(dirname(__FILE__) . '/dao.php'); require_once(dirname(__FILE__) . '/../../plugins/tospur/Dao/TospurDao.php');
require_once(dirname(__FILE__) . '/../../plugins/tospur/Dao/SearchDao.php'); require_once(dirname(__FILE__) . '/../../plugins/tospur/Dao/SearchDao.php');
require_once(dirname(__FILE__) . '/../../plugins/tospur/Tools/Image.php'); require_once(dirname(__FILE__) . '/../../plugins/tospur/Tools/Image.php');
...@@ -35,9 +35,6 @@ function page_template($template) ...@@ -35,9 +35,6 @@ function page_template($template)
case 'consultant_list': case 'consultant_list':
$page = $theme . '/consultant_list.php'; $page = $theme . '/consultant_list.php';
break; break;
case 'score':
$page = $theme . '/score.php';
break;
case 'comment': case 'comment':
$page = $theme . '/comment.php'; $page = $theme . '/comment.php';
break; break;
...@@ -56,6 +53,9 @@ function page_template($template) ...@@ -56,6 +53,9 @@ function page_template($template)
case 'manager': case 'manager':
$page = $theme . '/manager.php'; $page = $theme . '/manager.php';
break; break;
case 'sale':
$page = $theme . '/sale.php';
break;
} }
return $page; return $page;
} else { } else {
...@@ -88,7 +88,7 @@ function send_code() ...@@ -88,7 +88,7 @@ function send_code()
$array['code'] = 2002; $array['code'] = 2002;
} else { } else {
$code = generate_code(); $code = generate_code();
$insert_result = dao::insert_tospur_verify($phone, strtolower($code)); $insert_result = TospurDao::insert_tospur_verify($phone, strtolower($code));
$response = wp_remote_post('http://218.1.67.130:8988/api/NanTongWechat/MobileSendMessage' . $response = wp_remote_post('http://218.1.67.130:8988/api/NanTongWechat/MobileSendMessage' .
'?mobilePhone=' . $phone . '&VerificationCode=' . $code '?mobilePhone=' . $phone . '&VerificationCode=' . $code
); );
...@@ -117,7 +117,7 @@ function view_house() ...@@ -117,7 +117,7 @@ function view_house()
$date = $_POST['date']; $date = $_POST['date'];
} }
$time = (9 + $index) . ':00-' . (10 + $index) . ':00'; $time = (9 + $index) . ':00-' . (10 + $index) . ':00';
$result = dao::insert_view_house($_POST['house_id'], $_POST['user_id'], $date, $index, $time, $_POST['consultant_id']); $result = TospurDao::insert_view_house($_POST['house_id'], $_POST['user_id'], $date, $index, $time, $_POST['consultant_id']);
$array = array(); $array = array();
if ($result) { if ($result) {
$array['code'] = 2000; $array['code'] = 2000;
...@@ -134,7 +134,7 @@ function handle_view_house() ...@@ -134,7 +134,7 @@ function handle_view_house()
{ {
$id = $_POST['id']; $id = $_POST['id'];
if (isset($id)) { if (isset($id)) {
$result = dao::update_view_house($id); $result = TospurDao::update_view_house($id);
$array = array(); $array = array();
if ($result) { if ($result) {
$array['code'] = 2000; $array['code'] = 2000;
...@@ -150,7 +150,7 @@ add_action('wp_ajax_add_score', 'add_consultant_score'); ...@@ -150,7 +150,7 @@ add_action('wp_ajax_add_score', 'add_consultant_score');
function add_consultant_score() function add_consultant_score()
{ {
if (isset($_POST['score'])) { if (isset($_POST['score'])) {
$result = dao::insert_consultant_score($_POST['consultant_id'], $_POST['user_id'], $_POST['score']); $result = TospurDao::insert_consultant_score($_POST['consultant_id'], $_POST['user_id'], $_POST['score']);
$array = array(); $array = array();
if ($result) { if ($result) {
$array['code'] = 2000; $array['code'] = 2000;
...@@ -164,14 +164,14 @@ function add_consultant_score() ...@@ -164,14 +164,14 @@ function add_consultant_score()
//置业顾问信息 //置业顾问信息
function get_consultant_info($consultant_id) function get_consultant_info($consultant_id)
{ {
return dao::search_consultant_info($consultant_id); return TospurDao::search_consultant_info($consultant_id);
} }
add_action('wp_ajax_get_consultant', 'get_consultant'); add_action('wp_ajax_get_consultant', 'get_consultant');
function get_consultant() function get_consultant()
{ {
if (isset($_POST['city_id']) && isset($_POST['index'])) { if (isset($_POST['city_id']) && isset($_POST['index'])) {
$result = dao::search_consultant_by_city($_POST['city_id'], $_POST['index']); $result = TospurDao::search_consultant_by_city($_POST['city_id'], $_POST['index']);
$array = array(); $array = array();
if ($result) { if ($result) {
$array['code'] = 2000; $array['code'] = 2000;
......
<?php <?php
require_once(dirname(__FILE__) . '/dao.php');
$context = array(); $context = array();
$context['theme'] = get_template_directory_uri(); $context['theme'] = get_template_directory_uri();
$context['url'] = home_url(); $context['url'] = home_url();
...@@ -12,10 +11,10 @@ if ($current_user_id != 0) { ...@@ -12,10 +11,10 @@ if ($current_user_id != 0) {
$result = null; $result = null;
switch ($role) { switch ($role) {
case 'subscriber': case 'subscriber':
$result = dao::search_view_house_by_user_id($current_user_id); $result = TospurDao::search_view_house_by_user_id($current_user_id);
break; break;
case 'editor': case 'editor':
$result = dao::search_view_house_by_consultant_id($current_user_id); $result = TospurDao::search_view_house_by_consultant_id($current_user_id);
break; break;
} }
if ($result) { if ($result) {
......
...@@ -15,11 +15,11 @@ if ($_POST) { ...@@ -15,11 +15,11 @@ if ($_POST) {
} else if (!$password) { } else if (!$password) {
$context['error'] = '请输入密码'; $context['error'] = '请输入密码';
} else { } else {
$search_code = dao::search_tospur_verify($phone, $code); $search_code = TospurDao::search_tospur_verify($phone, $code);
if ($code == $search_code) { if ($code == $search_code) {
$result = wp_create_user($phone, $password); $result = wp_create_user($phone, $password);
if (is_integer($result)) { if (is_integer($result)) {
dao::update_tospur_verify($phone); TospurDao::update_tospur_verify($phone);
$creds['user_login'] = $phone; $creds['user_login'] = $phone;
$creds['user_password'] = $password; $creds['user_password'] = $password;
$creds['remember'] = true; $creds['remember'] = true;
......
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