Commit 4aa30a4b by felix

合并用

parent 4be24ca1
<?php <?php
require_once(PLUGIN_DIR . 'Dao/SearchDao.php');
class House { class House {
public static function init_view(){ public static function init_view(){
wp_enqueue_script('jquery-ui'); wp_enqueue_script('jquery-ui');
...@@ -11,33 +12,10 @@ class House { ...@@ -11,33 +12,10 @@ class House {
}else{ }else{
global $wpdb; global $wpdb;
$context = array(); $context = array();
$citysql ="select DISTINCT cityId,cityName from"; $context["city"] = SearchDao::searchCity();
$cityRes = $wpdb->get_results($citysql.' dic_city'); $context["buildProperty"] = SearchDao::searchBuildProperty();
foreach($cityRes as $value){ $context["room"] = SearchDao::searchRoom();
$cityParams = array( $context["photoType"] = SearchDao::searchPhotoType();
"cityId" => $value->cityId,
"cityName" => $value->cityName
);
$context["city"][] = $cityParams;
}
$sql = "select * from";
$buildpropertyRes = $wpdb->get_results($sql.' dic_buildproperty');
foreach($buildpropertyRes as $v){
$buildpropertyParams = array(
"value" => $v->value,
"literal" => $v->literal
);
$context["buildproperty"] []= $buildpropertyParams;
}
$buildpropertyRes = $wpdb->get_results($sql.' dic_room');
foreach($buildpropertyRes as $v){
$roomParams = array(
"value" => $v->value,
"literal" => $v->literal
);
$context["room"] []= $roomParams;
}
House::data_insert(); House::data_insert();
Timber::render("newhouse.html",$context); Timber::render("newhouse.html",$context);
} }
...@@ -70,79 +48,82 @@ class House { ...@@ -70,79 +48,82 @@ class House {
'parking_spaces' => $_POST['parking_spaces'], 'parking_spaces' => $_POST['parking_spaces'],
'property_management' => $_POST['property_management'], 'property_management' => $_POST['property_management'],
'overview' => $_POST['overview'], 'overview' => $_POST['overview'],
'plate_id'=>$_POST["basePlateId"], 'city_id' => $_POST['baseCity'],
"room_id"=>$_POST["baseRoom"], 'district_id' => $_POST['baseAreaId'],
"property_money" =>$_POST["property_money"], 'plate_id' => $_POST["basePlateId"],
'creattime'=>date("Y-m-d H:i:s") "room_id" => $_POST["baseRoom"],
"property_money" => $_POST["property_money"],
'creattime' => date("Y-m-d H:i:s"),
'user_id' => get_current_user_id()
); );
$res = $wpdb->get_results( 'SELECT * FROM tospur_house WHERE name="'.$_POST['name'].'" and address="'.$_POST['address'].'"', OBJECT ); $res = $wpdb->get_results('SELECT * FROM tospur_house WHERE name="' . $_POST['name'] . '" and address="' . $_POST['address'] . '"', OBJECT);
if(!$res){ if (!$res) {
$houseRes = $wpdb->insert('tospur_house', $insert_tospur_house_array); $houseRes = $wpdb->insert('tospur_house', $insert_tospur_house_array);
if(!$houseRes){ if (!$houseRes) {
return 500; return 500;
} }
$houseid = $wpdb->insert_id; $houseid = $wpdb->insert_id;
} }
for ($x=0; $x<=count($uploadedfile["name"])-1; $x++) { //主力房源的图片与房子信息关联插入数据库
foreach($uploadedfile["name"] as $key=> $value) {
$uploadParam = array( $uploadParam = array(
"name"=>$uploadedfile["name"]["$x"], "name" => $uploadedfile["name"][$key],
"type"=>$uploadedfile["type"]["$x"], "type" => $uploadedfile["type"][$key],
"tmp_name"=>$uploadedfile["tmp_name"]["$x"], "tmp_name" => $uploadedfile["tmp_name"][$key],
"error"=>$uploadedfile["error"]["$x"], "error" => $uploadedfile["error"][$key],
"size"=>$uploadedfile["size"]["$x"] "size" => $uploadedfile["size"][$key]
); );
//因为file提交过来有一个空的数组,所以这里判断在filename不为空的情况下,再做后续操作 //因为file提交过来有一个空的数组,所以这里判断在filename不为空的情况下,再做后续操作
if($uploadParam["name"]!=""){ if ($uploadParam["name"] != "") {
//从wp_options中获取地址域名
$results = $wpdb->get_row( 'SELECT * FROM wp_options WHERE option_name = "home"', OBJECT );
$patharray = explode("/", $results->option_value);
$path = "/".$patharray[3]."/wp-content/uploads/2015/08/".$uploadParam['name'];
//上传图片 //上传图片
if (!function_exists('wp_handle_upload')){ if (!function_exists('wp_handle_upload')) {
require_once(ABSPATH.'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/file.php');
} }
$overrides = array( 'test_form' => false); $overrides = array('test_form' => false);
$movefile = wp_handle_upload($uploadParam,$overrides); $movefile = wp_handle_upload($uploadParam, $overrides);
if ( $movefile && !isset( $movefile['error'] ) ) { $str = preg_replace('#^https?://#', '', $movefile["url"]);
$length = strpos($str, "/",strpos($str, "/")+1);
$url = substr($str,$length);
if ($movefile && !isset($movefile['error'])) {
//上传成功后将图片信息存入tospur_image表 //上传成功后将图片信息存入tospur_image表
$insert_image_array = array( $insert_image_array = array(
'name' => $uploadParam['name'], 'name' => $uploadParam["name"],
'path' => $path, 'path' => $url,
'creattime' => date("Y-m-d H:i:s"), 'creattime' => date("Y-m-d H:i:s"),
'alt' => "", 'alt' => "",
'image_type' =>$uploadParam['type'] 'image_type' =>$data[$key]["type"]
); );
//插入图片表 //插入图片表
$imgRes = $wpdb->insert('tospur_image', $insert_image_array); $imgRes = $wpdb->insert('tospur_image', $insert_image_array);
if(!$imgRes){ if (!$imgRes) {
return 501; return 501;
} }
//获取插入图片的id //获取插入图片的id
$imgid = $wpdb->insert_id; $imgid = $wpdb->insert_id;
//echo "File is valid, and was successfully uploaded.\n"; //房源类型、面积与图片关联表
if($data[$key]["type"] == "0"){
$houseTypeArea = array(
'house_id' => $houseid,
"buildproperty_id" => $data["$key"]["buildProperty"],
"house_area" => $data["$key"]["housearea"],
"image_id" => $imgid
);
$houseTypeAreaRes = $wpdb->insert('a_district_area', $houseTypeArea);
if (!$houseTypeAreaRes) {
return 502;
}
}
//将房源id与图片id储存到关联表中
$house_img_array = array(
'house_id' => $houseid,
'image_id' => $imgid,
);
$houseImgRes = $wpdb->insert('a_house_image', $house_img_array);
if (!$houseImgRes) {
return 503;
}
} else { } else {
echo $movefile['error']; return $movefile['error'];
}
//房源类型、面积与图片关联表
$houseTypeArea = array(
'house_id' =>$houseid,
"buildproperty_id" => $data["$x"]["buildproperty"],
"house_area" => $data["$x"]["housearea"],
"image_id" =>$imgid
);
$houseTypeAreaRes = $wpdb->insert('a_district_area', $houseTypeArea);
if(!$houseTypeAreaRes){
return 502;
}
//将房源id与图片id储存到关联表中
$house_img_array = array(
'house_id' =>$houseid,
'image_id'=>$imgid
);
$houseImgRes = $wpdb->insert('a_house_image', $house_img_array);
if(!$houseImgRes){
return 503;
} }
} }
} }
......
<?php
class Config {
//table name
const DIC_CITY_TABLE = 'dic_city';
const DIC_ROOM_TABLE = 'dic_room';
const DIC_BUILDPROPERTY_TABLE = 'dic_buildproperty';
const DIC_AREA_TABLE = 'dic_area';
const DIC_UNITPRICERANGE_TABLE = 'dic_unitpricerange';
const DIC_TOTALPRICE_TABLE = 'dic_totalprice';
const DIC_PHOTOTYPE_TABLE = "dic_phototype";
const TOSPUR_ORGANIZATION_TABLE = 'tospur_organization';
const TOSPUR_CONSULTANT = 'tospur_consultant';
//sync url
const user_url = 'http://218.1.67.130:8988/api/NanTongWechat/GetPropertyConsultant?cityId=1';
const other_url = 'http://218.1.67.130:8988/api/NanTongWechat/GetCommonPlate?radomPla=123456';
const organization_url = 'http://218.1.67.130:8988/api/NanTongWechat/GetOrgnaziTion?radomOrg=123456';
}
\ No newline at end of file
<?php <?php
class SearchDao{ class SearchDao{
public function __construct() {
require_once(PLUGIN_DIR . '\TCSync.php');
}
public static function ajax_serachCity(){ public static function ajax_serachCity(){
wp_send_json(SearchDao::searchCity($_GET["cityId"],$_GET['districtId'])); wp_send_json(SearchDao::searchCity($_GET["cityId"],$_GET['districtId']));
} }
...@@ -26,7 +22,7 @@ class SearchDao{ ...@@ -26,7 +22,7 @@ class SearchDao{
$params[] = $districtId; $params[] = $districtId;
$groupBy = ""; $groupBy = "";
} }
$result = $wpdb->get_results($wpdb->prepare('select '.$selectName.' from '.TCSync::DIC_CITY_TABLE.$where.$groupBy,$params)); $result = $wpdb->get_results($wpdb->prepare('select '.$selectName.' from '.Config::DIC_CITY_TABLE.$where.$groupBy,$params));
return $result; return $result;
} }
...@@ -40,7 +36,7 @@ class SearchDao{ ...@@ -40,7 +36,7 @@ class SearchDao{
if(isset($_GET['cityId'])){ if(isset($_GET['cityId'])){
$where .= " and cityId = %d"; $where .= " and cityId = %d";
} }
$result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from '.TCSync::DIC_AREA_TABLE.$where,$cityId)); $result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from '.Config::DIC_AREA_TABLE.$where,$cityId));
return $result; return $result;
} }
...@@ -50,7 +46,7 @@ class SearchDao{ ...@@ -50,7 +46,7 @@ class SearchDao{
public static function searchBuildProperty(){ public static function searchBuildProperty(){
global $wpdb; global $wpdb;
$result = $wpdb->get_results('select value as id,literal as value from '.TCSync::DIC_BUILDPROPERTY_TABLE); $result = $wpdb->get_results('select value as id,literal as value from '.Config::DIC_BUILDPROPERTY_TABLE);
return $result; return $result;
} }
...@@ -60,7 +56,7 @@ class SearchDao{ ...@@ -60,7 +56,7 @@ class SearchDao{
public static function searchRoom(){ public static function searchRoom(){
global $wpdb; global $wpdb;
$result = $wpdb->get_results('select value as id,literal as value from '.TCSync::DIC_ROOM_TABLE); $result = $wpdb->get_results('select value as id,literal as value from '.Config::DIC_ROOM_TABLE);
return $result; return $result;
} }
...@@ -74,7 +70,7 @@ class SearchDao{ ...@@ -74,7 +70,7 @@ class SearchDao{
if(isset($_GET['cityId'])){ if(isset($_GET['cityId'])){
$where .= " and cityId = %d"; $where .= " and cityId = %d";
} }
$result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from '.TCSync::DIC_UNITPRICERANGE_TABLE.$where,$cityId)); $result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from '.Config::DIC_UNITPRICERANGE_TABLE.$where,$cityId));
return $result; return $result;
} }
...@@ -88,7 +84,7 @@ class SearchDao{ ...@@ -88,7 +84,7 @@ class SearchDao{
if(isset($_GET['cityId'])){ if(isset($_GET['cityId'])){
$where .= " and cityId = ".$cityId; $where .= " and cityId = ".$cityId;
} }
$result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from '.TCSync::DIC_TOTALPRICE_TABLE.$where,$cityId)); $result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from '.Config::DIC_TOTALPRICE_TABLE.$where,$cityId));
return $result; return $result;
} }
...@@ -102,13 +98,13 @@ class SearchDao{ ...@@ -102,13 +98,13 @@ class SearchDao{
if($parentId != NULL){ if($parentId != NULL){
$where .= " and ParentId =".$parentId; $where .= " and ParentId =".$parentId;
} }
$result = $wpdb->get_results($wpdb->prepare('select Id as id,Name as name from '.TCSync::TOSPUR_ORGANIZATION_TABLE.$where,$parentId)); $result = $wpdb->get_results($wpdb->prepare('select Id as id,Name as name from '.Config::TOSPUR_ORGANIZATION_TABLE.$where,$parentId));
return $result; return $result;
} }
public static function getCityNameWithId($cityId){ public static function getCityNameWithId($cityId){
global $wpdb; global $wpdb;
$result = $wpdb->get_var($wpdb->prepare("select cityName from ".TCSync::DIC_CITY_TABLE." where cityId = %d",$cityId)); $result = $wpdb->get_var($wpdb->prepare("select cityName from ".Config::DIC_CITY_TABLE." where cityId = %d",$cityId));
if($result){ if($result){
return $result; return $result;
}else{ }else{
...@@ -120,51 +116,64 @@ class SearchDao{ ...@@ -120,51 +116,64 @@ class SearchDao{
wp_send_json(SearchDao::searchHouse($_GET["cityId"],$_GET["districtId"],$_GET["plateId"],$_GET["buildPropertyId"],$_GET["roomId"],$_GET["acreage"],$_GET["totalPrice"],$_GET["searchText"])); wp_send_json(SearchDao::searchHouse($_GET["cityId"],$_GET["districtId"],$_GET["plateId"],$_GET["buildPropertyId"],$_GET["roomId"],$_GET["acreage"],$_GET["totalPrice"],$_GET["searchText"]));
} }
public static function searchHouse($cityId = NULL,$districtId = NULL,$plateId = NULL,$buildpropertyId = NULL,$roomId = NULL,$acreage = NULL,$totalPrice = NULL,$searchText = NULL){ public static function searchHouse($cityId = 0,$districtId = 0,$plateId = 0,$buildPropertyId = 0,$roomId = 0,$acreage = 0,$totalPrice = 0,$searchText = NULL){
global $wpdb; global $wpdb;
if($acreage == "面积"){ $params = array();
$acreage = null;
}
if($totalPrice == "价格"){
$totalPrice = null;
}
$areaArray = explode("-",$acreage);
$priceArray = explode("-",$totalPrice);
$sql = "select * from tospur_house th $sql = "select * from tospur_house th
left join (select buildproperty_id,house_area,image_id,house_id as bph_id from a_district_area) ada on th.id = ada.bph_id left join (select buildproperty_id,house_area,image_id,house_id as bph_id from a_district_area) ada on th.id = ada.bph_id
left join dic_city dc on th.plate_id = dc.plateId left join dic_city dc on th.plate_id = dc.plateId
left join (select * from a_house_image group by house_id) hi on th.id = hi.house_id left join (select * from a_house_image group by house_id) hi on th.id = hi.house_id
left join (select id,name as iname,path,creattime as itime,alt,image_type from tospur_image) i on hi.image_id = i.id where 1=1"; left join (select id,name as iname,path,creattime as itime,alt,image_type from tospur_image) i on hi.image_id = i.id where 1=1";
if($cityId!=NULL ){ if($cityId!=0 ){
$sql = $sql." and cityId=".$cityId; $params[] = $cityId;
$sql = $sql." and cityId=%d";
} }
if($districtId != NULL ){ if($districtId != 0 ){
$sql = $sql." and districtId=".$districtId; $params[] = $districtId;
$sql = $sql." and districtId=%d";
} }
if($plateId != NULL){ if($plateId != 0){
$sql = $sql." and plateId=".$plateId; $params[] = $plateId;
$sql = $sql." and plateId=%d";
} }
if($buildpropertyId!=NULL){ if( $buildPropertyId != 0){
$sql = $sql." and buildproperty_id=".$buildpropertyId; $params[] = $buildPropertyId;
$sql = $sql." and buildproperty_id=%d";
} }
if($roomId!=NULL){ if($roomId!=0){
$sql = $sql." and room_id=".$roomId; $params[] = $roomId;
$sql = $sql." and room_id=%d";
} }
if($acreage!=NULL){ if($acreage!=0){
$sql = $sql." and covered_area between ". $areaArray[0]." and ". $areaArray[1]; $areaArray = explode("-",$acreage);
$params[] = $areaArray[0];
$params[] = $areaArray[1];
$sql = $sql." and covered_area between %d and %d";
} }
if($totalPrice!=NULL){ if($totalPrice!=0){
$sql = $sql." and total_price between ". $priceArray[0]." and ". $priceArray[1]; $priceArray = explode("-",$totalPrice);
$params[] = $priceArray[0];
$params[] = $priceArray[1];
$sql = $sql." and total_price between %d and %d";
} }
if($searchText!=NULL){ if($searchText!=0){
$sql = $sql." and name like '%".$searchText."%'"; $params[] = "%".$searchText."%";
$sql = $sql." and name like %s";
} }
$sql = $sql." group by bph_id order by th.creattime DESC"; $sql = $sql." group by bph_id order by th.creattime DESC";
$result = $wpdb->get_results($sql); print_r($wpdb->prepare($sql,$params));
$result = $wpdb->get_results($wpdb->prepare($sql,$params));
return $result; return $result;
} }
public static function getWorkUser(){
public static function ajax_searchPhotoType(){
wp_send_json(SearchDao::searchPhotoType());
}
public static function searchPhotoType(){
global $wpdb;
$result = $wpdb->get_results('select id,photo_name as value from '.Config::DIC_PHOTOTYPE_TABLE);
return $result;
} }
} }
\ No newline at end of file
<?php
class TCSync {
const user_url = 'http://218.1.67.130:8988/api/NanTongWechat/GetPropertyConsultant?cityId=1';
public static function user_sync(){
$response = wp_remote_post( TCSync::user_url );
$res = array(
'code' => 200,
'msg' => "success"
);
//判断请求是否成功
if( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ){
$res['code'] = 500;
$res['msg'] = "get user info error";
}else{
set_time_limit(0) ;
//获取请求内容
$result = wp_remote_retrieve_body( $response );
$result = json_decode($result,true);
foreach($result['data'] as $item){
if(username_exists($item['WorkNum'])){
$user = get_user_by( "login", $item['WorkNum'] );
$userdata = array(
'ID' => $user->data->ID,
'display_name' => $item['Name']
);
$user_id = wp_update_user( $userdata ) ;
}else{
$userdata = array(
'user_login' => $item['WorkNum'],
'user_pass' => $item['WorkNumAndID'], // When creating an user, `user_pass` is expected.
'role' => 'editor',
'wp_user_level' => 7,
'display_name' => $item['Name']
);
$user_id = wp_insert_user( $userdata ) ;
}
if(is_numeric($user_id) && !is_null($item['ImageUrl'])){
update_user_meta( $user_id, "tc_image", $item['ImageUrl'] );
}
}
}
return $res;
}
}
\ No newline at end of file
<?php <?php
require_once(PLUGIN_DIR . 'Config.php');
class TCSync { class TCSync {
const user_url = 'http://218.1.67.130:8988/api/NanTongWechat/GetPropertyConsultant?cityId=1';
const other_url = 'http://218.1.67.130:8988/api/NanTongWechat/GetCommonPlate?radomPla=123456';
const organization_url = 'http://218.1.67.130:8988/api/NanTongWechat/GetOrgnaziTion?radomOrg=123456';
const DIC_CITY_TABLE = 'dic_city';
const DIC_ROOM_TABLE = 'dic_room';
const DIC_BUILDPROPERTY_TABLE = 'dic_buildproperty';
const DIC_AREA_TABLE = 'dic_area';
const DIC_UNITPRICERANGE_TABLE = 'dic_unitpricerange';
const DIC_TOTALPRICE_TABLE = 'dic_totalprice';
const TOSPUR_ORGANIZATION_TABLE = 'tospur_organization';
const TOSPUR_CONSULTANT = 'tospur_consultant';
public static function user_sync(){ public static function user_sync(){
global $wpdb; global $wpdb;
$response = wp_remote_post( TCSync::user_url ); $response = wp_remote_post( Config::user_url );
$res = array( $res = array(
'code' => 200, 'code' => 200,
'msg' => "success" 'msg' => "success"
...@@ -55,7 +43,7 @@ class TCSync { ...@@ -55,7 +43,7 @@ class TCSync {
'mobile' => $item['Mobile'], 'mobile' => $item['Mobile'],
'name' => $item['Name'] 'name' => $item['Name']
); );
$wpdb->query(TCSync::create_insert_update_sql(TCSync::TOSPUR_CONSULTANT,$info,array('id'))); $wpdb->query(TCSync::create_insert_update_sql(Config::TOSPUR_CONSULTANT,$info,array('id')));
} }
} }
} }
...@@ -64,7 +52,7 @@ class TCSync { ...@@ -64,7 +52,7 @@ class TCSync {
public static function other_sync(){ public static function other_sync(){
global $wpdb; global $wpdb;
$response = wp_remote_post( TCSync::other_url ); $response = wp_remote_post( Config::other_url );
$res = array( $res = array(
'code' => 200, 'code' => 200,
'msg' => "success" 'msg' => "success"
...@@ -80,33 +68,33 @@ class TCSync { ...@@ -80,33 +68,33 @@ class TCSync {
$result = json_decode($result,true); $result = json_decode($result,true);
//print_r($result['data']['CityList']); //print_r($result['data']['CityList']);
foreach($result['data']['CityList'] as $item){ foreach($result['data']['CityList'] as $item){
$wpdb->query(TCSync::create_insert_update_sql(TCSync::DIC_CITY_TABLE,$item,array('plateId'))); $wpdb->query(TCSync::create_insert_update_sql(Config::DIC_CITY_TABLE,$item,array('plateId')));
//print_r(TCSync::create_insert_update_sql(TCSync::CITY_TABLE,$item,array('plateId')));print_r("<br />"); //print_r(TCSync::create_insert_update_sql(Config::CITY_TABLE,$item,array('plateId')));print_r("<br />");
} }
foreach($result['data']['RoomStyle'] as $item){ foreach($result['data']['RoomStyle'] as $item){
$wpdb->query(TCSync::create_insert_update_sql(TCSync::DIC_ROOM_TABLE,$item,array('id'))); $wpdb->query(TCSync::create_insert_update_sql(Config::DIC_ROOM_TABLE,$item,array('id')));
//print_r(TCSync::create_insert_update_sql(TCSync::DIC_ROOM_TABLE,$item,array('id')));print_r("<br />"); //print_r(TCSync::create_insert_update_sql(Config::DIC_ROOM_TABLE,$item,array('id')));print_r("<br />");
} }
foreach($result['data']['BulidProperty'] as $item){ foreach($result['data']['BulidProperty'] as $item){
$wpdb->query(TCSync::create_insert_update_sql(TCSync::DIC_BUILDPROPERTY_TABLE,$item,array('id'))); $wpdb->query(TCSync::create_insert_update_sql(Config::DIC_BUILDPROPERTY_TABLE,$item,array('id')));
//print_r(TCSync::create_insert_update_sql(TCSync::DIC_BUILDPROPERTY_TABLE,$item,array('id')));print_r("<br />"); //print_r(TCSync::create_insert_update_sql(Config::DIC_BUILDPROPERTY_TABLE,$item,array('id')));print_r("<br />");
} }
foreach($result['data']['AreaRange'] as $item){ foreach($result['data']['AreaRange'] as $item){
$wpdb->query(TCSync::create_insert_update_sql(TCSync::DIC_AREA_TABLE,$item,array('id'),array('maxValue'=>'max','minValue'=>'min'))); $wpdb->query(TCSync::create_insert_update_sql(Config::DIC_AREA_TABLE,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));
//print_r(TCSync::create_insert_update_sql(TCSync::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />"); //print_r(TCSync::create_insert_update_sql(Config::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
} }
foreach($result['data']['TotalPrice'] as $item){ foreach($result['data']['TotalPrice'] as $item){
$wpdb->query(TCSync::create_insert_update_sql(TCSync::DIC_TOTALPRICE_TABLE,$item,array('id'),array('maxValue'=>'max','minValue'=>'min'))); $wpdb->query(TCSync::create_insert_update_sql(Config::DIC_TOTALPRICE_TABLE,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));
//print_r(TCSync::create_insert_update_sql(TCSync::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />"); //print_r(TCSync::create_insert_update_sql(Config::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
} }
foreach($result['data']['UnitPriceRange'] as $item){ foreach($result['data']['UnitPriceRange'] as $item){
$wpdb->query(TCSync::create_insert_update_sql(TCSync::DIC_UNITPRICERANGE_TABLE,$item,array('id'),array('maxValue'=>'max','minValue'=>'min'))); $wpdb->query(TCSync::create_insert_update_sql(Config::DIC_UNITPRICERANGE_TABLE,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));
//print_r(TCSync::create_insert_update_sql(TCSync::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />"); //print_r(TCSync::create_insert_update_sql(Config::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
} }
} }
...@@ -114,7 +102,7 @@ class TCSync { ...@@ -114,7 +102,7 @@ class TCSync {
public static function organization_sync(){ public static function organization_sync(){
global $wpdb; global $wpdb;
$response = wp_remote_post( TCSync::organization_url ); $response = wp_remote_post( Config::organization_url );
$res = array( $res = array(
'code' => 200, 'code' => 200,
'msg' => "success" 'msg' => "success"
...@@ -128,8 +116,8 @@ class TCSync { ...@@ -128,8 +116,8 @@ class TCSync {
$result = wp_remote_retrieve_body( $response ); $result = wp_remote_retrieve_body( $response );
$result = json_decode($result,true); $result = json_decode($result,true);
foreach($result['data'] as $item){ foreach($result['data'] as $item){
$wpdb->query(TCSync::create_insert_update_sql(TCSync::TOSPUR_ORGANIZATION_TABLE,$item,array('Id'))); $wpdb->query(TCSync::create_insert_update_sql(Config::TOSPUR_ORGANIZATION_TABLE,$item,array('Id')));
//print_r(TCSync::create_insert_update_sql(TCSync::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />"); //print_r(TCSync::create_insert_update_sql(Config::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
} }
} }
} }
......
...@@ -166,6 +166,7 @@ function reset_menu() ...@@ -166,6 +166,7 @@ function reset_menu()
function create_table() function create_table()
{ {
TCSync::user_sync(); //TCSync::user_sync();
//TCSync::organization_sync(); TCSync::organization_sync();
TCSync::other_sync();
} }
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