diff --git a/app/command/SprictTest.php b/app/command/SprictTest.php index 341b7975..c0e8292c 100644 --- a/app/command/SprictTest.php +++ b/app/command/SprictTest.php @@ -9,6 +9,11 @@ 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 SprictTest extends Command @@ -33,11 +38,29 @@ class SprictTest extends Command protected function execute(Input $input, Output $output) { - echo "666"; + $this->setHomeLocation(); } - public function test() - { - echo "hello world"; + 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); + + + } + + } } \ No newline at end of file diff --git a/app/common/service/User.php b/app/common/service/User.php index b40d734b..1ecc2fe0 100644 --- a/app/common/service/User.php +++ b/app/common/service/User.php @@ -31,4 +31,30 @@ class User extends BaseService { 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)); + } } \ No newline at end of file diff --git a/app/store/controller/Order.php b/app/store/controller/Order.php index dfae7d37..3f3524aa 100644 --- a/app/store/controller/Order.php +++ b/app/store/controller/Order.php @@ -119,31 +119,5 @@ class Order extends Controller 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)); - } + }