Merge branch 'refs/heads/stock-share' into dev

This commit is contained in:
GYJ
2024-06-26 09:18:57 +08:00
6 changed files with 126 additions and 68 deletions

View File

@@ -36,4 +36,5 @@ public interface TbProductMapper {
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day); Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day);
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);
} }

View File

@@ -126,6 +126,8 @@ public class TbProduct implements Serializable {
private String specTableHeaders; private String specTableHeaders;
private Integer stockNumber;
@Transient @Transient
private int orderCount; private int orderCount;
@@ -642,4 +644,12 @@ public class TbProduct implements Serializable {
public void setOrderCount(int orderCount) { public void setOrderCount(int orderCount) {
this.orderCount = orderCount; this.orderCount = orderCount;
} }
public Integer getStockNumber() {
return stockNumber;
}
public void setStockNumber(Integer stockNumber) {
this.stockNumber = stockNumber;
}
} }

View File

@@ -49,5 +49,7 @@ public class TbProductSku implements Serializable {
private Long updatedAt; private Long updatedAt;
private Integer isPauseSale = 0;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@@ -45,6 +45,8 @@ public class DutyService {
@Autowired @Autowired
private TbProductSkuMapper productSkuMapper; private TbProductSkuMapper productSkuMapper;
@Autowired @Autowired
private TbProductMapper productMapper;
@Autowired
private CloudPrinterService cloudPrinterService; private CloudPrinterService cloudPrinterService;
@Autowired @Autowired
private RedisUtils redisUtil; private RedisUtils redisUtil;
@@ -372,8 +374,17 @@ public class DutyService {
} }
private void subInventory(Integer shopId, Integer skuId, Integer num) { private void subInventory(Integer shopId, Integer skuId, Integer num) {
String result = redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + skuId.toString(), num.toString());
TbProductSku tbProductSku = productSkuMapper.selectByPrimaryKey(skuId); TbProductSku tbProductSku = productSkuMapper.selectByPrimaryKey(skuId);
TbProductWithBLOBs product = productMapper.selectByPrimaryKey(Integer.valueOf(tbProductSku.getProductId()));
if (ObjectUtil.isNotEmpty(product)) {
if (product.getIsDistribute() == 1) {
redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":product" + product.getId().toString(), num.toString());
productMapper.updateStockById(skuId, num);
} else {
redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + skuId.toString(), num.toString());
if (ObjectUtil.isNotEmpty(tbProductSku)) {
if (num > tbProductSku.getStockNumber()) { if (num > tbProductSku.getStockNumber()) {
productSkuMapper.updateStockNum(skuId,num); productSkuMapper.updateStockNum(skuId,num);
} else { } else {
@@ -381,3 +392,7 @@ public class DutyService {
} }
} }
} }
}
}
}

View File

@@ -89,6 +89,9 @@ public class PayService {
@Autowired @Autowired
private TbProductSkuMapper productSkuMapper; private TbProductSkuMapper productSkuMapper;
@Autowired
private TbProductMapper productMapper;
@Autowired @Autowired
private RedisUtils redisUtil; private RedisUtils redisUtil;
@@ -920,11 +923,19 @@ public class PayService {
detail = tbOrderDetailMapper.selectByPrimaryKey(detail.getId()); detail = tbOrderDetailMapper.selectByPrimaryKey(detail.getId());
TbProductSku productSku = productSkuMapper.selectByPrimaryKey(detail.getProductSkuId()); TbProductSku productSku = productSkuMapper.selectByPrimaryKey(detail.getProductSkuId());
TbProductWithBLOBs product = productMapper.selectByPrimaryKey(detail.getProductId());
if (ObjectUtil.isNotEmpty(product)) {
if (product.getIsDistribute() == 1) {
redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":product" + product.getId().toString(), String.valueOf(detail.getReturnNum() + product.getStockNumber().intValue()));
productMapper.updateStockById(product.getId(), detail.getReturnNum() * -1);
} else {
if (ObjectUtil.isNotEmpty(productSku)) { if (ObjectUtil.isNotEmpty(productSku)) {
redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + productSku.getId().toString(), String.valueOf(detail.getReturnNum() + productSku.getStockNumber().intValue())); redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + productSku.getId().toString(), String.valueOf(detail.getReturnNum() + productSku.getStockNumber().intValue()));
productSkuMapper.updateByskuIdSub(productSku.getId(), detail.getReturnNum() * -1); productSkuMapper.updateByskuIdSub(productSku.getId(), detail.getReturnNum() * -1);
} }
} }
}
}
return Result.success(CodeEnum.SUCCESS); return Result.success(CodeEnum.SUCCESS);
} }

View File

