退款回滚库存
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);
|
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
|
@Autowired
|
||||||
private TbProductSkuMapper productSkuMapper;
|
private TbProductSkuMapper productSkuMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbProductMapper productMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisUtils redisUtil;
|
private RedisUtils redisUtil;
|
||||||
|
|
||||||
|
|
@ -920,9 +923,17 @@ 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());
|
||||||
if (ObjectUtil.isNotEmpty(productSku)) {
|
TbProductWithBLOBs product = productMapper.selectByPrimaryKey(detail.getProductId());
|
||||||
redisUtil.seckill(RedisCst.PRODUCT + shopId.toString() + ":" + productSku.getId().toString(), String.valueOf(detail.getReturnNum() + productSku.getStockNumber().intValue()));
|
if (ObjectUtil.isNotEmpty(product)) {
|
||||||
productSkuMapper.updateByskuIdSub(productSku.getId(), detail.getReturnNum() * -1);
|
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}
|
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>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue