Commit 90b82782 authored by hujun's avatar hujun

房东手机号转换

parent d56fea3f
<?php
namespace app\index\controller;
use app\index\extend\Basic;
use app\model\HouseInfos;
use think\Request;
/**
* Description of HouseInfo
*
* @author : fuju
* @date : 2018-1-15 11:09:56
* @internal : description
*/
class HouseInfo extends Basic{
protected $house_infos;
public function __construct(Request $request) {
parent::__construct($request);
$this->house_infos = new HouseInfos();
}
public function index() {
return $this->house_infos->select();
}
}
...@@ -15,8 +15,10 @@ use app\index\validate\HouseValidate; ...@@ -15,8 +15,10 @@ use app\index\validate\HouseValidate;
use app\model\AAgents; use app\model\AAgents;
use app\model\ACollectHouse; use app\model\ACollectHouse;
use app\model\GHouses; use app\model\GHouses;
use app\model\GHousesExt;
use app\model\GHousesImgs; use app\model\GHousesImgs;
use app\model\GHousesToAgents; use app\model\GHousesToAgents;
use app\model\GLandlordPhone;
use app\model\GOperatingRecords; use app\model\GOperatingRecords;
use app\model\SubletModel; use app\model\SubletModel;
use think\Request; use think\Request;
...@@ -505,4 +507,39 @@ class Houses extends Basic ...@@ -505,4 +507,39 @@ class Houses extends Basic
return $this->response($data['status'], $data['msg'], $data['data']); return $this->response($data['status'], $data['msg'], $data['data']);
} }
/**
* 转换房东手机号
*
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function transformLandlord() {
$time = time();
$m_landlord = new GLandlordPhone();
$m_house = new GHousesExt();
$total = $m_house->getTotal();
$page = ceil($total/5000);
$where[] = ['EXP','landlord_phone IS NOT NULL AND landlord_phone != ""'];
$kk = 0;
for ($i=1; $i<= $page; $i++) {
$data = $m_house->getList($i,5000,'id asc','house_id,landlord_phone', $where);
foreach ($data as $k=>$v) {
$landlord_data = json_decode($v['landlord_phone'], true);
foreach ($landlord_data as $k2=>$v2) {
$insert[$kk]['name'] = $v2['name'];
$insert[$kk]['phone'] = (int)$v2['phone'];
$insert[$kk]['house_id'] = $v['house_id'];
$kk++;
}
}
$m_landlord->saveAll($insert);
}
echo time() - $time .'秒';
}
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/8/13
* Time: 15:56
*/
namespace app\model;
class GLandlordPhone extends BaseModel
{
protected $table = 'g_landlord_phone';
}
\ No newline at end of file
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