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

Commit 75c196d8 authored by 姜秀龙's avatar 姜秀龙

自动审批验证功能未实现

parent 71b0d06e
...@@ -29,6 +29,7 @@ import com.liquidnet.service.adam.mapper.AdamUserMemberMapper; ...@@ -29,6 +29,7 @@ import com.liquidnet.service.adam.mapper.AdamUserMemberMapper;
import com.liquidnet.service.adam.util.ObjectUtil; import com.liquidnet.service.adam.util.ObjectUtil;
import com.liquidnet.service.base.ErrorMapping; import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.constant.RedisKeyExpireConst; import com.liquidnet.service.base.constant.RedisKeyExpireConst;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -36,6 +37,7 @@ import org.springframework.util.CollectionUtils; ...@@ -36,6 +37,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalAdjusters;
...@@ -805,35 +807,83 @@ public class AdamRdmService { ...@@ -805,35 +807,83 @@ public class AdamRdmService {
* 读取不到时返回 null。 * 读取不到时返回 null。
*/ */
public String getPerformanceTitleById(String performanceId) { public String getPerformanceTitleById(String performanceId) {
if (StringUtils.isEmpty(performanceId)) {
return null;
}
try { try {
if (redisDataSourceUtil == null || redisDataSourceUtil.getRedisKylinUtil() == null) { KylinPerformanceVo vo = getKylinPerformanceVoById(performanceId);
if (vo != null) {
return vo.getTitle();
}
return null;
} catch (Exception e) {
log.warn("[getPerformanceTitleById] 读取演出缓存失败, performanceId: {}", performanceId, e);
return null; return null;
} }
Object cached = redisDataSourceUtil.getRedisKylinUtil().get(KylinRedisConst.PERFORMANCES + performanceId);
if (cached instanceof KylinPerformanceVo) {
return ((KylinPerformanceVo) cached).getTitle();
} }
// 兼容:部分环境序列化配置不同,可能反序列化成 Map(如 LinkedHashMap)
if (cached instanceof Map) { /**
Object title = ((Map<?, ?>) cached).get("title"); * 从演出缓存读取开演/结束时间(yyyyMMddHHmmss),用于草莓徽章补签自动审核。
return title == null ? null : String.valueOf(title); * 读取不到时返回 null。
*/
public PerformanceTimeRange getPerformanceTimeRangeById(String performanceId) {
try {
KylinPerformanceVo vo = getKylinPerformanceVoById(performanceId);
if (vo == null) {
return null;
} }
String start = vo.getTimeStart();
String end = vo.getTimeEnd();
LocalDateTime st = parseKylinTime(start);
LocalDateTime et = parseKylinTime(end);
if (st == null || et == null) {
return null; return null;
}
return new PerformanceTimeRange(st, et);
} catch (Exception e) { } catch (Exception e) {
log.warn("[getPerformanceTitleById] 读取演出缓存失败, performanceId: {}", performanceId, e); log.warn("[getPerformanceTimeRangeById] 读取演出时间失败, performanceId: {}", performanceId, e);
return null; return null;
} }
} }
/** /**
* 删除用户徽章redis * 统一从 kylin redis 缓存读取演出 VO。
* @param uid * 缓存若因序列化差异读成 Map,则尽量转换成 {@link KylinPerformanceVo} 后返回。
*/ */
public void delUserCaomeiBadgesByUid(String uid) { public KylinPerformanceVo getKylinPerformanceVoById(String performanceId) {
redisUtil.del(AdamRedisConst.INFO_CAOMEI_BADGE_USER.concat(uid)); return (KylinPerformanceVo) redisDataSourceUtil.getRedisKylinUtil().get(KylinRedisConst.PERFORMANCES + performanceId);
}
private static final DateTimeFormatter KYLIN_TIME_COMPACT = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
private static final DateTimeFormatter KYLIN_TIME_DASH = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static LocalDateTime parseKylinTime(String v) {
if (StringUtils.isEmpty(v)) {
return null;
}
String t = v.trim();
// 优先 kylin 常见格式:yyyyMMddHHmmss
try {
if (t.length() >= 14) {
return LocalDateTime.parse(t.substring(0, 14), KYLIN_TIME_COMPACT);
}
} catch (Exception ignored) { }
// 兼容:yyyy-MM-dd HH:mm:ss
try {
if (t.length() >= 19) {
return LocalDateTime.parse(t.substring(0, 19), KYLIN_TIME_DASH);
}
} catch (Exception ignored) { }
return null;
}
@Getter
public static final class PerformanceTimeRange {
private final LocalDateTime start;
private final LocalDateTime end;
public PerformanceTimeRange(LocalDateTime start, LocalDateTime end) {
this.start = start;
this.end = end;
}
} }
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | List<购买会员黑名单UID> */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | List<购买会员黑名单UID> */
......
...@@ -227,17 +227,45 @@ public class AdamCaomeiBadgeUserServiceImpl implements IAdamCaomeiBadgeUserServi ...@@ -227,17 +227,45 @@ public class AdamCaomeiBadgeUserServiceImpl implements IAdamCaomeiBadgeUserServi
final String applyRecordId = IDGenerator.nextSnowId(); final String applyRecordId = IDGenerator.nextSnowId();
long t = System.currentTimeMillis(); long t = System.currentTimeMillis();
String performanceId = StringUtils.trimToEmpty(badge.getPerformanceId());
boolean autoPass = isPerformanceOngoing(performanceId);
if (autoPass) {
// 与 admin 审核通过保持一致:仅将申请记录标记为已通过,不自动发放徽章
queueUtils.sendMsgByRedis(
MQConst.AdamQueue.SQL_UCENTER.getKey(),
SqlMapping.get("adam_caomei_badge_apply_record.add_passed",
applyRecordId,
uid,
badgeId,
performanceId,
proofImageUrl)
);
} else {
queueUtils.sendMsgByRedis( queueUtils.sendMsgByRedis(
MQConst.AdamQueue.SQL_UCENTER.getKey(), MQConst.AdamQueue.SQL_UCENTER.getKey(),
SqlMapping.get("adam_caomei_badge_apply_record.add", SqlMapping.get("adam_caomei_badge_apply_record.add",
applyRecordId, applyRecordId,
uid, uid,
badgeId, badgeId,
badge.getPerformanceId(), performanceId,
proofImageUrl) proofImageUrl)
); );
}
log.info("[claimBadge] MQ耗时:{}ms, uid: {}, badgeId: {}", System.currentTimeMillis() - t, uid, badge.getBadgeId()); log.info("[claimBadge] MQ耗时:{}ms, uid: {}, badgeId: {}", System.currentTimeMillis() - t, uid, badge.getBadgeId());
return ResponseDto.success(applyRecordId); return ResponseDto.success(applyRecordId);
} }
private boolean isPerformanceOngoing(String performanceId) {
if (StringUtils.isBlank(performanceId)) {
return false;
}
AdamRdmService.PerformanceTimeRange r = adamRdmService.getPerformanceTimeRangeById(performanceId);
if (r == null || r.getStart() == null || r.getEnd() == null) {
return false;
}
java.time.LocalDateTime now = java.time.LocalDateTime.now();
return (now.isEqual(r.getStart()) || now.isAfter(r.getStart()))
&& (now.isEqual(r.getEnd()) || now.isBefore(r.getEnd()));
}
} }
...@@ -88,6 +88,9 @@ adam_caomei_user_badge.add=INSERT INTO adam_caomei_user_badge (user_id, badge_id ...@@ -88,6 +88,9 @@ adam_caomei_user_badge.add=INSERT INTO adam_caomei_user_badge (user_id, badge_id
# \u7528\u6237\u7AEF applyBadge\uFF1A\u4E0E\u300C\u5148\u5199 Redis \u8865\u7B7E\u5217\u8868\u3001\u518D MQ \u5F02\u6B65\u843D\u5E93\u300D\u914D\u5957\uFF1B\u53C2\u6570\u987A\u5E8F apply_record_id, user_id, badge_id, performance_id, proof_image_url\uFF1Baudit_status=0\u3001reject_reason \u7A7A\u4E32\u3001\u65F6\u95F4\u7531 now() \u5199\u5165 # \u7528\u6237\u7AEF applyBadge\uFF1A\u4E0E\u300C\u5148\u5199 Redis \u8865\u7B7E\u5217\u8868\u3001\u518D MQ \u5F02\u6B65\u843D\u5E93\u300D\u914D\u5957\uFF1B\u53C2\u6570\u987A\u5E8F apply_record_id, user_id, badge_id, performance_id, proof_image_url\uFF1Baudit_status=0\u3001reject_reason \u7A7A\u4E32\u3001\u65F6\u95F4\u7531 now() \u5199\u5165
adam_caomei_badge_apply_record.add=INSERT INTO adam_caomei_badge_apply_record (apply_record_id, user_id, badge_id, performance_id, proof_image_url, audit_status, reject_reason, created_at, updated_at) VALUES (?,?,?,?,?,0,'',now(),now()) adam_caomei_badge_apply_record.add=INSERT INTO adam_caomei_badge_apply_record (apply_record_id, user_id, badge_id, performance_id, proof_image_url, audit_status, reject_reason, created_at, updated_at) VALUES (?,?,?,?,?,0,'',now(),now())
# 补签自动通过:直接写入 audit_status=1
adam_caomei_badge_apply_record.add_passed=INSERT INTO adam_caomei_badge_apply_record (apply_record_id, user_id, badge_id, performance_id, proof_image_url, audit_status, reject_reason, created_at, updated_at) VALUES (?,?,?,?,?,1,'',now(),now())
# ---------------------------------------------------- # ----------------------------------------------------
candy_user_coupon.close=UPDATE candy_user_coupon SET state=2,updated_at=sysdate(),operator='close' WHERE uid=? AND state=1 candy_user_coupon.close=UPDATE candy_user_coupon SET state=2,updated_at=sysdate(),operator='close' WHERE uid=? AND state=1
goblin_user_coupon.close=UPDATE goblin_user_coupon SET state=2,updated_at=sysdate(),operator='close' WHERE uid=? AND state=1 goblin_user_coupon.close=UPDATE goblin_user_coupon SET state=2,updated_at=sysdate(),operator='close' WHERE uid=? AND state=1
......
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