From bb40f347a3638e5b64be4b3f2237b1a77245840e Mon Sep 17 00:00:00 2001 From: Timi Date: Tue, 18 Aug 2026 16:46:30 +0800 Subject: [PATCH] support consume point --- .../api/modules/gao/entity/GaoPointLedger.java | 2 +- .../implement/GaoPointLedgerServiceImplement.java | 4 ++-- .../implement/GaoPointRuleServiceImplement.java | 9 +++++---- .../implement/GaoPointTriggerServiceImplement.java | 12 ++++++------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointLedger.java b/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointLedger.java index 1e63444..00ab9ab 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointLedger.java +++ b/src/main/java/com/imyeyu/api/modules/gao/entity/GaoPointLedger.java @@ -17,7 +17,7 @@ public class GaoPointLedger extends UUIDEntity { /// 流水变化类型 public enum ChangeType { - /// 登记事件获得积分 + /// 登记事件积分变化 EARN, /// 删除登记记录撤销积分 diff --git a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointLedgerServiceImplement.java b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointLedgerServiceImplement.java index 0823059..e5f2098 100644 --- a/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointLedgerServiceImplement.java +++ b/src/main/java/com/imyeyu/api/modules/gao/service/implement/GaoPointLedgerServiceImplement.java @@ -74,7 +74,7 @@ public class GaoPointLedgerServiceImplement extends AbstractEntityService ruleList = ruleService.listActive(record.getStoreId(), record.getEventId(), Time.now()); Long count = null; - long earnedPointValue = 0L; + long pointDeltaTotal = 0L; for (GaoPointRule rule : ruleList) { RuleResolution resolution = resolveRule(record, rule, count); if (resolution == null) { @@ -72,16 +72,16 @@ public class GaoPointTriggerServiceImplement implements GaoPointTriggerService { count = count == null ? count(record) : count; } long pointDelta = resolution.pointDelta(); - if (0 < pointDelta) { + if (pointDelta != 0) { ledgerService.earn(record, rule, pointDelta, resolution.sourcePayload()); - earnedPointValue = Math.addExact(earnedPointValue, pointDelta); + pointDeltaTotal = Math.addExact(pointDeltaTotal, pointDelta); } if (Boolean.TRUE.equals(rule.getExclusive())) { break; } } - record.setEarnedPointValue(earnedPointValue); - eventRecordMapper.updateEarnedPointValue(record.getId(), earnedPointValue); + record.setEarnedPointValue(pointDeltaTotal); + eventRecordMapper.updateEarnedPointValue(record.getId(), pointDeltaTotal); } @Transactional(TimiServerDBConfig.ROLLBACKER) @@ -140,7 +140,7 @@ public class GaoPointTriggerServiceImplement implements GaoPointTriggerService { } permissionChecker.checkAny(ModuleCode.GAO, GaoPermissionCode.POINT_SOURCE_VALUE.getValue()); long pointValue = record.getPointValue(); - TimiException.requiredTrue(0 < pointValue, "pointValue invalid"); + TimiException.requiredTrue(pointValue != 0, "pointValue invalid"); JsonNode condition = rule.getConditionJson(); if (condition != null) { JsonNode min = condition.get("min");