java进销存--商品管理

商品管理属于系统基础信息中的一部分,主要包括分类管理和商品管理

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值