Skip to content

Commit 77d2f73

Browse files
authored
Merge pull request #1103 from ioito/automated-cherry-pick-of-#1102-upstream-release-3.12
Automated cherry pick of #1102: fix(ctyun): prepaid status
2 parents 210c46d + 6821e21 commit 77d2f73

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

pkg/multicloud/ctyun/eip.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020

2121
"yunion.io/x/jsonutils"
2222
"yunion.io/x/pkg/errors"
23-
"yunion.io/x/pkg/util/timeutils"
2423
"yunion.io/x/pkg/utils"
2524

2625
billing_api "yunion.io/x/cloudmux/pkg/apis/billing"
@@ -45,12 +44,12 @@ type SEip struct {
4544
Tags string
4645
CreatedAt time.Time
4746
UpdatedAt time.Time
48-
ExpiredAt string
47+
ExpiredAt time.Time
4948
ProjectId string
5049
}
5150

5251
func (self *SEip) GetBillingType() string {
53-
if len(self.ExpiredAt) > 0 {
52+
if !self.ExpiredAt.IsZero() {
5453
return billing_api.BILLING_TYPE_PREPAID
5554
}
5655
return billing_api.BILLING_TYPE_POSTPAID
@@ -61,11 +60,7 @@ func (self *SEip) GetCreatedAt() time.Time {
6160
}
6261

6362
func (self *SEip) GetExpiredAt() time.Time {
64-
if len(self.ExpiredAt) > 0 {
65-
t, _ := timeutils.ParseTimeStr(self.ExpiredAt)
66-
return t
67-
}
68-
return time.Time{}
63+
return self.ExpiredAt
6964
}
7065

7166
func (self *SEip) GetId() string {
@@ -133,7 +128,10 @@ func (self *SEip) GetBandwidth() int {
133128
}
134129

135130
func (self *SEip) GetInternetChargeType() string {
136-
return ""
131+
if self.GetBillingType() == billing_api.BILLING_TYPE_PREPAID {
132+
return api.EIP_CHARGE_TYPE_BY_BANDWIDTH
133+
}
134+
return api.EIP_CHARGE_TYPE_BY_TRAFFIC
137135
}
138136

139137
func (self *SEip) Delete() error {

pkg/multicloud/ctyun/instance.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package ctyun
1717
import (
1818
"context"
1919
"fmt"
20-
"strconv"
2120
"strings"
2221
"time"
2322

@@ -41,7 +40,7 @@ type SInstance struct {
4140
image *SImage
4241

4342
AzName string
44-
ExpiredTime string
43+
ExpiredTime time.Time
4544
CreatedTime time.Time
4645
ProjectId string
4746
AttachedVolume []string
@@ -96,7 +95,7 @@ type SInstance struct {
9695
}
9796

9897
func (self *SInstance) GetBillingType() string {
99-
if len(self.ExpiredTime) > 0 {
98+
if !self.OnDemand {
10099
return billing_api.BILLING_TYPE_PREPAID
101100
}
102101
return billing_api.BILLING_TYPE_POSTPAID
@@ -107,11 +106,7 @@ func (self *SInstance) GetCreatedAt() time.Time {
107106
}
108107

109108
func (self *SInstance) GetExpiredAt() time.Time {
110-
if len(self.ExpiredTime) > 0 {
111-
expire, _ := strconv.Atoi(self.ExpiredTime)
112-
return time.Unix(int64(expire/1000), 0)
113-
}
114-
return time.Time{}
109+
return self.ExpiredTime
115110
}
116111

117112
func (self *SInstance) GetId() string {

0 commit comments

Comments
 (0)