You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.9 KiB
66 lines
1.9 KiB
<?php
|
|
|
|
declare (strict_types=1);
|
|
|
|
namespace app\command;
|
|
|
|
use think\console\Input;
|
|
use think\console\Output;
|
|
use think\console\Command;
|
|
use think\db\exception\DataNotFoundException;
|
|
use think\db\exception\ModelNotFoundException;
|
|
use app\api\model\dealer\User as DealerUserModel;
|
|
use app\api\model\User;
|
|
use app\common\service\User as UserService;
|
|
use app\common\enum\user\UserTypeEnum;
|
|
use think\facade\Db;
|
|
|
|
|
|
class HomeLocation extends Command
|
|
{
|
|
|
|
protected function configure()
|
|
{
|
|
// 指令配置
|
|
$this->setName('HomeLocation')
|
|
->setDescription('测试输出');
|
|
}
|
|
|
|
/**
|
|
* @notes:执行
|
|
* @param Input $input
|
|
* @param Output $output
|
|
* @throws DataNotFoundException
|
|
* @throws DbException
|
|
* @throws ModelNotFoundException
|
|
* @author: wanghousheng
|
|
*/
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
|
|
$this->setHomeLocation();
|
|
}
|
|
|
|
public function setHomeLocation()
|
|
{
|
|
$model = new User();
|
|
$dealerUser = Db::name('user')->where('homelocation','')->where('mobile','<>','')
|
|
->distinct(true)->field('mobile')->select();
|
|
foreach($dealerUser as $user){
|
|
//$userMobiles = explode(',', $user['mobile']);
|
|
$localdate= UserService::getHomeLocation($user['mobile']);
|
|
// print_r( $localdate);
|
|
$localdate = json_decode($localdate,true);
|
|
// print_r( $localdate['data']);
|
|
$localdate = json_encode($localdate['data'],JSON_UNESCAPED_UNICODE);
|
|
// print_r( $localdate);
|
|
// exit;
|
|
$date = $model::where('mobile',$user['mobile'])->update(['homelocation'=>$localdate]);
|
|
var_dump($date);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
} |