|
|
@@ -12,6 +12,7 @@ import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
import com.cyksj.common.util.StringUtil;
|
|
|
@@ -101,6 +102,8 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
|
|
|
private final UpgradePackageMapper upgradePackageMapper;
|
|
|
|
|
|
+ private final OrderDonMapper orderDonMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public String addAccount(Account account) {
|
|
|
if (isAccountExists(account)) {
|
|
|
@@ -823,12 +826,25 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
.eq(UpgradePackage::getGptType, 0)
|
|
|
.eq(UpgradePackage::getDeleted, Boolean.TRUE));
|
|
|
Boolean upgrade = count > 0 ? true : false;
|
|
|
+ OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getRelationId, relationId)
|
|
|
+ .eq(OrderDon::getUserId, groupsRelation.getUserId())
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
|
|
|
+ .orderByDesc(OrderDon::getId)
|
|
|
+ .last("limit 1"));
|
|
|
+ Long orderId = null;
|
|
|
+ if (orderDon != null) {
|
|
|
+ orderId = orderDon.getId();
|
|
|
+ }
|
|
|
return ChatGptUserView.builder()
|
|
|
.skuName(goodsDonSku.getSubTitle())
|
|
|
.expireTime(chatgptUser.getExpireTime())
|
|
|
.limitNum(chatgptUser.getLimitNum())
|
|
|
.limitTime(chatgptUser.getLimitTime())
|
|
|
.upgrade(upgrade)
|
|
|
+ .orderId(orderId)
|
|
|
+ .goodsId(goodsDonSku.getGoodsId())
|
|
|
+ .skuId(goodsDonSku.getId())
|
|
|
.use(Math.min(chatgptUser.getLimitNum(), getConversationCount(chatgptUser.getUserToken(), chatgptUser.getLimitTime())))
|
|
|
.build();
|
|
|
} else {
|