🐛 Fix some issues in sepration of the Pass and Wallet service
This commit is contained in:
@@ -3,6 +3,7 @@ using DysonNetwork.Shared.Cache;
|
||||
using DysonNetwork.Shared.Models;
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using DysonNetwork.Shared.Queue;
|
||||
using DysonNetwork.Shared.Registry;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using NATS.Client.Core;
|
||||
@@ -17,6 +18,7 @@ public class AccountEventService(
|
||||
IStringLocalizer<Localization.AccountEventResource> localizer,
|
||||
RingService.RingServiceClient pusher,
|
||||
Pass.Leveling.ExperienceService experienceService,
|
||||
RemotePaymentService payment,
|
||||
INatsConnection nats
|
||||
)
|
||||
{
|
||||
@@ -70,21 +72,11 @@ public class AccountEventService(
|
||||
);
|
||||
}
|
||||
|
||||
private static bool StatusesEqual(SnAccountStatus a, SnAccountStatus b)
|
||||
{
|
||||
return a.Attitude == b.Attitude &&
|
||||
a.IsOnline == b.IsOnline &&
|
||||
a.IsCustomized == b.IsCustomized &&
|
||||
a.Label == b.Label &&
|
||||
a.IsInvisible == b.IsInvisible &&
|
||||
a.IsNotDisturb == b.IsNotDisturb;
|
||||
}
|
||||
|
||||
public async Task<SnAccountStatus> GetStatus(Guid userId)
|
||||
{
|
||||
var cacheKey = $"{StatusCacheKey}{userId}";
|
||||
var cachedStatus = await cache.GetAsync<SnAccountStatus>(cacheKey);
|
||||
SnAccountStatus status;
|
||||
SnAccountStatus? status;
|
||||
if (cachedStatus is not null)
|
||||
{
|
||||
cachedStatus!.IsOnline = !cachedStatus.IsInvisible && await GetAccountIsConnected(userId);
|
||||
@@ -360,7 +352,7 @@ public class AccountEventService(
|
||||
// Skip random logic and tips generation for birthday
|
||||
checkInLevel = CheckInResultLevel.Special;
|
||||
tips = [
|
||||
new CheckInFortuneTip()
|
||||
new CheckInFortuneTip
|
||||
{
|
||||
IsPositive = true,
|
||||
Title = localizer["FortuneTipSpecialTitle_Birthday"].Value,
|
||||
@@ -420,6 +412,22 @@ public class AccountEventService(
|
||||
CreatedAt = backdated ?? SystemClock.Instance.GetCurrentInstant(),
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
if (result.RewardPoints.HasValue)
|
||||
await payment.CreateTransactionWithAccount(
|
||||
null,
|
||||
user.Id.ToString(),
|
||||
WalletCurrency.SourcePoint,
|
||||
result.RewardPoints.Value.ToString(CultureInfo.InvariantCulture),
|
||||
$"Check-in reward on {now:yyyy/MM/dd}"
|
||||
);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result.RewardPoints = null;
|
||||
}
|
||||
|
||||
db.AccountCheckInResults.Add(result);
|
||||
await db.SaveChangesAsync(); // Remember to save changes to the database
|
||||
if (result.RewardExperience is not null)
|
||||
|
||||
2856
DysonNetwork.Pass/Migrations/20260203153052_PendingWalletRemoval.Designer.cs
generated
Normal file
2856
DysonNetwork.Pass/Migrations/20260203153052_PendingWalletRemoval.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,157 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DysonNetwork.Pass.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class PendingWalletRemoval : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_lotteries_accounts_account_id",
|
||||
table: "lotteries");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_wallet_fund_recipients_accounts_recipient_account_id",
|
||||
table: "wallet_fund_recipients");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_wallet_funds_accounts_creator_account_id",
|
||||
table: "wallet_funds");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_wallet_gifts_accounts_gifter_id",
|
||||
table: "wallet_gifts");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_wallet_gifts_accounts_recipient_id",
|
||||
table: "wallet_gifts");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_wallet_gifts_accounts_redeemer_id",
|
||||
table: "wallet_gifts");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_wallet_subscriptions_accounts_account_id",
|
||||
table: "wallet_subscriptions");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "fk_wallets_accounts_account_id",
|
||||
table: "wallets");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_wallets_account_id",
|
||||
table: "wallets");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_wallet_gifts_redeemer_id",
|
||||
table: "wallet_gifts");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_wallet_funds_creator_account_id",
|
||||
table: "wallet_funds");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_wallet_fund_recipients_recipient_account_id",
|
||||
table: "wallet_fund_recipients");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_lotteries_account_id",
|
||||
table: "lotteries");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_wallets_account_id",
|
||||
table: "wallets",
|
||||
column: "account_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_wallet_gifts_redeemer_id",
|
||||
table: "wallet_gifts",
|
||||
column: "redeemer_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_wallet_funds_creator_account_id",
|
||||
table: "wallet_funds",
|
||||
column: "creator_account_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_wallet_fund_recipients_recipient_account_id",
|
||||
table: "wallet_fund_recipients",
|
||||
column: "recipient_account_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_lotteries_account_id",
|
||||
table: "lotteries",
|
||||
column: "account_id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_lotteries_accounts_account_id",
|
||||
table: "lotteries",
|
||||
column: "account_id",
|
||||
principalTable: "accounts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_wallet_fund_recipients_accounts_recipient_account_id",
|
||||
table: "wallet_fund_recipients",
|
||||
column: "recipient_account_id",
|
||||
principalTable: "accounts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_wallet_funds_accounts_creator_account_id",
|
||||
table: "wallet_funds",
|
||||
column: "creator_account_id",
|
||||
principalTable: "accounts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_wallet_gifts_accounts_gifter_id",
|
||||
table: "wallet_gifts",
|
||||
column: "gifter_id",
|
||||
principalTable: "accounts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_wallet_gifts_accounts_recipient_id",
|
||||
table: "wallet_gifts",
|
||||
column: "recipient_id",
|
||||
principalTable: "accounts",
|
||||
principalColumn: "id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_wallet_gifts_accounts_redeemer_id",
|
||||
table: "wallet_gifts",
|
||||
column: "redeemer_id",
|
||||
principalTable: "accounts",
|
||||
principalColumn: "id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_wallet_subscriptions_accounts_account_id",
|
||||
table: "wallet_subscriptions",
|
||||
column: "account_id",
|
||||
principalTable: "accounts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "fk_wallets_accounts_account_id",
|
||||
table: "wallets",
|
||||
column: "account_id",
|
||||
principalTable: "accounts",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.11")
|
||||
.HasAnnotation("ProductVersion", "10.0.2")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
@@ -507,7 +507,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("account_id");
|
||||
|
||||
b.Property<List<string>>("BlockedPermissions")
|
||||
b.PrimitiveCollection<string>("BlockedPermissions")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("blocked_permissions");
|
||||
|
||||
@@ -865,12 +865,12 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("account_id");
|
||||
|
||||
b.Property<List<string>>("Audiences")
|
||||
b.PrimitiveCollection<string>("Audiences")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("audiences");
|
||||
|
||||
b.Property<List<Guid>>("BlacklistFactors")
|
||||
b.PrimitiveCollection<string>("BlacklistFactors")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("blacklist_factors");
|
||||
@@ -920,7 +920,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("platform");
|
||||
|
||||
b.Property<List<string>>("Scopes")
|
||||
b.PrimitiveCollection<string>("Scopes")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("scopes");
|
||||
@@ -1019,7 +1019,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("app_id");
|
||||
|
||||
b.Property<List<string>>("Audiences")
|
||||
b.PrimitiveCollection<string>("Audiences")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("audiences");
|
||||
@@ -1061,7 +1061,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("parent_session_id");
|
||||
|
||||
b.Property<List<string>>("Scopes")
|
||||
b.PrimitiveCollection<string>("Scopes")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("scopes");
|
||||
@@ -1129,7 +1129,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasColumnType("numeric")
|
||||
.HasColumnName("reward_points");
|
||||
|
||||
b.Property<ICollection<CheckInFortuneTip>>("Tips")
|
||||
b.Property<List<CheckInFortuneTip>>("Tips")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("tips");
|
||||
@@ -1226,7 +1226,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("draw_status");
|
||||
|
||||
b.Property<List<int>>("MatchedRegionOneNumbers")
|
||||
b.PrimitiveCollection<string>("MatchedRegionOneNumbers")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("matched_region_one_numbers");
|
||||
|
||||
@@ -1238,7 +1238,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("multiplier");
|
||||
|
||||
b.Property<List<int>>("RegionOneNumbers")
|
||||
b.PrimitiveCollection<string>("RegionOneNumbers")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("region_one_numbers");
|
||||
@@ -1254,9 +1254,6 @@ namespace DysonNetwork.Pass.Migrations
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_lotteries");
|
||||
|
||||
b.HasIndex("AccountId")
|
||||
.HasDatabaseName("ix_lotteries_account_id");
|
||||
|
||||
b.ToTable("lotteries", (string)null);
|
||||
});
|
||||
|
||||
@@ -1295,7 +1292,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated_at");
|
||||
|
||||
b.Property<List<int>>("WinningRegionOneNumbers")
|
||||
b.PrimitiveCollection<string>("WinningRegionOneNumbers")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("winning_region_one_numbers");
|
||||
@@ -1832,9 +1829,6 @@ namespace DysonNetwork.Pass.Migrations
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_wallets");
|
||||
|
||||
b.HasIndex("AccountId")
|
||||
.HasDatabaseName("ix_wallets_account_id");
|
||||
|
||||
b.ToTable("wallets", (string)null);
|
||||
});
|
||||
|
||||
@@ -1958,9 +1952,6 @@ namespace DysonNetwork.Pass.Migrations
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_wallet_funds");
|
||||
|
||||
b.HasIndex("CreatorAccountId")
|
||||
.HasDatabaseName("ix_wallet_funds_creator_account_id");
|
||||
|
||||
b.ToTable("wallet_funds", (string)null);
|
||||
});
|
||||
|
||||
@@ -2009,9 +2000,6 @@ namespace DysonNetwork.Pass.Migrations
|
||||
b.HasIndex("FundId")
|
||||
.HasDatabaseName("ix_wallet_fund_recipients_fund_id");
|
||||
|
||||
b.HasIndex("RecipientAccountId")
|
||||
.HasDatabaseName("ix_wallet_fund_recipients_recipient_account_id");
|
||||
|
||||
b.ToTable("wallet_fund_recipients", (string)null);
|
||||
});
|
||||
|
||||
@@ -2121,9 +2109,6 @@ namespace DysonNetwork.Pass.Migrations
|
||||
b.HasIndex("RecipientId")
|
||||
.HasDatabaseName("ix_wallet_gifts_recipient_id");
|
||||
|
||||
b.HasIndex("RedeemerId")
|
||||
.HasDatabaseName("ix_wallet_gifts_redeemer_id");
|
||||
|
||||
b.HasIndex("SubscriptionId")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("ix_wallet_gifts_subscription_id");
|
||||
@@ -2649,18 +2634,6 @@ namespace DysonNetwork.Pass.Migrations
|
||||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Shared.Models.SnLottery", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnAccount", "Account")
|
||||
.WithMany()
|
||||
.HasForeignKey("AccountId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_lotteries_accounts_account_id");
|
||||
|
||||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Shared.Models.SnMagicSpell", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnAccount", "Account")
|
||||
@@ -2741,30 +2714,6 @@ namespace DysonNetwork.Pass.Migrations
|
||||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Shared.Models.SnWallet", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnAccount", "Account")
|
||||
.WithMany()
|
||||
.HasForeignKey("AccountId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_wallets_accounts_account_id");
|
||||
|
||||
b.Navigation("Account");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Shared.Models.SnWalletFund", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnAccount", "CreatorAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("CreatorAccountId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_wallet_funds_accounts_creator_account_id");
|
||||
|
||||
b.Navigation("CreatorAccount");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Shared.Models.SnWalletFundRecipient", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnWalletFund", "Fund")
|
||||
@@ -2774,16 +2723,7 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_wallet_fund_recipients_wallet_funds_fund_id");
|
||||
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnAccount", "RecipientAccount")
|
||||
.WithMany()
|
||||
.HasForeignKey("RecipientAccountId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_wallet_fund_recipients_accounts_recipient_account_id");
|
||||
|
||||
b.Navigation("Fund");
|
||||
|
||||
b.Navigation("RecipientAccount");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Shared.Models.SnWalletGift", b =>
|
||||
@@ -2793,23 +2733,6 @@ namespace DysonNetwork.Pass.Migrations
|
||||
.HasForeignKey("CouponId")
|
||||
.HasConstraintName("fk_wallet_gifts_wallet_coupons_coupon_id");
|
||||
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnAccount", "Gifter")
|
||||
.WithMany()
|
||||
.HasForeignKey("GifterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_wallet_gifts_accounts_gifter_id");
|
||||
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnAccount", "Recipient")
|
||||
.WithMany()
|
||||
.HasForeignKey("RecipientId")
|
||||
.HasConstraintName("fk_wallet_gifts_accounts_recipient_id");
|
||||
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnAccount", "Redeemer")
|
||||
.WithMany()
|
||||
.HasForeignKey("RedeemerId")
|
||||
.HasConstraintName("fk_wallet_gifts_accounts_redeemer_id");
|
||||
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnWalletSubscription", "Subscription")
|
||||
.WithOne("Gift")
|
||||
.HasForeignKey("DysonNetwork.Shared.Models.SnWalletGift", "SubscriptionId")
|
||||
@@ -2817,12 +2740,6 @@ namespace DysonNetwork.Pass.Migrations
|
||||
|
||||
b.Navigation("Coupon");
|
||||
|
||||
b.Navigation("Gifter");
|
||||
|
||||
b.Navigation("Recipient");
|
||||
|
||||
b.Navigation("Redeemer");
|
||||
|
||||
b.Navigation("Subscription");
|
||||
});
|
||||
|
||||
@@ -2857,20 +2774,11 @@ namespace DysonNetwork.Pass.Migrations
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Shared.Models.SnWalletSubscription", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnAccount", "Account")
|
||||
.WithMany()
|
||||
.HasForeignKey("AccountId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_wallet_subscriptions_accounts_account_id");
|
||||
|
||||
b.HasOne("DysonNetwork.Shared.Models.SnWalletCoupon", "Coupon")
|
||||
.WithMany()
|
||||
.HasForeignKey("CouponId")
|
||||
.HasConstraintName("fk_wallet_subscriptions_wallet_coupons_coupon_id");
|
||||
|
||||
b.Navigation("Account");
|
||||
|
||||
b.Navigation("Coupon");
|
||||
});
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ builder.Services.AddAppAuthentication();
|
||||
builder.Services.AddRingService();
|
||||
builder.Services.AddDriveService();
|
||||
builder.Services.AddDevelopService();
|
||||
builder.Services.AddWalletService();
|
||||
|
||||
builder.Services.AddAppFlushHandlers();
|
||||
builder.Services.AddAppBusinessServices(builder.Configuration);
|
||||
|
||||
Reference in New Issue
Block a user