|
|
@@ -244,6 +244,12 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
private static final Date GPT_ACTIVITY_PAY_TIME_BEGIN = DateUtil.parse("2026-05-01 00:00:00");
|
|
|
|
|
|
+ private static final String GPT_ACTIVITY_REDEEM_NAME = "GPT代充/独立赠送";
|
|
|
+
|
|
|
+ private static final String STUDENT_CERT_API_QUOTA_REDEEM_NAME = "大学生认证API站额度券";
|
|
|
+
|
|
|
+ private static final Integer DEFAULT_API_QUOTA = 2500000;
|
|
|
+
|
|
|
@Override
|
|
|
public SearchResult<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize, String customId, String account, String orderNo, Integer cmt) {
|
|
|
User u = userMapper.selectById(userId);
|
|
|
@@ -2809,7 +2815,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
record.setSourceGoodsId(sourceGoodsId);
|
|
|
record.setSkuId(Constant.GPT_ACTIVITY_GIFT_SKU_ID);
|
|
|
record.setSourceType(RedisKey.GPT_API_QUOTA_KEY);
|
|
|
- record.setRedeemName("GPT代充/独立赠送");
|
|
|
+ record.setRedeemName(GPT_ACTIVITY_REDEEM_NAME);
|
|
|
record.setStatus("processing");
|
|
|
record.setRelationExpiryTime(sourceRelation.getExpiryTime());
|
|
|
ticketRedemptionCodeRecordMapper.insert(record);
|
|
|
@@ -2828,7 +2834,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
throw BusinessRuntimeException.getInstance("系统繁忙,请重新领取");
|
|
|
}
|
|
|
}
|
|
|
- GptActivityRedeemResult redeemResult = requestGptActivityRedeemCode(Constant.AI_API_SVC_DOMAIN, giftRelation, giftSku);
|
|
|
+ GptActivityRedeemResult redeemResult = requestGptActivityRedeemCode(Constant.AI_API_SVC_DOMAIN, GPT_ACTIVITY_REDEEM_NAME, DEFAULT_API_QUOTA);
|
|
|
record.setRelationId(giftRelation.getId());
|
|
|
record.setGoodsId(giftSku.getGoodsId());
|
|
|
record.setSourceGoodsId(sourceGoodsId);
|
|
|
@@ -2863,11 +2869,12 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ReceiveGptActivityTicketResp receiveStudentCertGptApiQuotaTicket(long userId) throws Exception {
|
|
|
+ public ReceiveGptActivityTicketResp receiveStudentCertGptApiQuotaTicket(long userId, Integer quota) throws Exception {
|
|
|
List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
if (CollUtil.isEmpty(userIds)) {
|
|
|
userIds = List.of(userId);
|
|
|
}
|
|
|
+ quota = resolveApiQuota(quota);
|
|
|
String lockKey = String.format("%s:%s", RedisKey.STUDENT_CERT_GPT_API_QUOTA_KEY, Collections.min(userIds));
|
|
|
if (!redisService.setNx(lockKey, userId, 60L)) {
|
|
|
throw BusinessRuntimeException.getInstance("领取中,请稍后再试");
|
|
|
@@ -2891,7 +2898,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
record.setUserId(userId);
|
|
|
record.setSkuId(Constant.GPT_ACTIVITY_GIFT_SKU_ID);
|
|
|
record.setSourceType(RedisKey.STUDENT_CERT_GPT_API_QUOTA_KEY);
|
|
|
- record.setRedeemName("大学生认证API站额度券");
|
|
|
+ record.setRedeemName(STUDENT_CERT_API_QUOTA_REDEEM_NAME);
|
|
|
record.setStatus("processing");
|
|
|
ticketRedemptionCodeRecordMapper.insert(record);
|
|
|
|
|
|
@@ -2910,7 +2917,7 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
throw BusinessRuntimeException.getInstance("系统繁忙,请重新领取");
|
|
|
}
|
|
|
|
|
|
- GptActivityRedeemResult redeemResult = requestGptActivityRedeemCode(Constant.AI_API_SVC_DOMAIN, giftRelation, giftSku);
|
|
|
+ GptActivityRedeemResult redeemResult = requestGptActivityRedeemCode(Constant.AI_API_SVC_DOMAIN, STUDENT_CERT_API_QUOTA_REDEEM_NAME, quota);
|
|
|
record.setRelationId(giftRelation.getId());
|
|
|
record.setGoodsId(giftSku.getGoodsId());
|
|
|
record.setRedeemCode(redeemResult.getRedeemCode());
|
|
|
@@ -2967,11 +2974,13 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
- private GptActivityRedeemResult requestGptActivityRedeemCode(String apiDomain, GroupsRelation giftRelation, GoodsDonSku giftSku) throws Exception {
|
|
|
- //默认5刀额度
|
|
|
- Integer quota = 2500000;
|
|
|
+ private Integer resolveApiQuota(Integer quota) {
|
|
|
+ return quota == null || quota <= 0 ? DEFAULT_API_QUOTA : quota;
|
|
|
+ }
|
|
|
+
|
|
|
+ private GptActivityRedeemResult requestGptActivityRedeemCode(String apiDomain, String redeemName, Integer quota) throws Exception {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("name", "GPT代充/独立赠送");
|
|
|
+ params.put("name", redeemName);
|
|
|
params.put("count", 1);
|
|
|
params.put("quota", quota);
|
|
|
String apiUrl = StrUtil.removeSuffix(apiDomain, "/") + "/api/redemption/";
|