struct{}{}
This commit is contained in:
@@ -54,7 +54,7 @@ type TokenInfo struct {
|
||||
type PrintInfo struct {
|
||||
PrintNo string `json:"print_no" form:"print_no" binding:"required"` //打印机编号
|
||||
Name string `json:"name" form:"name"` //打印机备注
|
||||
SIM string `json:"sim" form:"sim"` //流量卡号码
|
||||
//SIM string `json:"sim" form:"sim"` //流量卡号码
|
||||
}
|
||||
|
||||
type PagedInfo struct {
|
||||
|
||||
@@ -59,7 +59,8 @@ func SimFlowDaySettle() (err error) {
|
||||
flowExpend.Flow, flowExpend.FlowUnit = putils.SplitFlowAndUnit(getCardInfoResult.CardFlow)
|
||||
}
|
||||
}
|
||||
if flowExpend.Flow > 0 && flowExpend.FlowUnit != "" {
|
||||
//可能有精度误差
|
||||
if flowExpend.Flow > 0.1 && flowExpend.FlowUnit != "" {
|
||||
err = dao.Insert(db, flowExpend)
|
||||
}
|
||||
//算是否超了一个月的流量了
|
||||
|
||||
@@ -35,10 +35,10 @@ var (
|
||||
letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
letterBytesNum = "0123456789"
|
||||
|
||||
flowUnitMap = map[string]string{
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
flowUnitMap = map[string]struct{}{
|
||||
"KB": struct{}{},
|
||||
"MB": struct{}{},
|
||||
"GB": struct{}{},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -216,8 +216,8 @@ func GetNextTimeFromList(now time.Time, timeList []string) (snapshotAt time.Time
|
||||
}
|
||||
|
||||
func SplitFlowAndUnit(flowStr string) (flow float64, unit string) {
|
||||
for _, v := range flowUnitMap {
|
||||
if strings.Contains(flowStr, v) {
|
||||
for k, _ := range flowUnitMap {
|
||||
if strings.Contains(flowStr, k) {
|
||||
return utils.Str2Float64WithDefault(flowStr[:len(flowStr)-2], 0), flowStr[len(flowStr)-2:]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user