bigint conversion fixes
All checks were successful
Deploy to VPS / deploy (push) Successful in 1m16s

This commit is contained in:
Tihon
2026-03-12 14:21:37 +02:00
parent fb92993e39
commit 2958e645ad
4 changed files with 22 additions and 9 deletions

View File

@@ -43,8 +43,8 @@ public class OpenApiExamplesCustomizer implements GlobalOpenApiCustomizer {
value.put("screenName", "The Boy");
value.put("dateReg", 1772897273);
value.put("ip", "165.165.165.165");
value.put("balanceA", 100000);
value.put("balanceB", 100000);
value.put("balanceA", 10000);
value.put("balanceB", 10000);
value.put("avatarUrl", "/avatars/0/0/1/06c98267.png?v=1772897273");
value.put("languageCode", "EN");
value.put("paymentEnabled", true);

View File

@@ -24,6 +24,9 @@ import org.springframework.web.bind.annotation.*;
@RequiredArgsConstructor
public class UserController {
/** Divisor for converting balance bigint to display value (backend sends display value only). */
private static final double BALANCE_DISPLAY_DIVISOR = 1_000_000.0;
private final UserService userService;
private final UserBRepository userBRepository;
private final AvatarService avatarService;
@@ -37,10 +40,12 @@ public class UserController {
// Convert IP from byte[] to string for display
String ipAddress = IpUtils.bytesToIp(user.getIp());
// Get balances from UserB
// Get balances from UserB; convert to display value (divide by 1_000_000)
var userBOpt = userBRepository.findById(user.getId());
Long balanceA = userBOpt.map(UserB::getBalanceA).orElse(0L);
Long balanceB = userBOpt.map(UserB::getBalanceB).orElse(0L);
long rawBalanceA = userBOpt.map(UserB::getBalanceA).orElse(0L);
long rawBalanceB = userBOpt.map(UserB::getBalanceB).orElse(0L);
Double balanceA = rawBalanceA / BALANCE_DISPLAY_DIVISOR;
Double balanceB = rawBalanceB / BALANCE_DISPLAY_DIVISOR;
Integer depositCount = userBOpt.map(UserB::getDepositCount).orElse(0);
// Generate avatar URL on-the-fly (deterministic from userId)

View File

@@ -10,8 +10,16 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
public class ReferralDto {
private String name; // screen_name from db_users_a
private Long commission; // to_referer_1/2/3 from db_users_d (bigint, needs to be divided by 1,000,000 on frontend)
private String name; // screen_name from db_users_d
private Double commission; // display value (raw bigint / 1_000_000), sent ready for display
/** Constructor for JPQL: converts raw commission bigint to display value. */
public ReferralDto(String name, Long commissionRaw) {
this.name = name;
this.commission = commissionRaw != null ? commissionRaw / COMMISSION_DISPLAY_DIVISOR : 0.0;
}
private static final double COMMISSION_DISPLAY_DIVISOR = 1_000_000.0;
}

View File

@@ -16,8 +16,8 @@ public class UserDto {
private String screenName; // User's screen name
private Integer dateReg; // Registration date (Unix timestamp in seconds)
private String ip;
private Long balanceA; // Balance (stored as bigint, represents number with 6 decimal places)
private Long balanceB; // Second balance (stored as bigint)
private Double balanceA; // Balance for display (raw bigint / 1_000_000)
private Double balanceB; // Second balance for display (raw bigint / 1_000_000)
private String avatarUrl; // Public URL of user's avatar
private String languageCode; // User's language preference (EN, RU, DE, IT, NL, PL, FR, ES, ID, TR)
private Boolean paymentEnabled; // Runtime toggle: deposits (Store, Payment Options, etc.) allowed