xuzhiheng 1 жил өмнө
parent
commit
7158724dd1
1 өөрчлөгдсөн 0 нэмэгдсэн , 49 устгасан
  1. 0 49
      c_money.go

+ 0 - 49
c_money.go

@@ -1,49 +0,0 @@
-package clean
-
-import (
-	"fmt"
-	util "jygit.jydev.jianyu360.cn/data_processing/common_utils"
-	"math"
-	"regexp"
-	"strconv"
-	"strings"
-)
-
-var (
-	moneyReg1 = regexp.MustCompile("([\\s ,]+)")
-	moneyReg2 = regexp.MustCompile("^([0-9.]+)E([1-7])$")
-	numReg1   = regexp.MustCompile("([0-9\\.]+)")
-)
-
-// 清洗金额
-func CleanMoney(money interface{}) float64 {
-	tmpstr := ""
-	if _, ok := money.(float64); ok {
-		tmpstr = fmt.Sprintf("%f", money)
-	} else {
-		tmpstr = util.ObjToString(money)
-	}
-	//去除空格
-	tmpstr = moneyReg1.ReplaceAllString(tmpstr, "")
-	//科学计数法
-	if moneyReg2.MatchString(tmpstr) {
-		price := util.Float64All(moneyReg2.ReplaceAllString(tmpstr, "${1}"))
-		if unit := util.Float64All(moneyReg2.ReplaceAllString(tmpstr, "${2}")); unit > 0.0 && price > 0.0 {
-			tmpstr = fmt.Sprintf("%f", math.Pow(10, unit)*price)
-		}
-	}
-	if num := numReg1.FindString(tmpstr); num != "" {
-		f_num := util.Float64All(num)
-		if strings.Contains(tmpstr, "万") {
-			f, _ := strconv.ParseFloat(strconv.FormatFloat(f_num*10000.0, 'f', 4, 64), 64)
-			return f
-		} else if strings.Contains(tmpstr, "亿") {
-			f, _ := strconv.ParseFloat(strconv.FormatFloat(f_num*10000.0*10000.0, 'f', 4, 64), 64)
-			return f
-		} else {
-			f, _ := strconv.ParseFloat(strconv.FormatFloat(f_num, 'f', 4, 64), 64)
-			return f
-		}
-	}
-	return 0.0
-}