记得上下班打卡 | git大法好,push需谨慎

Commit bbc10c17 authored by 姜秀龙's avatar 姜秀龙

Merge branch 'refs/heads/dev-caomeihuizhang' into container-test

parents 732dfa7d 6230abef
package com.liquidnet.service.adam.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.adam.dto.AdamCaomeiPassportUserBadgeDto;
......@@ -30,6 +31,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Slf4j
......@@ -111,13 +113,19 @@ public class AdamCaomeiBadgeUserServiceImpl implements IAdamCaomeiBadgeUserServi
String idCard = real.getIdCard();
List<String> paidPerformanceIds = adamRdmService.getPaidPerformanceIdsByIdCard(idCard);
boolean hasPaidRecord = paidPerformanceIds != null && paidPerformanceIds.contains(badge.getPerformanceId());
Integer passedApplyCount = badgeApplyRecordMapper.selectCount(
Wrappers.lambdaQuery(AdamCaomeiBadgeApplyRecord.class)
.eq(AdamCaomeiBadgeApplyRecord::getUserId, uid)
.eq(AdamCaomeiBadgeApplyRecord::getBadgeId, badgeId)
.eq(AdamCaomeiBadgeApplyRecord::getAuditStatus, 1)
);
boolean hasPassedApply = passedApplyCount != null && passedApplyCount > 0;
String perfId = StringUtils.trimToEmpty(badge.getPerformanceId());
boolean hasPassedApply;
if (StringUtils.isNotBlank(perfId)) {
hasPassedApply = countApplyForUserPerformanceAudit(uid, perfId, 1) > 0;
} else {
Integer passedApplyCount = badgeApplyRecordMapper.selectCount(
Wrappers.lambdaQuery(AdamCaomeiBadgeApplyRecord.class)
.eq(AdamCaomeiBadgeApplyRecord::getUserId, uid)
.eq(AdamCaomeiBadgeApplyRecord::getBadgeId, badgeId)
.eq(AdamCaomeiBadgeApplyRecord::getAuditStatus, 1)
);
hasPassedApply = passedApplyCount != null && passedApplyCount > 0;
}
if (!hasPaidRecord && !hasPassedApply) {
log.error("[claimBadge] 无购票记录且无通过的补签申请,无法认领, uid: {}, badgeId: {}", uid, badgeId);
......@@ -215,19 +223,25 @@ public class AdamCaomeiBadgeUserServiceImpl implements IAdamCaomeiBadgeUserServi
return ResponseDto.failure(ErrorMapping.get("10608"));
}
Integer pendingCount = badgeApplyRecordMapper.selectCount(
Wrappers.lambdaQuery(AdamCaomeiBadgeApplyRecord.class)
.eq(AdamCaomeiBadgeApplyRecord::getUserId, uid)
.eq(AdamCaomeiBadgeApplyRecord::getBadgeId, badgeId)
.eq(AdamCaomeiBadgeApplyRecord::getAuditStatus, 0)
);
if (pendingCount != null && pendingCount > 0) {
return ResponseDto.failure("您已有待审核的补签申请,请勿重复提交");
String performanceId = StringUtils.trimToEmpty(badge.getPerformanceId());
int pendingApply;
if (StringUtils.isNotBlank(performanceId)) {
pendingApply = countApplyForUserPerformanceAudit(uid, performanceId, 0);
} else {
Integer pendingCount = badgeApplyRecordMapper.selectCount(
Wrappers.lambdaQuery(AdamCaomeiBadgeApplyRecord.class)
.eq(AdamCaomeiBadgeApplyRecord::getUserId, uid)
.eq(AdamCaomeiBadgeApplyRecord::getBadgeId, badgeId)
.eq(AdamCaomeiBadgeApplyRecord::getAuditStatus, 0)
);
pendingApply = pendingCount == null ? 0 : pendingCount;
}
if (pendingApply > 0) {
return ResponseDto.failure("该场次已有待审核的补签申请,请勿重复提交");
}
final String applyRecordId = IDGenerator.nextSnowId();
long t = System.currentTimeMillis();
String performanceId = StringUtils.trimToEmpty(badge.getPerformanceId());
boolean autoPass = isPerformanceOngoing(performanceId);
if (autoPass) {
// 与 admin 审核通过保持一致:仅将申请记录标记为已通过,不自动发放徽章
......@@ -256,6 +270,49 @@ public class AdamCaomeiBadgeUserServiceImpl implements IAdamCaomeiBadgeUserServi
return ResponseDto.success(applyRecordId);
}
/**
* 同场次 type=2 徽章 ID(用于补签记录 performance_id 为空等历史数据的 OR 查询)。
*/
private Set<String> type2BadgeIdsForPerformance(String performanceId) {
if (StringUtils.isBlank(performanceId)) {
return Collections.emptySet();
}
List<AdamCaomeiBadge> list = adamCaomeiBadgeMapper.selectList(
Wrappers.lambdaQuery(AdamCaomeiBadge.class)
.eq(AdamCaomeiBadge::getType, 2)
.eq(AdamCaomeiBadge::getPerformanceId, performanceId));
if (list == null || list.isEmpty()) {
return Collections.emptySet();
}
return list.stream()
.map(AdamCaomeiBadge::getBadgeId)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
}
/**
* 用户对某场次是否存在指定审核状态的补签记录(按 performance_id 或同场徽章 ID 命中)。
*/
private int countApplyForUserPerformanceAudit(String uid, String performanceId, int auditStatus) {
if (StringUtils.isBlank(performanceId)) {
return 0;
}
Set<String> samePerfBadgeIds = type2BadgeIdsForPerformance(performanceId);
LambdaQueryWrapper<AdamCaomeiBadgeApplyRecord> qw =
Wrappers.lambdaQuery(AdamCaomeiBadgeApplyRecord.class)
.eq(AdamCaomeiBadgeApplyRecord::getUserId, uid)
.eq(AdamCaomeiBadgeApplyRecord::getAuditStatus, auditStatus);
if (samePerfBadgeIds.isEmpty()) {
qw.eq(AdamCaomeiBadgeApplyRecord::getPerformanceId, performanceId);
} else {
qw.and(w -> w.eq(AdamCaomeiBadgeApplyRecord::getPerformanceId, performanceId)
.or()
.in(AdamCaomeiBadgeApplyRecord::getBadgeId, samePerfBadgeIds));
}
Integer n = badgeApplyRecordMapper.selectCount(qw);
return n == null ? 0 : n;
}
private boolean isPerformanceOngoing(String performanceId) {
if (StringUtils.isBlank(performanceId)) {
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment