🐛 Fix missing fields

This commit is contained in:
2025-09-21 01:33:33 +08:00
parent 3458e85a8b
commit 4efbfa948a
3 changed files with 29 additions and 5 deletions

View File

@@ -213,13 +213,15 @@ public class Subscription : ModelBase
Status = (Shared.Proto.SubscriptionStatus)Status, Status = (Shared.Proto.SubscriptionStatus)Status,
PaymentMethod = PaymentMethod, PaymentMethod = PaymentMethod,
PaymentDetails = PaymentDetails.ToProtoValue(), PaymentDetails = PaymentDetails.ToProtoValue(),
BasePrice = BasePrice.ToString(), BasePrice = BasePrice.ToString(CultureInfo.InvariantCulture),
CouponId = CouponId?.ToString(), CouponId = CouponId?.ToString(),
Coupon = Coupon?.ToProtoValue(), Coupon = Coupon?.ToProtoValue(),
RenewalAt = RenewalAt?.ToTimestamp(), RenewalAt = RenewalAt?.ToTimestamp(),
AccountId = AccountId.ToString(), AccountId = AccountId.ToString(),
IsAvailable = IsAvailable, IsAvailable = IsAvailable,
FinalPrice = FinalPrice.ToString(), FinalPrice = FinalPrice.ToString(CultureInfo.InvariantCulture),
CreatedAt = CreatedAt.ToTimestamp(),
UpdatedAt = UpdatedAt.ToTimestamp()
}; };
public static Subscription FromProtoValue(Shared.Proto.Subscription proto) => new() public static Subscription FromProtoValue(Shared.Proto.Subscription proto) => new()
@@ -238,6 +240,8 @@ public class Subscription : ModelBase
Coupon = proto.Coupon is not null ? Coupon.FromProtoValue(proto.Coupon) : null, Coupon = proto.Coupon is not null ? Coupon.FromProtoValue(proto.Coupon) : null,
RenewalAt = proto.RenewalAt?.ToInstant(), RenewalAt = proto.RenewalAt?.ToInstant(),
AccountId = Guid.Parse(proto.AccountId), AccountId = Guid.Parse(proto.AccountId),
CreatedAt = proto.CreatedAt.ToInstant(),
UpdatedAt = proto.UpdatedAt.ToInstant()
}; };
} }
@@ -283,6 +287,8 @@ public class SubscriptionReferenceObject : ModelBase
RenewalAt = RenewalAt?.ToTimestamp(), RenewalAt = RenewalAt?.ToTimestamp(),
AccountId = AccountId.ToString(), AccountId = AccountId.ToString(),
DisplayName = DisplayName, DisplayName = DisplayName,
CreatedAt = CreatedAt.ToTimestamp(),
UpdatedAt = UpdatedAt.ToTimestamp()
}; };
public static SubscriptionReferenceObject FromProtoValue(Shared.Proto.SubscriptionReferenceObject proto) => new() public static SubscriptionReferenceObject FromProtoValue(Shared.Proto.SubscriptionReferenceObject proto) => new()
@@ -299,6 +305,8 @@ public class SubscriptionReferenceObject : ModelBase
FinalPrice = decimal.Parse(proto.FinalPrice), FinalPrice = decimal.Parse(proto.FinalPrice),
RenewalAt = proto.RenewalAt?.ToInstant(), RenewalAt = proto.RenewalAt?.ToInstant(),
AccountId = Guid.Parse(proto.AccountId), AccountId = Guid.Parse(proto.AccountId),
CreatedAt = proto.CreatedAt.ToInstant(),
UpdatedAt = proto.UpdatedAt.ToInstant()
}; };
} }
@@ -377,6 +385,8 @@ public class Coupon : ModelBase
DiscountAmount = DiscountAmount?.ToString(), DiscountAmount = DiscountAmount?.ToString(),
DiscountRate = DiscountRate, DiscountRate = DiscountRate,
MaxUsage = MaxUsage, MaxUsage = MaxUsage,
CreatedAt = CreatedAt.ToTimestamp(),
UpdatedAt = UpdatedAt.ToTimestamp()
}; };
public static Coupon FromProtoValue(Shared.Proto.Coupon proto) => new() public static Coupon FromProtoValue(Shared.Proto.Coupon proto) => new()
@@ -389,5 +399,7 @@ public class Coupon : ModelBase
DiscountAmount = proto.HasDiscountAmount ? decimal.Parse(proto.DiscountAmount) : null, DiscountAmount = proto.HasDiscountAmount ? decimal.Parse(proto.DiscountAmount) : null,
DiscountRate = proto.DiscountRate, DiscountRate = proto.DiscountRate,
MaxUsage = proto.MaxUsage, MaxUsage = proto.MaxUsage,
CreatedAt = proto.CreatedAt.ToInstant(),
UpdatedAt = proto.UpdatedAt.ToInstant()
}; };
} }

