@adonia
2016-12-07T07:48:59.000000Z
字数 5808
阅读 161
店铺模块化
-- 店铺与模板信息表
CREATE TABLE decorator_template (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(255) NOT NULL DEFAULT '' COMMENT '店铺模板名称',
creator varchar(255) NOT NULL DEFAULT '' COMMENT '店铺模板创建人信息',
scope tinyint(4) NOT NULL DEFAULT '0' COMMENT '店铺模板作用域,0:系统模板,1:店铺模板',
create_time int(11) NOT NULL DEFAULT '0' COMMENT '模板创建时间,为0不展示',
shop_id int(11) NOT NULL DEFAULT '0' COMMENT '模板归属店铺ID,系统模板为0',
platform tinyint(4) NOT NULL DEFAULT '0' COMMENT '模板所属平台,0:有货PC,1:有货APP,2:BLK-PC,3:BLK-APP',
status tinyint(4) NOT NULL DEFAULT '0' COMMENT '模板状态,0: 暂存,1:发布,系统模板为0',
type tinyint(4) NOT NULL DEFAULT '0' COMMENT '模板类型,0:基础模板,1:经典模板,2:红人店铺',
PRIMARY KEY(id)
);
-- 装修模板与模块关联关系表
CREATE TABLE decorator_template_module (
id int(11) NOT NULL AUTO_INCREMENT,
template_id int(11) NOT NULL DEFAULT '0' COMMENT '装修模板标识',
module_id int(11) NOT NULL DEFAULT '0' COMMENT '装修模块标识',
module_style tinyint(4) NOT NULL DEFAULT '0' COMMENT '模块展示区域,0: 1150, 1: 975, 2: 160。APP端均为0',
module_type varchar(64) NOT NULL DEFAULT '' COMMENT '模块类型,店招、导航...',
module_data varchar(255) NOT NULL DEFAULT '[]' COMMENT '店铺装修数据',
module_order int(11) NOT NULL DEFAULT '0' COMMENT '模块间展示顺序,按照从小到大依次展示',
PRIMARY KEY(id)
);
-- 装修模块表
CREATE TABLE decorator_module (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(64) NOT NULL DEFAULT '' COMMENT '模块名称';
platform tinyint(4) NOT NULL DEFAULT '0' COMMENT '模块所属平台,0: 有货PC,1:有货APP,2:BLK-PC,3:BLK-APP',
style tinyint(4) NOT NULL DEFAULT '0' COMMENT '模块所属区域,0:1150, 1:975, 2:160。APP端的均为0',
description varchar(255) NOT NULL DEFAULT '' COMMENT '模块描述信息',
type varchar(64) NOT NULL DEFAULT '' COMMENT '模块类型,店招、导航...',
pic varchar(64) NOT NULL DEFAULT '' COMMENT '模块的默认展示图片',
PRIMARY KEY(id)
);
-- 店铺与装修模板关系表
CREATE TABLE decorator_template (
shop_id int(11) NOT NULL DEFAULT '0' COMMENT '店铺标识',
template_id int(11) NOT NULL DEFAULT '0' COMMENT '装修模板标识',
publish_time int(11) NOT NULL DEFAULT '0' COMMENT '装修模板发布时间',
platform tinyint(4) NOT NULL DEFAULT '0' COMMENT '模板所属平台,0:有货PC,1:有货APP,2:BLK-PC,3:BLK-APP',
type tinyint(4) NOT NULL DEFAULT '0' COMMENT '模板类型,0:基础模板,1:经典模板,2:红人店铺',
PRIMARY KEY(shop_id, template_id)
);
-- 店铺模板装修数据表
CREATE TABLE decorator_template_module (
id int(11) NOT NULL AUTO_INCREMENT,
template_id int(11) NOT NULL DEFAULT '0' COMMENT '装修模板标识',
module_id int(11) NOT NULL DEFAULT '0' COMMENT '装修模块标识',
module_style tinyint(4) NOT NULL DEFAULT '0' COMMENT '模块展示区域,0: 1150, 1: 975, 2: 160。APP端均为0',
module_type varchar(64) NOT NULL DEFAULT '' COMMENT '模块类型,店招、导航...',
module_data varchar(255) NOT NULL DEFAULT '[]' COMMENT '店铺装修数据',
module_order int(11) NOT NULL DEFAULT '0' COMMENT '模块间展示顺序,按照从小到大依次展示',
PRIMARY KEY(id)
);
首先,向数据库表decorator_module
中录入所有支持的模块信息:
750*234
,展示效果尺寸为375*117
;750*x
,展示效果尺寸为375*x
;375*375
,展示效果为187*375
;660*358
;比如店招
模块,数据如下:
id | name | platform | style | type | pic | description |
---|---|---|---|---|---|---|
1 | 店招模块 | 0 | 0 | shopTopBanner | http://xxx/ | 店铺APP端店招模块,要求上传图片尺寸为'750*234' |
其次,向数据库表中录入默认的系统模板:
暂时只支持红人店铺
。
decorator_template
中录入店铺装修模板基本信息,例如:id | name | creator | scope | create_time | shop_id | platform | status | type |
---|---|---|---|---|---|---|---|---|
1 | 红人店铺 | system | 0 | 2016-12-06 18:00:00 | 0 | 1 | 0 | 2 |
decorator_template_module
中录入店铺装修模板与模块之间的关联关系,包括了系统模板中默认包含了哪些模块,例如:id | template_id | module_id | module_style | module_order |
---|---|---|---|---|
1 | 1 | 1234 | 0 | 2 |
decorator_module_data
表中录入店铺模块装修内容信息,系统模板中是只包含了基本的模块信息,例如APP端只包含了店招模块
,而且是没有任何装修信息的。这里的模块的装修内容是模块的默认展示图片。例如:id | name | type | data |
---|---|---|---|
1234 | 店招 | shopTopBanner | [ {"properties": {},"data": [{"src": "http://www.xxxx.xxx"}]}] |
默认情况下,店铺下是不包含任何自备份的模板的,所有刚开始加载的时候,只会有系统模板。
在进行APP端装修时,默认展示系统模板中的红人店铺
的默认内容,只包含店招模块
,如下:
平台信息
(有货、BLK),及客户端类型
(APP、PC),从decorator_template
表中筛选出系统模板列表(通过platform
、scope
字段);再结合店铺信息,筛选出自备份
模板列表(通过platform
、scope
、shop_id
字段)。自备份
模板,根据其create_time
进行排序,选择最新的;如果没有自备份
模板,选择系统模板中的红人店铺
。platform
字段,查询模块信息
列表,异步Ajax。module_type
来确认模块支持的动作。PC端,默认包含店招
、导航栏
、商品分类列表
、商品列表
;其中店招
、导航栏
可编辑,但不可删除、移动;商品分类列表
不支持任何行为;商品列表
可删除。APP端,默认包含店招
(其中囊括导航栏),可编辑。三张图
,就直接展示三张默认图片。在编辑保存后,直接替换成编辑后的数据即可。暂存
时,再根据数组中的顺序,生成order
字段的值。暂存
操作,会根据现有模块中的数据,重新生成一个新的模板,数据保存在后头表中。发布
操作,先执行暂存
逻辑,再将新生成的模板状态置为发布
。同时,将数据更新至前台表(异步),前台表中最多只有一条装修数据。暂存
动作完成后,检查自备份
模板个数是否超过上限,如果是,根据其中的中的create_time
进行排序,将最早创建的模板及装修数据移除(只处理暂存
状态的模板),异步操作。APP端
PC端
platform: 平台类型, string,
templateType: 启用的模板类型, string, 1--基础模板,2--经典模板
appType: 0--有货装修,1--BLK装修
id | shops_id | check_status | create_time | update_time | status | app_type | blk_check_status |
---|---|---|---|---|---|---|---|
214 | 454 | 300 | 1465334069 | 1477026470 | 0 | 0 | 0 |
id | shops_decorator_id | platform | template_type | create_time | update_time | is_enable | app_type |
---|---|---|---|---|---|---|---|
2 | 214 | PC | 1 | 1465334069 | 1477026470 | Y | 0 |
id | shops_decorator_id | shops_decorator_template_id | resource_name | resource_data | create_time | update_time | app_type | resource_type | is_display |
---|---|---|---|---|---|---|---|---|---|
2 | 214 | 2 | signboard | 1465334069 | 1477026470 | 0 | 0 | 1 |
resource_data
内容如下:
[
{
"data": [
{
"src": "http://img02.static.yohobuy.com/cms/2016/05/06/11/024b64d9671b7831b454074731a16e28a7.jpg",
"startTime": "",
"end Time": "2016-10-20 14:16:43",
"url": ""
}
],
"position": 5
}
]