Your Name 3 anos atrás
pai
commit
f93c988eb9
3 arquivos alterados com 168 adições e 0 exclusões
  1. 15 0
      database/skin.php
  2. 123 0
      database/template.php
  3. 30 0
      lib/Base.php

+ 15 - 0
database/skin.php

@@ -110,4 +110,19 @@ return array
 			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
 		),
 	),
+
+	'request' => array
+	(
+		'getAll' => array
+		(
+			'option' => array
+			(
+				'key' => array('yes', 'in'),
+				'state' => 1,
+			),
+			'type' => 'all',
+			'order' => array('id' => 'desc'),
+			'col' => '*',
+		),
+	)
 );

+ 123 - 0
database/template.php

@@ -0,0 +1,123 @@
+<?php
+
+$type = function()
+{
+    $array = array
+    (
+        // -1 => array
+        // (
+        //     'id' => '-1',
+        //     'name' => '无来源',
+        // ),
+    );
+    $data = Dever::load('sms/lib/base')->type();
+    if($data)
+    {
+        $array += $data;
+    }
+    return $array;
+};
+$name = Dever::input('search_option_name');
+$mobile = Dever::input('search_option_mobile');
+return array
+(
+	# 表名
+	'name' => 'template',
+	# 显示给用户看的名称
+	'lang' => '短息发送模板',
+	'end' => array
+    (
+    	'insert' => 'sms/lib/base.templateUpdate',
+        'update' => 'sms/lib/base.templateUpdate',
+    ),
+	// 'menu' => false,
+	# 数据结构
+	'struct' => array
+	(
+	
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'search'	=> 'order',
+			//'list'		=> true,
+		),
+
+		'type'        => array
+        (
+            'type'      => 'varchar-2000',
+            'name'      => '类型',
+            'default'   => '',
+            'desc'      => '类型',
+            'match'     => 'is_string',
+            'option'    => $type,
+            'update'    => 'radio',
+            'list'      => true,
+        ),
+
+		'name'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '名称',
+            'default'   => $name,
+            'desc'      => '名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+		
+        'content'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '未审核通过内容',
+            'default'   => '',
+            'desc'      => '未审核通过内容',
+            'match'     => 'is_string',
+            'update'    => 'textarea',
+        ),
+
+        'mobile'      => array
+        (
+            'type'      => 'bigint-11',
+            'name'      => '手机号',
+            'default'   => $mobile,
+            'desc'      => '请输入手机号',
+            'match'     => Dever::rule('mobile'),
+            'update'    => 'hidden',
+        ),
+
+		'state'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '申请时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+			'search'	=> 'date',
+			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
+		),
+	),
+	'manage' => array
+    (
+       'insert' => false,
+        'delete' => false,
+        'edit' => false,
+    ),
+	'request' => array
+	(
+		
+	)
+);

+ 30 - 0
lib/Base.php

@@ -180,4 +180,34 @@ class Base
         $type = isset($this->config['code_type']) ? $this->config['code_type'] : 1;
         return Dever::rand($len, $type - 1);
     }
+    public function type(){
+        $type = Dever::input('search_option_type');
+        $where = array();
+        if ($type) {
+            $where['key'] = $type;
+        }
+        $data = Dever::db('sms/skin')->getAll($where);
+        return $data;
+    }
+    public function templateUpdate($id,$name,$data){
+        $update = array();
+        $content = Dever::param('content', $data);
+        $name = Dever::param('name', $data);
+        $type = Dever::param('type', $data);
+        $info = Dever::db('sms/template')->one($id);
+        if($info){
+            if (Dever::project('sms')) {
+                $skin = Dever::db('sms/skin')->find($type);
+                Dever::load('sms/api')->send($skin['key'], $info['mobile'], array('name' => $name , 'content' => $content),true);
+            }
+        }
+    }
+    public function getTable($table=false){
+
+        // $table = Dever::input('table',$table);
+        if(!$table){
+            $table = 'template';
+        }
+        return 'project/database/update?project=sms&table='.$table;
+    }
 }