- jdapi.MonthSaleNum2Int

This commit is contained in:
gazebo
2019-06-28 17:47:09 +08:00
parent 449cee14c9
commit 9f2a572919
2 changed files with 36 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
"regexp"
"strings"
"git.rosy.net.cn/baseapi"
@@ -136,6 +137,10 @@ type PageShopInfo struct {
StoreShareURL string `json:"storeShareUrl"`
}
var (
monthSaleNumReg = regexp.MustCompile(`(\d+)([千|万])`)
)
func (a *API) SetStoreCookie(storeCookie string) {
a.locker.Lock()
defer a.locker.Unlock()
@@ -307,3 +312,18 @@ func (a *API) GetCorporationInfo(stationNo, qualifyNumber string) (corporatonInf
}
return corporatonInfo, err
}
func MonthSaleNum2Int(monthSaleNumStr string) (monthSaleNum int) {
searchResult := monthSaleNumReg.FindStringSubmatch(monthSaleNumStr)
if searchResult != nil && len(searchResult[1]) > 0 && len(searchResult[2]) > 0 {
monthSaleNum = int(utils.Str2Int64WithDefault(searchResult[1], 0))
if searchResult[2] == "千" {
monthSaleNum *= 1000
} else if searchResult[2] == "万" {
monthSaleNum *= 10000
}
} else {
monthSaleNum = int(utils.Str2Int64WithDefault(monthSaleNumStr, 0))
}
return monthSaleNum
}