|
|
@@ -604,7 +604,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
// PLUS 仅 skuNum == 1 的独立规格可领;与实际领取接口共用资格校验。
|
|
|
ticket.setCanReceiveGptApiQuota(isGptApiQuotaSourceTicket(sourceOrder, ticket.getGoodsId(), ticket.getSkuNum())
|
|
|
&& !hasReceivedGptApiQuota(userIds, ticket.getGoodsId(), yearQuota)
|
|
|
- && !hasPendingGptApiQuota(userIds)
|
|
|
+ && !hasPendingGptApiQuota(userIds, ticket.getGoodsId())
|
|
|
&& (!yearQuota || hasNewGptApiQuotaPurchase(userIds, ticket.getGoodsId(), sourceOrder)));
|
|
|
}
|
|
|
|
|
|
@@ -613,26 +613,25 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
.in(TicketRedemptionCodeRecord::getUserId, userIds)
|
|
|
.eq(TicketRedemptionCodeRecord::getSkuId, Constant.GPT_ACTIVITY_GIFT_SKU_ID)
|
|
|
.eq(TicketRedemptionCodeRecord::getSourceType, RedisKey.GPT_API_QUOTA_KEY)
|
|
|
+ .eq(TicketRedemptionCodeRecord::getSourceGoodsId, sourceGoodsId)
|
|
|
.and(wrapper -> wrapper.eq(TicketRedemptionCodeRecord::getStatus, "success")
|
|
|
.or(issued -> issued.isNotNull(TicketRedemptionCodeRecord::getRedeemCode)
|
|
|
.ne(TicketRedemptionCodeRecord::getRedeemCode, "")));
|
|
|
if (yearQuota) {
|
|
|
- // 两种年付共享一次50元资格;原5元不占用,历史已发50元仍计入。
|
|
|
- query.in(TicketRedemptionCodeRecord::getSourceGoodsId, Constant.GPT_RECHARGE_GOODS_ID, Constant.GPT_PLUS_GID)
|
|
|
- .ge(TicketRedemptionCodeRecord::getQuota, YEAR_RECHARGE_API_QUOTA);
|
|
|
- } else {
|
|
|
- // 普通规格保持原有按商品限制一次的规则。
|
|
|
- query.eq(TicketRedemptionCodeRecord::getSourceGoodsId, sourceGoodsId);
|
|
|
+ // 独立年付、代充年付按商品各限领一次50元;原5元不占用50元资格。
|
|
|
+ query.ge(TicketRedemptionCodeRecord::getQuota, YEAR_RECHARGE_API_QUOTA);
|
|
|
}
|
|
|
+ // 普通规格仍按当前商品的任意已发额度限制一次。
|
|
|
return ticketRedemptionCodeRecordMapper.selectCount(query) > 0;
|
|
|
}
|
|
|
|
|
|
- private boolean hasPendingGptApiQuota(List<Long> userIds) {
|
|
|
- // 发放中或远端结果不确定时不允许自动重发,避免 Redis 锁过期后重复领取。
|
|
|
+ private boolean hasPendingGptApiQuota(List<Long> userIds, Long sourceGoodsId) {
|
|
|
+ // 同一商品发放中或结果不确定时禁止重发,不占用另一商品的领取资格。
|
|
|
return ticketRedemptionCodeRecordMapper.selectCount(Wrappers.lambdaQuery(TicketRedemptionCodeRecord.class)
|
|
|
.in(TicketRedemptionCodeRecord::getUserId, userIds)
|
|
|
.eq(TicketRedemptionCodeRecord::getSkuId, Constant.GPT_ACTIVITY_GIFT_SKU_ID)
|
|
|
.eq(TicketRedemptionCodeRecord::getSourceType, RedisKey.GPT_API_QUOTA_KEY)
|
|
|
+ .eq(TicketRedemptionCodeRecord::getSourceGoodsId, sourceGoodsId)
|
|
|
.eq(TicketRedemptionCodeRecord::getStatus, "processing")) > 0;
|
|
|
}
|
|
|
|
|
|
@@ -675,7 +674,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
if (hasReceivedGptApiQuota(userIds, record.getSourceGoodsId(), yearQuota)) {
|
|
|
throw BusinessRuntimeException.getInstance(yearQuota ? "您已领取50元API额度" : "您已领取");
|
|
|
}
|
|
|
- if (hasPendingGptApiQuota(userIds)) {
|
|
|
+ if (hasPendingGptApiQuota(userIds, record.getSourceGoodsId())) {
|
|
|
throw BusinessRuntimeException.getInstance("额度正在发放或结果待确认,请勿重复领取;长时间未到账请联系客服");
|
|
|
}
|
|
|
if (yearQuota && !hasNewGptApiQuotaPurchase(userIds, record.getSourceGoodsId(), sourceOrder)) {
|