|
@@ -30,6 +30,7 @@ import com.cyksj.model.excel.ExcelSheetAndData;
|
|
|
import com.cyksj.model.request.BatchServiceReq;
|
|
import com.cyksj.model.request.BatchServiceReq;
|
|
|
import com.cyksj.model.request.RedBookReq;
|
|
import com.cyksj.model.request.RedBookReq;
|
|
|
import com.cyksj.model.request.RenewTimeUpReq;
|
|
import com.cyksj.model.request.RenewTimeUpReq;
|
|
|
|
|
+import com.cyksj.model.request.TicketCompensationDaysReq;
|
|
|
import com.cyksj.model.views.*;
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.service.claude.ClaudeCodeService;
|
|
import com.cyksj.service.claude.ClaudeCodeService;
|
|
|
import com.cyksj.service.codex.CodexService;
|
|
import com.cyksj.service.codex.CodexService;
|
|
@@ -226,14 +227,60 @@ public class StatisticsDataController {
|
|
|
if (relation.getExpiryTime() == null) {
|
|
if (relation.getExpiryTime() == null) {
|
|
|
throw BusinessRuntimeException.getInstance("车票已过期");
|
|
throw BusinessRuntimeException.getInstance("车票已过期");
|
|
|
}
|
|
}
|
|
|
|
|
+ addRelationExpiryDays(relation, renewTimeUpReq.getDays(), renewTimeUpReq.getRemark(), adminId, false);
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult("增加车票有效期成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按商品补偿车票天数
|
|
|
|
|
+ */
|
|
|
|
|
+ @PutMapping("/ticket/compensation/days")
|
|
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
|
|
+ @SaCheckPermission("validAccount:addTime")
|
|
|
|
|
+ @Log(module = "有效子账号管理/补偿车票天数", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
|
|
+ public Result<String> compensateTicketDays(@RequestBody @Validated TicketCompensationDaysReq req) {
|
|
|
|
|
+ if (req.getDays() == null || req.getDays() <= 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("补偿天数必须大于0");
|
|
|
|
|
+ }
|
|
|
|
|
+ long adminId = StpUtil.getLoginIdAsLong();
|
|
|
|
|
+ List<GroupsRelation> relations = groupsRelationMapper.selectCompensateRelations(
|
|
|
|
|
+ req.getGoodsId(), req.getSkuId(), req.getIsMirror(), req.getUserId());
|
|
|
|
|
+ if (CollUtil.isEmpty(relations)) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("未找到可补偿的有效车票");
|
|
|
|
|
+ }
|
|
|
|
|
+ String remark = StrUtil.trim(req.getRemark());
|
|
|
|
|
+ Map<Long, GroupsRelation> relationByUser = new LinkedHashMap<>();
|
|
|
|
|
+ for (GroupsRelation relation : relations) {
|
|
|
|
|
+ relationByUser.putIfAbsent(relation.getUserId(), relation);
|
|
|
|
|
+ }
|
|
|
|
|
+ int compensatedUsers = 0;
|
|
|
|
|
+ int skippedUsers = 0;
|
|
|
|
|
+ for (GroupsRelation relation : relationByUser.values()) {
|
|
|
|
|
+ Long userId = relation.getUserId();
|
|
|
|
|
+ Long recordId = incrExpiryTimeRecordMapper.selectIdByUserIdAndRemark(userId, remark);
|
|
|
|
|
+ if (recordId != null) {
|
|
|
|
|
+ skippedUsers++;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ addRelationExpiryDays(relation, req.getDays(), remark, adminId, true);
|
|
|
|
|
+ compensatedUsers++;
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(String.format(
|
|
|
|
|
+ "补偿车票有效期完成,成功补偿%s个用户,跳过%s个已补偿用户", compensatedUsers, skippedUsers));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void addRelationExpiryDays(GroupsRelation relation, Integer days, String remark, long adminId, boolean compensation) {
|
|
|
IncrExpiryTimeRecord incrExpiryTimeRecord = new IncrExpiryTimeRecord();
|
|
IncrExpiryTimeRecord incrExpiryTimeRecord = new IncrExpiryTimeRecord();
|
|
|
incrExpiryTimeRecord.setExpiryTimeInitial(relation.getExpiryTime());
|
|
incrExpiryTimeRecord.setExpiryTimeInitial(relation.getExpiryTime());
|
|
|
- incrExpiryTimeRecord.setIncrExpiryDays(renewTimeUpReq.getDays());
|
|
|
|
|
- incrExpiryTimeRecord.setRemark(renewTimeUpReq.getRemark());
|
|
|
|
|
- relation.setExpiryTime(DateUtil.offsetDay(relation.getExpiryTime(), renewTimeUpReq.getDays()));
|
|
|
|
|
|
|
+ incrExpiryTimeRecord.setIncrExpiryDays(days);
|
|
|
|
|
+ incrExpiryTimeRecord.setRemark(remark);
|
|
|
|
|
+ relation.setExpiryTime(DateUtil.offsetDay(relation.getExpiryTime(), days));
|
|
|
if (relation.getReservedDays() != null && relation.getReservedDays() > 0) {
|
|
if (relation.getReservedDays() != null && relation.getReservedDays() > 0) {
|
|
|
relation.setReservedDays(relation.getReservedDays() + incrExpiryTimeRecord.getIncrExpiryDays());
|
|
relation.setReservedDays(relation.getReservedDays() + incrExpiryTimeRecord.getIncrExpiryDays());
|
|
|
}
|
|
}
|
|
|
|
|
+ if (compensation) {
|
|
|
|
|
+ relation.setCompensationDays(Optional.ofNullable(relation.getCompensationDays()).orElse(0) + days);
|
|
|
|
|
+ }
|
|
|
groupsRelationMapper.updateById(relation);
|
|
groupsRelationMapper.updateById(relation);
|
|
|
|
|
|
|
|
//扣除镜像过期时间
|
|
//扣除镜像过期时间
|
|
@@ -241,14 +288,14 @@ public class StatisticsDataController {
|
|
|
.eq(ChatgptUser::getRelationId, relation.getId())
|
|
.eq(ChatgptUser::getRelationId, relation.getId())
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
|
if (chatgptUser != null) {
|
|
if (chatgptUser != null) {
|
|
|
- chatgptUser.setExpireTime(DateUtil.offsetDay(chatgptUser.getExpireTime(), renewTimeUpReq.getDays()));
|
|
|
|
|
|
|
+ chatgptUser.setExpireTime(DateUtil.offsetDay(chatgptUser.getExpireTime(), days));
|
|
|
chatgptUserMapper.updateById(chatgptUser);
|
|
chatgptUserMapper.updateById(chatgptUser);
|
|
|
} else {
|
|
} else {
|
|
|
MidjourneyUser midjourneyUser = midjourneyUserMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUser.class)
|
|
MidjourneyUser midjourneyUser = midjourneyUserMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUser.class)
|
|
|
.eq(MidjourneyUser::getRelationId, relation.getId())
|
|
.eq(MidjourneyUser::getRelationId, relation.getId())
|
|
|
.last("limit 1"));
|
|
.last("limit 1"));
|
|
|
if (midjourneyUser != null) {
|
|
if (midjourneyUser != null) {
|
|
|
- midjourneyUser.setExpireTime(DateUtil.offsetDay(midjourneyUser.getExpireTime(), renewTimeUpReq.getDays()));
|
|
|
|
|
|
|
+ midjourneyUser.setExpireTime(DateUtil.offsetDay(midjourneyUser.getExpireTime(), days));
|
|
|
midjourneyUserMapper.updateById(midjourneyUser);
|
|
midjourneyUserMapper.updateById(midjourneyUser);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -267,19 +314,18 @@ public class StatisticsDataController {
|
|
|
GroupsTrips groupsTrips = groupsMapper.selectById(groupsId);
|
|
GroupsTrips groupsTrips = groupsMapper.selectById(groupsId);
|
|
|
Long skuId = groupsTrips.getSkuId();
|
|
Long skuId = groupsTrips.getSkuId();
|
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
|
|
|
- if (sku.getGoodsId() == Constant.CODEX_GOODS_ID) {
|
|
|
|
|
|
|
+ if (Objects.equals(sku.getGoodsId(), Constant.CODEX_GOODS_ID)) {
|
|
|
CodexUser codexUser = codexUserMapper.selectOne(Wrappers.lambdaQuery(CodexUser.class).eq(CodexUser::getRelationId, relation.getId()).last("limit 1"));
|
|
CodexUser codexUser = codexUserMapper.selectOne(Wrappers.lambdaQuery(CodexUser.class).eq(CodexUser::getRelationId, relation.getId()).last("limit 1"));
|
|
|
if (codexUser != null) {
|
|
if (codexUser != null) {
|
|
|
codexService.updateCodexUserPackageInfo(codexUser, relation.getExpiryTime(), null);
|
|
codexService.updateCodexUserPackageInfo(codexUser, relation.getExpiryTime(), null);
|
|
|
}
|
|
}
|
|
|
- } else if (sku.getGoodsId() == Constant.CLAUDE_CODE_GOODS_ID) {
|
|
|
|
|
|
|
+ } else if (Objects.equals(sku.getGoodsId(), Constant.CLAUDE_CODE_GOODS_ID)) {
|
|
|
ClaudeCodeUser claudeCodeUser = claudeCodeUserMapper.selectOne(Wrappers.lambdaQuery(ClaudeCodeUser.class).eq(ClaudeCodeUser::getRelationId, relation.getId()).last("limit 1"));
|
|
ClaudeCodeUser claudeCodeUser = claudeCodeUserMapper.selectOne(Wrappers.lambdaQuery(ClaudeCodeUser.class).eq(ClaudeCodeUser::getRelationId, relation.getId()).last("limit 1"));
|
|
|
if (claudeCodeUser != null) {
|
|
if (claudeCodeUser != null) {
|
|
|
claudeCodeService.updateClaudeCodeUserPackageInfo(claudeCodeUser, relation.getExpiryTime(), null);
|
|
claudeCodeService.updateClaudeCodeUserPackageInfo(claudeCodeUser, relation.getExpiryTime(), null);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult("增加车票有效期成功");
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|