退款回滚库存
This commit is contained in:
parent
fa2668ed1c
commit
b66a89b143
|
|
@ -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);
|
||||
|
||||
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);
|
||||
}
|
||||
|
|
@ -89,6 +89,9 @@ public class PayService {
|
|||
@Autowired
|
||||
private TbProductSkuMapper productSkuMapper;
|
||||
|
||||
@Autowired
|
||||
private TbProductMapper productMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisUtils redisUtil;
|
||||
|
||||
|
|
@ -920,9 +923,17 @@ public class PayService {
|
|||
detail = tbOrderDetailMapper.selectByPrimaryKey(detail.getId());
|
||||
|
||||
TbProductSku productSku = productSkuMapper.selectByPrimaryKey(detail.getProductSkuId());
|
||||
if (ObjectUtil.isNotEmpty(productSku)) {
|
||||
redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + productSku.getId().toString(), String.valueOf(detail.getReturnNum() + productSku.getStockNumber().intValue()));
|
||||
productSkuMapper.updateByskuIdSub(productSku.getId(), detail.getReturnNum() * -1);
|
||||
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)) {
|
||||
redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + productSku.getId().toString(), String.valueOf(detail.getReturnNum() + productSku.getStockNumber().intValue()));
|
||||
productSkuMapper.updateByskuIdSub(productSku.getId(), detail.getReturnNum() * -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -929,4 +929,10 @@
|
|||
and trade_day = #{day}
|
||||
group by shop_id,product_id
|
||||
</select>
|
||||
|
||||
<update id="updateStockById">
|
||||
update tb_product
|
||||
set stock_number = stock_number - #{number,jdbcType=INTEGER}
|
||||
where id = #{productId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue