|
@@ -14,6 +14,7 @@ import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
import com.cyksj.mapper.*;
|
|
import com.cyksj.mapper.*;
|
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
|
|
+import com.cyksj.model.request.GptIndependentExportRechargeReq;
|
|
|
import com.cyksj.model.request.GroupsRelationRechargeReq;
|
|
import com.cyksj.model.request.GroupsRelationRechargeReq;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.server.recharge.dto.CardKeyValidationResult;
|
|
import com.cyksj.server.recharge.dto.CardKeyValidationResult;
|
|
@@ -22,12 +23,15 @@ import com.cyksj.server.recharge.dto.TaskSubmitResult;
|
|
|
import com.cyksj.server.recharge.dto.TokenParseResult;
|
|
import com.cyksj.server.recharge.dto.TokenParseResult;
|
|
|
import com.cyksj.service.chatgpt.GptUserRechargeRecordService;
|
|
import com.cyksj.service.chatgpt.GptUserRechargeRecordService;
|
|
|
import com.cyksj.service.mange.gpt.GptRechargeService;
|
|
import com.cyksj.service.mange.gpt.GptRechargeService;
|
|
|
|
|
+import com.cyksj.service.user.UserBindRelationService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 项目名: yhlxj11111111
|
|
* 项目名: yhlxj11111111
|
|
@@ -57,6 +61,8 @@ public class GptRechargeServiceImpl implements GptRechargeService {
|
|
|
|
|
|
|
|
private final RedisService redisService;
|
|
private final RedisService redisService;
|
|
|
|
|
|
|
|
|
|
+ private final UserBindRelationService userBindRelationService;
|
|
|
|
|
+
|
|
|
private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
|
|
private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
@@ -232,6 +238,59 @@ public class GptRechargeServiceImpl implements GptRechargeService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void gptIndependentExportRecharge(GptIndependentExportRechargeReq rechargeReq) {
|
|
|
|
|
+ String orderNo = rechargeReq.getOrderNo();
|
|
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getOrderNo, orderNo).notIn(OrderDon::getStatus, Constant.noOrderAllStatus));
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单不存在或已退款");
|
|
|
|
|
+ }
|
|
|
|
|
+ //只支持GPT独立会员类型
|
|
|
|
|
+ List<Long> gptIdpSkuIds = skuMapper.selectList(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, Constant.GPT_PLUS_GID).eq(GoodsDonSku::getNum, 1)).stream().map(GoodsDonSku::getId).collect(Collectors.toList());
|
|
|
|
|
+ if (!gptIdpSkuIds.contains(orderDon.getSkuId())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("只支持GPT独立会员类型");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long relationId = orderDon.getRelationId();
|
|
|
|
|
+ Long userId = orderDon.getUserId();
|
|
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ GroupsRelation relation = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getId, relationId).in(GroupsRelation::getUserId, userIdList).gt(GroupsRelation::getExpiryTime, DateTime.now()).last("limit 1"));
|
|
|
|
|
+ if (relation == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("独立会员车票不存在或已过期");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (relation.getRenewStatus() != null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该笔订单号已导入");
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer num = rechargeReq.getNum();
|
|
|
|
|
+ relation.setRechargeStatus(GroupsRelation.RechargeStatus.waiting);
|
|
|
|
|
+ GoodsDonSku sku = skuMapper.selectById(orderDon.getSkuId());
|
|
|
|
|
+ Integer months = sku.getMonths();
|
|
|
|
|
+ //总代充次数
|
|
|
|
|
+ relation.setRechargeNum(months > num ? months : num);
|
|
|
|
|
+ relation.setRechargeRemainNum(num);
|
|
|
|
|
+ relationMapper.updateById(relation);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public GroupsRelation getOrderRelation(String orderNo) {
|
|
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getOrderNo, orderNo).notIn(OrderDon::getStatus, Constant.noOrderAllStatus));
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单不存在或已退款");
|
|
|
|
|
+ }
|
|
|
|
|
+ //只支持GPT独立会员类型
|
|
|
|
|
+ List<Long> gptIdpSkuIds = skuMapper.selectList(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, Constant.GPT_PLUS_GID).eq(GoodsDonSku::getNum, 1)).stream().map(GoodsDonSku::getId).collect(Collectors.toList());
|
|
|
|
|
+ if (!gptIdpSkuIds.contains(orderDon.getSkuId())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("只支持GPT独立会员类型");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long relationId = orderDon.getRelationId();
|
|
|
|
|
+ Long userId = orderDon.getUserId();
|
|
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ GroupsRelation relation = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getId, relationId).in(GroupsRelation::getUserId, userIdList).gt(GroupsRelation::getExpiryTime, DateTime.now()).last("limit 1"));
|
|
|
|
|
+ if (relation == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("独立会员车票不存在或已过期");
|
|
|
|
|
+ }
|
|
|
|
|
+ return relation;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public CardKeyValidationResult validateCardKey(String cardKey) {
|
|
public CardKeyValidationResult validateCardKey(String cardKey) {
|
|
|
log.info("开始验证卡密: {}", cardKey);
|
|
log.info("开始验证卡密: {}", cardKey);
|
|
|
try {
|
|
try {
|