重构商品管理模块,支持多规格
This commit is contained in:
@@ -1,13 +1,10 @@
|
|||||||
package com.gxwebsoft.shop.controller;
|
package com.gxwebsoft.shop.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.gxwebsoft.common.core.web.BaseController;
|
import com.gxwebsoft.common.core.web.BaseController;
|
||||||
import com.gxwebsoft.oa.entity.App;
|
|
||||||
import com.gxwebsoft.shop.entity.GoodsSku;
|
import com.gxwebsoft.shop.entity.GoodsSku;
|
||||||
import com.gxwebsoft.shop.entity.GoodsSpec;
|
import com.gxwebsoft.shop.entity.GoodsSpec;
|
||||||
import com.gxwebsoft.shop.entity.SpecValue;
|
|
||||||
import com.gxwebsoft.shop.service.GoodsService;
|
import com.gxwebsoft.shop.service.GoodsService;
|
||||||
import com.gxwebsoft.shop.entity.Goods;
|
import com.gxwebsoft.shop.entity.Goods;
|
||||||
import com.gxwebsoft.shop.param.GoodsParam;
|
import com.gxwebsoft.shop.param.GoodsParam;
|
||||||
@@ -21,22 +18,19 @@ import com.gxwebsoft.shop.service.GoodsSkuService;
|
|||||||
import com.gxwebsoft.shop.service.GoodsSpecService;
|
import com.gxwebsoft.shop.service.GoodsSpecService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.tomcat.util.buf.StringUtils;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品记录表控制器
|
* 商品记录表控制器
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-03-30 20:00:50
|
* @since 2024-07-25 19:22:01
|
||||||
*/
|
*/
|
||||||
@Api(tags = "商品记录表管理")
|
@Api(tags = "商品记录表管理")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -73,36 +67,27 @@ public class GoodsController extends BaseController {
|
|||||||
return success(data);
|
return success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("分页查询商品记录表")
|
@ApiOperation("分页查询商品记录表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public ApiResult<PageResult<Goods>> page(GoodsParam param) {
|
public ApiResult<PageResult<Goods>> page(GoodsParam param) {
|
||||||
// 使用关联查询
|
// 使用关联查询
|
||||||
return success(goodsService.pageRel(param));
|
return success(goodsService.pageRel(param));
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation("查询全部商品记录表")
|
|
||||||
@GetMapping()
|
|
||||||
public ApiResult<List<Goods>> list(GoodsParam param) {
|
|
||||||
// 使用关联查询
|
|
||||||
return success(goodsService.listRel(param));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
|
||||||
@ApiOperation("根据id查询商品记录表")
|
|
||||||
@GetMapping("/{id}")
|
|
||||||
public ApiResult<Goods> get(@PathVariable("id") Integer id) {
|
|
||||||
// 使用关联查询
|
|
||||||
final Goods goods = goodsService.getByIdRel(id);
|
|
||||||
final List<GoodsSpec> goodsSpecList = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().eq(GoodsSpec::getGoodsId, id));
|
|
||||||
final List<GoodsSku> goodsSkuList = goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, id));
|
|
||||||
if(goodsSpecList != null){
|
|
||||||
goods.setGoodsSpecs(goodsSpecList);
|
|
||||||
}
|
}
|
||||||
if(goodsSkuList != null){
|
|
||||||
goods.setGoodsSkus(goodsSkuList);
|
@ApiOperation("查询全部商品记录表")
|
||||||
|
@GetMapping()
|
||||||
|
public ApiResult<List<Goods>> list(GoodsParam param) {
|
||||||
|
// 使用关联查询
|
||||||
|
return success(goodsService.listRel(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasAuthority('shop:goods:list')")
|
||||||
|
@ApiOperation("根据id查询商品记录表")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public ApiResult<Goods> get(@PathVariable("id") Integer id) {
|
||||||
|
// 使用关联查询
|
||||||
|
return success(goodsService.getByIdRel(id));
|
||||||
}
|
}
|
||||||
return success(goods);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('shop:goods:save')")
|
@PreAuthorize("hasAuthority('shop:goods:save')")
|
||||||
@ApiOperation("添加商品记录表")
|
@ApiOperation("添加商品记录表")
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
* 商品记录表
|
* 商品记录表
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-03-30 20:00:50
|
* @since 2024-07-25 19:22:01
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@@ -37,7 +37,7 @@ public class Goods implements Serializable {
|
|||||||
@ApiModelProperty(value = "商品编码")
|
@ApiModelProperty(value = "商品编码")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@ApiModelProperty(value = "商品名称")
|
@ApiModelProperty(value = "商品标题")
|
||||||
private String goodsName;
|
private String goodsName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "商品封面图")
|
@ApiModelProperty(value = "商品封面图")
|
||||||
@@ -46,10 +46,7 @@ public class Goods implements Serializable {
|
|||||||
@ApiModelProperty(value = "商品详情")
|
@ApiModelProperty(value = "商品详情")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@ApiModelProperty(value = "商品附件")
|
@ApiModelProperty(value = "商品分类ID")
|
||||||
private String files;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "分类ID")
|
|
||||||
private Integer categoryId;
|
private Integer categoryId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "一级分类")
|
@ApiModelProperty(value = "一级分类")
|
||||||
@@ -64,31 +61,46 @@ public class Goods implements Serializable {
|
|||||||
@ApiModelProperty(value = "货架")
|
@ApiModelProperty(value = "货架")
|
||||||
private String position;
|
private String position;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "单位名称")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "消费赚取积分")
|
||||||
|
private BigDecimal gainIntegral;
|
||||||
|
|
||||||
@ApiModelProperty(value = "进货价格")
|
@ApiModelProperty(value = "进货价格")
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
@ApiModelProperty(value = "销售价格")
|
@ApiModelProperty(value = "销售价格")
|
||||||
private BigDecimal salePrice;
|
private BigDecimal salePrice;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "库存计算方式(10下单减库存 20付款减库存)")
|
||||||
|
private Integer deductStockType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "封面图")
|
||||||
|
private String files;
|
||||||
|
|
||||||
@ApiModelProperty(value = "销量")
|
@ApiModelProperty(value = "销量")
|
||||||
private Integer sales;
|
private Integer sales;
|
||||||
|
|
||||||
@ApiModelProperty(value = "库存")
|
@ApiModelProperty(value = "库存")
|
||||||
private Integer stock;
|
private Integer stock;
|
||||||
|
|
||||||
@ApiModelProperty(value = "库存计算方式(10下单减库存 20付款减库存)")
|
|
||||||
private Integer deductStockType;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "商品重量")
|
@ApiModelProperty(value = "商品重量")
|
||||||
private Integer goodsWeight;
|
private Integer goodsWeight;
|
||||||
|
|
||||||
@ApiModelProperty(value = "推荐")
|
@ApiModelProperty(value = "推荐")
|
||||||
private Integer recommend;
|
private Integer recommend;
|
||||||
|
|
||||||
@ApiModelProperty(value = "1上架 0下架")
|
@ApiModelProperty(value = "商户ID")
|
||||||
|
private Integer merchantId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "商户名称")
|
||||||
|
private String merchantName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态(0:未上架,1:上架)")
|
||||||
private Integer isShow;
|
private Integer isShow;
|
||||||
|
|
||||||
@ApiModelProperty(value = "状态, 0上架 1下架 2待审核 3审核不通过")
|
@ApiModelProperty(value = "状态, 0上架 1待上架 2待审核 3审核不通过")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@ApiModelProperty(value = "备注")
|
@ApiModelProperty(value = "备注")
|
||||||
@@ -97,15 +109,9 @@ public class Goods implements Serializable {
|
|||||||
@ApiModelProperty(value = "排序号")
|
@ApiModelProperty(value = "排序号")
|
||||||
private Integer sortNumber;
|
private Integer sortNumber;
|
||||||
|
|
||||||
@ApiModelProperty(value = "所有人")
|
@ApiModelProperty(value = "用户ID")
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "商户ID")
|
|
||||||
private Integer merchantId;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "商户名称")
|
|
||||||
private String merchantName;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||||
@TableLogic
|
@TableLogic
|
||||||
private Integer deleted;
|
private Integer deleted;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class GoodsSpec implements Serializable {
|
|||||||
private String specName;
|
private String specName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "规格值")
|
@ApiModelProperty(value = "规格值")
|
||||||
private String specValues;
|
private String specValue;
|
||||||
|
|
||||||
@ApiModelProperty(value = "规格值")
|
@ApiModelProperty(value = "规格值")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
* 商品记录表Mapper
|
* 商品记录表Mapper
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-03-30 20:00:50
|
* @since 2024-07-25 19:22:01
|
||||||
*/
|
*/
|
||||||
public interface GoodsMapper extends BaseMapper<Goods> {
|
public interface GoodsMapper extends BaseMapper<Goods> {
|
||||||
|
|
||||||
|
|||||||
@@ -2,103 +2,121 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.gxwebsoft.shop.mapper.GoodsMapper">
|
<mapper namespace="com.gxwebsoft.shop.mapper.GoodsMapper">
|
||||||
|
|
||||||
<!-- 关联查询sql -->
|
<!-- 关联查询sql -->
|
||||||
<sql id="selectSql">
|
<sql id="selectSql">
|
||||||
SELECT a.*
|
SELECT a.*
|
||||||
FROM shop_goods a
|
FROM shop_goods a
|
||||||
<where>
|
<where>
|
||||||
<if test="param.goodsId != null">
|
<if test="param.goodsId != null">
|
||||||
AND a.goods_id = #{param.goodsId}
|
AND a.goods_id = #{param.goodsId}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.type != null">
|
<if test="param.type != null">
|
||||||
AND a.type = #{param.type}
|
AND a.type = #{param.type}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.code != null">
|
<if test="param.code != null">
|
||||||
AND a.code LIKE CONCAT('%', #{param.code}, '%')
|
AND a.code LIKE CONCAT('%', #{param.code}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.goodsName != null">
|
<if test="param.goodsName != null">
|
||||||
AND a.goods_name LIKE CONCAT('%', #{param.goodsName}, '%')
|
AND a.goods_name LIKE CONCAT('%', #{param.goodsName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.content != null">
|
<if test="param.image != null">
|
||||||
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
AND a.image LIKE CONCAT('%', #{param.image}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.categoryId != null">
|
<if test="param.content != null">
|
||||||
AND a.category_id = #{param.categoryId}
|
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.parentId != null">
|
<if test="param.categoryId != null">
|
||||||
AND a.category_id IN (SELECT category_id FROM shop_goods_category WHERE parent_id=#{param.parentId})
|
AND a.category_id = #{param.categoryId}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.categoryParent != null">
|
<if test="param.categoryParent != null">
|
||||||
AND a.category_parent LIKE CONCAT('%', #{param.categoryParent}, '%')
|
AND a.category_parent LIKE CONCAT('%', #{param.categoryParent}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.categoryChildren != null">
|
<if test="param.categoryChildren != null">
|
||||||
AND a.category_children LIKE CONCAT('%', #{param.categoryChildren}, '%')
|
AND a.category_children LIKE CONCAT('%', #{param.categoryChildren}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.specs != null">
|
<if test="param.specs != null">
|
||||||
AND a.specs LIKE CONCAT('%', #{param.specs}, '%')
|
AND a.specs = #{param.specs}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.position != null">
|
<if test="param.position != null">
|
||||||
AND a.position LIKE CONCAT('%', #{param.position}, '%')
|
AND a.position LIKE CONCAT('%', #{param.position}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.price != null">
|
<if test="param.price != null">
|
||||||
AND a.price = #{param.price}
|
AND a.price = #{param.price}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.salePrice != null">
|
<if test="param.salePrice != null">
|
||||||
AND a.sale_price = #{param.salePrice}
|
AND a.sale_price = #{param.salePrice}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.recommend != null">
|
<if test="param.deductStockType != null">
|
||||||
AND a.recommend = #{param.recommend}
|
AND a.deduct_stock_type = #{param.deductStockType}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.isShow != null">
|
<if test="param.files != null">
|
||||||
AND a.is_show = #{param.isShow}
|
AND a.files LIKE CONCAT('%', #{param.files}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.status != null">
|
<if test="param.sales != null">
|
||||||
AND a.status = #{param.status}
|
AND a.sales = #{param.sales}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.stock != null">
|
<if test="param.stock != null">
|
||||||
AND a.stock = #{param.stock}
|
AND a.stock = #{param.stock}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.comments != null">
|
<if test="param.goodsWeight != null">
|
||||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
AND a.goods_weight = #{param.goodsWeight}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.sortNumber != null">
|
<if test="param.recommend != null">
|
||||||
AND a.sort_number = #{param.sortNumber}
|
AND a.recommend = #{param.recommend}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.userId != null">
|
<if test="param.merchantId != null">
|
||||||
AND a.user_id = #{param.userId}
|
AND a.merchant_id = #{param.merchantId}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.merchantId != null">
|
<if test="param.parentId != null">
|
||||||
AND a.merchant_id = #{param.merchantId}
|
AND a.category_id IN (SELECT category_id FROM shop_goods_category WHERE parent_id=#{param.parentId})
|
||||||
</if>
|
</if>
|
||||||
<if test="param.deleted != null">
|
<if test="param.merchantName != null">
|
||||||
AND a.deleted = #{param.deleted}
|
AND a.merchant_name LIKE CONCAT('%', #{param.merchantName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.deleted == null">
|
<if test="param.isShow != null">
|
||||||
AND a.deleted = 0
|
AND a.is_show = #{param.isShow}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.createTimeStart != null">
|
<if test="param.status != null">
|
||||||
AND a.create_time >= #{param.createTimeStart}
|
AND a.status = #{param.status}
|
||||||
</if>
|
</if>
|
||||||
<if test="param.createTimeEnd != null">
|
<if test="param.comments != null">
|
||||||
AND a.create_time <= #{param.createTimeEnd}
|
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.keywords != null">
|
<if test="param.sortNumber != null">
|
||||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
AND a.sort_number = #{param.sortNumber}
|
||||||
OR a.goods_name = #{param.keywords}
|
</if>
|
||||||
OR a.code = #{param.keywords}
|
<if test="param.userId != null">
|
||||||
)
|
AND a.user_id = #{param.userId}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
<if test="param.deleted != null">
|
||||||
</sql>
|
AND a.deleted = #{param.deleted}
|
||||||
|
</if>
|
||||||
|
<if test="param.deleted == null">
|
||||||
|
AND a.deleted = 0
|
||||||
|
</if>
|
||||||
|
<if test="param.createTimeStart != null">
|
||||||
|
AND a.create_time >= #{param.createTimeStart}
|
||||||
|
</if>
|
||||||
|
<if test="param.createTimeEnd != null">
|
||||||
|
AND a.create_time <= #{param.createTimeEnd}
|
||||||
|
</if>
|
||||||
|
<if test="param.keywords != null">
|
||||||
|
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||||
|
OR a.goods_name = #{param.keywords}
|
||||||
|
OR a.code = #{param.keywords}
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
|
||||||
<!-- 分页查询 -->
|
<!-- 分页查询 -->
|
||||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.Goods">
|
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.Goods">
|
||||||
<include refid="selectSql"></include>
|
<include refid="selectSql"></include>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询全部 -->
|
<!-- 查询全部 -->
|
||||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.Goods">
|
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.Goods">
|
||||||
<include refid="selectSql"></include>
|
<include refid="selectSql"></include>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
<if test="param.specName != null">
|
<if test="param.specName != null">
|
||||||
AND a.spec_name LIKE CONCAT('%', #{param.specName}, '%')
|
AND a.spec_name LIKE CONCAT('%', #{param.specName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.valueList != null">
|
<if test="param.specValue != null">
|
||||||
AND a.value_list LIKE CONCAT('%', #{param.valueList}, '%')
|
AND a.spec_value LIKE CONCAT('%', #{param.specValue}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="param.type != null">
|
<if test="param.type != null">
|
||||||
AND a.type = #{param.type}
|
AND a.type = #{param.type}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import lombok.EqualsAndHashCode;
|
|||||||
* 商品记录表查询参数
|
* 商品记录表查询参数
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-03-30 20:00:50
|
* @since 2024-07-25 19:22:01
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@@ -36,13 +36,16 @@ public class GoodsParam extends BaseParam {
|
|||||||
@ApiModelProperty(value = "商品编码")
|
@ApiModelProperty(value = "商品编码")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@ApiModelProperty(value = "商品名称")
|
@ApiModelProperty(value = "商品标题")
|
||||||
private String goodsName;
|
private String goodsName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "商品封面图")
|
||||||
|
private String image;
|
||||||
|
|
||||||
@ApiModelProperty(value = "商品详情")
|
@ApiModelProperty(value = "商品详情")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@ApiModelProperty(value = "分类ID")
|
@ApiModelProperty(value = "商品分类ID")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer categoryId;
|
private Integer categoryId;
|
||||||
|
|
||||||
@@ -52,7 +55,8 @@ public class GoodsParam extends BaseParam {
|
|||||||
@ApiModelProperty(value = "二级分类")
|
@ApiModelProperty(value = "二级分类")
|
||||||
private String categoryChildren;
|
private String categoryChildren;
|
||||||
|
|
||||||
@ApiModelProperty(value = "规格")
|
@ApiModelProperty(value = "商品规格 0单规格 1多规格")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer specs;
|
private Integer specs;
|
||||||
|
|
||||||
@ApiModelProperty(value = "货架")
|
@ApiModelProperty(value = "货架")
|
||||||
@@ -66,22 +70,44 @@ public class GoodsParam extends BaseParam {
|
|||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private BigDecimal salePrice;
|
private BigDecimal salePrice;
|
||||||
|
|
||||||
@ApiModelProperty(value = "推荐")
|
@ApiModelProperty(value = "库存计算方式(10下单减库存 20付款减库存)")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer recommend;
|
private Integer deductStockType;
|
||||||
|
|
||||||
@ApiModelProperty(value = "1上架 0下架")
|
@ApiModelProperty(value = "封面图")
|
||||||
@QueryField(type = QueryType.EQ)
|
private String files;
|
||||||
private Integer isShow;
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "状态, 0上架 1下架 2待审核 3审核不通过")
|
@ApiModelProperty(value = "销量")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer status;
|
private Integer sales;
|
||||||
|
|
||||||
@ApiModelProperty(value = "库存")
|
@ApiModelProperty(value = "库存")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer stock;
|
private Integer stock;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "商品重量")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer goodsWeight;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "推荐")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer recommend;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "商户ID")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer merchantId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "商户名称")
|
||||||
|
private String merchantName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态(0:未上架,1:上架)")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer isShow;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "状态, 0上架 1待上架 2待审核 3审核不通过")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
@ApiModelProperty(value = "备注")
|
@ApiModelProperty(value = "备注")
|
||||||
private String comments;
|
private String comments;
|
||||||
|
|
||||||
@@ -89,7 +115,7 @@ public class GoodsParam extends BaseParam {
|
|||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer sortNumber;
|
private Integer sortNumber;
|
||||||
|
|
||||||
@ApiModelProperty(value = "所有人")
|
@ApiModelProperty(value = "用户ID")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class GoodsSpecParam extends BaseParam {
|
|||||||
private String specName;
|
private String specName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "规格值")
|
@ApiModelProperty(value = "规格值")
|
||||||
private String valueList;
|
private String specValue;
|
||||||
|
|
||||||
@ApiModelProperty(value = "活动类型 0=商品,1=秒杀,2=砍价,3=拼团")
|
@ApiModelProperty(value = "活动类型 0=商品,1=秒杀,2=砍价,3=拼团")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
* 商品记录表Service
|
* 商品记录表Service
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-03-30 20:00:50
|
* @since 2024-07-25 19:22:01
|
||||||
*/
|
*/
|
||||||
public interface GoodsService extends IService<Goods> {
|
public interface GoodsService extends IService<Goods> {
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,15 @@ import org.springframework.util.CollectionUtils;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品记录表Service实现
|
* 商品记录表Service实现
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-03-30 20:00:50
|
* @since 2024-07-25 19:22:01
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
|
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {
|
||||||
@@ -40,6 +42,18 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|||||||
PageParam<Goods, GoodsParam> page = new PageParam<>(param);
|
PageParam<Goods, GoodsParam> page = new PageParam<>(param);
|
||||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||||
List<Goods> list = baseMapper.selectPageRel(page, param);
|
List<Goods> list = baseMapper.selectPageRel(page, param);
|
||||||
|
final Set<Integer> goodsIds = list.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||||
|
if (!CollectionUtils.isEmpty(goodsIds)) {
|
||||||
|
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||||
|
final List<GoodsSku> skus = goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().in(GoodsSku::getGoodsId, goodsIds));
|
||||||
|
final Map<Integer, List<GoodsSpec>> collectSpecs = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||||
|
final Map<Integer, List<GoodsSku>> collectSkus = skus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId));
|
||||||
|
list.forEach(d -> {
|
||||||
|
d.setGoodsSpecs(collectSpecs.get(d.getGoodsId()));
|
||||||
|
d.setGoodsSkus(collectSkus.get(d.getGoodsId()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return new PageResult<>(list, page.getTotal());
|
return new PageResult<>(list, page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,11 +80,21 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|||||||
if (!CollectionUtils.isEmpty(goodsSpecs)) {
|
if (!CollectionUtils.isEmpty(goodsSpecs)) {
|
||||||
goodsSpecs.forEach(d -> {
|
goodsSpecs.forEach(d -> {
|
||||||
d.setGoodsId(goods.getGoodsId());
|
d.setGoodsId(goods.getGoodsId());
|
||||||
final List<String> collect = d.getValueList().stream().map(SpecValue::getSpecValue).collect(Collectors.toList());
|
|
||||||
d.setSpecValues(StringUtils.join(collect, ','));
|
|
||||||
});
|
});
|
||||||
goodsSpecService.saveBatch(goodsSpecs);
|
goodsSpecService.saveBatch(goodsSpecs);
|
||||||
|
// final GoodsSpec spec = goodsSpecs.get(0);
|
||||||
|
// if (spec != null) {
|
||||||
|
// final GoodsSpec goodsSpec = new GoodsSpec();
|
||||||
|
// goodsSpec.setGoodsId(goods.getGoodsId());
|
||||||
|
// goodsSpec.setSpecId(spec.getSpecId());
|
||||||
|
// goodsSpec.setSpecName(spec.getSpecName());
|
||||||
|
// goodsSpec.setSpecValue(spec.getSpecValue());
|
||||||
|
// goodsSpec.setTenantId(goods.getTenantId());
|
||||||
|
// System.out.println("goodsSpec = " + goodsSpec);
|
||||||
|
// goodsSpecService.save(goodsSpec);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存商品sku表
|
// 保存商品sku表
|
||||||
final List<GoodsSku> goodsSkus = goods.getGoodsSkus();
|
final List<GoodsSku> goodsSkus = goods.getGoodsSkus();
|
||||||
if (!CollectionUtils.isEmpty(goodsSkus)) {
|
if (!CollectionUtils.isEmpty(goodsSkus)) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class GoodsSpecServiceImpl extends ServiceImpl<GoodsSpecMapper, GoodsSpec
|
|||||||
@Override
|
@Override
|
||||||
public PageResult<GoodsSpec> pageRel(GoodsSpecParam param) {
|
public PageResult<GoodsSpec> pageRel(GoodsSpecParam param) {
|
||||||
PageParam<GoodsSpec, GoodsSpecParam> page = new PageParam<>(param);
|
PageParam<GoodsSpec, GoodsSpecParam> page = new PageParam<>(param);
|
||||||
page.setDefaultOrder("create_time desc");
|
page.setDefaultOrder("id desc");
|
||||||
List<GoodsSpec> list = baseMapper.selectPageRel(page, param);
|
List<GoodsSpec> list = baseMapper.selectPageRel(page, param);
|
||||||
return new PageResult<>(list, page.getTotal());
|
return new PageResult<>(list, page.getTotal());
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ public class GoodsSpecServiceImpl extends ServiceImpl<GoodsSpecMapper, GoodsSpec
|
|||||||
List<GoodsSpec> list = baseMapper.selectListRel(param);
|
List<GoodsSpec> list = baseMapper.selectListRel(param);
|
||||||
// 排序
|
// 排序
|
||||||
PageParam<GoodsSpec, GoodsSpecParam> page = new PageParam<>();
|
PageParam<GoodsSpec, GoodsSpecParam> page = new PageParam<>();
|
||||||
page.setDefaultOrder("create_time desc");
|
page.setDefaultOrder("id desc");
|
||||||
return page.sortRecords(list);
|
return page.sortRecords(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class OrderInfoTask extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 自动处理过期订单任务
|
* 自动处理过期订单任务
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron="*/10 * * * * *")
|
// @Scheduled(cron="*/10 * * * * *")
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void settledExpirationOrder() {
|
public void settledExpirationOrder() {
|
||||||
final Order order = new Order();
|
final Order order = new Order();
|
||||||
@@ -57,7 +57,7 @@ public class OrderInfoTask extends BaseController {
|
|||||||
* 自动处理过期订单任务(游泳馆专用)
|
* 自动处理过期订单任务(游泳馆专用)
|
||||||
* Scheduled(cron="0 30 21 * * ?")
|
* Scheduled(cron="0 30 21 * * ?")
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron="*/30 * * * * *")
|
// @Scheduled(cron="*/30 * * * * *")
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void settledExpirationOrderBy3028() {
|
public void settledExpirationOrderBy3028() {
|
||||||
final Order order = new Order();
|
final Order order = new Order();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class OrderTask extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 自动处理过期订单任务
|
* 自动处理过期订单任务
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedDelay = 2000, initialDelay = 2000)
|
// @Scheduled(fixedDelay = 2000, initialDelay = 2000)
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
public void settledExpirationOrder() {
|
public void settledExpirationOrder() {
|
||||||
final OrderParam p = new OrderParam();
|
final OrderParam p = new OrderParam();
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ public class ShopGenerator {
|
|||||||
private static final String MODULE_NAME = "shop";
|
private static final String MODULE_NAME = "shop";
|
||||||
// 需要生成的表
|
// 需要生成的表
|
||||||
private static final String[] TABLE_NAMES = new String[]{
|
private static final String[] TABLE_NAMES = new String[]{
|
||||||
"shop_spec",
|
// "shop_spec",
|
||||||
// "shop_spec_value",
|
// "shop_spec_value",
|
||||||
// "shop_goods",
|
"shop_goods",
|
||||||
// "shop_goods_spec",
|
// "shop_goods_spec",
|
||||||
// "shop_goods_sku",
|
// "shop_goods_sku",
|
||||||
// "shop_goods_category",
|
// "shop_goods_category",
|
||||||
|
|||||||
Reference in New Issue
Block a user