|
@@ -20,6 +20,7 @@ import com.cyksj.model.manage.views.OrderDonView;
|
|
|
import com.cyksj.model.request.ClaudeCodeApiKeysReq;
|
|
import com.cyksj.model.request.ClaudeCodeApiKeysReq;
|
|
|
import com.cyksj.model.request.ClaudeCodeDelReq;
|
|
import com.cyksj.model.request.ClaudeCodeDelReq;
|
|
|
import com.cyksj.model.response.ClaudeCodePointsHistoryResp;
|
|
import com.cyksj.model.response.ClaudeCodePointsHistoryResp;
|
|
|
|
|
+import com.cyksj.model.response.TimeRateConfigsResp;
|
|
|
import com.cyksj.model.response.claudecode.ClaudeCodeResp;
|
|
import com.cyksj.model.response.claudecode.ClaudeCodeResp;
|
|
|
import com.cyksj.model.views.*;
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.service.claude.AnnouncementService;
|
|
import com.cyksj.service.claude.AnnouncementService;
|
|
@@ -32,6 +33,7 @@ import com.cyksj.web.util.StpUserUtil;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
import com.ejlchina.searcher.param.Operator;
|
|
|
|
|
+import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -394,8 +396,23 @@ public class ClaudeCodeController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取中继服务器信息
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/relays/info")
|
|
|
|
|
+ public Result<List<RelayServer>> getRelaysInfo(@RequestParam(required = false) String domain) {
|
|
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
|
|
+ MapBuilder builder = MapUtils.builder();
|
|
|
|
|
+ if (StrUtil.isNotBlank(domain)) {
|
|
|
|
|
+ builder.field(RelayServer::getHost, domain).op(Operator.Contain);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<RelayServer> relayServers = beanSearcher.searchAll(RelayServer.class, builder.field(RelayServer::getStatus, 1).onlySelect(RelayServer::getHost, RelayServer::getLatencyMs).build());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(relayServers);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void setClaudeCodeSkuCouponInfo(String dsCode, Long userId, List<GoodsDonSkuView> goodsDonSkuViews) {
|
|
public void setClaudeCodeSkuCouponInfo(String dsCode, Long userId, List<GoodsDonSkuView> goodsDonSkuViews) {
|
|
|
//渠道推广
|
|
//渠道推广
|
|
|
|
|
+ Coupon coupon = null;
|
|
|
if (dsCode != null) {
|
|
if (dsCode != null) {
|
|
|
UserSharedDto popularizeDto = userService.getUserShredDtoByDsCode(dsCode);
|
|
UserSharedDto popularizeDto = userService.getUserShredDtoByDsCode(dsCode);
|
|
|
if (popularizeDto != null) {
|
|
if (popularizeDto != null) {
|
|
@@ -407,41 +424,74 @@ public class ClaudeCodeController {
|
|
|
.eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID)
|
|
.eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID)
|
|
|
.eq(CouponDistributePopularize::getDeleted, Boolean.TRUE));
|
|
.eq(CouponDistributePopularize::getDeleted, Boolean.TRUE));
|
|
|
//已配置使用渠道优惠码 未配置使用推荐优惠券
|
|
//已配置使用渠道优惠码 未配置使用推荐优惠券
|
|
|
- Coupon coupon = couponMapper.selectById(selectCount > 0 ? Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID : Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID);
|
|
|
|
|
- if (coupon == null) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (coupon.getId().intValue() == Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID.intValue()) {
|
|
|
|
|
- int isTj = couponRecommendMapper.checkPresentRecommendByCouponId(Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID);
|
|
|
|
|
- if (isTj == 0) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- List<Long> couponSkuIds = couponSkuMapper.selectList(Wrappers.lambdaQuery(CouponSku.class).eq(CouponSku::getCouponId, coupon.getId()).eq(CouponSku::getDeleted, Boolean.TRUE)).stream().map(CouponSku::getSkuId).collect(Collectors.toList());
|
|
|
|
|
- //该优惠券是否已经使用
|
|
|
|
|
- if (userId != null) {
|
|
|
|
|
- Integer isUsed = couponUserMapper.selectCount(Wrappers.lambdaQuery(CouponUser.class)
|
|
|
|
|
- .eq(CouponUser::getCouponId, coupon.getId())
|
|
|
|
|
- .eq(CouponUser::getStatus, CouponUser.Status.unused)
|
|
|
|
|
- .eq(CouponUser::getUserId, userId)
|
|
|
|
|
- .lt(CouponUser::getValidStartTime, DateTime.now())
|
|
|
|
|
- .gt(CouponUser::getValidEndTime, DateTime.now()));
|
|
|
|
|
- if (isUsed == 0) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- goodsDonSkuViews.forEach(sku -> {
|
|
|
|
|
- if (couponSkuIds.contains(sku.getSkuId())) {
|
|
|
|
|
- if (coupon.getType() == Coupon.Type.discount) {
|
|
|
|
|
- sku.setDiscount(coupon.getDiscount());
|
|
|
|
|
- sku.setDiscountPrice(sku.getMoney().multiply(coupon.getDiscount()));
|
|
|
|
|
- } else {
|
|
|
|
|
- sku.setReduceMoney(coupon.getReduceMoney());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ coupon = couponMapper.selectById(selectCount > 0 ? Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID : Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ Boolean isTjB = false;
|
|
|
|
|
+ //非推广链接
|
|
|
|
|
+ if (dsCode == null && coupon == null) {
|
|
|
|
|
+ coupon = couponRecommendMapper.getRecommendCouponByGoodsId(Constant.CLAUDE_CODE_GOODS_ID);
|
|
|
|
|
+ isTjB = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (coupon == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isTjB || coupon.getId().intValue() == Constant.DISTRIBUTE_CLAUDE_CODE_NO_CODE_COUPON_ID.intValue()) {
|
|
|
|
|
+ int isTj = couponRecommendMapper.checkPresentRecommendByCouponId(coupon.getId());
|
|
|
|
|
+ if (isTj == 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Long> couponSkuIds = couponSkuMapper.selectList(Wrappers.lambdaQuery(CouponSku.class).eq(CouponSku::getCouponId, coupon.getId()).eq(CouponSku::getDeleted, Boolean.TRUE)).stream().map(CouponSku::getSkuId).collect(Collectors.toList());
|
|
|
|
|
+ //该优惠券是否已经使用
|
|
|
|
|
+ if (userId != null) {
|
|
|
|
|
+ Integer selectCount = couponUserMapper.selectCount(Wrappers.lambdaQuery(CouponUser.class).eq(CouponUser::getCouponId, coupon.getId()).eq(CouponUser::getUserId, userId));
|
|
|
|
|
+ if (selectCount > 0) {
|
|
|
|
|
+ Integer isUsed = couponUserMapper.selectCount(Wrappers.lambdaQuery(CouponUser.class)
|
|
|
|
|
+ .eq(CouponUser::getCouponId, coupon.getId())
|
|
|
|
|
+ .eq(CouponUser::getStatus, CouponUser.Status.unused)
|
|
|
|
|
+ .eq(CouponUser::getUserId, userId)
|
|
|
|
|
+ .lt(CouponUser::getValidStartTime, DateTime.now())
|
|
|
|
|
+ .gt(CouponUser::getValidEndTime, DateTime.now()));
|
|
|
|
|
+ if (isUsed == 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (GoodsDonSkuView sku : goodsDonSkuViews) {
|
|
|
|
|
+ if (couponSkuIds.contains(sku.getSkuId())) {
|
|
|
|
|
+ sku.setCouonId(coupon.getId());
|
|
|
|
|
+ if (coupon.getType() == Coupon.Type.discount) {
|
|
|
|
|
+ sku.setDiscount(coupon.getDiscount());
|
|
|
|
|
+ sku.setDiscountPrice(sku.getMoney().multiply(coupon.getDiscount()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ sku.setReduceMoney(coupon.getReduceMoney());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //======================================================================时间倍率===============================================================================
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取系统中所有的时间倍率配置列表(包括已启用和已禁用的配置)
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/timeRate/configs")
|
|
|
|
|
+ public Result<TimeRateConfigsResp> getAllConfigs() {
|
|
|
|
|
+ TimeRateConfigsResp resp = claudeCodeService.getAllConfigs();
|
|
|
|
|
+ if (resp != null && CollUtil.isNotEmpty(resp.getConfigs())) {
|
|
|
|
|
+ resp.setConfigs(resp.getConfigs().stream().filter(time -> time.getIsActive()).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(resp);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * claude code模型倍率
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/get/multiplier")
|
|
|
|
|
+ public Result<List<ClaudeCodeMultiplier>> getMultiplier() {
|
|
|
|
|
+ List<ClaudeCodeMultiplier> claudeCodeMultipliers = beanSearcher.searchAll(ClaudeCodeMultiplier.class, MapUtils.builder().build());
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(claudeCodeMultipliers);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|