Browse Source

库存信息修改

Signed-off-by: fengb <fengbin1989@aliyun.com>
cangku
fengb 3 years ago
parent
commit
d91068f3d1
  1. 27
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java
  2. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java
  3. 1
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java
  4. 11
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Stock.java
  5. 60
      hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/StockExample.java
  6. 29
      hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml

27
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java

@ -4,7 +4,9 @@ import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.Result; import cc.hiver.core.common.vo.Result;
import cc.hiver.mall.entity.Product; import cc.hiver.mall.entity.Product;
import cc.hiver.mall.service.mybatis.ProductService; import cc.hiver.mall.service.mybatis.ProductService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -47,6 +49,20 @@ public class ProductController {
} }
} }
@RequestMapping(value = "/down", method = RequestMethod.POST)
@ApiOperation(value = "根据货品id下架货品")
public Result down(String id) {
UpdateWrapper<Product> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("del_flag",0);
updateWrapper.eq("id",id);
boolean result = productService.update(updateWrapper);
if(result) {
return ResultUtil.success("下架成功");
} else {
return ResultUtil.error("下架失败");
}
}
@RequestMapping(value = "/delById", method = RequestMethod.POST) @RequestMapping(value = "/delById", method = RequestMethod.POST)
@ApiOperation(value = "根据id删除货品") @ApiOperation(value = "根据id删除货品")
public Result delete(Product product) { public Result delete(Product product) {
@ -73,13 +89,22 @@ public class ProductController {
// } // }
@RequestMapping(value = "/list", method = RequestMethod.GET) @RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(value = "查询货品列表") @ApiOperation(value = "查询所有货品列表")
public Result list() { public Result list() {
QueryWrapper<Product> queryWrapper = new QueryWrapper<>(); QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
List<Product> list = productService.list(queryWrapper); List<Product> list = productService.list(queryWrapper);
return new ResultUtil<List<Product>>().setData(list); return new ResultUtil<List<Product>>().setData(list);
} }
@RequestMapping(value = "/listWithUp", method = RequestMethod.GET)
@ApiOperation(value = "查询上架货品列表")
public Result listWithUp() {
QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("del_flag",1);
List<Product> list = productService.list(queryWrapper);
return new ResultUtil<List<Product>>().setData(list);
}
@RequestMapping(value = "/listByName", method = RequestMethod.GET) @RequestMapping(value = "/listByName", method = RequestMethod.GET)
@ApiOperation(value = "根据货品名称查询货品列表") @ApiOperation(value = "根据货品名称查询货品列表")
public Result listByName(String name) { public Result listByName(String name) {

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/StockController.java

@ -2,9 +2,11 @@ package cc.hiver.mall.controller;
import cc.hiver.core.common.utils.ResultUtil; import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.Result; import cc.hiver.core.common.vo.Result;
import cc.hiver.mall.entity.Product;
import cc.hiver.mall.entity.Stock; import cc.hiver.mall.entity.Stock;
import cc.hiver.mall.pojo.vo.PurchaseVo; import cc.hiver.mall.pojo.vo.PurchaseVo;
import cc.hiver.mall.service.mybatis.StockService; import cc.hiver.mall.service.mybatis.StockService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -55,4 +57,13 @@ public class StockController {
return new ResultUtil<List<Stock>>().setData(list); return new ResultUtil<List<Stock>>().setData(list);
} }
@RequestMapping(value = "/count", method = RequestMethod.POST)
@ApiOperation(value = "根据货品id统计库存数量")
public long count(String id) {
QueryWrapper<Stock> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("product_id",id);
long count = stockService.count(queryWrapper);
return count;
}
} }

1
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Product.java

@ -18,6 +18,7 @@ public class Product implements Serializable {
private Date createTime; private Date createTime;
@ApiModelProperty(value = "商品是否上架 0-否 1-是")
private Integer delFlag; private Integer delFlag;
private String updateBy; private String updateBy;

11
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/Stock.java

@ -78,6 +78,9 @@ public class Stock implements Serializable {
@ApiModelProperty(value = "库存数量") @ApiModelProperty(value = "库存数量")
private Integer stockCount; private Integer stockCount;
@ApiModelProperty(value = "库存预警数量")
private Integer stockWarnCount;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public String getId() { public String getId() {
@ -272,6 +275,14 @@ public class Stock implements Serializable {
this.stockCount = stockCount; this.stockCount = stockCount;
} }
public Integer getStockWarnCount() {
return stockWarnCount;
}
public void setStockWarnCount(Integer stockWarnCount) {
this.stockWarnCount = stockWarnCount;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

60
hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/StockExample.java

@ -1715,6 +1715,66 @@ public class StockExample {
addCriterion("stock_count not between", value1, value2, "stockCount"); addCriterion("stock_count not between", value1, value2, "stockCount");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andStockWarnCountIsNull() {
addCriterion("stock_warn_count is null");
return (Criteria) this;
}
public Criteria andStockWarnCountIsNotNull() {
addCriterion("stock_warn_count is not null");
return (Criteria) this;
}
public Criteria andStockWarnCountEqualTo(Integer value) {
addCriterion("stock_warn_count =", value, "stockWarnCount");
return (Criteria) this;
}
public Criteria andStockWarnCountNotEqualTo(Integer value) {
addCriterion("stock_warn_count <>", value, "stockWarnCount");
return (Criteria) this;
}
public Criteria andStockWarnCountGreaterThan(Integer value) {
addCriterion("stock_warn_count >", value, "stockWarnCount");
return (Criteria) this;
}
public Criteria andStockWarnCountGreaterThanOrEqualTo(Integer value) {
addCriterion("stock_warn_count >=", value, "stockWarnCount");
return (Criteria) this;
}
public Criteria andStockWarnCountLessThan(Integer value) {
addCriterion("stock_warn_count <", value, "stockWarnCount");
return (Criteria) this;
}
public Criteria andStockWarnCountLessThanOrEqualTo(Integer value) {
addCriterion("stock_warn_count <=", value, "stockWarnCount");
return (Criteria) this;
}
public Criteria andStockWarnCountIn(List<Integer> values) {
addCriterion("stock_warn_count in", values, "stockWarnCount");
return (Criteria) this;
}
public Criteria andStockWarnCountNotIn(List<Integer> values) {
addCriterion("stock_warn_count not in", values, "stockWarnCount");
return (Criteria) this;
}
public Criteria andStockWarnCountBetween(Integer value1, Integer value2) {
addCriterion("stock_warn_count between", value1, value2, "stockWarnCount");
return (Criteria) this;
}
public Criteria andStockWarnCountNotBetween(Integer value1, Integer value2) {
addCriterion("stock_warn_count not between", value1, value2, "stockWarnCount");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

29
hiver-modules/hiver-mall/src/main/resources/mapper/StockMapper.xml

@ -26,6 +26,7 @@
<result column="sales_week" jdbcType="VARCHAR" property="salesWeek" /> <result column="sales_week" jdbcType="VARCHAR" property="salesWeek" />
<result column="print_barcode" jdbcType="VARCHAR" property="printBarcode" /> <result column="print_barcode" jdbcType="VARCHAR" property="printBarcode" />
<result column="stock_count" jdbcType="INTEGER" property="stockCount" /> <result column="stock_count" jdbcType="INTEGER" property="stockCount" />
<result column="stock_warn_count" jdbcType="INTEGER" property="stockWarnCount" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -89,7 +90,7 @@
id, create_by, create_time, del_flag, update_by, update_time, product_id, product_name, id, create_by, create_time, del_flag, update_by, update_time, product_id, product_name,
unit, shop_id, category_id, attribute_list, supplier_id, product_sn, barcode, price, unit, shop_id, category_id, attribute_list, supplier_id, product_sn, barcode, price,
purchase_price, wholesale_price, product_picture, product_video, product_intro, sales_week, purchase_price, wholesale_price, product_picture, product_video, product_intro, sales_week,
print_barcode, stock_count print_barcode, stock_count, stock_warn_count
</sql> </sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.StockExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="cc.hiver.mall.entity.StockExample" resultMap="BaseResultMap">
select select
@ -129,8 +130,8 @@
supplier_id, product_sn, barcode, supplier_id, product_sn, barcode,
price, purchase_price, wholesale_price, price, purchase_price, wholesale_price,
product_picture, product_video, product_intro, product_picture, product_video, product_intro,
sales_week, print_barcode, stock_count sales_week, print_barcode, stock_count,
) stock_warn_count)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{productId,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR}, #{productId,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR},
@ -138,8 +139,8 @@
#{supplierId,jdbcType=VARCHAR}, #{productSn,jdbcType=VARCHAR}, #{barcode,jdbcType=VARCHAR}, #{supplierId,jdbcType=VARCHAR}, #{productSn,jdbcType=VARCHAR}, #{barcode,jdbcType=VARCHAR},
#{price,jdbcType=DECIMAL}, #{purchasePrice,jdbcType=DECIMAL}, #{wholesalePrice,jdbcType=DECIMAL}, #{price,jdbcType=DECIMAL}, #{purchasePrice,jdbcType=DECIMAL}, #{wholesalePrice,jdbcType=DECIMAL},
#{productPicture,jdbcType=VARCHAR}, #{productVideo,jdbcType=VARCHAR}, #{productIntro,jdbcType=VARCHAR}, #{productPicture,jdbcType=VARCHAR}, #{productVideo,jdbcType=VARCHAR}, #{productIntro,jdbcType=VARCHAR},
#{salesWeek,jdbcType=VARCHAR}, #{printBarcode,jdbcType=VARCHAR}, #{stockCount,jdbcType=INTEGER} #{salesWeek,jdbcType=VARCHAR}, #{printBarcode,jdbcType=VARCHAR}, #{stockCount,jdbcType=INTEGER},
) #{stockWarnCount,jdbcType=INTEGER})
</insert> </insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.Stock"> <insert id="insertSelective" parameterType="cc.hiver.mall.entity.Stock">
insert into t_stock insert into t_stock
@ -216,6 +217,9 @@
<if test="stockCount != null"> <if test="stockCount != null">
stock_count, stock_count,
</if> </if>
<if test="stockWarnCount != null">
stock_warn_count,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -290,6 +294,9 @@
<if test="stockCount != null"> <if test="stockCount != null">
#{stockCount,jdbcType=INTEGER}, #{stockCount,jdbcType=INTEGER},
</if> </if>
<if test="stockWarnCount != null">
#{stockWarnCount,jdbcType=INTEGER},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="cc.hiver.mall.entity.StockExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="cc.hiver.mall.entity.StockExample" resultType="java.lang.Long">
@ -373,6 +380,9 @@
<if test="record.stockCount != null"> <if test="record.stockCount != null">
stock_count = #{record.stockCount,jdbcType=INTEGER}, stock_count = #{record.stockCount,jdbcType=INTEGER},
</if> </if>
<if test="record.stockWarnCount != null">
stock_warn_count = #{record.stockWarnCount,jdbcType=INTEGER},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -403,7 +413,8 @@
product_intro = #{record.productIntro,jdbcType=VARCHAR}, product_intro = #{record.productIntro,jdbcType=VARCHAR},
sales_week = #{record.salesWeek,jdbcType=VARCHAR}, sales_week = #{record.salesWeek,jdbcType=VARCHAR},
print_barcode = #{record.printBarcode,jdbcType=VARCHAR}, print_barcode = #{record.printBarcode,jdbcType=VARCHAR},
stock_count = #{record.stockCount,jdbcType=INTEGER} stock_count = #{record.stockCount,jdbcType=INTEGER},
stock_warn_count = #{record.stockWarnCount,jdbcType=INTEGER}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -480,6 +491,9 @@
<if test="stockCount != null"> <if test="stockCount != null">
stock_count = #{stockCount,jdbcType=INTEGER}, stock_count = #{stockCount,jdbcType=INTEGER},
</if> </if>
<if test="stockWarnCount != null">
stock_warn_count = #{stockWarnCount,jdbcType=INTEGER},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -507,7 +521,8 @@
product_intro = #{productIntro,jdbcType=VARCHAR}, product_intro = #{productIntro,jdbcType=VARCHAR},
sales_week = #{salesWeek,jdbcType=VARCHAR}, sales_week = #{salesWeek,jdbcType=VARCHAR},
print_barcode = #{printBarcode,jdbcType=VARCHAR}, print_barcode = #{printBarcode,jdbcType=VARCHAR},
stock_count = #{stockCount,jdbcType=INTEGER} stock_count = #{stockCount,jdbcType=INTEGER},
stock_warn_count = #{stockWarnCount,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>
Loading…
Cancel
Save