|
|
@@ -74,6 +74,17 @@ public class PlatformPointsService {
|
|
|
if (amount <= 0) {
|
|
|
throw new IllegalArgumentException("CF值数量必须为正数");
|
|
|
}
|
|
|
+ // 幂等:按 (userId, ref_type, ref_id) 去重
|
|
|
+ if (refId != null) {
|
|
|
+ Long existing = logMapper.selectCount(
|
|
|
+ new LambdaQueryWrapper<PlatformBalanceLog>()
|
|
|
+ .eq(PlatformBalanceLog::getUserId, userId)
|
|
|
+ .eq(PlatformBalanceLog::getRefType, refType)
|
|
|
+ .eq(PlatformBalanceLog::getRefId, refId));
|
|
|
+ if (existing != null && existing > 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
UserPlatformBalance b = getOrCreate(userId);
|
|
|
b.setTotalEarned(safeInt(b.getTotalEarned()) + amount);
|
|
|
b.setAvailable(safeInt(b.getAvailable()) + amount);
|