@@ -62,6 +62,7 @@
<result column="enable_label" jdbcType="TINYINT" property="enableLabel" /> <result column="enable_label" jdbcType="TINYINT" property="enableLabel" />
<result column="tax_config_id" jdbcType="VARCHAR" property="taxConfigId" /> <result column="tax_config_id" jdbcType="VARCHAR" property="taxConfigId" />
<result column="spec_table_headers" jdbcType="VARCHAR" property="specTableHeaders" /> <result column="spec_table_headers" jdbcType="VARCHAR" property="specTableHeaders" />
<result column="stock_number" jdbcType="INTEGER" property="stockNumber" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs"> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
<result column="images" jdbcType="LONGVARCHAR" property="images" /> <result column="images" jdbcType="LONGVARCHAR" property="images" />
@@ -80,7 +81,7 @@
created_at, updated_at, base_sales_number, real_sales_number, sales_number, thumb_count, created_at, updated_at, base_sales_number, real_sales_number, sales_number, thumb_count,
store_count, furnish_meal, furnish_express, furnish_draw, furnish_vir, is_combo, store_count, furnish_meal, furnish_express, furnish_draw, furnish_vir, is_combo,
is_show_cash, is_show_mall, is_need_examine, show_on_mall_status, show_on_mall_time, is_show_cash, is_show_mall, is_need_examine, show_on_mall_status, show_on_mall_time,
show_on_mall_error_msg, enable_label, tax_config_id, spec_table_headers show_on_mall_error_msg, enable_label, tax_config_id, spec_table_headers, stock_number
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List">
images, video, notice, group_snap, spec_info, select_spec images, video, notice, group_snap, spec_info, select_spec
@@ -119,7 +120,7 @@
show_on_mall_status, show_on_mall_time, show_on_mall_error_msg, show_on_mall_status, show_on_mall_time, show_on_mall_error_msg,
enable_label, tax_config_id, spec_table_headers, enable_label, tax_config_id, spec_table_headers,
images, video, notice, images, video, notice,
group_snap, spec_info, select_spec group_snap, spec_info, select_spec, stock_number
) )
values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=VARCHAR}, #{specId,jdbcType=INTEGER}, values (#{id,jdbcType=INTEGER}, #{categoryId,jdbcType=VARCHAR}, #{specId,jdbcType=INTEGER},
#{sourcePath,jdbcType=VARCHAR}, #{brandId,jdbcType=INTEGER}, #{merchantId,jdbcType=VARCHAR}, #{sourcePath,jdbcType=VARCHAR}, #{brandId,jdbcType=INTEGER}, #{merchantId,jdbcType=VARCHAR},
@@ -142,7 +143,8 @@
#{showOnMallStatus,jdbcType=TINYINT}, #{showOnMallTime,jdbcType=BIGINT}, #{showOnMallErrorMsg,jdbcType=VARCHAR}, #{showOnMallStatus,jdbcType=TINYINT}, #{showOnMallTime,jdbcType=BIGINT}, #{showOnMallErrorMsg,jdbcType=VARCHAR},
#{enableLabel,jdbcType=TINYINT}, #{taxConfigId,jdbcType=VARCHAR}, #{specTableHeaders,jdbcType=VARCHAR}, #{enableLabel,jdbcType=TINYINT}, #{taxConfigId,jdbcType=VARCHAR}, #{specTableHeaders,jdbcType=VARCHAR},
#{images,jdbcType=LONGVARCHAR}, #{video,jdbcType=LONGVARCHAR}, #{notice,jdbcType=LONGVARCHAR}, #{images,jdbcType=LONGVARCHAR}, #{video,jdbcType=LONGVARCHAR}, #{notice,jdbcType=LONGVARCHAR},
#{groupSnap,jdbcType=LONGVARCHAR}, #{specInfo,jdbcType=LONGVARCHAR}, #{selectSpec,jdbcType=LONGVARCHAR} #{groupSnap,jdbcType=LONGVARCHAR}, #{specInfo,jdbcType=LONGVARCHAR}, #{selectSpec,jdbcType=LONGVARCHAR},
#{stockNumber,jdbcType=INTEGER}
) )
</insert> </insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs"> <insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
@@ -346,6 +348,9 @@
<if test="selectSpec != null"> <if test="selectSpec != null">
select_spec, select_spec,
</if> </if>
<if test="stockNumber != null">
stock_number,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@@ -546,6 +551,9 @@
<if test="selectSpec != null"> <if test="selectSpec != null">
#{selectSpec,jdbcType=LONGVARCHAR}, #{selectSpec,jdbcType=LONGVARCHAR},
</if> </if>
<if test="stockNumber != null">
#{stockNumber,jdbcType=INTEGER},
</if>
</trim> </trim>
</insert> </insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs"> <update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProductWithBLOBs">
@@ -746,6 +754,9 @@
<if test="selectSpec != null"> <if test="selectSpec != null">
select_spec = #{selectSpec,jdbcType=LONGVARCHAR}, select_spec = #{selectSpec,jdbcType=LONGVARCHAR},
</if> </if>
<if test="stockNumber != null">
stock_number = #{stockNumber,jdbcType=INTEGER},
</if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
@@ -815,7 +826,8 @@
notice = #{notice,jdbcType=LONGVARCHAR}, notice = #{notice,jdbcType=LONGVARCHAR},
group_snap = #{groupSnap,jdbcType=LONGVARCHAR}, group_snap = #{groupSnap,jdbcType=LONGVARCHAR},
spec_info = #{specInfo,jdbcType=LONGVARCHAR}, spec_info = #{specInfo,jdbcType=LONGVARCHAR},
select_spec = #{selectSpec,jdbcType=LONGVARCHAR} select_spec = #{selectSpec,jdbcType=LONGVARCHAR},
stock_number = #{stockNumber,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProduct"> <update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbProduct">
@@ -878,7 +890,8 @@
show_on_mall_error_msg = #{showOnMallErrorMsg,jdbcType=VARCHAR}, show_on_mall_error_msg = #{showOnMallErrorMsg,jdbcType=VARCHAR},
enable_label = #{enableLabel,jdbcType=TINYINT}, enable_label = #{enableLabel,jdbcType=TINYINT},
tax_config_id = #{taxConfigId,jdbcType=VARCHAR}, tax_config_id = #{taxConfigId,jdbcType=VARCHAR},
spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR} spec_table_headers = #{specTableHeaders,jdbcType=VARCHAR},
stock_number = #{stockNumber,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
@@ -916,4 +929,10 @@
and trade_day = #{day} and trade_day = #{day}
group by shop_id,product_id group by shop_id,product_id
</select> </select>
<update id="updateStockById">
update tb_product
set stock_number = stock_number - #{number,jdbcType=INTEGER}
where id = #{productId}
</update>
</mapper> </mapper>