dever 6 years ago
parent
commit
cbfbad1ec9
4 changed files with 96 additions and 4 deletions
  1. BIN
      doc/mobile.xlsx
  2. 4 4
      journal/database/mobile.php
  3. 57 0
      journal/database/mobile_upload.php
  4. 35 0
      journal/lib/Manage.php

BIN
doc/mobile.xlsx


+ 4 - 4
journal/database/mobile.php

@@ -25,7 +25,7 @@ return array
             'desc'      => '',
             'match'     => 'is_numeric',
             'search'    => 'order',
-            'list'      => true,
+            //'list'      => true,
         ),
 
         'mobile'      => array
@@ -50,8 +50,8 @@ return array
             'match'     => 'is_numeric',
             'update'    => 'select',
             'option'    => $product,
-            //'search'    => 'select',
-            //'list'        => true,
+            'search'    => 'select',
+            'list'        => true,
         ),
 
         'state'     => array
@@ -86,7 +86,7 @@ return array
 
         'button' => array
         (
-            '导入用户' => 'modal|<input type="text" class="autoload_text update_value form-control layui-input " value="" autocomplete="new-password" placeholder="手机号">',
+            '导入用户' => array('fast', 1, 'mobile_upload&where_id=1'),
             '下载导入模板' => array('location', 'journal/lib/manage.mobileTemplate'),
         ),
     ),

+ 57 - 0
journal/database/mobile_upload.php

@@ -0,0 +1,57 @@
+<?php
+
+return array
+(
+	# 表名
+	'name' => 'mobile_upload',
+	# 显示给用户看的名称
+	'lang' => '导入用户',
+	'order' => 1,
+	'menu' => false,
+	'end' => array
+	(
+		'update' => 'journal/lib/manage.mobileImport',
+		'insert' => 'journal/lib/manage.mobileImport',
+	),
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '系统ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'value'		=> Dever::input('where_id'),
+		),
+
+		'file'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '导入用户-请先下载模板',
+			'default' 	=> '',
+			'desc' 		=> '导入用户',
+			'match' 	=> 'is_string',
+			'update'	=> 'upload',
+			'key' 		=> '4',
+			'value'		=> '',
+		),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	'manage' => array
+	(
+		# 后台管理不要列表页
+		'list' => 'update',
+	),
+);

+ 35 - 0
journal/lib/Manage.php

@@ -411,4 +411,39 @@ class Manage
 
         Dever::location($file);
     }
+
+    /**
+     * 导入用户
+     *
+     * @return mixed
+     */
+    public function mobileImport($id, $name, $param)
+    {
+        $file = Dever::param('file', $param);
+        if ($file) {
+            $file = Dever::local($file);
+            //$file = '/www/upload/data/upload/4/2019/04/11/f730437f0b5764790baed3c96c5264b2.xlsx';
+            $data = Dever::excelImport($file);
+            if ($data) {
+                foreach ($data as $k => $v) {
+                    if ($k > 1) {
+                        if (isset($v['A']) && isset($v['B'])) {
+                            if ($v['A']) {
+                                $name = $v['A'];
+                            }
+                            
+                            $journal = Dever::db('journal/info')->one(array('name' => $name));
+                            if ($journal) {
+                                $info = Dever::db('journal/mobile')->one(array('product_id' => $journal['id'], 'mobile' => $v['B']));
+
+                                if (!$info) {
+                                    Dever::db('journal/mobile')->insert(array('product_id' => $journal['id'], 'mobile' => $v['B']));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
 }