作者 刘锟

update

@@ -77,9 +77,13 @@ class ProjectVisit extends Command @@ -77,9 +77,13 @@ class ProjectVisit extends Command
77 if (isset($data['count']) && $data['count'] > 0) { 77 if (isset($data['count']) && $data['count'] > 0) {
78 $count = $data['count']; 78 $count = $data['count'];
79 $max_id = $data['data'][0]['id'] ?? 0; 79 $max_id = $data['data'][0]['id'] ?? 0;
  80 + $is_stop = 0;
80 81
81 $total_page = ceil($count / $page_size); 82 $total_page = ceil($count / $page_size);
82 for ($page = 1; $page <= $total_page; $page++) { 83 for ($page = 1; $page <= $total_page; $page++) {
  84 + if ($is_stop) {
  85 + break;
  86 + }
83 $url_page = $api_url . '?' . http_build_query(['w' => 'visit_list', 'page' => $page, 'pagesize' => $page_size]); 87 $url_page = $api_url . '?' . http_build_query(['w' => 'visit_list', 'page' => $page, 'pagesize' => $page_size]);
84 $data_page = curl_c($url_page); 88 $data_page = curl_c($url_page);
85 if (isset($data_page['data']) && $data_page['data']) { 89 if (isset($data_page['data']) && $data_page['data']) {
@@ -104,9 +108,13 @@ class ProjectVisit extends Command @@ -104,9 +108,13 @@ class ProjectVisit extends Command
104 'updated_date' => date('Y-m-d', isset($item['c_time']) && $item['c_time'] ? strtotime($item['c_time']) : time()), 108 'updated_date' => date('Y-m-d', isset($item['c_time']) && $item['c_time'] ? strtotime($item['c_time']) : time()),
105 'original_id' => $item['id'], 109 'original_id' => $item['id'],
106 ]; 110 ];
  111 + } else {
  112 + $is_stop = 1;
  113 + break;
107 } 114 }
108 } 115 }
109 } 116 }
  117 + if ($insert) {
110 try { 118 try {
111 $model->insert($insert); 119 $model->insert($insert);
112 } catch (\Exception $e) { 120 } catch (\Exception $e) {
@@ -115,9 +123,9 @@ class ProjectVisit extends Command @@ -115,9 +123,9 @@ class ProjectVisit extends Command
115 } 123 }
116 } 124 }
117 } 125 }
  126 + }
118 if ($max_id) { 127 if ($max_id) {
119 $task->max_id = $max_id; 128 $task->max_id = $max_id;
120 - $task->save();  
121 } 129 }
122 } else { 130 } else {
123 return true; 131 return true;
@@ -129,9 +137,13 @@ class ProjectVisit extends Command @@ -129,9 +137,13 @@ class ProjectVisit extends Command
129 if (isset($data['count']) && $data['count'] > 0) { 137 if (isset($data['count']) && $data['count'] > 0) {
130 $count = $data['count']; 138 $count = $data['count'];
131 $max_id = $data['data'][0]['id'] ?? 0; 139 $max_id = $data['data'][0]['id'] ?? 0;
  140 + $is_stop = 0;
132 141
133 $total_page = ceil($count / $page_size); 142 $total_page = ceil($count / $page_size);
134 for ($page = 1; $page <= $total_page; $page++) { 143 for ($page = 1; $page <= $total_page; $page++) {
  144 + if ($is_stop) {
  145 + break;
  146 + }
135 $url_page = $api_url . '?' . http_build_query(['w' => 'visit_detail_list', 'page' => $page, 'pagesize' => $page_size]); 147 $url_page = $api_url . '?' . http_build_query(['w' => 'visit_detail_list', 'page' => $page, 'pagesize' => $page_size]);
136 $data_page = curl_c($url_page); 148 $data_page = curl_c($url_page);
137 if (isset($data_page['data']) && $data_page['data']) { 149 if (isset($data_page['data']) && $data_page['data']) {
@@ -158,9 +170,13 @@ class ProjectVisit extends Command @@ -158,9 +170,13 @@ class ProjectVisit extends Command
158 'original_id' => $item['id'], 170 'original_id' => $item['id'],
159 ]; 171 ];
160 } 172 }
  173 + } else {
  174 + $is_stop = 1;
  175 + break;
161 } 176 }
162 } 177 }
163 } 178 }
  179 + if ($insert) {
164 try { 180 try {
165 $model->insert($insert); 181 $model->insert($insert);
166 } catch (\Exception $e) { 182 } catch (\Exception $e) {
@@ -169,9 +185,9 @@ class ProjectVisit extends Command @@ -169,9 +185,9 @@ class ProjectVisit extends Command
169 } 185 }
170 } 186 }
171 } 187 }
  188 + }
172 if ($max_id) { 189 if ($max_id) {
173 $task->max_id = $max_id; 190 $task->max_id = $max_id;
174 - $task->save();  
175 } 191 }
176 } else { 192 } else {
177 return true; 193 return true;