商品管理属于系统基础信息中的一部分,主要包括分类管理和商品管理
1.分类管理
分类支持无限极分类,包括分类名称,编码,排序
表设计
CREATE TABLE `category` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`category_code` varchar(100) NOT NULL COMMENT '编码',
`category_name` varchar(100) NOT NULL COMMENT '分类名称',
`parent_code` varchar(100) DEFAULT NULL COMMENT '上级ID',
`status` smallint(6) NOT NULL DEFAULT '0' COMMENT '0:停用 1:启用',
`level` int(11) NOT NULL DEFAULT '0' COMMENT '级别',
`priority` int(11) NOT NULL DEFAULT '0' COMMENT '优先级',
`create_user` varchar(50) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_user` varchar(50) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`yn` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COMMENT='分类表'
2.商品管理
表设计
CREATE TABLE `goods` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`sku_code` varchar(100) NOT NULL COMMENT '编码',
`goods_name` varchar(100) NOT NULL COMMENT '分类名称',
`category_code` varchar(100) DEFAULT NULL COMMENT '一级分类编码',
`category_name` varchar(100) DEFAULT NULL COMMENT '一级分类名称',
`two_category_code` varchar(100) DEFAULT NULL COMMENT '二级分类编码',
`two_category_name` varchar(100) DEFAULT NULL COMMENT '二级分类名称',
`status` smallint(6) NOT NULL DEFAULT '1' COMMENT '0:停用 1:启用',
`goods_model` varchar(100) DEFAULT NULL COMMENT '规格型号',
`goods_brand` varchar(100) DEFAULT NULL COMMENT '品牌',
`weight` decimal(18,3) NOT NULL DEFAULT '0.000' COMMENT '重量',
`unit_name` varchar(100) DEFAULT NULL COMMENT '单位名称',
`unit_code` varchar(100) DEFAULT NULL COMMENT '单位编码',
`is_fresh` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否生鲜 0:否 1:是',
`weighed` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否称重 0:否 1:是',
`product_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '商品类型 0:成品 1:半成品 2:原料',
`price` decimal(18,3) NOT NULL DEFAULT '0.000' COMMENT '价格',
`expire_day` int(11) NOT NULL DEFAULT '0' COMMENT '保质期',
`create_user` varchar(50) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_user` varchar(50) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`yn` tinyint(4) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='商品表'
@RequestMapping("/addItem")
@ResponseBody
public ResponseData addItem(GoodsParam goodsParam) {
CategoryParam categoryParam=new CategoryParam();
categoryParam.setCategoryCode(goodsParam.getTwoCategoryCode());
Category twoCategory=categoryService.selectCategoryByCode(categoryParam);
if (twoCategory==null)
return ResponseData.error("查询不到分类信息");
if (Strings.isNullOrEmpty(twoCategory.getParentCode())||twoCategory.getParentCode().equals("0"))
{
return ResponseData.error("只能选择末级分类");
}
String code=this.codeService.generateCode(
CodeExpressEnum.skuCode, null);
if (Strings.isNullOrEmpty(code))
{
return ResponseData.error("商品编码为空");
}
CategoryParam categoryParamTwo=new CategoryParam();
categoryParamTwo.setCategoryCode(twoCategory.getParentCode());
Category category=categoryService.selectCategoryByCode(categoryParamTwo);
goodsParam.setSkuCode(code);
goodsParam.setCategoryCode(category.getCategoryCode());
goodsParam.setCategoryName(category.getCategoryName());
goodsParam.setYn(1);
goodsParam.setStatus(1);
goodsParam.setCreateUser(LoginContextHolder.getContext().getUser().getUsername());
goodsParam.setCreateTime(new Date());
goodsParam.setUpdateUser(LoginContextHolder.getContext().getUser().getUsername());
goodsParam.setUpdateTime(new Date());
this.goodsService.add(goodsParam);
return ResponseData.success();
}
QQ 524300045