|
@@ -10,10 +10,11 @@ import (
|
|
|
)
|
|
|
|
|
|
var numReg = regexp.MustCompile("[0-9.]+")
|
|
|
+var symbolReg = regexp.MustCompile("[%%﹪!!]")
|
|
|
|
|
|
// 清洗时间
|
|
|
func CleanTime(st string) int64 {
|
|
|
- if st == "" {
|
|
|
+ if st == "" || st == "无" {
|
|
|
return 0
|
|
|
}
|
|
|
//YYYY-MM-DD HH:MM:SS
|
|
@@ -23,11 +24,10 @@ func CleanTime(st string) int64 {
|
|
|
|
|
|
// 清洗折扣率
|
|
|
func CleanDiscount(str string) float64 {
|
|
|
- /*
|
|
|
- 上浮率:20%
|
|
|
- 下浮率:20%
|
|
|
- 折扣率:20%
|
|
|
- */
|
|
|
+ str = fieldReg1.ReplaceAllString(str, "")
|
|
|
+ if str == "" || str == "无" {
|
|
|
+ return 0.0
|
|
|
+ }
|
|
|
if biddiscount := RateToFloat(str); biddiscount > 0.0 {
|
|
|
baseCount := 1.0
|
|
|
num1 := decimal.NewFromFloat(baseCount)
|
|
@@ -52,7 +52,7 @@ func RateToFloat(str string) float64 {
|
|
|
if num0 := qu.Float64All(numReg.FindString(str)); num0 > 0.0 {
|
|
|
num1 := decimal.NewFromFloat(100.0)
|
|
|
num2 := decimal.NewFromFloat(num0)
|
|
|
- if strings.Contains(str, "%") || strings.Contains(str, "%") {
|
|
|
+ if symbolReg.MatchString(str) {
|
|
|
decimalValue := num2.Div(num1)
|
|
|
res, _ := decimalValue.Float64()
|
|
|
if res < 1.0 {
|