Created
October 13, 2022 14:10
-
-
Save bl1zzz7k/4dd99c819aa59802308fd2c8d23e81bd to your computer and use it in GitHub Desktop.
account playable bonus issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @AccountTable table | |
( | |
party_id int, | |
playable_bonus numeric(38, 18) | |
) | |
declare @InvalidAccount table | |
( | |
party_id int, | |
manual_bonus_platform_provider_id int, | |
bonus_plan_id int, | |
playable_bonus numeric(38, 18), | |
playable_bonus_fix numeric(38, 18) | |
) | |
insert into @AccountTable | |
select acc.partyid, acc.playable_bonus | |
from admin_all.account as acc | |
where acc.playable_bonus > 0 and (acc.playable_bonus * 100) - convert(bigint, (acc.playable_bonus * 100)) <> 0 | |
and PARTYID = 6627593 | |
insert into @InvalidAccount | |
select u.partyid, | |
manual_bonus_platform_provider_id = (select r.VALUE | |
from admin_all.registry_hash r | |
where r.map_key = 'manualBonusRelease.zeroWagerReq.defaultProvider'), | |
bonus_plan_id = (select bp.id | |
from admin_all.bonus_plan bp | |
where bp.plan_name = | |
concat(replace(b.brandname, ' ', ''), '_CASINO_ManualBonusPlan')), | |
a.playable_bonus, | |
playable_bonus_fix = (select (1 - (a.playable_bonus % 1)) % 1) | |
from @AccountTable a | |
inner join external_mpt.user_conf u on u.PARTYID = a.party_id | |
inner join admin_all.currency c on c.iso_code = u.currency | |
inner join admin.casino_brand_def b on b.brandid = u.brandid | |
where ((a.playable_bonus * power(convert(numeric, 10), c.precision)) - | |
convert(bigint, (a.playable_bonus * power(convert(bigint, 10), c.precision)))) <> 0 | |
declare @PartyId int | |
declare @PlatformID int | |
declare @BonusPlanId int | |
declare @PlayableBonus numeric(38, 18) | |
DECLARE @Cursor CURSOR; | |
BEGIN | |
SET @Cursor = CURSOR FOR | |
select acc.party_id, | |
acc.manual_bonus_platform_provider_id, | |
acc.bonus_plan_id, | |
acc.playable_bonus_fix | |
from @InvalidAccount acc | |
OPEN @Cursor | |
FETCH NEXT FROM @Cursor | |
INTO @PartyId, @PlatformID, @BonusPlanId, @PlayableBonus | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
begin | |
declare @ReleasedBonus numeric(38, 18) = 0 | |
declare @AmountReal numeric(38, 18) = 0 | |
declare @AmountSecondary numeric(38, 18) = 0 | |
declare @TranType varchar(10) = 'MAN_BONUS' | |
declare @Reference varchar(100) = 'account round fix' | |
declare @DateTime datetime2 = current_timestamp | |
declare @MachineID int = 0 | |
declare @BonusTable table | |
( | |
id int | |
) | |
declare @BonusID int | |
declare @AccountTranID bigint | |
declare @UpdateAccountResult int | |
insert into admin_all.BONUS(PARTYID, BONUS_PLAN_ID, TRIGGER_DATE, EXPIRY_DATE, STATUS, AMOUNT_WAGERED, | |
WAGER_REQUIREMENT, AMOUNT, PLAYABLE_BONUS, RELEASED_BONUS, COMMENT) | |
output inserted.id into @BonusTable | |
values (@PartyID, @BonusPlanId, @DateTime, @DateTime, 'QUEUED', 0, @PlayableBonus, @PlayableBonus, @PlayableBonus, | |
@ReleasedBonus, @Reference) | |
set @BonusID = (select b.id from @BonusTable as b) | |
exec @UpdateAccountResult = admin_all.usp_UpdateAccount | |
@PartyID = @PartyID, | |
@AmountReal = @AmountReal, | |
@ReleasedBonus = @ReleasedBonus, | |
@PlayableBonus = @PlayableBonus, | |
@AmountSecondary = @AmountSecondary, | |
@TranType = @TranType, | |
@PlatformID = @PlatformID, | |
@Reference = @Reference, | |
@DateTime = @DateTime, | |
@MachineID = @MachineID, | |
@AccountTranID = @AccountTranID output | |
select @UpdateAccountResult | |
end | |
FETCH NEXT FROM @Cursor | |
INTO @PartyId, @PlatformID, @BonusPlanId, @PlayableBonus | |
END; | |
CLOSE @Cursor; | |
DEALLOCATE @Cursor; | |
END; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment