Created
October 13, 2022 14:08
-
-
Save bl1zzz7k/1857d57166a74b4bea62bfe769f04a50 to your computer and use it in GitHub Desktop.
account released bonuses iisue
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, | |
released_bonus numeric(38, 18) | |
) | |
declare @InvalidAccount table | |
( | |
party_id int, | |
manual_bonus_platform_provider_id int, | |
bonus_plan_id int, | |
released_bonus numeric(38, 18), | |
released_bonus_fix numeric(38, 18) | |
) | |
insert into @AccountTable | |
select acc.partyid, acc.released_bonus | |
from admin_all.account as acc | |
where acc.released_bonus > 0 | |
and (((acc.released_bonus * 100) - convert(bigint, (acc.released_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.released_bonus, | |
released_bonus_fix = (select (1 - (a.released_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.released_bonus * power(convert(bigint, 10), c.precision)) - | |
convert(bigint, (a.released_bonus * power(convert(bigint, 10), c.precision)))) <> 0 | |
declare @PartyId int | |
declare @PlatformID int | |
declare @BonusPlanId int | |
declare @ReleasedBonus 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.released_bonus_fix | |
from @InvalidAccount acc | |
OPEN @Cursor | |
FETCH NEXT FROM @Cursor | |
INTO @PartyId, @PlatformID, @BonusPlanId, @ReleasedBonus | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
begin | |
declare @PlayableBonus 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 | |
declare @BaseReleaseBonusResult 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, 0, @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 | |
exec @BaseReleaseBonusResult = admin_all.usp_BaseReleaseBonus | |
@BonusID = @BonusID, | |
@PlatformID = @PlatformID, | |
@AccountTranID = @AccountTranID | |
select @UpdateAccountResult | |
end | |
FETCH NEXT FROM @Cursor | |
INTO @PartyId, @PlatformID, @BonusPlanId, @ReleasedBonus | |
END; | |
CLOSE @Cursor; | |
DEALLOCATE @Cursor; | |
END; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment