🐛 Fix Null value issue

This commit is contained in:
2026-02-04 02:56:27 +08:00
parent f6e5888ebc
commit 43985b2046

View File

@@ -405,27 +405,40 @@ public class SnWalletSubscription : ModelBase
}; };
} }
public Proto.Subscription ToProtoValue() => new() public Proto.Subscription ToProtoValue()
{ {
Id = Id.ToString(), var proto = new Proto.Subscription
BegunAt = BegunAt.ToTimestamp(), {
EndedAt = EndedAt?.ToTimestamp(), Id = Id.ToString(),
Identifier = Identifier, BegunAt = BegunAt.ToTimestamp(),
IsActive = IsActive, EndedAt = EndedAt?.ToTimestamp(),
IsFreeTrial = IsFreeTrial, Identifier = Identifier,
Status = (Proto.SubscriptionStatus)Status, IsActive = IsActive,
PaymentMethod = PaymentMethod, IsFreeTrial = IsFreeTrial,
PaymentDetails = PaymentDetails.ToProtoValue(), Status = (Proto.SubscriptionStatus)Status,
BasePrice = BasePrice.ToString(CultureInfo.InvariantCulture), PaymentMethod = PaymentMethod,
CouponId = CouponId?.ToString(), PaymentDetails = PaymentDetails.ToProtoValue(),
Coupon = Coupon?.ToProtoValue(), BasePrice = BasePrice.ToString(CultureInfo.InvariantCulture),
RenewalAt = RenewalAt?.ToTimestamp(), RenewalAt = RenewalAt?.ToTimestamp(),
AccountId = AccountId.ToString(), AccountId = AccountId.ToString(),
IsAvailable = IsAvailable, IsAvailable = IsAvailable,
FinalPrice = FinalPrice.ToString(CultureInfo.InvariantCulture), FinalPrice = FinalPrice.ToString(CultureInfo.InvariantCulture),
CreatedAt = CreatedAt.ToTimestamp(), CreatedAt = CreatedAt.ToTimestamp(),
UpdatedAt = UpdatedAt.ToTimestamp() UpdatedAt = UpdatedAt.ToTimestamp()
}; };
if (CouponId.HasValue)
{
proto.CouponId = CouponId.Value.ToString();
}
if (Coupon != null)
{
proto.Coupon = Coupon.ToProtoValue();
}
return proto;
}
public static SnWalletSubscription FromProtoValue(Proto.Subscription proto) => new() public static SnWalletSubscription FromProtoValue(Proto.Subscription proto) => new()
{ {