|
|
|
@@ -29,10 +29,7 @@ import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
@@ -331,11 +328,14 @@ import java.util.stream.Collectors; |
|
|
|
if(record.getInventory() != null && record.getRemainInventory() != null) { |
|
|
|
// 库存修改检查 |
|
|
|
WxCoupon oldCoupon = wxCouponMapper.selectByPrimaryKey(record.getId()); |
|
|
|
if(oldCoupon.getRemainInventory() == record.getRemainInventory()) { |
|
|
|
if (Objects.equals(oldCoupon.getRemainInventory(), record.getRemainInventory())) { |
|
|
|
// 库存未变, 不更新库存 |
|
|
|
record.setRemainInventory(null); |
|
|
|
record.setInventory(null); |
|
|
|
} else { |
|
|
|
// TODO bug记录 |
|
|
|
logger.info("设置库存:record.getRemainInventory {},oldCoupon.getRemainInventory {},oldCoupon.getInventory {}", |
|
|
|
record.getRemainInventory(), oldCoupon.getRemainInventory(), oldCoupon.getInventory()); |
|
|
|
// 库存增加,要同时增加, 库存减少,要同时减少 |
|
|
|
record.setInventory(oldCoupon.getInventory() + record.getRemainInventory() - oldCoupon.getRemainInventory()); |
|
|
|
} |
|
|
|
@@ -651,7 +651,7 @@ import java.util.stream.Collectors; |
|
|
|
@Override |
|
|
|
@Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) |
|
|
|
public void reduceRemainInventory(Long id, Integer remainInventory, Integer number) { |
|
|
|
int num = wxCouponMapper.reduceRemainInventory(id, remainInventory, number); |
|
|
|
int num = wxCouponMapper.reduceInventory(id, number, remainInventory); |
|
|
|
if (num == 0) { |
|
|
|
throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); |
|
|
|
} |
|
|
|
@@ -660,7 +660,7 @@ import java.util.stream.Collectors; |
|
|
|
@Override |
|
|
|
@Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) |
|
|
|
public void backRemainInventory(Long id, Integer remainInventory, Integer number) { |
|
|
|
int num = wxCouponMapper.backRemainInventory(id, remainInventory, number); |
|
|
|
int num = wxCouponMapper.backInventory(id, number, remainInventory); |
|
|
|
if (num == 0) { |
|
|
|
throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL); |
|
|
|
} |
|
|
|
|