|
@@ -640,6 +640,7 @@ public class CouponLogic {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public void getCoupon(HttpServletRequest request, String userId, List<String> couponIds) {
|
|
public void getCoupon(HttpServletRequest request, String userId, List<String> couponIds) {
|
|
|
|
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
|
|
CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat(request);
|
|
@@ -664,19 +665,20 @@ public class CouponLogic {
|
|
Integer leftAmount = coupon.getLeftAmount();
|
|
Integer leftAmount = coupon.getLeftAmount();
|
|
//已领取数量
|
|
//已领取数量
|
|
Integer receiveAmount = coupon.getReceiveAmount() == null ? 0 : coupon.getReceiveAmount();
|
|
Integer receiveAmount = coupon.getReceiveAmount() == null ? 0 : coupon.getReceiveAmount();
|
|
- if (leftAmount <= 0) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(couponIds)) {
|
|
if (!CollectionUtils.isEmpty(couponIds)) {
|
|
|
|
|
|
Integer count = userCouponService.lambdaQuery()
|
|
Integer count = userCouponService.lambdaQuery()
|
|
.eq(UserCoupon::getUserId, userId)
|
|
.eq(UserCoupon::getUserId, userId)
|
|
.eq(UserCoupon::getCouponId, coupon.getCouponId()).count();
|
|
.eq(UserCoupon::getCouponId, coupon.getCouponId()).count();
|
|
|
|
+
|
|
|
|
+ if (leftAmount <= 0) {
|
|
|
|
+ throw new RemoteServiceException("该券已被领完");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
if (receiveLimitCount != 0 && count >= receiveLimitCount) {
|
|
if (receiveLimitCount != 0 && count >= receiveLimitCount) {
|
|
- continue;
|
|
|
|
|
|
+ throw new RemoteServiceException("该券已被领完");
|
|
}
|
|
}
|
|
|
|
|
|
UserCoupon userCoupon = new UserCoupon();
|
|
UserCoupon userCoupon = new UserCoupon();
|
|
@@ -726,6 +728,10 @@ public class CouponLogic {
|
|
|
|
|
|
}else {
|
|
}else {
|
|
|
|
|
|
|
|
+ if (leftAmount <= 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
//实际领取张数
|
|
//实际领取张数
|
|
int num = leftAmount - receiveLimitCount < 0 ? 0 : leftAmount - receiveLimitCount;
|
|
int num = leftAmount - receiveLimitCount < 0 ? 0 : leftAmount - receiveLimitCount;
|