mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
0779aa8439
- Implemented ProgressionEventsController to handle progression event retrieval and active events. - Created RoomConsumablesController for listing and purchasing room consumables. - Developed RoomCurrenciesController for managing room currencies, including creation, updates, and balance retrieval. - Added RoomEarningsDistributionsController to fetch earnings distribution data for rooms. - Introduced ScreenShareReportsController for reporting screen share incidents. - Established SubscriptionSeasonsController to provide current subscription season details and rewards. - Launched UgcPurchasablesController for managing user-generated content purchasables, including bulk operations. - Added new data entities for customization and room economy, including custom avatar items, room currencies, and UGC purchasables.
58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using DorkNet.Server.Auth;
|
|
using DorkNet.Server.Data;
|
|
using DorkNet.Server.Data.Entities;
|
|
using DorkNet.Server.Services;
|
|
|
|
namespace DorkNet.Server.Controllers.API.IncentivizedReferrals;
|
|
|
|
[ApiController]
|
|
[Authorize]
|
|
[Route("api/incentivizedreferrals")]
|
|
public class IncentivizedReferralsController(DorkNetDbContext db, LevelService level) : ControllerBase
|
|
{
|
|
private long Me => this.RequireCurrentPlayerId();
|
|
|
|
[HttpGet("")]
|
|
[HttpGet("progress")]
|
|
public async Task<IActionResult> Progress()
|
|
{
|
|
var referralCount = await db.PlayerSettings
|
|
.CountAsync(s => s.Key.StartsWith($"referral:credited:{Me}:"));
|
|
var claimed = await db.PlayerSettings
|
|
.AnyAsync(s => s.PlayerId == Me && s.Key == "referral:reward_claimed");
|
|
return Ok(new
|
|
{
|
|
ReferralCount = referralCount,
|
|
RequiredReferralCount = 1,
|
|
CanClaim = referralCount >= 1 && !claimed,
|
|
Claimed = claimed,
|
|
RewardCurrencyType = 2,
|
|
RewardCurrency = 250,
|
|
});
|
|
}
|
|
|
|
[HttpPost("claim")]
|
|
public async Task<IActionResult> Claim()
|
|
{
|
|
var referralCount = await db.PlayerSettings
|
|
.CountAsync(s => s.Key.StartsWith($"referral:credited:{Me}:"));
|
|
if (referralCount < 1)
|
|
return Ok(new { Success = false, Error = "not_enough_referrals" });
|
|
if (await db.PlayerSettings.AnyAsync(s => s.PlayerId == Me && s.Key == "referral:reward_claimed"))
|
|
return Ok(new { Success = false, Error = "already_claimed" });
|
|
|
|
var balance = await level.GrantCurrencyAsync(Me, 2, 250, "incentivized_referral");
|
|
db.PlayerSettings.Add(new PlayerSettingEntity
|
|
{
|
|
PlayerId = Me,
|
|
Key = "referral:reward_claimed",
|
|
Value = DateTime.UtcNow.ToString("O"),
|
|
});
|
|
await db.SaveChangesAsync();
|
|
return Ok(new { Success = true, Balance = balance, CurrencyType = 2, Currency = 250 });
|
|
}
|
|
}
|