rabin 3 年之前
父节点
当前提交
bb8a8301bf
共有 1 个文件被更改,包括 8 次插入4 次删除
  1. 8 4
      service/mail/lib/Manage.php

+ 8 - 4
service/mail/lib/Manage.php

@@ -762,7 +762,9 @@ class Manage
                 }
             }
 
+            $area_id = array();
             foreach ($area as $k => $v) {
+                $area_value = explode(',', $k);
                 $update = array();
                 $update['month'] = $where['start'];
                 $update['name'] = $k;
@@ -796,9 +798,11 @@ class Manage
                 if ($v['type'] == 1) {
                     $update['parent_id'] = -1;
                 } elseif ($v['type'] == 2) {
-                    $update['parent_id'] = $city_id;
+                    $k2 = $area_value[0] . ',' . $area_value[1];
+                    $update['parent_id'] = isset($area_id[$k2]) ? $area_id[$k2] : -1;
                 } elseif ($v['type'] == 3) {
-                    $update['parent_id'] = $county_id;
+                    $k2 = $area_value[0] . ',' . $area_value[1] . ',' . $area_value[2];
+                    $update['parent_id'] = isset($area_id[$k2]) ? $area_id[$k2] : -1;
                 }
 
                 # 设置收益代理商
@@ -810,9 +814,9 @@ class Manage
                 if (!$info) {
                     $stat_id = Dever::db('mail/area_stat')->insert($update);
                     if ($v['type'] == 1) {
-                        $city_id = $stat_id;
+                        $area_id[$k] = $stat_id;
                     } elseif ($v['type'] == 2) {
-                        $county_id = $stat_id;
+                        $area_id[$k] = $stat_id;
                     }
                 } else {
                     $update['where_id'] = $info['id'];