View File

@@ -3,7 +3,7 @@ using NodaTime.Serialization.Protobuf;
namespace DysonNetwork.Shared.Data; namespace DysonNetwork.Shared.Data;
public class SubscriptionReference public class SubscriptionReference : ModelBase
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public string Identifier { get; set; } = string.Empty; public string Identifier { get; set; } = string.Empty;
@@ -30,6 +30,8 @@ public class SubscriptionReference
RenewalAt = proto.RenewalAt?.ToInstant(), RenewalAt = proto.RenewalAt?.ToInstant(),
Status = (SubscriptionReferenceStatus)proto.Status, Status = (SubscriptionReferenceStatus)proto.Status,
AccountId = Guid.Parse(proto.AccountId), AccountId = Guid.Parse(proto.AccountId),
CreatedAt = proto.CreatedAt.ToInstant(),
UpdatedAt = proto.UpdatedAt.ToInstant(),
}; };
} }
@@ -46,6 +48,8 @@ public class SubscriptionReference
EndedAt = EndedAt?.ToTimestamp(), EndedAt = EndedAt?.ToTimestamp(),
RenewalAt = RenewalAt?.ToTimestamp(), RenewalAt = RenewalAt?.ToTimestamp(),
AccountId = AccountId.ToString(), AccountId = AccountId.ToString(),
CreatedAt = CreatedAt.ToTimestamp(),
UpdatedAt = UpdatedAt.ToTimestamp(),
Status = Status switch Status = Status switch
{ {
SubscriptionReferenceStatus.Unpaid => Proto.SubscriptionStatus.Unpaid, SubscriptionReferenceStatus.Unpaid => Proto.SubscriptionStatus.Unpaid,

View File

@@ -50,6 +50,8 @@ message Subscription {
bool is_available = 15; bool is_available = 15;
// Using string for decimal to avoid precision loss. // Using string for decimal to avoid precision loss.
string final_price = 16; string final_price = 16;
google.protobuf.Timestamp created_at = 17;
google.protobuf.Timestamp updated_at = 18;
} }
message SubscriptionReferenceObject { message SubscriptionReferenceObject {
@@ -68,6 +70,8 @@ message SubscriptionReferenceObject {
optional google.protobuf.Timestamp renewal_at = 11; optional google.protobuf.Timestamp renewal_at = 11;
string account_id = 12; string account_id = 12;
optional string display_name = 13; optional string display_name = 13;
google.protobuf.Timestamp created_at = 14;
google.protobuf.Timestamp updated_at = 15;
} }
message PaymentDetails { message PaymentDetails {
@@ -85,6 +89,8 @@ message Coupon {
optional string discount_amount = 6; optional string discount_amount = 6;
optional google.protobuf.DoubleValue discount_rate = 7; optional google.protobuf.DoubleValue discount_rate = 7;
optional google.protobuf.Int32Value max_usage = 8; optional google.protobuf.Int32Value max_usage = 8;
google.protobuf.Timestamp created_at = 9;
google.protobuf.Timestamp updated_at = 10;
} }
service WalletService { service WalletService {
@@ -163,6 +169,8 @@ message Transaction {
string amount = 5; string amount = 5;
google.protobuf.StringValue remarks = 6; google.protobuf.StringValue remarks = 6;
TransactionType type = 7; TransactionType type = 7;
google.protobuf.Timestamp created_at = 8;
google.protobuf.Timestamp updated_at = 9;
} }
enum TransactionType { enum TransactionType {