|
|
@@ -19,7 +19,9 @@ import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.OrderDonView;
|
|
|
import com.cyksj.model.request.ClaudeCodeApiKeysReq;
|
|
|
import com.cyksj.model.request.ClaudeCodeDelReq;
|
|
|
-import com.cyksj.model.response.ClaudeCodePointsHistoryResp;
|
|
|
+import com.cyksj.model.request.CreditResetReq;
|
|
|
+import com.cyksj.model.request.TimeRateConfigReq;
|
|
|
+import com.cyksj.model.response.*;
|
|
|
import com.cyksj.model.response.claudecode.ClaudeCodeResp;
|
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.service.claude.AnnouncementService;
|
|
|
@@ -396,6 +398,7 @@ public class ClaudeCodeController {
|
|
|
|
|
|
public void setClaudeCodeSkuCouponInfo(String dsCode, Long userId, List<GoodsDonSkuView> goodsDonSkuViews) {
|
|
|
//渠道推广
|
|
|
+ Coupon coupon = null;
|
|
|
if (dsCode != null) {
|
|
|
UserSharedDto popularizeDto = userService.getUserShredDtoByDsCode(dsCode);
|
|
|
if (popularizeDto != null) {
|
|
|
@@ -407,41 +410,100 @@ public class ClaudeCodeController {
|
|
|
.eq(CouponDistributePopularize::getCouponId, Constant.DISTRIBUTE_CLAUDE_CODE_COUPON_ID)
|
|
|
.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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //非推广链接
|
|
|
+ if (coupon == null) {
|
|
|
+ coupon = couponMapper.selectById(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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (GoodsDonSkuView sku : goodsDonSkuViews) {
|
|
|
+ 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());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //======================================================================时间倍率===============================================================================
|
|
|
+ /**
|
|
|
+ * 获取当前时间的积分倍率配置信息
|
|
|
+ */
|
|
|
+ @GetMapping("/timeRate/current")
|
|
|
+ public Result<TimeRateCurrentResp> getCurrentTimeRate() {
|
|
|
+ TimeRateCurrentResp resp = claudeCodeService.getCurrentTimeRate();
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(resp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取系统中所有的时间倍率配置列表(包括已启用和已禁用的配置)
|
|
|
+ */
|
|
|
+ @GetMapping("/timeRate/configs")
|
|
|
+ public Result<TimeRateConfigsResp> getAllConfigs() {
|
|
|
+ TimeRateConfigsResp resp = claudeCodeService.getAllConfigs();
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(resp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建新的时间倍率配置。系统支持跨天配置(如23点到6点)
|
|
|
+ */
|
|
|
+ @PostMapping("/timeRate/configs")
|
|
|
+ public Result<TimeRateConfigResp> createConfig(@RequestBody @Validated TimeRateConfigReq req) {
|
|
|
+ TimeRateConfigResp resp = claudeCodeService.createConfig(req);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(resp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新指定ID的时间倍率配置
|
|
|
+ */
|
|
|
+ @PutMapping("/timeRate/configs/{id}")
|
|
|
+ public Result<TimeRateConfigResp> updateConfig(@PathVariable Long id, @RequestBody @Validated TimeRateConfigReq req) {
|
|
|
+ TimeRateConfigResp resp = claudeCodeService.updateConfig(id, req);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(resp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除指定ID的时间倍率配置。删除后该时间段将使用默认倍率1.0
|
|
|
+ */
|
|
|
+ @DeleteMapping("/timeRate/configs/{id}")
|
|
|
+ public Result<String> deleteConfig(@PathVariable Long id) {
|
|
|
+ claudeCodeService.deleteConfig(id);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("Time multiplier config deleted successfully");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将指定用户的积分重置为满积分状态(used_credits设为0)
|
|
|
+ */
|
|
|
+ @PostMapping("/users/{userId}/credits/reset")
|
|
|
+ public Result<CreditResetResp> resetUserCredits(@PathVariable Long userId, @RequestBody(required = false) CreditResetReq req) {
|
|
|
+ CreditResetResp resp = claudeCodeService.resetUserCredits(userId, req);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(resp);
|
|
|
+ }
|
|
|
}
|