|
|
@@ -1,5 +1,6 @@
|
|
|
package com.cyksj.service.order.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
@@ -48,6 +49,7 @@ import com.cyksj.mapper.manage.distribute.*;
|
|
|
import com.cyksj.mapper.market.task.TaskTypeMapper;
|
|
|
import com.cyksj.mapper.market.task.UserBindDetailMapper;
|
|
|
import com.cyksj.model.dto.AliPayParams;
|
|
|
+import com.cyksj.model.dto.ChatGPTPlusPurchaseLimitDto;
|
|
|
import com.cyksj.model.dto.CouponPopularizeDto;
|
|
|
import com.cyksj.model.dto.H5JsPayParams;
|
|
|
import com.cyksj.model.entity.Address;
|
|
|
@@ -229,7 +231,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
} else {
|
|
|
user = userMapper.selectById(payRequest.getUserId());
|
|
|
if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
- if (user.getIsBlack()) throw BusinessRuntimeException.getInstance("您的账号操作异常,已被拉黑");
|
|
|
+ if (user.getIsBlack()) throw BusinessRuntimeException.getInstance("系统检测操作异常,请稍后再试");
|
|
|
+ //ChatGPT Plus账号限购校验
|
|
|
+ checkChatGPTPlusPurchaseLimit(user.getId(), goodsDon.getId(), sku.getId(), sku.getSpecVal());
|
|
|
payOpenId = user.getOpenId();
|
|
|
if (goodsDon.getType() == 1) {
|
|
|
GroupsRelation relation = null;
|
|
|
@@ -641,7 +645,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
Long userId = payRequest.getUserId();
|
|
|
User user = userMapper.selectById(userId);
|
|
|
if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
- if (user.getIsBlack()) throw BusinessRuntimeException.getInstance("您的账号操作异常,已被拉黑");
|
|
|
+ if (user.getIsBlack()) throw BusinessRuntimeException.getInstance("系统检测操作异常,请稍后再试");
|
|
|
Long renewSkuId = payRequest.getSkuId();
|
|
|
CouponUser couponUser = null;
|
|
|
if (StrUtil.isNotBlank(payRequest.getCouponExCode()) || payRequest.getCouponId() != null) {
|
|
|
@@ -2144,4 +2148,44 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * chatGPT Plus账号购买限购校验
|
|
|
+ */
|
|
|
+ public void checkChatGPTPlusPurchaseLimit(Long userId, Long goodsId, Long skuId, String specVal) {
|
|
|
+ if (goodsId == 18) {
|
|
|
+ SysConfig sysConfig = sysConfigService.getOne(Wrappers.lambdaQuery(SysConfig.class)
|
|
|
+ .eq(SysConfig::getSysKey, Constant.CHAT_GPT_PLUS_SKU_PURCHASE_LIMIT).last("limit 1"));
|
|
|
+ if (sysConfig != null) {
|
|
|
+ String sysValue = sysConfig.getSysValue();
|
|
|
+ if (StrUtil.isNotBlank(sysValue)) {
|
|
|
+ List<ChatGPTPlusPurchaseLimitDto> chatGPTPlusPurchaseLimitDtos = null;
|
|
|
+ try {
|
|
|
+ chatGPTPlusPurchaseLimitDtos = Jsons.parseList(sysValue, ChatGPTPlusPurchaseLimitDto.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("ChatGPT Plus限购配置错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(chatGPTPlusPurchaseLimitDtos)) {
|
|
|
+ for (ChatGPTPlusPurchaseLimitDto chatGPTPlusPurchaseLimitDto : chatGPTPlusPurchaseLimitDtos) {
|
|
|
+ Long limitSkuId = chatGPTPlusPurchaseLimitDto.getSkuId();
|
|
|
+ Integer time = chatGPTPlusPurchaseLimitDto.getTime();
|
|
|
+ Integer days = chatGPTPlusPurchaseLimitDto.getDays();
|
|
|
+ if (limitSkuId != null && skuId.equals(limitSkuId)) {
|
|
|
+ //半个月内是否购买过1单 chatGPT Plus
|
|
|
+ Integer count = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ .eq(OrderDon::getUserId, userId)
|
|
|
+ .eq(OrderDon::getSkuId, skuId)
|
|
|
+ .gt(OrderDon::getCreatedTime, DateUtil.offsetDay(DateTime.now(), -days))
|
|
|
+ .notIn(OrderDon::getStatus, Constant.noOrderAllStatus));
|
|
|
+ if (count > time - 1)
|
|
|
+ throw BusinessRuntimeException.getInstance(String.format("%s天内只能购买%s次ChatGPT Plus %s规格账号", days, time, specVal.replaceAll(";", "")));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|