Add License Integration
This commit is contained in:
@@ -93,3 +93,29 @@ func (o *LicenseDB) ToUpdatedLicense(updatedBy int64, req License) {
|
||||
o.SerialNumber = req.SerialNumber
|
||||
}
|
||||
}
|
||||
|
||||
type PartnerLicense struct {
|
||||
PartnerID int64 `json:"partner_id"`
|
||||
LicenseStatus string `json:"license_status"`
|
||||
DaysToExpire int64 `json:"days_to_expire"`
|
||||
}
|
||||
|
||||
func (l *LicenseDB) ToPartnerLicense() PartnerLicense {
|
||||
now := time.Now()
|
||||
daysToExpire := int64(l.EndDate.Sub(now).Hours() / 24)
|
||||
|
||||
var licenseStatus string
|
||||
if daysToExpire < 0 {
|
||||
licenseStatus = "EXPIRED"
|
||||
} else if daysToExpire <= 30 {
|
||||
licenseStatus = "EXPIRING_SOON"
|
||||
} else {
|
||||
licenseStatus = "ACTIVE"
|
||||
}
|
||||
|
||||
return PartnerLicense{
|
||||
PartnerID: l.PartnerID,
|
||||
DaysToExpire: daysToExpire,
|
||||
LicenseStatus: licenseStatus,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user