'上架', 2 => '下架', ); $id = Dever::input('where_id'); $unit = function() { $array = array(); $data = Dever::load('product/unit-state'); if($data) { $array += $data; } return $array; }; $type = array ( 1 => '实物商品', 2 => '虚拟商品',//虚拟商品可以通过分类设置 //3 => '功能商品',//对应道具市场 11 => '套餐商品', 12 => '组合商品', ); $pay_money = array ( 1 => '法定货币', 2 => '积分', ); $money = function() { $array = array(); $data = Dever::load('account/money-state'); if($data) { $array += $data; } return $array; }; $score = function() { $array = array(); $data = Dever::load('score/config-state'); if($data) { $array += $data; } return $array; }; $sell_type = array ( 1 => '可售卖', 2 => '不可售卖', ); $buy_type = array ( 1 => '可采购', 2 => '不可采购', ); $stock = array ( 1 => '是', 2 => '否', ); $config = array ( # 表名 'name' => 'info', # 显示给用户看的名称 'lang' => '商品资料', 'order' => 200, 'auto' => 10000000, 'set' => array ( 'status' => $status, ), 'start' => array ( 'insert' => 'product/lib/manage.check', 'update' => 'product/lib/manage.check', ), 'end' => array ( 'insert' => 'product/lib/manage.infoUpdate', 'update' => 'product/lib/manage.infoUpdate', ), # 同步更新另外一个或多个表的数据,将数据同步到关联表中 'sync' => array ( 'product/info_category' => array ( # 更新另外一个表的字段 => 本表的字段 'where' => array('info_id', 'id'), # 要更新的数据 'update' => array('category_id' => 'category'), # 同步更新的类型,delete为先删再插入,update为直接更新 'type' => 'delete', ) ), # 数据结构 不同的字段放这里 'struct' => array ( 'id' => array ( 'type' => 'int-11', 'name' => '商品编码', 'default' => '', 'desc' => '', 'match' => 'is_numeric', 'list' => true, ), 'name' => array ( 'type' => 'varchar-800', 'name' => '商品标题', 'default' => '', 'desc' => '商品标题', 'match' => 'is_string', 'update' => 'textarea', 'search' => 'fulltext', 'list' => true, //'edit' => true, ), 'unit' => array ( 'type' => 'int-11', 'name' => '商品单位', 'default' => '', 'desc' => '商品单位', 'match' => 'is_numeric', 'search' => 'select', 'lang' => '请选择', 'update' => 'select', 'option' => $unit, 'option_add' => array('[添加新单位]', 'product/lib/unit.add'), 'tab' => 1, ), 'type' => array ( 'type' => 'int-11', 'name' => '商品类型-套餐商品和组合商品都是由多个商品组成,区别是组合商品的库存由组成的商品的最少库存决定,套餐商品可以单独设置库存', 'default' => '1', 'desc' => '商品类型', 'match' => 'is_numeric', 'update' => 'radio', 'option' => $type, 'search' => 'select', 'list' => true, 'tab' => 1, 'control' => 'type', ), 'goods' => array ( 'type' => 'text-1000', 'name' => '商品配置-套餐和组合商品可以选择多个套餐或者组合内的商品', 'default' => '', 'desc' => '商品配置', 'match' => 'is_string', 'show' => 'type=11,12', 'update' => array ( array ( 'col' => 'goods_id', 'name' => '选择商品', 'default' => '', 'desc' => '选择商品', 'match' => 'option', 'update' => 'select', 'update_search' => 'product/lib/manage.searchProduct?{id}', ), array ( 'col' => 'num', 'name' => '数量', 'default' => '1', 'desc' => '数量', 'match' => 'is_string', 'update' => 'text', ), ), 'tab' => 1, ), 'stock' => array ( 'type' => 'tinyint-1', 'name' => '是否有库存', 'default' => '1', 'desc' => '是否有库存', 'match' => 'is_numeric', 'update' => 'radio', 'option' => $stock, 'tab' => 1, ), 'sell_type' => array ( 'type' => 'int-11', 'name' => '售卖类型', 'default' => '1', 'desc' => '售卖类型', 'match' => 'is_numeric', 'update' => 'radio', 'option' => $sell_type, 'control' => 'sell_type', 'tab' => 1, ), 'buy_type' => array ( 'type' => 'int-11', 'name' => '采购类型', 'default' => '1', 'desc' => '采购类型', 'match' => 'is_numeric', 'update' => 'radio', 'option' => $buy_type, 'control' => 'buy_type', 'tab' => 1, ), 'pay_money' => array ( 'type' => 'tinyint-1', 'name' => '支付货币-默认用该货币购买商品', 'default' => '1', 'desc' => '支付货币', 'match' => 'is_numeric', 'update' => 'radio', 'option' => $pay_money, 'search' => 'select', //'list' => true, 'tab' => 1, 'control' => 'pay_money', ), 'money_id' => array ( 'type' => 'int-11', 'name' => '法定货币', 'default' => '', 'desc' => '法定货币', 'match' => 'is_numeric', 'update' => 'radio', 'option' => $money, 'tab' => 1, 'show' => 'pay_money=1', ), 'score_id' => array ( 'type' => 'int-11', 'name' => '积分', 'default' => '', 'desc' => '积分', 'match' => 'is_numeric', 'update' => 'radio', 'option' => $score, 'tab' => 1, 'show' => 'pay_money=2', ), 'commission' => array ( 'type' => 'varchar-20', 'name' => '销售商佣金-设置佣金之后,销售商销售了商品,能得到的相应佣金,也可以在销售商里单独设置,填写10%就是销售价的百分之10,直接填写数字就是佣金数额', 'default' => '0', 'desc' => '销售商佣金', 'match' => 'is_string', 'update' => 'text', 'tab' => 1, ), 'category' => array ( 'type' => 'varchar-500', 'name' => '属性分类', 'default' => '', 'desc' => '分类', 'match' => 'is_string', 'search' => 'linkage', //'update' => $id ? false : 'linkage', 'update' => 'linkage', 'option' => Dever::url('lib/category.get?type=1', 'product'), //'update' => 'radio', //'option' => Dever::db('product/category')->select(), 'list' => 'Dever::load("product/lib/category.string", "{category}")', 'load' => 'product-info_attr', 'tab' => 2, ), 'product-info_attr'=> array ( 'name' => '属性设置', 'default' => '', 'desc' => '请先选择属性分类', 'match' => 'option', # 同步更新另外一个表的内容,两个表相关联的id,更新另一个表的字段 'sync' => array('id', 'info_id'), # 根据category字段的值,获取product/attr.search接口的内容 'update' => 'load', 'update_load' => array('product/lib/attr.getManageByCate', 'category'), 'tab' => 2, ), 'product-info_spec'=> array ( 'name' => '规格设置-成本价为平台进货成本价格,采购价为销售商采购商品价格,销售价为用户购买价格,划线价为用户购买价的划线价格', 'default' => '', 'desc' => '规格设置', 'match' => 'option', 'sync' => array('id', 'info_id'), 'update' => 'sku', 'tab' => 3, ), 'spec_type' => array ( 'type' => 'tinyint-1', 'name' => '规格类型', 'default' => '1', 'desc' => '规格类型', 'match' => 'is_numeric', //'update' => 'select', 'option' => array(1 => '单规格', 2 => '多规格'), ), # 以下几个分类其实在关联表中已经有了,放到这里是为了查询方便,一般只有三级分类,多了就从关联表查询吧 'top_category_id' => array ( 'type' => 'int-11', 'name' => '顶级分类ID-顶级分类,用于分类查询', 'default' => '-1', 'desc' => '顶级分类ID', 'match' => 'is_numeric', ), 'second_category_id' => array ( 'type' => 'int-11', 'name' => '二级分类ID-二级分类,用于分类查询', 'default' => '-1', 'desc' => '二级分类ID', 'match' => 'is_numeric', ), 'category_id' => array ( 'type' => 'int-11', 'name' => '子分类ID-最后一个级别的分类,用于分类查询', 'default' => '-1', 'desc' => '子分类ID', 'match' => 'is_numeric', ), 'pic' => array ( 'type' => 'text-255', 'name' => '商品主图-图片尺寸500*500px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式', 'default' => '', 'desc' => '多张图片', 'match' => 'option', 'update' => 'images', 'key' => '1', 'place' => '500*500', ), 'video' => array ( 'type' => 'varchar-800', 'name' => '商品视频-视频格式mp4,上传大小不能超过4G', 'default' => '', 'desc' => '商品视频', 'match' => 'option', 'update' => 'video', 'key' => '3', 'place' => '150', 'upload' => 'yun', 'large' => true, //'cover' => 'pic',//封面图字段名 ), 'status' => array ( 'type' => 'tinyint-1', 'name' => '状态', 'default' => '1', 'desc' => '状态', 'match' => 'is_numeric', //'update' => 'select', 'option' => $status, 'search' => 'select', 'list' => true, 'edit' => true, ), 'reorder' => array ( 'type' => 'int-11', 'name' => '排序-数值越大越靠前,相当于置顶', 'default' => '1', 'desc' => '请输入排序', 'match' => 'option', //'update' => 'text', 'search' => 'order', 'list' => true, 'order' => 'desc', 'edit' => true, ), 'content' => array ( 'type' => 'text-800', 'name' => '商品介绍', 'default' => '', 'desc' => '商品介绍', 'match' => 'is_string', 'update' => 'editor', 'key' => '1', ), 'state' => array ( 'type' => 'tinyint-1', 'name' => '数据状态', 'default' => '1', 'desc' => '请选择状态', 'match' => 'is_numeric', ), 'udate' => array ( 'type' => 'int-11', 'name' => '更新时间', 'match' => array('is_numeric', time()), 'desc' => '', 'search' => 'date', ), '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})', ), ), # 索引 'index' => array ( 1 => array ( 'search' => 'category,top_category_id,second_category_id,category_id', ), # 版本号 更改版本号会更新当前表的索引 'version' => 1, ), # 管理功能 'manage' => array ( # 定义sku对应的表,不填写则默认为info_spec和info_sku 'sku' => array ( # 定义表名 'spec' => 'info_spec', 'sku' => 'info_sku', # 定义字段 'col' => array ( 'pic' => array('name' => '图片', 'verify' => 'string', 'type' => 'image'), 'code' => array('name' => '商品编码', 'verify' => 'string', 'type' => 'input'), 'cost_price' => array('name' => '成本价', 'verify' => 'number', 'type' => 'input'), 'buy_price' => array('name' => '采购价', 'verify' => 'number', 'type' => 'input'), 'price' => array('name' => '销售价', 'verify' => 'number', 'type' => 'input'), 'un_price' => array('name' => '划线价', 'verify' => 'number', 'type' => 'input'), ), # 接口 'api' => array ( 'spec' => 'product/lib/spec.get', 'sku' => 'product/lib/sku.get', # 上传接口 'upload' => 'upload/save.start?key=1', ), ), 'tab' => array('内容设置', '基础设置', '属性设置', '规格设置'), // 载入自定义资源 路径可以配置在config里。这里没有写路径。demo.css 'res' => array ( //'css' => 'demo', ), //'insert' => false, //'delete' => false, //'mul' => true, # 自定义快捷新增和编辑 'button' => array ( //'类别管理' => array('list', 'cate&project=demand&search_option_key=cate&search_option_tablename=类别&oper_parent=info&oper_project=demand'), ), # 列表里的按钮 /* 'list_button' => array ( 'add' => array('属性', '"info_attr &project=goods &search_option_info_id={id} &search_option_category={category} &oper_parent=info&oper_project=goods &oper_save_jump=info &where_id={id}"'), 'list' => array('规格', '"info_sku &project=goods &search_option_info_id={id} &oper_parent=info&oper_project=goods &oper_save_jump=info&page_type=1"'), ),*/ ), # request 请求接口定义 'request' => array ( # 后台搜索用到,也可以不加,自动生成 'search' => array ( # 匹配的正则或函数 选填项 'option' => array ( 'ids' => array('yes-id', 'in'), 'name' => array('yes', 'like'), 'id_no' => array('yes-id', '!='), 'state' => 1, ), 'type' => 'all', 'order' => array('reorder' => 'desc', 'id' => 'desc'), 'limit' => '0,10', 'col' => 'name as name, id, id as value, "" as selected, "" as disabled,spec_type|id', ), # 列表 'getData' => array ( # 匹配的正则或函数 选填项 'option' => array ( 'category' => array('yes', 'like'), 'top_category_id' => array('yes', 'in'), 'second_category_id' => 'yes', 'category_id' => 'yes', 'status' => 'yes', 'state' => 1, ), 'type' => 'all', 'order' => array('reorder' => 'desc', 'id' => 'desc'), 'col' => '*', ), # 列表 'getAll' => array ( # 匹配的正则或函数 选填项 'option' => array ( 'category' => array('yes', 'like'), 'top_category_id' => 'yes', 'second_category_id' => 'yes', 'category_id' => 'yes', 'status' => 1, 'state' => 1, ), 'type' => 'all', 'order' => array('reorder' => 'desc', 'id' => 'desc'), 'limit' => '0,10', //'page' => array(10, 'list'), 'col' => '*', ), # 分页 'getPageAll' => array ( # 匹配的正则或函数 选填项 'option' => array ( 'shop_id' => 'yes', 'name' => array('yes', 'like'), 'audit' => 2, 'category' => array('yes', 'like'), 'top_category_id' => 'yes', 'second_category_id' => 'yes', 'category_id' => 'yes', //'status' => 1, 'state' => 1, ), 'type' => 'all', 'order' => array('reorder' => 'desc', 'id' => 'desc'), 'page' => array(10, 'list'), 'col' => '*', ), 'getOne' => array ( # 匹配的正则或函数 选填项 'option' => array ( 'id' => 'yes', 'status' => 1, 'state' => 1, ), 'type' => 'one', 'col' => 'id,name,category,pic,content,video,type,unit,spec_type,goods,commission,pay_money,money_id,score_id,sell_type,buy_type,udate,cdate', ), ), ); return $config;