|
@@ -77,74 +77,58 @@ class Import
|
|
|
|
|
|
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_act($host, $state);
|
|
|
- }
|
|
|
- return 'ok';
|
|
|
- }
|
|
|
-
|
|
|
- public function get_area_act($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);
|
|
|
+ $data = Dever::db('agent/member')->getDataByRole(array('role' => '2,3,4'));
|
|
|
|
|
|
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;
|
|
|
- }
|
|
|
+ $area = explode(',', $v['area']);
|
|
|
+
|
|
|
+ $num = count($area);
|
|
|
+
|
|
|
+ $area_name = Dever::load("area/api.string", $v['area']);
|
|
|
+ if ($v['role'] == 2 && $num != 2) {
|
|
|
+ $this->log($v['id'], 9, $area_name, '城市错误');
|
|
|
+ }
|
|
|
+ if ($v['role'] == 3 && $num != 3) {
|
|
|
+ $this->log($v['id'], 9, $area_name, '区县错误');
|
|
|
+ }
|
|
|
+ if ($v['role'] == 4 && $num != 4) {
|
|
|
+ $this->log($v['id'], 9, $area_name, '街道错误');
|
|
|
+ }
|
|
|
+ if ($v['area']) {
|
|
|
+ $check = Dever::db('agent/member')->find(array('area' => $v['area'], 'role' => $v['role']));
|
|
|
+ if (!$check) {
|
|
|
+ $this->log($v['id'], 9, $area_name, '区域匹配错误');
|
|
|
}
|
|
|
- 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 ($v['role'] == 2 && isset($area[1]) && $area[1]) {
|
|
|
+ $city = Dever::db('area/city')->find($area[1]);
|
|
|
+ if ($city['status'] == 1) {
|
|
|
+
|
|
|
+ Dever::load('area/api')->upStatus($v['area'], 2);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- 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 ($v['role'] == 3 && isset($area[2]) && $area[2]) {
|
|
|
+ $city = Dever::db('area/county')->find($area[2]);
|
|
|
+ if ($city['status'] == 1) {
|
|
|
+
|
|
|
+ Dever::load('area/api')->upStatus($v['area'], 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']);
|
|
|
+ if ($v['role'] == 4 && isset($area[3]) && $area[3]) {
|
|
|
+ $city = Dever::db('area/town')->find($area[3]);
|
|
|
+ if ($city['status'] == 1) {
|
|
|
+
|
|
|
+ Dever::load('area/api')->upStatus($v['area'], 2);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- } else {
|
|
|
- $this->log($v['id'], 9, $data['address'], '无区域编码');
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+ return 'ok';
|
|
|
}
|
|
|
|
|
|
public function get_data($host, $index = 0)
|
|
@@ -711,7 +695,7 @@ class Import
|
|
|
}
|
|
|
|
|
|
|
|
|
- public function log($mid, $type, $before, $after, $update = false)
|
|
|
+ public function log($mid, $type, $before, $after, $update = true)
|
|
|
{
|
|
|
|
|
|
$data['mid'] = $mid;
|