Skip to content

Commit

Permalink
Merge pull request #1102 from ioito/hotfix/qx-ctyun-prepaid
Browse files Browse the repository at this point in the history
fix(ctyun): prepaid status
  • Loading branch information
ioito authored Oct 29, 2024
2 parents 9bd0fd7 + 890b25c commit c92ac41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
16 changes: 7 additions & 9 deletions pkg/multicloud/ctyun/eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"yunion.io/x/jsonutils"
"yunion.io/x/pkg/errors"
"yunion.io/x/pkg/util/timeutils"
"yunion.io/x/pkg/utils"

billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
Expand All @@ -45,12 +44,12 @@ type SEip struct {
Tags string
CreatedAt time.Time
UpdatedAt time.Time
ExpiredAt string
ExpiredAt time.Time
ProjectId string
}

func (self *SEip) GetBillingType() string {
if len(self.ExpiredAt) > 0 {
if !self.ExpiredAt.IsZero() {
return billing_api.BILLING_TYPE_PREPAID
}
return billing_api.BILLING_TYPE_POSTPAID
Expand All @@ -61,11 +60,7 @@ func (self *SEip) GetCreatedAt() time.Time {
}

func (self *SEip) GetExpiredAt() time.Time {
if len(self.ExpiredAt) > 0 {
t, _ := timeutils.ParseTimeStr(self.ExpiredAt)
return t
}
return time.Time{}
return self.ExpiredAt
}

func (self *SEip) GetId() string {
Expand Down Expand Up @@ -133,7 +128,10 @@ func (self *SEip) GetBandwidth() int {
}

func (self *SEip) GetInternetChargeType() string {
return ""
if self.GetBillingType() == billing_api.BILLING_TYPE_PREPAID {
return api.EIP_CHARGE_TYPE_BY_BANDWIDTH
}
return api.EIP_CHARGE_TYPE_BY_TRAFFIC
}

func (self *SEip) Delete() error {
Expand Down
11 changes: 3 additions & 8 deletions pkg/multicloud/ctyun/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package ctyun
import (
"context"
"fmt"
"strconv"
"strings"
"time"

Expand All @@ -41,7 +40,7 @@ type SInstance struct {
image *SImage

AzName string
ExpiredTime string
ExpiredTime time.Time
CreatedTime time.Time
ProjectId string
AttachedVolume []string
Expand Down Expand Up @@ -96,7 +95,7 @@ type SInstance struct {
}

func (self *SInstance) GetBillingType() string {
if len(self.ExpiredTime) > 0 {
if !self.OnDemand {
return billing_api.BILLING_TYPE_PREPAID
}
return billing_api.BILLING_TYPE_POSTPAID
Expand All @@ -107,11 +106,7 @@ func (self *SInstance) GetCreatedAt() time.Time {
}

func (self *SInstance) GetExpiredAt() time.Time {
if len(self.ExpiredTime) > 0 {
expire, _ := strconv.Atoi(self.ExpiredTime)
return time.Unix(int64(expire/1000), 0)
}
return time.Time{}
return self.ExpiredTime
}

func (self *SInstance) GetId() string {
Expand Down

0 comments on commit c92ac41

Please sign in to comment.