struct{}{}

This commit is contained in:
suyl
2021-07-22 17:07:26 +08:00
parent a6cdea6610
commit 08cdbe84cf
3 changed files with 9 additions and 8 deletions

View File

@@ -54,7 +54,7 @@ type TokenInfo struct {
type PrintInfo struct { type PrintInfo struct {
PrintNo string `json:"print_no" form:"print_no" binding:"required"` //打印机编号 PrintNo string `json:"print_no" form:"print_no" binding:"required"` //打印机编号
Name string `json:"name" form:"name"` //打印机备注 Name string `json:"name" form:"name"` //打印机备注
SIM string `json:"sim" form:"sim"` //流量卡号码 //SIM string `json:"sim" form:"sim"` //流量卡号码
} }
type PagedInfo struct { type PagedInfo struct {

View File

@@ -59,7 +59,8 @@ func SimFlowDaySettle() (err error) {
flowExpend.Flow, flowExpend.FlowUnit = putils.SplitFlowAndUnit(getCardInfoResult.CardFlow) 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) err = dao.Insert(db, flowExpend)
} }
//算是否超了一个月的流量了 //算是否超了一个月的流量了

View File

@@ -35,10 +35,10 @@ var (
letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
letterBytesNum = "0123456789" letterBytesNum = "0123456789"
flowUnitMap = map[string]string{ flowUnitMap = map[string]struct{}{
"KB": "KB", "KB": struct{}{},
"MB": "MB", "MB": struct{}{},
"GB": "GB", "GB": struct{}{},
} }
) )
@@ -216,8 +216,8 @@ func GetNextTimeFromList(now time.Time, timeList []string) (snapshotAt time.Time
} }
func SplitFlowAndUnit(flowStr string) (flow float64, unit string) { func SplitFlowAndUnit(flowStr string) (flow float64, unit string) {
for _, v := range flowUnitMap { for k, _ := range flowUnitMap {
if strings.Contains(flowStr, v) { if strings.Contains(flowStr, k) {
return utils.Str2Float64WithDefault(flowStr[:len(flowStr)-2], 0), flowStr[len(flowStr)-2:] return utils.Str2Float64WithDefault(flowStr[:len(flowStr)-2], 0), flowStr[len(flowStr)-2:]
} }
} }