<?php

$type = Dever::config('base', 'pay')->pay['type'];

$system_source = Dever::config('base')->system_source;

$channel = function()
{
	return Dever::db('pay/channel')->state();
};

$box = array
(
	1 => '正式环境',
	2 => '沙箱模式',
	3 => '测试环境',
);

return array
(
	# 表名
	'name' => 'account',
	# 显示给用户看的名称
	'lang' => '账户管理',
	'order' => 10,
	# 数据结构
	'struct' => array
	(
	
		'id' 		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> 'ID',
			'default' 	=> '',
			'desc' 		=> '',
			'match' 	=> 'is_numeric',
			'search'	=> 'order',
			'list'		=> true,
		),

		'name'		=> array
		(
			'type' 		=> 'varchar-60',
			'name' 		=> '账户名称',
			'default' 	=> '',
			'desc' 		=> '账户名称',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'search'	=> 'fulltext',
			'list'		=> true,
		),

		'type'		=> array
		(
			'type' 		=> 'varchar-30',
			'name' 		=> '支付类型',
			'default' 	=> 'wechat',
			'desc' 		=> '支付类型',
			'match' 	=> 'is_string',
			'update'	=> 'radio',
			'option'	=> $type,
			'search'	=> 'select',
			'list'		=> true,
			'control'	=> 'type',
		),

		'box'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '支付环境-沙箱模式为支付时第三方平台不实际收费,测试环境为不拉取第三方支付',
			'default' 	=> '1',
			'desc' 		=> '支付环境',
			'match' 	=> 'is_numeric',
			'update'	=> 'radio',
			'option'	=> $box,
			'show'		=> 'alipay',
		),

		'system_source'		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '所属平台',
			'default' 	=> '1',
			'desc' 		=> '所属平台',
			'match' 	=> 'is_numeric',
			'update'	=> 'radio',
			'option'	=> $system_source,
			'search'	=> 'select',
			'list'		=> true,
		),

		'channel_id'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '所属渠道',
			'default' 	=> '1',
			'desc' 		=> '所属渠道',
			'match' 	=> 'is_numeric',
			'update'	=> 'radio',
			'option'	=> $channel,
			'search'	=> 'select',
			'list'		=> true,
		),

		'mchid'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '商户号',
			'default' 	=> '',
			'desc' 		=> '商户号',
			'match' 	=> 'is_string',
			'update'	=> 'text',
		),

		'key'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '密匙key',
			'default' 	=> '',
			'desc' 		=> '密匙key',
			'match' 	=> 'is_string',
			'update'	=> 'text',
		),

		'appid'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> 'appid',
			'default' 	=> '',
			'desc' 		=> 'appid',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'show'	=> 'type=wechat,cmbc,alipay,yspay,yspaym',
		),

		'appsecret'		=> array
		(
			'type' 		=> 'varchar-300',
			'name' 		=> 'appsecret',
			'default' 	=> '',
			'desc' 		=> 'appsecret',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'show'	=> 'type=wechat,cmbc,yspay,yspaym',
		),

		'account'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '支付账号',
			'default' 	=> '',
			'desc' 		=> '支付账号',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'show'	=> 'type=alipay',
		),

		'private_key'		=> array
		(
			'type' 		=> 'text-255',
			'name' 		=> '商户私钥-https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.nBDxfy&treeId=58&articleId=103242&docType=1',
			'default' 	=> '',
			'desc' 		=> '商户私钥',
			'match' 	=> 'is_string',
			'update'	=> 'textarea',
			'show'	=> 'type=alipay',
		),

		'm_public_key'		=> array
		(
			'type' 		=> 'varchar-1000',
			'name' 		=> '商户公钥-https://b.alipay.com/order/pidAndKey.htm',
			'default' 	=> '',
			'desc' 		=> '商户公钥',
			'match' 	=> 'is_string',
			'update'	=> 'textarea',
			'show'	=> 'type=alipay',
		),

		'public_key'		=> array
		(
			'type' 		=> 'varchar-1000',
			'name' 		=> '支付宝公钥-https://b.alipay.com/order/pidAndKey.htm',
			'default' 	=> '',
			'desc' 		=> '支付宝公钥',
			'match' 	=> 'is_string',
			'update'	=> 'textarea',
			'show'	=> 'type=alipay',
		),

		'appCertPath'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '支付宝appCertPath',
			'default' 	=> '',
			'desc' 		=> '证书cert文件',
			'match' 	=> 'option',
			'update'	=> 'upload',
			'key'		=> '4',
			'show'	=> 'type=alipay',
		),

		'alipayCertPath'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '支付宝alipayCertPath',
			'default' 	=> '',
			'desc' 		=> '证书key文件',
			'match' 	=> 'option',
			'update'	=> 'upload',
			'key'		=> '4',
			'show'	=> 'type=alipay',
		),

		'rootCertPath'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '支付宝rootCertPath',
			'default' 	=> '',
			'desc' 		=> '证书key文件',
			'match' 	=> 'option',
			'update'	=> 'upload',
			'key'		=> '4',
			'show'	=> 'type=alipay',
		),

		'file_cert'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '证书cert文件',
			'default' 	=> '',
			'desc' 		=> '证书cert文件',
			'match' 	=> 'option',
			'update'	=> 'upload',
			'key'		=> '4',
			'show'	=> 'type=wechat',
		),

		'file_key'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '证书key文件',
			'default' 	=> '',
			'desc' 		=> '证书key文件',
			'match' 	=> 'option',
			'update'	=> 'upload',
			'key'		=> '4',
			'show'	=> 'type=wechat',
		),

		'timeout'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '支付有效期-秒',
			'default' 	=> '600',
			'desc' 		=> '支付有效期',
			'match' 	=> 'is_numeric',
			'update'	=> 'text',
		),

		'pay/yspay' => array
		(
			'name' 		=> '银商扩展设置',
			'default' 	=> '',
			'desc' 		=> '银商扩展设置',
			'match' 	=> 'option',
			# 同步更新另外一个表的内容,另外一个表的字段=>本表的字段
			'sync'		=> array('account_id' => 'id'),
			'update'	=> array(1),
			'option'	=> array('默认配置'),
			# 1纵向展示 2横向展示
			'update_type' => 1,
			'show'		=> 'type=yspay',
		),

		'pay/yspay_project'      => array
        (
            'name'      => '关联项目',
            'default'   => '',
            'desc'      => '关联项目',
            'match'     => 'option',
            'sync'      => array('account_id' => 'id'),
            'update_type' => 2,
            'update'    => array(1),
            'show'		=> 'type=yspay',
        ),

		'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
	(
		# 自定义快捷新增和编辑
        'button' => array
        (
            '渠道管理' => array('list', 'channel&project=pay&oper_parent=account&oper_project=pay'),
        ),
        'list_button' => array
        (
        	'list' => array('商户列表', '"yspay_merchant&search_option_account_id={id}&oper_table=account"', '"{type}" == "yspay"'),

			//'list1' => array('资管', '"yspay_sign&search_option_account_id={id}&oper_table=account"', '"{type}" == "yspay"'),
        ),
	),

	# 默认值
	'default' => array
	(
		'col' => 'name,system_source,type,state,cdate',
		'value' => array
		(
			'"h5支付",1,"wechat",1,' . time(),
			'"安卓支付",2,"wechat",1,' . time(),
			'"苹果支付",3,"wechat",1,' . time(),
			'"微信二维码支付",4,"wechat",1,' . time(),
			'"微信小程序支付",5,"wechat",1,' . time(),
			'"微信公众号支付",6,"wechat",1,' . time(),
		),
	),
);