Commit 987c2f98 authored by hujun's avatar hujun

数据转换

parent e1bc76cc
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
namespace app\api\controller; namespace app\api\controller;
use app\model\GHousesExt;
use app\model\Regions; use app\model\Regions;
use app\model\Users;
use think\Controller; use think\Controller;
use think\Db; use think\Db;
...@@ -249,4 +251,92 @@ class TransferHouseInfo extends Controller ...@@ -249,4 +251,92 @@ class TransferHouseInfo extends Controller
$result = Db::table('g_houses_to_agents')->insertAll($agent_house_data); $result = Db::table('g_houses_to_agents')->insertAll($agent_house_data);
dump($result); dump($result);
} }
/**
* user_nick同步到user_name
*
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function userNickToUserName() {
set_time_limit(0);
$m_user = new Users();
$user_data = $m_user->field('id,user_nick')->where('user_nick','NOT NULL')->select();
dump(count($user_data));
foreach ($user_data as $k=>$v) {
$insert_data['id'] = $v['id'];
$insert_data['user_name'] = $v['user_nick'];
$m_user->update($insert_data);
}
return ;
}
/**
* 房东手机号转换
*
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function landlordPhoneToJson() {
$this->landlordPhoneStar();//去除号码中带*号的
$m_house_ext = new GHousesExt();
$house_data = $m_house_ext->field('id,landlord_phone')->where('landlord_phone','NOT NULL')->select();
foreach ($house_data as $k => $v) {
$phone = explode(',', $v['landlord_phone']);
if (count($phone) == 1) {
if (!empty($phone[0])) {
$insert_data['id'] = $v['id'];
$landlord_phone[0]['name'] = '房东';
$landlord_phone[0]['phone'] = str_replace(' ', '',$phone[0]);
$insert_data['landlord_phone'] = json_encode($landlord_phone);
$m_house_ext->update($insert_data);
}
} else {
foreach ($phone as $key => $val) {
if (!empty($val)) {
$landlord_phone[$key]['name'] = '房东';
$landlord_phone[$key]['phone'] = $val;
}
}
if (!empty($landlord_phone[0]['phone'])) {
$insert_data['id'] = $v['id'];
$insert_data['landlord_phone'] = json_encode($landlord_phone);
$m_house_ext->update($insert_data);
}
}
}
}
/**
* 去除号码中带*号的
*
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function landlordPhoneStar() {
$m_house_ext = new GHousesExt();
$house_data = $m_house_ext->field('id,landlord_phone')->where('landlord_phone','NOT NULL')->select();
foreach ($house_data as $k => $v) {
$phone = explode(',', $v['landlord_phone']);
if (count($phone) == 1) {
if (stripos($phone[0],'*') > 0) {
$insert_data['id'] = $v['id'];
$insert_data['landlord_phone'] = NULL;
$m_house_ext->update($insert_data);
}
} else {
if (count($phone) > 4) {
$insert_data['id'] = $v['id'];
$insert_data['landlord_phone'] = NULL;
$m_house_ext->update($insert_data);
}
}
}
}
} }
\ No newline at end of file
...@@ -312,6 +312,9 @@ Route::group('api', [ ...@@ -312,6 +312,9 @@ Route::group('api', [
'houseTable' => [ 'api/TransferHouseInfo/table', [ 'method' => 'post|get' ] ], //转商铺表 'houseTable' => [ 'api/TransferHouseInfo/table', [ 'method' => 'post|get' ] ], //转商铺表
'houseImgTable' => [ 'api/TransferHouseInfo/houseImg', [ 'method' => 'post|get' ] ], //转楼盘表 'houseImgTable' => [ 'api/TransferHouseInfo/houseImg', [ 'method' => 'post|get' ] ], //转楼盘表
'agentHouse' => [ 'api/TransferHouseInfo/agentHouse', [ 'method' => 'post|get' ] ], //转楼盘表 'agentHouse' => [ 'api/TransferHouseInfo/agentHouse', [ 'method' => 'post|get' ] ], //转楼盘表
'userNickToUserName' => [ 'api/TransferHouseInfo/userNickToUserName', [ 'method' => 'post|get' ] ], //user_nick同步到user_name
'landlordPhoneToJson' => [ 'api/TransferHouseInfo/landlordPhoneToJson', [ 'method' => 'post|get' ] ], //房东手机号转json
'landlordPhoneStar' => [ 'api/TransferHouseInfo/landlordPhoneStar', [ 'method' => 'post|get' ] ], //房东手机号转json
]); ]);
Route::group('chat', [ Route::group('chat', [
......
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