Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tospur
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
felix
tospur
Commits
4aa30a4b
Commit
4aa30a4b
authored
Aug 13, 2015
by
felix
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并用
parent
4be24ca1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
194 deletions
+149
-194
wp-content/plugins/tospur/Admin/House.php
+58
-77
wp-content/plugins/tospur/Admin/views/newhouse.html
+0
-0
wp-content/plugins/tospur/Config.php
+20
-0
wp-content/plugins/tospur/Dao/SearchDao.php
+49
-39
wp-content/plugins/tospur/TCSync.php
+0
-45
wp-content/plugins/tospur/Tools/TCSync.php
+19
-31
wp-content/plugins/tospur/index.php
+3
-2
No files found.
wp-content/plugins/tospur/Admin/House.php
View file @
4aa30a4b
<?php
require_once
(
PLUGIN_DIR
.
'Dao/SearchDao.php'
);
class
House
{
public
static
function
init_view
(){
wp_enqueue_script
(
'jquery-ui'
);
...
...
@@ -11,33 +12,10 @@ class House {
}
else
{
global
$wpdb
;
$context
=
array
();
$citysql
=
"select DISTINCT cityId,cityName from"
;
$cityRes
=
$wpdb
->
get_results
(
$citysql
.
' dic_city'
);
foreach
(
$cityRes
as
$value
){
$cityParams
=
array
(
"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
;
}
$context
[
"city"
]
=
SearchDao
::
searchCity
();
$context
[
"buildProperty"
]
=
SearchDao
::
searchBuildProperty
();
$context
[
"room"
]
=
SearchDao
::
searchRoom
();
$context
[
"photoType"
]
=
SearchDao
::
searchPhotoType
();
House
::
data_insert
();
Timber
::
render
(
"newhouse.html"
,
$context
);
}
...
...
@@ -70,79 +48,82 @@ class House {
'parking_spaces'
=>
$_POST
[
'parking_spaces'
],
'property_management'
=>
$_POST
[
'property_management'
],
'overview'
=>
$_POST
[
'overview'
],
'plate_id'
=>
$_POST
[
"basePlateId"
],
"room_id"
=>
$_POST
[
"baseRoom"
],
"property_money"
=>
$_POST
[
"property_money"
],
'creattime'
=>
date
(
"Y-m-d H:i:s"
)
'city_id'
=>
$_POST
[
'baseCity'
],
'district_id'
=>
$_POST
[
'baseAreaId'
],
'plate_id'
=>
$_POST
[
"basePlateId"
],
"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
);
if
(
!
$res
)
{
$res
=
$wpdb
->
get_results
(
'SELECT * FROM tospur_house WHERE name="'
.
$_POST
[
'name'
]
.
'" and address="'
.
$_POST
[
'address'
]
.
'"'
,
OBJECT
);
if
(
!
$res
)
{
$houseRes
=
$wpdb
->
insert
(
'tospur_house'
,
$insert_tospur_house_array
);
if
(
!
$houseRes
)
{
if
(
!
$houseRes
)
{
return
500
;
}
$houseid
=
$wpdb
->
insert_id
;
}
for
(
$x
=
0
;
$x
<=
count
(
$uploadedfile
[
"name"
])
-
1
;
$x
++
)
{
//主力房源的图片与房子信息关联插入数据库
foreach
(
$uploadedfile
[
"name"
]
as
$key
=>
$value
)
{
$uploadParam
=
array
(
"name"
=>
$uploadedfile
[
"name"
][
"
$x
"
],
"type"
=>
$uploadedfile
[
"type"
][
"
$x
"
],
"tmp_name"
=>
$uploadedfile
[
"tmp_name"
][
"
$x
"
],
"error"
=>
$uploadedfile
[
"error"
][
"
$x
"
],
"size"
=>
$uploadedfile
[
"size"
][
"
$x
"
]
"name"
=>
$uploadedfile
[
"name"
][
$key
],
"type"
=>
$uploadedfile
[
"type"
][
$key
],
"tmp_name"
=>
$uploadedfile
[
"tmp_name"
][
$key
],
"error"
=>
$uploadedfile
[
"error"
][
$key
],
"size"
=>
$uploadedfile
[
"size"
][
$key
]
);
//因为file提交过来有一个空的数组,所以这里判断在filename不为空的情况下,再做后续操作
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
(
$uploadParam
[
"name"
]
!=
""
)
{
//上传图片
if
(
!
function_exists
(
'wp_handle_upload'
)){
require_once
(
ABSPATH
.
'wp-admin/includes/file.php'
);
if
(
!
function_exists
(
'wp_handle_upload'
))
{
require_once
(
ABSPATH
.
'wp-admin/includes/file.php'
);
}
$overrides
=
array
(
'test_form'
=>
false
);
$movefile
=
wp_handle_upload
(
$uploadParam
,
$overrides
);
if
(
$movefile
&&
!
isset
(
$movefile
[
'error'
]
)
)
{
$overrides
=
array
(
'test_form'
=>
false
);
$movefile
=
wp_handle_upload
(
$uploadParam
,
$overrides
);
$str
=
preg_replace
(
'#^https?://#'
,
''
,
$movefile
[
"url"
]);
$length
=
strpos
(
$str
,
"/"
,
strpos
(
$str
,
"/"
)
+
1
);
$url
=
substr
(
$str
,
$length
);
if
(
$movefile
&&
!
isset
(
$movefile
[
'error'
]))
{
//上传成功后将图片信息存入tospur_image表
$insert_image_array
=
array
(
'name'
=>
$uploadParam
[
'name'
],
'path'
=>
$
path
,
'name'
=>
$uploadParam
[
"name"
],
'path'
=>
$
url
,
'creattime'
=>
date
(
"Y-m-d H:i:s"
),
'alt'
=>
""
,
'image_type'
=>
$
uploadParam
[
'type'
]
'image_type'
=>
$
data
[
$key
][
"type"
]
);
//插入图片表
$imgRes
=
$wpdb
->
insert
(
'tospur_image'
,
$insert_image_array
);
if
(
!
$imgRes
)
{
if
(
!
$imgRes
)
{
return
501
;
}
//获取插入图片的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
{
echo
$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
;
return
$movefile
[
'error'
];
}
}
}
...
...
wp-content/plugins/tospur/Admin/views/newhouse.html
View file @
4aa30a4b
This diff is collapsed.
Click to expand it.
wp-content/plugins/tospur/Config.php
0 → 100644
View file @
4aa30a4b
<?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
wp-content/plugins/tospur/Dao/SearchDao.php
View file @
4aa30a4b
<?php
class
SearchDao
{
public
function
__construct
()
{
require_once
(
PLUGIN_DIR
.
'\TCSync.php'
);
}
public
static
function
ajax_serachCity
(){
wp_send_json
(
SearchDao
::
searchCity
(
$_GET
[
"cityId"
],
$_GET
[
'districtId'
]));
}
...
...
@@ -26,7 +22,7 @@ class SearchDao{
$params
[]
=
$districtId
;
$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
;
}
...
...
@@ -40,7 +36,7 @@ class SearchDao{
if
(
isset
(
$_GET
[
'cityId'
])){
$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
;
}
...
...
@@ -50,7 +46,7 @@ class SearchDao{
public
static
function
searchBuildProperty
(){
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
;
}
...
...
@@ -60,7 +56,7 @@ class SearchDao{
public
static
function
searchRoom
(){
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
;
}
...
...
@@ -74,7 +70,7 @@ class SearchDao{
if
(
isset
(
$_GET
[
'cityId'
])){
$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
;
}
...
...
@@ -88,7 +84,7 @@ class SearchDao{
if
(
isset
(
$_GET
[
'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
;
}
...
...
@@ -102,13 +98,13 @@ class SearchDao{
if
(
$parentId
!=
NULL
){
$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
;
}
public
static
function
getCityNameWithId
(
$cityId
){
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
){
return
$result
;
}
else
{
...
...
@@ -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"
]));
}
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
;
if
(
$acreage
==
"面积"
){
$acreage
=
null
;
}
if
(
$totalPrice
==
"价格"
){
$totalPrice
=
null
;
}
$areaArray
=
explode
(
"-"
,
$acreage
);
$priceArray
=
explode
(
"-"
,
$totalPrice
);
$params
=
array
();
$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 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 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
){
$sql
=
$sql
.
" and cityId="
.
$cityId
;
if
(
$cityId
!=
0
){
$params
[]
=
$cityId
;
$sql
=
$sql
.
" and cityId=%d"
;
}
if
(
$districtId
!=
NULL
){
$sql
=
$sql
.
" and districtId="
.
$districtId
;
if
(
$districtId
!=
0
){
$params
[]
=
$districtId
;
$sql
=
$sql
.
" and districtId=%d"
;
}
if
(
$plateId
!=
NULL
){
$sql
=
$sql
.
" and plateId="
.
$plateId
;
if
(
$plateId
!=
0
){
$params
[]
=
$plateId
;
$sql
=
$sql
.
" and plateId=%d"
;
}
if
(
$buildpropertyId
!=
NULL
){
$sql
=
$sql
.
" and buildproperty_id="
.
$buildpropertyId
;
if
(
$buildPropertyId
!=
0
){
$params
[]
=
$buildPropertyId
;
$sql
=
$sql
.
" and buildproperty_id=%d"
;
}
if
(
$roomId
!=
NULL
){
$sql
=
$sql
.
" and room_id="
.
$roomId
;
if
(
$roomId
!=
0
){
$params
[]
=
$roomId
;
$sql
=
$sql
.
" and room_id=%d"
;
}
if
(
$acreage
!=
NULL
){
$sql
=
$sql
.
" and covered_area between "
.
$areaArray
[
0
]
.
" and "
.
$areaArray
[
1
];
if
(
$acreage
!=
0
){
$areaArray
=
explode
(
"-"
,
$acreage
);
$params
[]
=
$areaArray
[
0
];
$params
[]
=
$areaArray
[
1
];
$sql
=
$sql
.
" and covered_area between %d and %d"
;
}
if
(
$totalPrice
!=
NULL
){
$sql
=
$sql
.
" and total_price between "
.
$priceArray
[
0
]
.
" and "
.
$priceArray
[
1
];
if
(
$totalPrice
!=
0
){
$priceArray
=
explode
(
"-"
,
$totalPrice
);
$params
[]
=
$priceArray
[
0
];
$params
[]
=
$priceArray
[
1
];
$sql
=
$sql
.
" and total_price between %d and %d"
;
}
if
(
$searchText
!=
NULL
){
$sql
=
$sql
.
" and name like '%"
.
$searchText
.
"%'"
;
if
(
$searchText
!=
0
){
$params
[]
=
"%"
.
$searchText
.
"%"
;
$sql
=
$sql
.
" and name like %s"
;
}
$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
;
}
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
wp-content/plugins/tospur/TCSync.php
deleted
100644 → 0
View file @
4be24ca1
<?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
wp-content/plugins/tospur/Tools/TCSync.php
View file @
4aa30a4b
<?php
require_once
(
PLUGIN_DIR
.
'Config.php'
);
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
(){
global
$wpdb
;
$response
=
wp_remote_post
(
TCSync
::
user_url
);
$response
=
wp_remote_post
(
Config
::
user_url
);
$res
=
array
(
'code'
=>
200
,
'msg'
=>
"success"
...
...
@@ -55,7 +43,7 @@ class TCSync {
'mobile'
=>
$item
[
'Mobile'
],
'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 {
public
static
function
other_sync
(){
global
$wpdb
;
$response
=
wp_remote_post
(
TCSync
::
other_url
);
$response
=
wp_remote_post
(
Config
::
other_url
);
$res
=
array
(
'code'
=>
200
,
'msg'
=>
"success"
...
...
@@ -80,33 +68,33 @@ class TCSync {
$result
=
json_decode
(
$result
,
true
);
//print_r($result['data']['CityList']);
foreach
(
$result
[
'data'
][
'CityList'
]
as
$item
){
$wpdb
->
query
(
TCSync
::
create_insert_update_sql
(
TCSync
::
DIC_CITY_TABLE
,
$item
,
array
(
'plateId'
)));
//print_r(TCSync::create_insert_update_sql(
TCSync
::CITY_TABLE,$item,array('plateId')));print_r("<br />");
$wpdb
->
query
(
TCSync
::
create_insert_update_sql
(
Config
::
DIC_CITY_TABLE
,
$item
,
array
(
'plateId'
)));
//print_r(TCSync::create_insert_update_sql(
Config
::CITY_TABLE,$item,array('plateId')));print_r("<br />");
}
foreach
(
$result
[
'data'
][
'RoomStyle'
]
as
$item
){
$wpdb
->
query
(
TCSync
::
create_insert_update_sql
(
TCSync
::
DIC_ROOM_TABLE
,
$item
,
array
(
'id'
)));
//print_r(TCSync::create_insert_update_sql(
TCSync
::DIC_ROOM_TABLE,$item,array('id')));print_r("<br />");
$wpdb
->
query
(
TCSync
::
create_insert_update_sql
(
Config
::
DIC_ROOM_TABLE
,
$item
,
array
(
'id'
)));
//print_r(TCSync::create_insert_update_sql(
Config
::DIC_ROOM_TABLE,$item,array('id')));print_r("<br />");
}
foreach
(
$result
[
'data'
][
'BulidProperty'
]
as
$item
){
$wpdb
->
query
(
TCSync
::
create_insert_update_sql
(
TCSync
::
DIC_BUILDPROPERTY_TABLE
,
$item
,
array
(
'id'
)));
//print_r(TCSync::create_insert_update_sql(
TCSync
::DIC_BUILDPROPERTY_TABLE,$item,array('id')));print_r("<br />");
$wpdb
->
query
(
TCSync
::
create_insert_update_sql
(
Config
::
DIC_BUILDPROPERTY_TABLE
,
$item
,
array
(
'id'
)));
//print_r(TCSync::create_insert_update_sql(
Config
::DIC_BUILDPROPERTY_TABLE,$item,array('id')));print_r("<br />");
}
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'
)));
//print_r(TCSync::create_insert_update_sql(
TCSync
::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
$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(
Config
::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
}
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'
)));
//print_r(TCSync::create_insert_update_sql(
TCSync
::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
$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(
Config
::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
}
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'
)));
//print_r(TCSync::create_insert_update_sql(
TCSync
::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
$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(
Config
::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
}
}
...
...
@@ -114,7 +102,7 @@ class TCSync {
public
static
function
organization_sync
(){
global
$wpdb
;
$response
=
wp_remote_post
(
TCSync
::
organization_url
);
$response
=
wp_remote_post
(
Config
::
organization_url
);
$res
=
array
(
'code'
=>
200
,
'msg'
=>
"success"
...
...
@@ -128,8 +116,8 @@ class TCSync {
$result
=
wp_remote_retrieve_body
(
$response
);
$result
=
json_decode
(
$result
,
true
);
foreach
(
$result
[
'data'
]
as
$item
){
$wpdb
->
query
(
TCSync
::
create_insert_update_sql
(
TCSync
::
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 />");
$wpdb
->
query
(
TCSync
::
create_insert_update_sql
(
Config
::
TOSPUR_ORGANIZATION_TABLE
,
$item
,
array
(
'Id'
)));
//print_r(TCSync::create_insert_update_sql(
Config
::DIC_AREA,$item,array('id'),array('maxValue'=>'max','minValue'=>'min')));print_r("<br />");
}
}
}
...
...
wp-content/plugins/tospur/index.php
View file @
4aa30a4b
...
...
@@ -166,6 +166,7 @@ function reset_menu()
function
create_table
()
{
TCSync
::
user_sync
();
//TCSync::organization_sync();
//TCSync::user_sync();
TCSync
::
organization_sync
();
TCSync
::
other_sync
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment