|
@@ -9,6 +9,7 @@ |
|
@@ -9,6 +9,7 @@ |
|
9
|
|
9
|
|
|
10
|
namespace App\Console\Commands\Sync;
|
10
|
namespace App\Console\Commands\Sync;
|
|
11
|
|
11
|
|
|
|
|
12
|
+use App\Models\Manage\Mobile;
|
|
12
|
use App\Models\User\User;
|
13
|
use App\Models\User\User;
|
|
13
|
use Illuminate\Console\Command;
|
14
|
use Illuminate\Console\Command;
|
|
14
|
use Illuminate\Support\Facades\DB;
|
15
|
use Illuminate\Support\Facades\DB;
|
|
@@ -40,30 +41,40 @@ class SyncMobile extends Command |
|
@@ -40,30 +41,40 @@ class SyncMobile extends Command |
|
40
|
$url = 'https://www.quanqiusou.cn/extend_api/saas/get_phone.php';
|
41
|
$url = 'https://www.quanqiusou.cn/extend_api/saas/get_phone.php';
|
|
41
|
// $data = curlGet($url);//TODO::获取号码库
|
42
|
// $data = curlGet($url);//TODO::获取号码库
|
|
42
|
$client = new \GuzzleHttp\Client();
|
43
|
$client = new \GuzzleHttp\Client();
|
|
43
|
- $data = $client->request('GET', $url, [
|
|
|
|
44
|
- 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
|
|
|
|
45
|
- ])->getBody()->getContents();
|
|
|
|
46
|
- $data = json_decode($data, true);
|
|
|
|
47
|
- DB::table('gl_mobile')->delete();
|
|
|
|
48
|
- $create_time = date('Y-m-d H:i:s');
|
|
|
|
49
|
- foreach ($data as $v){
|
|
|
|
50
|
- $param = [
|
|
|
|
51
|
- 'mobile'=>$v,
|
|
|
|
52
|
- 'created_at'=>$create_time
|
|
|
|
53
|
- ];
|
|
|
|
54
|
- DB::table('gl_mobile')->insert($param);
|
44
|
+ try {
|
|
|
|
45
|
+ $data = $client->request('GET', $url, [
|
|
|
|
46
|
+ 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
|
|
|
|
47
|
+ ])->getBody()->getContents();
|
|
|
|
48
|
+ }catch (\Exception $e){
|
|
|
|
49
|
+ echo date('Y-m-d H:i:s').':未拉起到数据'.PHP_EOL;
|
|
55
|
}
|
50
|
}
|
|
56
|
if(!empty($data)){
|
51
|
if(!empty($data)){
|
|
|
|
52
|
+ $mobileModel = new Mobile();
|
|
|
|
53
|
+ $mobileModel->truncate();
|
|
|
|
54
|
+ $data = json_decode($data, true);
|
|
57
|
$userModel = new User();
|
55
|
$userModel = new User();
|
|
58
|
- try {
|
|
|
|
59
|
- $data[] = '13083988828';
|
|
|
|
60
|
- $data[] = '6591559603';
|
|
|
|
61
|
- $userModel->edit(['status'=>1],['project_id'=>1,'mobile'=>['not in',$data]]);
|
|
|
|
62
|
- $userModel->edit(['status'=>0],['project_id'=>1,'mobile'=>['in',$data]]);
|
|
|
|
63
|
- }catch (\Exception $e){
|
|
|
|
64
|
- echo date('Y-m-d H:i:s') . 'error' . PHP_EOL;
|
56
|
+ foreach ($data as $mobile){
|
|
|
|
57
|
+ $param = [
|
|
|
|
58
|
+ 'mobile'=>$mobile,
|
|
|
|
59
|
+ 'created_at'=>date('Y-m-d H:i:s')
|
|
|
|
60
|
+ ];
|
|
|
|
61
|
+ $mobile->insert($param);
|
|
|
|
62
|
+ //查看当前用户是否存在
|
|
|
|
63
|
+ $info = $userModel->read(['mobile'=>$mobile,'project_id'=>1]);
|
|
|
|
64
|
+ if($info === false){
|
|
|
|
65
|
+ $data = [
|
|
|
|
66
|
+ 'mobile'=>$mobile,
|
|
|
|
67
|
+ 'password'=>base64_encode(md5('123456')),
|
|
|
|
68
|
+ 'project_id'=>1,
|
|
|
|
69
|
+ 'name'=>$mobile,
|
|
|
|
70
|
+ 'type'=>$userModel::TYPE_ONE
|
|
|
|
71
|
+ ];
|
|
|
|
72
|
+ $userModel->add($data);
|
|
|
|
73
|
+ }
|
|
65
|
}
|
74
|
}
|
|
|
|
75
|
+ $data[] = '13083988828';
|
|
|
|
76
|
+ $userModel->edit(['status'=>1],['project_id'=>1,'mobile'=>['not in',$data]]);
|
|
|
|
77
|
+ $userModel->edit(['status'=>0],['project_id'=>1,'mobile'=>['in',$data]]);
|
|
66
|
}
|
78
|
}
|
|
67
|
}
|
79
|
}
|
|
68
|
-
|
|
|
|
69
|
} |
80
|
} |