归属地查询

lszyh
zengyyh 5 months ago
parent a1d8efffd7
commit 332f60d8bd
  1. 29
      app/command/SprictTest.php
  2. 26
      app/common/service/User.php
  3. 26
      app/store/controller/Order.php

@ -9,6 +9,11 @@ use think\console\Output;
use think\console\Command; use think\console\Command;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException; 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 SprictTest extends Command class SprictTest extends Command
@ -33,11 +38,29 @@ class SprictTest extends Command
protected function execute(Input $input, Output $output) protected function execute(Input $input, Output $output)
{ {
echo "666"; $this->setHomeLocation();
} }
public function test() public function setHomeLocation()
{ {
echo "hello world"; $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);
}
} }
} }

@ -31,4 +31,30 @@ class User extends BaseService
{ {
return !OrderService::getValidCountByUser($userId); return !OrderService::getValidCountByUser($userId);
} }
public static function getHomeLocation(string $mobile){
$host = "https://ec8a.api.huachen.cn";
$path = "/mobile";
$method = "GET";
$appcode = "06d67297e6e14268801dbc3c974bec7e";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$bodys = "";
$url = $host . $path . "?" .'mobile='. $mobile;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($curl, CURLOPT_HEADER, true);
// if (1 == strpos("$".$host, "https://"))
// {
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
// }
return (curl_exec($curl));
}
} }

@ -119,31 +119,5 @@ class Order extends Controller
return $this->renderSuccess(compact('detail')); return $this->renderSuccess(compact('detail'));
} }
public function getHomeLocation(string $mobile){
$host = "https://ec8a.api.huachen.cn";
$path = "/mobile";
$method = "GET";
$appcode = "06d67297e6e14268801dbc3c974bec7e";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$bodys = "";
$url = $host . $path . "?" .'mobile='. $mobile;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
print_r(curl_exec($curl));
exit;
// curl_setopt($curl, CURLOPT_HEADER, true);
// if (1 == strpos("$".$host, "https://"))
// {
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
// }
return (curl_exec($curl));
}
} }

Loading…
Cancel
Save