|
@@ -75,6 +75,78 @@ class Import
|
|
|
return 'ok';
|
|
|
}
|
|
|
|
|
|
+ public function get_area_api()
|
|
|
+ {
|
|
|
+ $this->date = Dever::maketime('2021-09-01 00:00:00');
|
|
|
+ Dever::config('base')->hook = true;
|
|
|
+ $host = 'https://cryl.yijiuguanfang.com/attachment/';
|
|
|
+
|
|
|
+ $state = 1;
|
|
|
+ while($state) {
|
|
|
+ $state = $this->get_area_api($host, $state);
|
|
|
+ }
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
+
|
|
|
+ public function get_area_api($host, $index = 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ $index = $index - 1;
|
|
|
+ $limit = 1000;
|
|
|
+
|
|
|
+ $data = $this->db->fetchAll('select * from ims_ewei_shop_member where status = 1 and prestatus = 1 and isagent = 1 order by id asc limit ' . $index . ', ' . $limit);
|
|
|
+
|
|
|
+ if (!$data) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ $data['address'] = $v['province'] . $v['city'] . $v['area'] . $v['street'];
|
|
|
+ if ($v['datavalue']) {
|
|
|
+ $v['datavalue'] = trim(str_replace(" ", ',', $v['datavalue']));
|
|
|
+ $temp = explode(',', $v['datavalue']);
|
|
|
+ if (isset($temp[0]) && $temp[0]) {
|
|
|
+ $a['id'] = $temp[0];
|
|
|
+ $a['clear'] = true;
|
|
|
+ $info = Dever::db('area/province')->one($a);
|
|
|
+ if (!$info) {
|
|
|
+ $this->log($v['id'], 9, $data['address'], '省份编码错误:' . $temp[0]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($temp[1]) && $temp[1]) {
|
|
|
+ $a['id'] = $temp[1];
|
|
|
+ $a['clear'] = true;
|
|
|
+ $info = Dever::db('area/city')->one($a);
|
|
|
+ if (!$info) {
|
|
|
+ $this->log($v['id'], 9, $data['address'], '城市编码错误:' . $temp[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($temp[2]) && $temp[2]) {
|
|
|
+ $a['id'] = $temp[2];
|
|
|
+ $a['clear'] = true;
|
|
|
+ $info = Dever::db('area/county')->one($a);
|
|
|
+ if (!$info) {
|
|
|
+ $this->log($v['id'], 9, $data['address'], '区县编码错误:' . $temp[2]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($v['streetvalue']) && $v['streetvalue']]) {
|
|
|
+ $a['id'] = $v['streetvalue'];
|
|
|
+ $a['clear'] = true;
|
|
|
+ $info = Dever::db('area/town')->one($a);
|
|
|
+ if (!$info) {
|
|
|
+ $this->log($v['id'], 9, $data['address'], '街道编码错误:' . $v['streetvalue']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $this->log($v['id'], 9, $data['address'], '无区域编码');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function get_data($host, $index = 0)
|
|
|
{
|
|
|
|