src/main/java/cc/mrbird/febs/mall/controller/ViewScoreController.java
@@ -30,4 +30,14 @@ } return FebsUtil.view("modules/score/setting"); } @GetMapping("goods") public String goodsList() { return FebsUtil.view("modules/score/goodsList"); } @GetMapping("goods/add") public String goodsAdd() { return FebsUtil.view("modules/score/goodsAdd"); } } src/main/java/cc/mrbird/febs/mall/dto/AddMallGoodsDto.java
@@ -71,4 +71,9 @@ * 是否普通商品 1-普通商品 2-套餐 */ private Integer isNormal; private BigDecimal score; private Integer goodsType; } src/main/java/cc/mrbird/febs/mall/dto/MallGoodsQueryDto.java
@@ -37,4 +37,7 @@ @ApiModelProperty(value = "是否套餐 1-普通商品 2-套餐", example = "2") private Integer isNormal; @ApiModelProperty(value = "1-付费商品 2-积分商品") private Integer goodsType; } src/main/java/cc/mrbird/febs/mall/entity/MallGoods.java
@@ -82,6 +82,16 @@ */ private BigDecimal costPrice; /** * 商品类型 1-付费商品 2-积分商品 */ private Integer goodsType; /** * 积分 */ private BigDecimal score; @TableField(exist = false) private List<MallGoodsStyle> styles; src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
@@ -49,55 +49,59 @@ @Transactional public FebsResponse addMallGoods(AddMallGoodsDto addMallGoodsDto) { String goodsName = addMallGoodsDto.getGoodsName(); if(StrUtil.isEmpty(goodsName)){ if (StrUtil.isEmpty(goodsName)) { return new FebsResponse().fail().message("商品名称不能为空"); } Integer mallGoodsByGoodsName = mallGoodsMapper.selectMallGoodsCountByGoodsName(goodsName); if(mallGoodsByGoodsName > 0){ if (mallGoodsByGoodsName > 0) { return new FebsResponse().fail().message("商品名称不能重复"); } String goodsNo = addMallGoodsDto.getGoodsNo(); if(StrUtil.isEmpty(goodsNo)){ if (StrUtil.isEmpty(goodsNo)) { return new FebsResponse().fail().message("商品编号不能为空"); } Integer mallGoodsByGoodsNo = mallGoodsMapper.selectMallGoodsCountByGoodsNo(goodsNo); if(mallGoodsByGoodsNo > 0){ if (mallGoodsByGoodsNo > 0) { return new FebsResponse().fail().message("商品编号不能重复"); } Long categoryId = addMallGoodsDto.getCategoryId(); if(ObjectUtil.isEmpty(categoryId)){ return new FebsResponse().fail().message("商品分类不能为空"); } List<AddMallGoodsSkuDto> addSkus = addMallGoodsDto.getAddMallGoodsSkuDtos(); if(CollUtil.isEmpty(addSkus)){ return new FebsResponse().fail().message("商品规格不能为空"); } for(AddMallGoodsSkuDto addSku : addSkus){ String skuName = addSku.getSkuName(); if(StrUtil.isEmpty(skuName)){ return new FebsResponse().fail().message("商品规格名称不能为空"); } String skuImage = addSku.getSkuImage(); if(StrUtil.isEmpty(skuImage)){ return new FebsResponse().fail().message("商品规格图片不能为空"); } Integer skuVolume = addSku.getSkuVolume()==null?0: addSku.getSkuVolume(); if(skuVolume < 0){ return new FebsResponse().fail().message("商品规格销售数量不能小于0"); } Integer stock = addSku.getStock()==null?0: addSku.getStock(); if(stock < 0){ return new FebsResponse().fail().message("商品规格库存必须大于0"); } String originalPrice = addSku.getOriginalPrice(); if(StrUtil.isEmpty(originalPrice)){ return new FebsResponse().fail().message("商品规格原价不能为空"); } String presentPrice = addSku.getPresentPrice(); if(StrUtil.isEmpty(presentPrice)){ return new FebsResponse().fail().message("商品规格现价不能为空"); // 付费商品 if (addMallGoodsDto.getGoodsType() != 2) { Long categoryId = addMallGoodsDto.getCategoryId(); if (ObjectUtil.isEmpty(categoryId)) { return new FebsResponse().fail().message("商品分类不能为空"); } List<AddMallGoodsSkuDto> addSkus = addMallGoodsDto.getAddMallGoodsSkuDtos(); if (CollUtil.isEmpty(addSkus)) { return new FebsResponse().fail().message("商品规格不能为空"); } for (AddMallGoodsSkuDto addSku : addSkus) { String skuName = addSku.getSkuName(); if (StrUtil.isEmpty(skuName)) { return new FebsResponse().fail().message("商品规格名称不能为空"); } String skuImage = addSku.getSkuImage(); if (StrUtil.isEmpty(skuImage)) { return new FebsResponse().fail().message("商品规格图片不能为空"); } Integer skuVolume = addSku.getSkuVolume() == null ? 0 : addSku.getSkuVolume(); if (skuVolume < 0) { return new FebsResponse().fail().message("商品规格销售数量不能小于0"); } Integer stock = addSku.getStock() == null ? 0 : addSku.getStock(); if (stock < 0) { return new FebsResponse().fail().message("商品规格库存必须大于0"); } String originalPrice = addSku.getOriginalPrice(); if (StrUtil.isEmpty(originalPrice)) { return new FebsResponse().fail().message("商品规格原价不能为空"); } String presentPrice = addSku.getPresentPrice(); if (StrUtil.isEmpty(presentPrice)) { return new FebsResponse().fail().message("商品规格现价不能为空"); } } } //新增商品 MallGoods mallGoods = MallGoodsConversion.INSTANCE.dtoToEntity(addMallGoodsDto); @@ -105,11 +109,11 @@ mallGoodsMapper.insert(mallGoods); String thumbs = addMallGoodsDto.getThumbs(); if(StrUtil.isNotEmpty(thumbs)){ if (StrUtil.isNotEmpty(thumbs)) { List<String> imgs = StrUtil.splitTrim(thumbs, ","); if(CollUtil.isNotEmpty(imgs)){ if (CollUtil.isNotEmpty(imgs)) { int i = 1; for(String img : imgs){ for (String img : imgs) { MallGoodsImages mallGoodsImages = new MallGoodsImages(); mallGoodsImages.setGoodsId(mallGoods.getId()); mallGoodsImages.setImageUrl(img); @@ -120,17 +124,20 @@ } } if (addMallGoodsDto.getGoodsType() == 2) { return new FebsResponse().success().message("添加成功"); } List<AddMallGoodsSkuDto> addMallGoodsSkuDtos = addMallGoodsDto.getAddMallGoodsSkuDtos(); Set<String> styles = new HashSet<>(); if(CollUtil.isNotEmpty(addMallGoodsSkuDtos)){ for(AddMallGoodsSkuDto addStyleDto : addMallGoodsSkuDtos){ if (CollUtil.isNotEmpty(addMallGoodsSkuDtos)) { for (AddMallGoodsSkuDto addStyleDto : addMallGoodsSkuDtos) { styles.add(addStyleDto.getStyleName()); } } if(CollUtil.isNotEmpty(styles)){ for(String style : styles){ if (CollUtil.isNotEmpty(styles)) { for (String style : styles) { //新增样式 MallGoodsStyle mallGoodsStyle = new MallGoodsStyle(); mallGoodsStyle.setName(style); @@ -140,15 +147,15 @@ } if(CollUtil.isNotEmpty(addMallGoodsSkuDtos)){ for(AddMallGoodsSkuDto addMallGoodsSkuDto : addMallGoodsSkuDtos){ MallGoodsStyle mallGoodsStyleSku = mallGoodsStyleMapper.selectByStyleName(addMallGoodsSkuDto.getStyleName(),mallGoods.getId()); if (CollUtil.isNotEmpty(addMallGoodsSkuDtos)) { for (AddMallGoodsSkuDto addMallGoodsSkuDto : addMallGoodsSkuDtos) { MallGoodsStyle mallGoodsStyleSku = mallGoodsStyleMapper.selectByStyleName(addMallGoodsSkuDto.getStyleName(), mallGoods.getId()); //新增商品规格 MallGoodsSku mallGoodsSku = new MallGoodsSku(); mallGoodsSku.setSkuName(addMallGoodsSkuDto.getSkuName()); mallGoodsSku.setSkuImage(addMallGoodsSkuDto.getSkuImage()); mallGoodsSku.setStock(addMallGoodsSkuDto.getStock()==null?0:addMallGoodsSkuDto.getStock()); mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume()==null?0:addMallGoodsSkuDto.getSkuVolume()); mallGoodsSku.setStock(addMallGoodsSkuDto.getStock() == null ? 0 : addMallGoodsSkuDto.getStock()); mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume() == null ? 0 : addMallGoodsSkuDto.getSkuVolume()); mallGoodsSku.setOriginalPrice(new BigDecimal(addMallGoodsSkuDto.getOriginalPrice())); mallGoodsSku.setPresentPrice(new BigDecimal(addMallGoodsSkuDto.getPresentPrice())); mallGoodsSku.setStyleId(mallGoodsStyleSku.getId()); @@ -164,7 +171,7 @@ @Override public FebsResponse upMallGoods(Long id) { MallGoods mallGoods = mallGoodsMapper.selectById(id); if(ObjectUtil.isEmpty(mallGoods)){ if (ObjectUtil.isEmpty(mallGoods)) { return new FebsResponse().fail().message("商品不存在,请刷新当前页面"); } mallGoods.setIsSale(MallGoods.ISSALE_STATUS_ENABLE); @@ -175,7 +182,7 @@ @Override public FebsResponse downMallGoods(Long id) { MallGoods mallGoods = mallGoodsMapper.selectById(id); if(ObjectUtil.isEmpty(mallGoods)){ if (ObjectUtil.isEmpty(mallGoods)) { return new FebsResponse().fail().message("商品不存在,请刷新当前页面"); } mallGoods.setIsSale(MallGoods.ISSALE_STATUS_DISABLED); @@ -187,11 +194,11 @@ @Transactional public FebsResponse delMallGoods(Long id) { MallGoods mallGoods = mallGoodsMapper.selectById(id); if(ObjectUtil.isEmpty(mallGoods)){ if (ObjectUtil.isEmpty(mallGoods)) { return new FebsResponse().fail().message("商品不存在,请刷新当前页面"); } Integer isSale = mallGoods.getIsSale(); if(MallGoods.ISSALE_STATUS_DISABLED != isSale){ if (MallGoods.ISSALE_STATUS_DISABLED != isSale) { return new FebsResponse().fail().message("请先下架该商品"); } @@ -215,11 +222,11 @@ public AdminMailGoodsUpdateVo getMallGoodsUpdateInfoById(long id) { AdminMailGoodsUpdateVo adminMailGoodsUpdateVo = mallGoodsMapper.getMallGoodsUpdateInfoById(id); List<AdminMailGoodsSkuDetailVo> adminMailGoodsSkuDetailVos = mallGoodsSkuMapper.selectByGoodId(id); if(CollUtil.isNotEmpty(adminMailGoodsSkuDetailVos)){ if (CollUtil.isNotEmpty(adminMailGoodsSkuDetailVos)) { adminMailGoodsUpdateVo.setMailGoodsSkuDetailVo(adminMailGoodsSkuDetailVos); } List<String> adminMailGoodsImagesVos = mallGoodsImagesMapper.selectByGoodId(id); if(CollUtil.isNotEmpty(adminMailGoodsImagesVos)){ if (CollUtil.isNotEmpty(adminMailGoodsImagesVos)) { adminMailGoodsUpdateVo.setMailGoodsImagesVo(adminMailGoodsImagesVos); } return adminMailGoodsUpdateVo; @@ -229,52 +236,52 @@ @Transactional public FebsResponse updateMallGoods(MallGoodsUpdateDto mallGoodsUpdateDto) { String goodsName = mallGoodsUpdateDto.getGoodsName(); if(StrUtil.isEmpty(goodsName)){ if (StrUtil.isEmpty(goodsName)) { return new FebsResponse().fail().message("商品名称不能为空"); } Integer mallGoodsByGoodsName = mallGoodsMapper.selectMallGoodsCountByGoodsNameAndGoodId(goodsName,mallGoodsUpdateDto.getId()); if(mallGoodsByGoodsName > 0){ Integer mallGoodsByGoodsName = mallGoodsMapper.selectMallGoodsCountByGoodsNameAndGoodId(goodsName, mallGoodsUpdateDto.getId()); if (mallGoodsByGoodsName > 0) { return new FebsResponse().fail().message("商品名称不能重复"); } String goodsNo = mallGoodsUpdateDto.getGoodsNo(); if(StrUtil.isEmpty(goodsNo)){ if (StrUtil.isEmpty(goodsNo)) { return new FebsResponse().fail().message("商品编号不能为空"); } Integer mallGoodsByGoodsNo = mallGoodsMapper.selectMallGoodsCountByGoodsNoAndGoodId(goodsNo,mallGoodsUpdateDto.getId()); if(mallGoodsByGoodsNo > 0){ Integer mallGoodsByGoodsNo = mallGoodsMapper.selectMallGoodsCountByGoodsNoAndGoodId(goodsNo, mallGoodsUpdateDto.getId()); if (mallGoodsByGoodsNo > 0) { return new FebsResponse().fail().message("商品编号不能重复"); } Long categoryId = mallGoodsUpdateDto.getCategoryId(); if(ObjectUtil.isEmpty(categoryId)){ if (ObjectUtil.isEmpty(categoryId)) { return new FebsResponse().fail().message("商品分类不能为空"); } List<MailGoodsSkuDto> addSkus = mallGoodsUpdateDto.getMailGoodsSkuDto(); if(CollUtil.isEmpty(addSkus)){ if (CollUtil.isEmpty(addSkus)) { return new FebsResponse().fail().message("商品规格不能为空"); } for(MailGoodsSkuDto addSku : addSkus){ for (MailGoodsSkuDto addSku : addSkus) { String skuName = addSku.getSkuName(); if(StrUtil.isEmpty(skuName)){ if (StrUtil.isEmpty(skuName)) { return new FebsResponse().fail().message("商品规格名称不能为空"); } String skuImage = addSku.getSkuImage(); if(StrUtil.isEmpty(skuImage)){ if (StrUtil.isEmpty(skuImage)) { return new FebsResponse().fail().message("商品规格图片不能为空"); } Integer skuVolume = addSku.getSkuVolume()==null?0: addSku.getSkuVolume(); if(skuVolume < 0){ Integer skuVolume = addSku.getSkuVolume() == null ? 0 : addSku.getSkuVolume(); if (skuVolume < 0) { return new FebsResponse().fail().message("商品规格销售数量不能小于0"); } Integer stock = addSku.getStock()==null?0: addSku.getStock(); if(stock < 0){ Integer stock = addSku.getStock() == null ? 0 : addSku.getStock(); if (stock < 0) { return new FebsResponse().fail().message("商品规格库存必须大于0"); } BigDecimal originalPrice = addSku.getOriginalPrice(); if(originalPrice.compareTo(BigDecimal.ZERO) <= 0){ if (originalPrice.compareTo(BigDecimal.ZERO) <= 0) { return new FebsResponse().fail().message("商品规格原价不能小于0"); } BigDecimal presentPrice = addSku.getPresentPrice(); if(presentPrice.compareTo(BigDecimal.ZERO) <= 0){ if (presentPrice.compareTo(BigDecimal.ZERO) <= 0) { return new FebsResponse().fail().message("商品规格现价不能小于0"); } @@ -297,11 +304,11 @@ mallGoodsImagesMapper.deleteByGoodsId(mallGoodsUpdateDto.getId()); String thumbs = mallGoodsUpdateDto.getThumbs(); if(StrUtil.isNotEmpty(thumbs)){ if (StrUtil.isNotEmpty(thumbs)) { List<String> imgs = StrUtil.splitTrim(thumbs, ","); if(CollUtil.isNotEmpty(imgs)){ if (CollUtil.isNotEmpty(imgs)) { int i = 1; for(String img : imgs){ for (String img : imgs) { MallGoodsImages mallGoodsImages = new MallGoodsImages(); mallGoodsImages.setGoodsId(mallGoods.getId()); mallGoodsImages.setImageUrl(img); @@ -314,23 +321,23 @@ List<MailGoodsSkuDto> mailGoodsSkuDto = mallGoodsUpdateDto.getMailGoodsSkuDto(); Set<String> styles = new HashSet<>(); if(CollUtil.isNotEmpty(mailGoodsSkuDto)){ for(MailGoodsSkuDto addStyleDto : mailGoodsSkuDto){ if(ObjectUtil.isNotEmpty(addStyleDto.getDelLog())){ if (CollUtil.isNotEmpty(mailGoodsSkuDto)) { for (MailGoodsSkuDto addStyleDto : mailGoodsSkuDto) { if (ObjectUtil.isNotEmpty(addStyleDto.getDelLog())) { mallGoodsSkuMapper.deleteById(addStyleDto.getId()); mallShoppingCartMapper.deleteByGoodsIdAndSkuId(addStyleDto.getId(),addStyleDto.getGoodsId()); mallShoppingCartMapper.deleteByGoodsIdAndSkuId(addStyleDto.getId(), addStyleDto.getGoodsId()); } if(ObjectUtil.isEmpty(addStyleDto.getStyleId())){ MallGoodsStyle mallGoodsStyleSku = mallGoodsStyleMapper.selectByStyleName(addStyleDto.getStyleName(),mallGoods.getId()); if(ObjectUtil.isEmpty(mallGoodsStyleSku)){ if (ObjectUtil.isEmpty(addStyleDto.getStyleId())) { MallGoodsStyle mallGoodsStyleSku = mallGoodsStyleMapper.selectByStyleName(addStyleDto.getStyleName(), mallGoods.getId()); if (ObjectUtil.isEmpty(mallGoodsStyleSku)) { styles.add(addStyleDto.getStyleName()); } } } } if(CollUtil.isNotEmpty(styles)){ for(String style : styles){ if (CollUtil.isNotEmpty(styles)) { for (String style : styles) { //新增样式 MallGoodsStyle mallGoodsStyle = new MallGoodsStyle(); mallGoodsStyle.setName(style); @@ -339,28 +346,28 @@ } } if(CollUtil.isNotEmpty(mailGoodsSkuDto)){ for(MailGoodsSkuDto addMallGoodsSkuDto : mailGoodsSkuDto){ if(StrUtil.isEmpty(addMallGoodsSkuDto.getDelLog())){ if(ObjectUtil.isNotEmpty(addMallGoodsSkuDto.getId())){ if (CollUtil.isNotEmpty(mailGoodsSkuDto)) { for (MailGoodsSkuDto addMallGoodsSkuDto : mailGoodsSkuDto) { if (StrUtil.isEmpty(addMallGoodsSkuDto.getDelLog())) { if (ObjectUtil.isNotEmpty(addMallGoodsSkuDto.getId())) { MallGoodsSku mallGoodsSku = mallGoodsSkuMapper.selectById(addMallGoodsSkuDto.getId()); mallGoodsSku.setSkuName(addMallGoodsSkuDto.getSkuName()); mallGoodsSku.setSkuImage(addMallGoodsSkuDto.getSkuImage()); mallGoodsSku.setStock(addMallGoodsSkuDto.getStock()==null?0:addMallGoodsSkuDto.getStock()); mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume()==null?0:addMallGoodsSkuDto.getSkuVolume()); mallGoodsSku.setStock(addMallGoodsSkuDto.getStock() == null ? 0 : addMallGoodsSkuDto.getStock()); mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume() == null ? 0 : addMallGoodsSkuDto.getSkuVolume()); mallGoodsSku.setOriginalPrice(addMallGoodsSkuDto.getOriginalPrice()); mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getPresentPrice()); mallGoodsSku.setStyleId(addMallGoodsSkuDto.getStyleId()); mallGoodsSku.setGoodsId(mallGoods.getId()); mallGoodsSkuMapper.updateById(mallGoodsSku); }else{ } else { //新增商品规格 MallGoodsStyle mallGoodsStyleSku = mallGoodsStyleMapper.selectByStyleName(addMallGoodsSkuDto.getStyleName(),mallGoods.getId()); MallGoodsStyle mallGoodsStyleSku = mallGoodsStyleMapper.selectByStyleName(addMallGoodsSkuDto.getStyleName(), mallGoods.getId()); MallGoodsSku mallGoodsSku = new MallGoodsSku(); mallGoodsSku.setSkuName(addMallGoodsSkuDto.getSkuName()); mallGoodsSku.setSkuImage(addMallGoodsSkuDto.getSkuImage()); mallGoodsSku.setStock(addMallGoodsSkuDto.getStock()==null?0:addMallGoodsSkuDto.getStock()); mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume()==null?0:addMallGoodsSkuDto.getSkuVolume()); mallGoodsSku.setStock(addMallGoodsSkuDto.getStock() == null ? 0 : addMallGoodsSkuDto.getStock()); mallGoodsSku.setSkuVolume(addMallGoodsSkuDto.getSkuVolume() == null ? 0 : addMallGoodsSkuDto.getSkuVolume()); mallGoodsSku.setOriginalPrice(addMallGoodsSkuDto.getOriginalPrice()); mallGoodsSku.setPresentPrice(addMallGoodsSkuDto.getPresentPrice()); mallGoodsSku.setStyleId(mallGoodsStyleSku.getId()); src/main/java/cc/mrbird/febs/mall/service/impl/ScoreServiceImpl.java
@@ -76,7 +76,6 @@ mallScoreSignRecord = new MallScoreSignRecord(); } System.out.println(DateUtil.between(mallScoreSignRecord.getSignTime(), new Date(), DateUnit.DAY)); if (mallScoreSignRecord.getSignTime() != null && DateUtil.between(mallScoreSignRecord.getSignTime(), new Date(), DateUnit.DAY) == 0) { throw new FebsException("今天已签到"); } src/main/java/cc/mrbird/febs/mall/vo/AdminMallGoodsVo.java
@@ -3,6 +3,8 @@ import io.swagger.annotations.ApiModel; import lombok.Data; import java.math.BigDecimal; @Data @ApiModel(value = "AdminMallGoodsVo", description = "信息返回类") public class AdminMallGoodsVo { @@ -38,4 +40,6 @@ private Integer skuVolume; private Integer stock; private BigDecimal score; } src/main/resources/mapper/modules/MallGoodsMapper.xml
@@ -77,6 +77,9 @@ <if test="record.isNormal != null and record.isNormal != ''"> and a.is_normal = #{record.isNormal} </if> <if test="record.goodsType != null and record.goodsType != ''"> and a.goods_type = #{record.goodsType} </if> <if test="record.categoryId != null and record.categoryId != ''"> and (c.id = #{record.categoryId} or c.parent_id=#{record.categoryId}) </if> @@ -120,9 +123,10 @@ a.original_price, a.present_price, a.is_hot, a.score, b.name categaryName, sum(c.sku_volume) skuVolume, sum(c.stock) stock IFNULL(sum(c.sku_volume), a.volume) skuVolume, IFNULL(sum(c.stock), a.stock) stock from mall_goods a left join mall_goods_category b on b.id = a.category_id left join mall_goods_sku c on c.goods_id = a.id @@ -131,6 +135,9 @@ <if test="record.goodsName != null and record.goodsName != ''"> and a.goods_name like CONCAT('%', CONCAT(#{record.goodsName}, '%')) </if> <if test="record.goodsType != null and record.goodsType != ''"> and a.goods_type=#{record.goodsType} </if> </if> </where> group by a.id src/main/resources/templates/febs/views/modules/score/goodsAdd.html
New file @@ -0,0 +1,285 @@ <style> #score-goods-add { padding: 20px 25px 25px 0; } #score-goods-add .layui-treeSelect .ztree li a, .ztree li span { margin: 0 0 2px 3px !important; } #score-goods-add #data-permission-tree-block { border: 1px solid #eee; border-radius: 2px; padding: 3px 0; } #score-goods-add .layui-treeSelect .ztree li span.button.switch { top: 1px; left: 3px; } .layui-upload-img{ max-width: 300px; } </style> <div class="layui-fluid" id="score-goods-add"> <form class="layui-form" action="" lay-filter="score-goods-add-form"> <div class="layui-row layui-col-space10 layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">商品名称:</label> <div class="layui-input-block"> <input type="text" name="goodsName" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">商品编号:</label> <div class="layui-input-block"> <input type="text" name="goodsNo" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> </div> </div> </div> <div class="layui-row layui-col-space10 layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">原价:</label> <div class="layui-input-block"> <input type="text" name="originalPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">兑换积分:</label> <div class="layui-input-block"> <input type="text" name="score" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> </div> </div> </div> <div class="layui-form-item"> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">库存:</label> <div class="layui-input-block"> <input type="text" name="stock" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> </div> </div> <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">销量:</label> <div class="layui-input-block"> <input type="text" name="volume" lay-verify="required" placeholder="" autocomplete="off" class="layui-input"> </div> </div> </div> <div class="layui-form-item"> <label class="layui-form-label">商品介绍:</label> <div class="layui-input-block"> <label> <textarea name="goodsIntrodution" rows="5" autocomplete="off" class="layui-textarea" ></textarea> </label> </div> </div> <div class="layui-form-item"> <label class="layui-form-label febs-form-item-require">缩略图:</label> <div class="layui-input-block"> <div class="layui-upload"> <button type="button" class="layui-btn" id="test2">上传</button> <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> <div class="layui-upload-list" id="demo2"></div> </blockquote> </div> </div> </div> <div class="layui-form-item febs-hide"> <label class="layui-form-label febs-form-item-require">缩略图链接:</label> <div class="layui-input-block"> <input type="text" id="thumb" name="thumb" autocomplete="off" class="layui-input" readonly> </div> </div> <div class="layui-form-item"> <label class="layui-form-label febs-form-item-require">轮播图:</label> <div class="layui-input-block"> <div class="layui-upload"> <button type="button" class="layui-btn layui-btn-normal layui-btn" id="thumbsBanner">上传</button> <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> <div class="layui-upload-list" id="thumbsBanners"></div> </blockquote> </div> </div> </div> <div class="layui-form-item febs-hide"> <label class="layui-form-label">缩略图链接:</label> <div class="layui-input-block"> <input type="text" id="thumbs" lay-verify="required" name="thumbs" autocomplete="off" class="layui-input" readonly> </div> </div> <div class="layui-form-item"> <label class="layui-form-label febs-form-item-require">商品详情:</label> <div class="layui-input-block"> <textarea id="lay_edit" lay-verify="goodsDetails" name = "goodsDetails" class="layui-textarea"></textarea> </div> </div> <div class="layui-form-item febs-hide"> <button class="layui-btn" lay-submit="" lay-filter="score-goods-add-form-submit" id="submit"></button> </div> </form> </div> <script data-th-inline="javascript"> layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'laydate','layedit','upload'], function () { var $ = layui.jquery, febs = layui.febs, layer = layui.layer, formSelects = layui.formSelects, treeSelect = layui.treeSelect, form = layui.form, laydate = layui.laydate, eleTree = layui.eleTree, member = [[${member}]], $view = $('#score-goods-add'), layedit = layui.layedit, upload = layui.upload, validate = layui.validate; form.render(); laydate.render({ elem: '#febs-form-group-date' }); formSelects.render(); formSelects.config('user-add-goods', { searchUrl: ctx + 'admin/goodsCategory/categorys', response: { statusCode: 200 }, beforeSuccess: function (id, url, searchVal, result) { var data = result.data; var tranData = []; for (var i = 0; i < data.length; i++) { tranData.push({ name: data[i].name, value: data[i].id }) } result.data = tranData; return result; }, success: function () { // formSelects.value('user-add-goods', result.id); }, error: function (id, url, searchVal, err) { console.error(err); febs.alert.error('获取分类列表失败'); } }); //普通图片上传 upload.render({ elem: '#skuImg' ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ $('#skuImgs').attr('src', result); //图片链接(base64) }); } ,done: function(res){ febs.alert.success(res.data.src); $("#skuImage").val(res.data.src); } }); //多图片上传 upload.render({ elem: '#test2' ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 ,multiple: true ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">') }); } ,done: function(res){ var thumbs = $("#thumb").val(); if(thumbs == ''){ $("#thumb").val(res.data.src); }else{ $("#thumb").val(thumbs + ',' + res.data.src); } // alert($("#thumb").val()); } }); upload.render({ elem: '#thumbsBanner' ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 ,multiple: true ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ $('#thumbsBanners').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img" style="width: 100px">') }); } ,done: function(res){ var thumbs = $("#thumbs").val(); if(thumbs == ''){ $("#thumbs").val(res.data.src); }else{ $("#thumbs").val(thumbs + ',' + res.data.src); } } }); layedit.set({ //设置图片接口 uploadImage: { url: 'admin/goods/uploadFileBase64', //接口url type: 'post', } }); //创建一个编辑器 var index = layedit.build('lay_edit',{ height: 300 }); //提交时把值同步到文本域中 form.verify({ //content富文本域中的lay-verify值 goodsDetails: function(value) { return layedit.sync(index); } }); form.on('submit(score-goods-add-form-submit)', function (data) { data.field.goodsType = 2; // febs.post(ctx + 'admin/goods/addMallGoods', data.field, function () { // layer.closeAll(); // febs.alert.success('新增成功'); // $('#febs-score-goods').find('#query').click(); // }); $.ajax({ 'url':ctx + 'admin/goods/addMallGoods', 'type':'post', 'dataType':'json', 'headers' : {'Content-Type' : 'application/json;charset=utf-8'}, //接口json格式 'traditional': true,//ajax传递数组必须添加属性 'data':JSON.stringify(data.field), 'success':function (data) { if(data.code==0){ layer.closeAll(); febs.alert.success('新增成功'); $('#febs-score-goods').find('#query').click(); }else{ febs.alert.warn(data.message); } }, 'error':function () { febs.alert.warn('服务器繁忙'); } }) return false; }); }); </script> src/main/resources/templates/febs/views/modules/score/goodsList.html
New file @@ -0,0 +1,224 @@ <div class="layui-fluid layui-anim febs-anim" id="febs-score-goods" lay-title="积分商品列表"> <div class="layui-row febs-container"> <div class="layui-col-md12"> <div class="layui-card"> <div class="layui-card-body febs-table-full"> <form class="layui-form layui-table-form" lay-filter="score-goods-table-form"> <div class="layui-row"> <div class="layui-col-md10"> <div class="layui-form-item"> <div class="layui-inline"> <div class="layui-input-inline"> <input type="text" placeholder="名称" name="goodsName" autocomplete="off" class="layui-input"> </div> </div> </div> </div> <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area"> <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="add"> 新增 </div> <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query"> <i class="layui-icon"></i> </div> <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset"> <i class="layui-icon"></i> </div> </div> </div> </form> <table lay-filter="scoreGoodsTable" lay-data="{id: 'scoreGoodsTable'}"></table> <style type="text/css"> .layui-table-cell{ text-align:center; height: auto; white-space: nowrap; /*文本不会换行,在同一行显示*/ overflow: hidden; /*超出隐藏*/ text-overflow: ellipsis; /*省略号显示*/ } .layui-table img{ max-width:100px } </style> </div> </div> </div> </div> </div> <!-- 表格操作栏 start --> <script type="text/html" id="user-option"> <span shiro:lacksPermission="user:view,user:update,user:delete"> <span class="layui-badge-dot febs-bg-orange"></span> 无权限 </span> <a lay-event="edit" shiro:hasPermission="user:update"><i class="layui-icon febs-edit-area febs-blue"></i></a> </script> <!-- 表格操作栏 end --> <script data-th-inline="none" type="text/javascript"> // 引入组件并初始化 layui.use([ 'jquery', 'form', 'table', 'febs'], function () { var $ = layui.jquery, febs = layui.febs, form = layui.form, table = layui.table, $view = $('#febs-score-goods'), $query = $view.find('#query'), $reset = $view.find('#reset'), $searchForm = $view.find('form'), $add = $view.find('#add'), sortObject = {field: 'phone', type: null}, tableIns; form.render(); // 表格初始化 initTable(); // 初始化表格操作栏各个按钮功能 table.on('tool(scoreGoodsTable)', function (obj) { var data = obj.data, layEvent = obj.event; if (layEvent === 'downGoods') { febs.modal.confirm('下架', '确认下架该商品?', function () { downGoods(data.id); }); } if (layEvent === 'upGoods') { febs.modal.confirm('上架', '确认上架该商品?', function () { upGoods(data.id); }); } if (layEvent === 'delGoods') { febs.modal.confirm('删除', '确认删除该商品?', function () { delGoods(data.id); }); } if (layEvent === 'detailGoods') { febs.modal.open( '商品详情', 'modules/goods/detailGoods/' + data.id, { maxmin: true, }); } if (layEvent === 'goodsUpdate') { febs.modal.open('编辑', 'modules/goods/goodsUpdateNew/' + data.id, { btn: ['提交', '取消'], yes: function (index, layero) { $('#goods-updatenew').find('#submit').trigger('click'); }, btn2: function () { layer.closeAll(); } }); } if (layEvent === 'seeImgThumb') { var t = $view.find('#seeImgThumb'+data.id+''); //页面层 layer.open({ type: 1, title: "图片", skin: 'layui-layer-rim', //加上边框 area: ['80%', '80%'], //宽高 shadeClose: true, //开启遮罩关闭 end: function (index, layero) { return false; }, content: '<div style="text-align:center"><img src="' + $(t).attr('src') + '" /></div>' }); } }); function downGoods(id) { febs.get(ctx + 'admin/goods/downMallGoods/' + id, null, function () { febs.alert.success('下架成功'); $query.click(); }); } function delGoods(id) { febs.get(ctx + 'admin/goods/delMallGoods/' + id, null, function () { febs.alert.success('删除成功'); $query.click(); }); } function upGoods(id) { febs.get(ctx + 'admin/goods/upMallGoods/' + id, null, function () { febs.alert.success('上架成功'); $query.click(); }); } // 查询按钮 $query.on('click', function () { var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type}); tableIns.reload({where: params, page: {curr: 1}}); }); // 刷新按钮 $reset.on('click', function () { $searchForm[0].reset(); sortObject.type = 'null'; tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject}); }); $add.on('click', function () { febs.modal.open('新增积分商品', 'modules/score/goods/add', { btn: ['提交', '取消'], area: ['100%','100%'], yes: function (index, layero) { $('#score-goods-add').find('#submit').trigger('click'); }, btn2: function () { layer.closeAll(); // return false; } }); }); function initTable() { tableIns = febs.table.init({ elem: $view.find('table'), id: 'scoreGoodsTable', url: ctx + 'admin/goods/goodsList?goodsType=2', cols: [[ {field: 'goodsNo', title: '商品编号', minWidth: 150,align:'left'}, {field: 'goodsName', title: '商品名称', minWidth: 150,align:'left'}, {field: 'thumb', title: '缩略图', templet: function (d) { return '<a lay-event="seeImgThumb"><img id="seeImgThumb'+d.id+'" src="'+d.thumb+'" alt=""></a>'; }, minWidth: 150,align:'center'}, {field: 'isSale', title: '是否上架', templet: function (d) { if (d.isSale === 1) { return '<span>上架</span>' } else if (d.isSale === 2) { return '<span>下架</span>' }else{ return '' } }, minWidth: 80,align:'center'}, {field: 'score', title: '兑换积分', minWidth: 150,align:'left'}, {field: 'originalPrice', title: '原价', minWidth: 150,align:'left'}, {field: 'stock', title: '商品库存', minWidth: 150,align:'left'}, {field: 'skuVolume', title: '商品销量', minWidth: 150,align:'left'}, {title: '操作', templet: function (d) { if (d.isSale === 1) { return '<button class="layui-btn layui-btn-normal layui-btn-xs febs-bg-orange" lay-event="downGoods" shiro:hasPermission="user:update">下架</button>' + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detailGoods" shiro:hasPermission="user:update">详情</button>' }else{ return '<button class="layui-btn layui-btn-normal layui-btn-xs febs-bg-green" lay-event="upGoods" shiro:hasPermission="user:update">上架</button>' + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="goodsUpdate" shiro:hasPermission="user:update">编辑</button>' + '<button class="layui-btn layui-btn-normal layui-btn-xs febs-bg-red" lay-event="delGoods" shiro:hasPermission="user:update">删除</button>' } },minWidth: 160,align:'center'} ]] }); } // 获取查询参数 function getQueryParams() { return { goodsName: $searchForm.find('input[name="goodsName"]').val().trim(), }; } }) </script>