| @@ -189,6 +189,30 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| return new ResultData(resultMap); | 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_PRESS_COMPLETE.getCode()); | ||||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | ||||
| statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); | statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); | ||||
| statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING.getCode()); | |||||
| orderQ.setStatusS(statusS); | orderQ.setStatusS(statusS); | ||||
| return wxOrderMapper.countList(orderQ); | return wxOrderMapper.countList(orderQ); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -419,6 +442,21 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| throw new MallinkException(ErrorCode.ORDER_UNPAID); | 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 { | try { | ||||
| count = getUserCouponOrderCount(user, coupon); | count = getUserCouponOrderCount(user, coupon); | ||||
| @@ -1586,8 +1624,8 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| record.setCUserId(user.getId()); | record.setCUserId(user.getId()); | ||||
| record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | ||||
| record.setDetail(bodyStr); | record.setDetail(bodyStr); | ||||
| record.setCreateDate(curr); | |||||
| record.setUpdateDate(curr); | record.setUpdateDate(curr); | ||||
| record.setCreateDate(curr); | |||||
| if (isPress) { | if (isPress) { | ||||
| // 初始砍价信息 | // 初始砍价信息 | ||||
| record.setPressCurrentNum(0); | record.setPressCurrentNum(0); | ||||