Просмотр исходного кода

[拼团][修改][拼团中要限购]

release_toaliyun_real
gongbiao 6 лет назад
Родитель
Сommit
e9889c545c
1 измененных файлов: 40 добавлений и 2 удалений
  1. +40
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java

+ 40
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java Просмотреть файл

@@ -189,6 +189,30 @@ public class WxOrderServiceImpl implements WxOrderService {
return new ResultData(resultMap);
}

/**
* 拼团数量
*
* @param user
* @param counpon
* @return
*/
private int getUserOrderGroupCount(WxCUser user, WxCoupon counpon) {
// + Order 待支付
try {
WxOrder orderQ = new WxOrder();
orderQ.setTenantId(user.getTenantId());
orderQ.setProductId(counpon.getId());
orderQ.setType(EnumOrderType.COUPON.getCode());
orderQ.setCUserId(user.getId());
orderQ.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING.getCode());
return wxOrderMapper.countList(orderQ);
} catch (Exception e) {
logger.error("购买是否超限-DB, couponId: " + counpon.getId() + ", e:" + e.getMessage());
throw new MallinkException(ErrorCode.ORDER_IS_FAIL);
}

}


/**
* 用户购买的订单数量
@@ -209,7 +233,6 @@ public class WxOrderServiceImpl implements WxOrderService {
statusS.add(EnumOrderStatus.ORDER_STATUS_PRESS_COMPLETE.getCode());
statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode());
statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode());
statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING.getCode());
orderQ.setStatusS(statusS);
return wxOrderMapper.countList(orderQ);
} catch (Exception e) {
@@ -419,6 +442,21 @@ public class WxOrderServiceImpl implements WxOrderService {
throw new MallinkException(ErrorCode.ORDER_UNPAID);
}
}
//检查拼团中的数量
try {
count = getUserOrderGroupCount(user, coupon);
} catch (Exception e) {
//解锁
redisLock.unlock(couponIdStr, timeStr);
throw new MallinkException(ErrorCode.DB_FAIL);
}
if (count >= coupon.getUseLimitQuantity()) {
//解锁
redisLock.unlock(couponIdStr, timeStr);
logger.error("此券购买数量已超限, couponId: " + couponIdStr + ", count: " + count);
throw new MallinkException(ErrorCode.ORDER_IS_LIMITED);
}

// 检查用户已购买数量
try {
count = getUserCouponOrderCount(user, coupon);
@@ -1586,8 +1624,8 @@ public class WxOrderServiceImpl implements WxOrderService {
record.setCUserId(user.getId());
record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode());
record.setDetail(bodyStr);
record.setCreateDate(curr);
record.setUpdateDate(curr);
record.setCreateDate(curr);
if (isPress) {
// 初始砍价信息
record.setPressCurrentNum(0);


Загрузка…
Отмена
Сохранить