附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

svc_comm.go 587 B

3 months ago
12345678910111213141516171819202122232425
  1. package svc
  2. import (
  3. "applet/app/utils"
  4. "github.com/gin-gonic/gin"
  5. "strings"
  6. )
  7. func GetCommissionPrec(c *gin.Context, sum, commPrec, isShowPoint string) string {
  8. if sum == "" {
  9. sum = "0"
  10. }
  11. sum = utils.StrToFormat(c, sum, utils.StrToInt(commPrec))
  12. ex := strings.Split(sum, ".")
  13. if len(ex) == 2 && isShowPoint != "1" {
  14. if utils.StrToFloat64(ex[1]) == 0 {
  15. sum = ex[0]
  16. } else {
  17. val := utils.Float64ToStrByPrec(utils.StrToFloat64(ex[1]), 0)
  18. valNew := strings.ReplaceAll(val, "0", "")
  19. sum = ex[0] + "." + strings.ReplaceAll(ex[1], val, valNew)
  20. }
  21. }
  22. return sum
  23. }