Payment grpc services and perks in proto

This commit is contained in:
2025-07-23 20:14:02 +08:00
parent 8e61a8b43d
commit 925ddd9e8b
10 changed files with 542 additions and 5 deletions

View File

@@ -32,7 +32,7 @@ public class Account : ModelBase
[JsonIgnore] public ICollection<Relationship> OutgoingRelationships { get; set; } = new List<Relationship>();
[JsonIgnore] public ICollection<Relationship> IncomingRelationships { get; set; } = new List<Relationship>();
[NotMapped] public SubscriptionReferenceObject? PerkSubscription { get; set; }
public Shared.Proto.Account ToProtoValue()
@@ -46,6 +46,7 @@ public class Account : ModelBase
ActivatedAt = ActivatedAt?.ToTimestamp(),
IsSuperuser = IsSuperuser,
Profile = Profile.ToProtoValue(),
PerkSubscription = PerkSubscription?.ToProtoValue(),
CreatedAt = CreatedAt.ToTimestamp(),
UpdatedAt = UpdatedAt.ToTimestamp()
};
@@ -72,6 +73,9 @@ public class Account : ModelBase
Language = proto.Language,
ActivatedAt = proto.ActivatedAt?.ToInstant(),
IsSuperuser = proto.IsSuperuser,
PerkSubscription = proto.PerkSubscription is not null
? SubscriptionReferenceObject.FromProtoValue(proto.PerkSubscription)
: null,
CreatedAt = proto.CreatedAt.ToInstant(),
UpdatedAt = proto.UpdatedAt.ToInstant(),
};

View File

@@ -39,7 +39,7 @@ public class AccountCurrentController(
.Where(e => e.Id == userId)
.FirstOrDefaultAsync();
var perk = await subscriptions.GetPerkSubscriptionAsync(account.Id);
var perk = await subscriptions.GetPerkSubscriptionAsync(account!.Id);
account.PerkSubscription = perk?.ToReference();
return Ok(account);

View File

@@ -10,7 +10,7 @@ namespace DysonNetwork.Pass.Account;
public class AccountEventService(
AppDatabase db,
PaymentService payment,
Wallet.PaymentService payment,
ICacheService cache,
IStringLocalizer<Localization.AccountEventResource> localizer,
PusherService.PusherServiceClient pusher