|
|
@@ -1,5 +1,6 @@
|
|
|
package com.cyksj.service.codex.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
@@ -56,6 +57,7 @@ import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 项目名: yhlxj11111111
|
|
|
@@ -269,8 +271,8 @@ public class CodexServiceImpl implements CodexService {
|
|
|
if (sku == null || sku.getGoodsId() != Constant.CLAUDE_CODE_GOODS_ID || !sku.getIsCodex()) {
|
|
|
throw BusinessRuntimeException.getInstance("系统异常,请刷新页面重试");
|
|
|
}
|
|
|
-
|
|
|
- int noPayCount = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class).eq(OrderDon::getUserId, userId).eq(OrderDon::getGoodsId, sku.getGoodsId())
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
+ int noPayCount = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class).in(OrderDon::getUserId, userIdList).eq(OrderDon::getGoodsId, sku.getGoodsId())
|
|
|
.eq(OrderDon::getStatus, OrderDon.Status.noPayment.toString()));
|
|
|
if (noPayCount > 0) {
|
|
|
throw new BusinessRuntimeException("您有未支付订单.");
|
|
|
@@ -303,6 +305,21 @@ public class CodexServiceImpl implements CodexService {
|
|
|
|
|
|
//锁一个cc的车票id
|
|
|
//是否存在无赠送的claude code 直接原规格上抵扣
|
|
|
+ List<Long> sendCodexSkuIds = skuMapper.selectList(Wrappers.lambdaQuery(GoodsDonSku.class).eq(GoodsDonSku::getGoodsId, Constant.CLAUDE_CODE_GOODS_ID).eq(GoodsDonSku::getIsCodex, Boolean.TRUE)).stream().map(GoodsDonSku::getId).collect(Collectors.toList());
|
|
|
+ //cc车票id
|
|
|
+ Long ccRelationId = null;
|
|
|
+ if (CollUtil.isEmpty(sendCodexSkuIds)) {
|
|
|
+ //是否存在cc
|
|
|
+ Integer selectCount = claudeCodeUserMapper.selectCount(Wrappers.lambdaQuery(ClaudeCodeUser.class).in(ClaudeCodeUser::getUserId, userIdList));
|
|
|
+ if (selectCount > 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("你存在claude code 无法抵扣");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder().field(GroupsRelationView::getUserId, userIdList).op(Operator.InList).field(GroupsRelationView::getSkuId, sendCodexSkuIds).op(Operator.InList).field(GroupsRelationView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan).build());
|
|
|
+ if (groupsRelationView != null) {
|
|
|
+ ccRelationId = groupsRelationView.getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
GroupsRelation relation = getClaudeCodeRelation(userId, sku);
|
|
|
orderDon.setRelationId(relation.getId());
|
|
|
@@ -310,6 +327,7 @@ public class CodexServiceImpl implements CodexService {
|
|
|
|
|
|
//记录抵扣记录
|
|
|
CodexDeductRecord codexDeductRecord = new CodexDeductRecord();
|
|
|
+ codexDeductRecord.setCcRelationId(ccRelationId);
|
|
|
codexDeductRecord.setOrderId(orderDon.getId());
|
|
|
codexDeductRecord.setRelationId(relationId);
|
|
|
codexDeductRecordMapper.insert(codexDeductRecord);
|