rabin 2 年之前
當前提交
3b442674fe

+ 7 - 0
config/base.php

@@ -0,0 +1,7 @@
+<?php
+$config['base'] = array
+(
+	'request_desc' => '变量:{timestamp}毫秒时间戳,{appkey}渠道的appkey,{signature}签名后的信息,{api_request}业务参数,支持Dever自带的所有方法,如Dever::uuid(),就是获取唯一值,传入参数字符串请使用双引号',
+);
+
+return $config;

+ 235 - 0
database/channel.php

@@ -0,0 +1,235 @@
+<?php
+
+$sign_method = array
+(
+	1 => 'md5',
+	2 => 'sha256',
+);
+
+$type = array
+(
+	1 => '标准请求体',
+	2 => '标准请求头',
+);
+
+$method = array
+(
+	1 => 'get',
+	2 => 'post',
+);
+
+$post_method = array
+(
+	1 => '普通表单:application/x-www-form-urlencoded',
+	2 => '文件表单:multipart/form-data',
+	3 => 'JSON:application/json',
+	//4 => 'XML:text/xml',
+);
+
+return array
+(
+	# 表名
+	'name' => 'channel',
+	# 显示给用户看的名称
+	'lang' => '渠道设置',
+	# 是否显示在后台菜单
+	'order' => 10,
+
+	'set' => array
+	(
+		'method' => $method,
+		'post_method' => $post_method,
+	),
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '渠道名称',
+			'default' 	=> '',
+			'desc' 		=> '渠道名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'appid'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '渠道APPID',
+			'default' 	=> '',
+			'desc' 		=> '渠道APPID',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'appkey'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '渠道APPKEY',
+			'default' 	=> '',
+			'desc' 		=> '渠道APPKEY',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			//'search'	=> 'fulltext',
+			//'list'		=> true,
+		),
+
+		'host'		=> array
+		(
+			'type' 		=> 'varchar-1000',
+			'name' 		=> '渠道接口域名',
+			'default' 	=> '',
+			'desc' 		=> '渠道接口域名',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'sign_method'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '请求加密方式',
+			'default' 	=> '1',
+			'desc' 		=> '请求加密方式',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $sign_method,
+		),
+
+		'method'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '标准请求方式',
+			'default' 	=> '1',
+			'desc' 		=> '标准请求方式',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $method,
+			//'list'		=> true,
+			'control'	=> 'method',
+		),
+
+		'post_method'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '标准请求头设置',
+			'default' 	=> '1',
+			'desc' 		=> '标准请求头设置',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $post_method,
+			'show'		=> 'method=2',
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'varchar-20',
+			'name' 		=> '是否有标准请求参数',
+			'default' 	=> '1,2',
+			'desc' 		=> '是否有标准请求参数',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'checkbox',
+			'option'	=> $type,
+			//'list'		=> true,
+			'control'	=> 'type',
+		),
+
+		'middleware-channel_request_body'=> array
+		(
+			'name' 		=> '标准请求体参数',
+			'default' 	=> '',
+			'desc' 		=> '标准请求体参数',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'channel_id'),
+			'update'	=> array(1),
+			'show'		=> 'type=1',
+		),
+
+		'middleware-channel_request_header'=> array
+		(
+			'name' 		=> '标准请求头参数',
+			'default' 	=> '',
+			'desc' 		=> '标准请求头参数',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'channel_id'),
+			'update'	=> array(1),
+			'show'		=> 'type=2',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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
+	(
+		//'tab' => array('基本设置', '联系人信息', '认证信息'),
+		'button' => array
+        (
+            //'类型配置' => array('list', 'supplier_type&oper_parent=supplier'),
+        ),
+        'list_button' => array
+        (
+        	//'location' => array('产品设置', Dever::url('lib/channel.setProduct', 'middleware')),
+            'list' => array('业务接口配置', 'channel_api&oper_table=channel&search_option_channel_id={id}'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 230 - 0
database/channel_api.php

@@ -0,0 +1,230 @@
+<?php
+$method = array(-1 => '使用渠道标准请求方式');
+$method += Dever::db('middleware/channel')->config['set']['method'];
+
+$post_method = Dever::db('middleware/channel')->config['set']['post_method'];
+
+$task = array
+(
+	1 => '非定时任务',
+	2 => '定时轮询任务',
+);
+
+$status = array
+(
+	1 => '可执行',
+	2 => '已完成',
+);
+
+return array
+(
+	# 表名
+	'name' => 'channel_api',
+	# 显示给用户看的名称
+	'lang' => '渠道接口配置',
+	# 是否显示在后台菜单
+	'order' => -10,
+	'menu' => false,
+	'info' => '',
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'channel_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '渠道id',
+			'default' 	=> '1',
+			'desc' 		=> '渠道id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_channel_id'),
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '接口名称',
+			'default' 	=> '',
+			'desc' 		=> '接口名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'uri'		=> array
+		(
+			'type' 		=> 'varchar-1000',
+			'name' 		=> '接口地址',
+			'default' 	=> '',
+			'desc' 		=> '接口地址',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'method'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '请求方式',
+			'default' 	=> '-1',
+			'desc' 		=> '请求方式',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $method,
+			//'list'		=> true,
+			'control'	=> 'method',
+		),
+
+		'post_method'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '请求头设置',
+			'default' 	=> '1',
+			'desc' 		=> '请求头设置',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $post_method,
+			'show'		=> 'method=2',
+		),
+
+		'middleware-channel_api_request'=> array
+		(
+			'name' 		=> '业务请求参数',
+			'default' 	=> '',
+			'desc' 		=> '业务请求参数',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'api_id'),
+			'update'	=> array(1),
+		),
+
+		'middleware-channel_api_response'=> array
+		(
+			'name' 		=> '业务响应参数',
+			'default' 	=> '',
+			'desc' 		=> '业务响应参数',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'api_id'),
+			'update'	=> array(1),
+		),
+
+		'task'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '定时请求',
+			'default' 	=> '1',
+			'desc' 		=> '定时请求',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $task,
+			'control'	=> 'task',
+		),
+
+		'ldate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '下次执行时间',
+			'match' 	=> 'is_numeric',
+			'desc' 		=> '请选择执行时间',
+			'update'	=> 'date',
+			'callback'	=> 'maketime',
+			//'list'		=> 'date("Y-m-d H:i:s", {ldate})',
+			'show'		=> 'task=2',
+		),
+
+		'time'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '每次时间间隔-输入数值为与上次执行时间间隔的秒数,为0则执行一次',
+			'default' 	=> '0',
+			'match' 	=> 'is_numeric',
+			'desc' 		=> '请输入时间间隔',
+			'update'	=> 'text',
+			'show'		=> 'task=2',
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+
+		'status'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '状态',
+			'default' 	=> '1',
+			'desc' 		=> '请选择状态',
+			'match' 	=> 'is_numeric',
+			'option' 	=> $status,
+			'list'		=> true,
+		),
+		
+		'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,
+        //'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	//'edit' => array('编辑'),
+        	'list' => array('字段列表', 'service_product_col&oper_table=service_product&top_table=service&search_option_product_id={id}'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 167 - 0
database/channel_api_request.php

@@ -0,0 +1,167 @@
+<?php
+
+$type = array
+(
+	1 => '数值型',
+	2 => '字符串型',
+	3 => 'JSON型',
+);
+
+$sign = array
+(
+	1 => '参与签名',
+	2 => '不参与签名',
+);
+
+return array
+(
+	# 表名
+	'name' => 'channel_api_request',
+	# 显示给用户看的名称
+	'lang' => '请求参数配置',
+	# 是否显示在后台菜单
+	'order' => -10,
+	'menu' => false,
+	'check' => 'key',
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'api_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '接口id',
+			'default' 	=> '1',
+			'desc' 		=> '接口id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_api_id'),
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '参数名称',
+			'default' 	=> '',
+			'desc' 		=> '字段名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '参数标识',
+			'default' 	=> '',
+			'desc' 		=> '参数标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'default'		=> array
+		(
+			'type' 		=> 'varchar-300',
+			'name' 		=> '默认值-' . Dever::config('base', 'middleware')->request_desc,
+			'default' 	=> '',
+			'desc' 		=> '默认值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '参数类型',
+			'default' 	=> '1',
+			'desc' 		=> '参数类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+		),
+
+		'sign'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否参与签名',
+			'default' 	=> '1',
+			'desc' 		=> '是否参与签名',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $sign,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 167 - 0
database/channel_api_response.php

@@ -0,0 +1,167 @@
+<?php
+
+$type = array
+(
+	1 => '数值型',
+	2 => '字符串型',
+);
+
+$sign = array
+(
+	1 => '参与签名',
+	2 => '不参与签名',
+);
+
+
+return array
+(
+	# 表名
+	'name' => 'channel_api_response',
+	# 显示给用户看的名称
+	'lang' => '响应参数配置',
+	# 是否显示在后台菜单
+	'order' => -10,
+	'menu' => false,
+	'check' => 'key',
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'api_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '接口id',
+			'default' 	=> '1',
+			'desc' 		=> '接口id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_api_id'),
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '参数名称',
+			'default' 	=> '',
+			'desc' 		=> '字段名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '参数标识',
+			'default' 	=> '',
+			'desc' 		=> '参数标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'default'		=> array
+		(
+			'type' 		=> 'varchar-300',
+			'name' 		=> '默认值-' . Dever::config('base', 'middleware')->request_desc,
+			'default' 	=> '',
+			'desc' 		=> '默认值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '参数类型',
+			'default' 	=> '1',
+			'desc' 		=> '参数类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+		),
+
+		'sign'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否参与签名',
+			'default' 	=> '1',
+			'desc' 		=> '是否参与签名',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $sign,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 167 - 0
database/channel_request_body.php

@@ -0,0 +1,167 @@
+<?php
+
+$type = array
+(
+	1 => '数值型',
+	2 => '字符串型',
+	3 => 'JSON型',
+);
+
+$sign = array
+(
+	1 => '参与签名',
+	2 => '不参与签名',
+);
+
+return array
+(
+	# 表名
+	'name' => 'channel_request_body',
+	# 显示给用户看的名称
+	'lang' => '请求参数配置',
+	# 是否显示在后台菜单
+	'order' => -10,
+	'menu' => false,
+	'check' => 'key',
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'channel_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '渠道id',
+			'default' 	=> '1',
+			'desc' 		=> '渠道id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_channel_id'),
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '参数名称',
+			'default' 	=> '',
+			'desc' 		=> '字段名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '参数标识',
+			'default' 	=> '',
+			'desc' 		=> '参数标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'default'		=> array
+		(
+			'type' 		=> 'varchar-300',
+			'name' 		=> '默认值-' . Dever::config('base', 'middleware')->request_desc,
+			'default' 	=> '',
+			'desc' 		=> '默认值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '参数类型',
+			'default' 	=> '1',
+			'desc' 		=> '参数类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+		),
+
+		'sign'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '是否参与签名',
+			'default' 	=> '1',
+			'desc' 		=> '是否参与签名',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $sign,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 150 - 0
database/channel_request_header.php

@@ -0,0 +1,150 @@
+<?php
+
+$type = array
+(
+	1 => '数值型',
+	2 => '字符串型',
+	3 => 'JSON型',
+);
+
+return array
+(
+	# 表名
+	'name' => 'channel_request_header',
+	# 显示给用户看的名称
+	'lang' => '请求参数配置',
+	# 是否显示在后台菜单
+	'order' => -10,
+	'menu' => false,
+	'check' => 'key',
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'channel_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '渠道id',
+			'default' 	=> '1',
+			'desc' 		=> '渠道id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_channel_id'),
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '参数名称',
+			'default' 	=> '',
+			'desc' 		=> '字段名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '参数标识',
+			'default' 	=> '',
+			'desc' 		=> '参数标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'default'		=> array
+		(
+			'type' 		=> 'varchar-300',
+			'name' 		=> '默认值-' . Dever::config('base', 'middleware')->request_desc,
+			'default' 	=> '',
+			'desc' 		=> '默认值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'tinyint-1',
+			'name' 		=> '参数类型',
+			'default' 	=> '1',
+			'desc' 		=> '参数类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'radio',
+			'option'	=> $type,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 117 - 0
database/service.php

@@ -0,0 +1,117 @@
+<?php
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+return array
+(
+	# 表名
+	'name' => 'service',
+	# 显示给用户看的名称
+	'lang' => '业务管理',
+	# 是否显示在后台菜单
+	'order' => -10,
+	'check' => 'key',
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '业务名称',
+			'default' 	=> '',
+			'desc' 		=> '业务名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+			'edit'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '业务标识',
+			'default' 	=> '',
+			'desc' 		=> '业务标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        	'list' => array('产品列表', 'service_product&oper_table=service&search_option_service_id={id}'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 151 - 0
database/service_product.php

@@ -0,0 +1,151 @@
+<?php
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+return array
+(
+	# 表名
+	'name' => 'service_product',
+	# 显示给用户看的名称
+	'lang' => '产品管理',
+	# 是否显示在后台菜单
+	'order' => -10,
+	'menu' => false,
+	'check' => 'key',
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'service_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '业务id',
+			'default' 	=> '1',
+			'desc' 		=> '业务id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_service_id'),
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '产品名称',
+			'default' 	=> '',
+			'desc' 		=> '产品名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '产品标识',
+			'default' 	=> '',
+			'desc' 		=> '产品标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'value'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '产品值',
+			'default' 	=> '',
+			'desc' 		=> '产品值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'middleware-service_product_col'=> array
+		(
+			'name' 		=> '字段设置',
+			'default' 	=> '',
+			'desc' 		=> '字段设置',
+			'match' 	=> 'option',
+			# 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段
+			'sync'		=> array('id', 'product_id'),
+			'update'	=> array(1),
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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,
+        //'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            //'新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	//'edit' => array('编辑'),
+        	//'list' => array('字段列表', 'service_product_col&oper_table=service_product&top_table=service&search_option_product_id={id}'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 139 - 0
database/service_product_col.php

@@ -0,0 +1,139 @@
+<?php
+
+$identity = array
+(
+	1 => '个人',
+	2 => '个体户',
+	3 => '企业',
+);
+
+return array
+(
+	# 表名
+	'name' => 'service_product_col',
+	# 显示给用户看的名称
+	'lang' => '产品字段管理',
+	# 是否显示在后台菜单
+	'order' => -10,
+	'menu' => false,
+	'check' => 'key',
+
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> 'ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+			'order'		=> 'desc',
+		),
+
+		'product_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '产品id',
+			'default' 	=> '1',
+			'desc' 		=> '产品id',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'hidden',
+			'value'		=> Dever::input('search_option_product_id'),
+		),
+
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '字段名称',
+			'default' 	=> '',
+			'desc' 		=> '字段名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'key'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '字段标识',
+			'default' 	=> '',
+			'desc' 		=> '字段标识',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'default'		=> array
+		(
+			'type' 		=> 'varchar-300',
+			'name' 		=> '字段默认值',
+			'default' 	=> '',
+			'desc' 		=> '字段默认值',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+			'search'	=> 'fulltext',
+			'list'		=> true,
+		),
+
+		'reorder'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '排序(数值越大越靠前)',
+			'default' 	=> '1',
+			'desc' 		=> '请输入排序',
+			'match' 	=> 'option',
+			//'update'	=> 'text',
+			'search'	=> 'order',
+			'list_name' => '排序',
+			'list'		=> true,
+			'order'		=> 'desc',
+			'edit'		=> true,
+		),
+		
+		'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,
+        'edit' => false,
+
+        # 自定义快捷新增和编辑
+        'button' => array
+        (
+            '新增' => array('fast'),
+        ),
+		'list_button' => array
+        (
+        	'edit' => array('编辑'),
+        )
+	),
+
+	'request' => array
+	(
+		
+	)
+);

+ 10 - 0
index.php

@@ -0,0 +1,10 @@
+<?php
+
+define('DEVER_APP_NAME', 'middleware');
+define('DEVER_APP_LANG', '中间件');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 98);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-flag');
+define('DEVER_GROUP_ORDER', -1);
+define('DEVER_GROUP_NAME', '工具包');
+include(DEVER_APP_PATH . '../boot.php');

+ 115 - 0
lib/Task.php

@@ -0,0 +1,115 @@
+<?php
+
+namespace Middleware\Lib;
+
+use Dever;
+
+class Task
+{
+    # 执行某个业务接口
+    public function run_api()
+    {
+        $channel_id = 1;
+        $api_id = 1;
+        $channel = Dever::db('middleware/channel')->find($channel_id);
+        $channel_api = Dever::db('middleware/channel_api')->find($api_id);
+
+        $url = $channel['host'] . $channel_api['uri'];
+
+        $param = array();
+        $header = $body = false;
+        $method = 'get';
+        $json = false;
+
+        if ($channel_api['method'] == -1) {
+            $channel_api['method'] = $channel['method'];
+            $channel_api['post_method'] = $channel['post_method'];
+        }
+        if ($channel_api['post_method'] == 2) {
+            $method = 'file';
+        } elseif ($channel_api['method'] == 2) {
+            $method = 'post';
+        }
+        if ($channel_api['post_method'] == 3) {
+            $json = true;
+        }
+
+        if ($channel['type']) {
+            $type = explode(',', $channel['type']);
+            if (in_array(1, $type)) {
+                # 请求体
+                $this->request($body, 'request_body', array('channel_id' => $channel['id']), $channel, $channel_api);
+            }
+
+            if (in_array(2, $type)) {
+                # 请求头
+                $this->request($header, 'request_header', array('channel_id' => $channel['id']), $channel, $channel_api);
+            }
+        }
+
+        if (!$body) {
+            $body = $this->body($channel, $channel_api);
+        }
+
+        # 如果是ssl 这里需要处理一下
+
+        $log['url'] = $url;
+        $log['body'] = $body;
+        $log['method'] = $method;
+        $log['json'] = $json;
+        $log['header'] = $header;
+
+        print_r($log);die;
+        //Dever::log($log, 'middleware');
+
+        $response = Dever::curl($url, $body, $method, $json, $header);
+    }
+
+    public function value($data, $channel, $channel_api = array())
+    {
+        $value = $data['default'];
+        if (strstr($value, 'Dever')) {
+            $value = '$value = '.$value.';';
+            eval($value);
+        } elseif ($value == '{timestamp}') {
+            $value = time();
+        } elseif ($value == '{appkey}') {
+            $value = $channel['appkey'];
+        } elseif ($value == '{signature}') {
+            //$value = $channel['signature'];//待处理
+        } elseif ($value == '{api_request}' && $channel_api) {
+            $value = $this->body($channel, $channel_api);
+        }
+
+        if ($data['type'] == 1) {
+            $value = (float) $value;
+        } elseif ($data['type'] == 2) {
+            $value = (string) $value;
+        } elseif ($data['type'] == 3 && is_array($value)) {
+            $value = Dever::json_encode($value);
+        }
+
+        return $value;
+    }
+
+    public function request(&$data, $table, $where, $channel, $channel_api = array())
+    {
+        $request_body = Dever::db('middleware/channel_' . $table)->select($where);
+        if ($request_body) {
+            foreach ($request_body as $k => $v) {
+                $data[$v['key']] = $this->value($v, $channel, $channel_api);
+            }
+        }
+    }
+
+    public function body($channel, $channel_api)
+    {
+        $body = array();
+        $this->request($body, 'api_request', array('api_id' => $channel_api['id']), $channel);
+
+        if (!$body) {
+            $body = '';
+        }
+        return $body;
+    }
+}