Skip to content

Commit

Permalink
change the name of basecount to currency unit
Browse files Browse the repository at this point in the history
  • Loading branch information
yxxchange committed Aug 14, 2023
1 parent 83588b1 commit 5cdbcf5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions controllers/common/account/count.go
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package count
package account

// BaseCount is the base count for account
const BaseCount = 1000000
// CurrencyUnit is the unit of currency for accounting.
const CurrencyUnit = 1000000
6 changes: 3 additions & 3 deletions controllers/licenseissuer/internal/controller/util/collect.go
Expand Up @@ -22,7 +22,7 @@ import (
"time"

accountv1 "github.com/labring/sealos/controllers/account/api/v1"
count "github.com/labring/sealos/controllers/common/account"
account "github.com/labring/sealos/controllers/common/account"
"github.com/labring/sealos/controllers/pkg/database"
ntf "github.com/labring/sealos/controllers/pkg/notification"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -166,7 +166,7 @@ func (c *collect) getUsageYesterday(instance *TaskInstance) error {
instance.logger.Error(err, "failed to get billing amount")
return err
}
dailyClusterUsage.TotalUsageFee = float64(amount) / float64(count.BaseCount)
dailyClusterUsage.TotalUsageFee = float64(amount) / float64(account.CurrencyUnit)
// get billing amount for yesterday hourly usage fee
hourlyUsage := make([]float64, 24)
for cnt := 0; cnt < 24; cnt++ {
Expand All @@ -177,7 +177,7 @@ func (c *collect) getUsageYesterday(instance *TaskInstance) error {
instance.logger.Error(err, "failed to get billing amount")
return err
}
hourlyUsage[cnt] = float64(amount) / float64(count.BaseCount)
hourlyUsage[cnt] = float64(amount) / float64(account.CurrencyUnit)
}
dailyClusterUsage.HourlyUsage = hourlyUsage
c.DailyClusterUsage = dailyClusterUsage
Expand Down
Expand Up @@ -95,7 +95,7 @@ func RechargeByLicense(ctx context.Context, client client.Client, account accoun
if err != nil {
return errors.New("amount error type")
}
charge := amount * count.BaseCount
charge := amount * count.CurrencyUnit
account.Status.Balance += charge
err = crypto.RechargeBalance(account.Status.EncryptBalance, charge)
if err != nil {
Expand Down

0 comments on commit 5cdbcf5

Please sign in to comment.