This commit is contained in:
suyl
2021-07-20 14:13:39 +08:00
parent 2fd881f172
commit 902a245674
7 changed files with 100 additions and 9 deletions

View File

@@ -0,0 +1,52 @@
package cms
import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals/api"
"time"
)
//每日流量卡流量结算
func SimFlowDaySettle(ctx *jxcontext.Context) {
var (
db = dao.GetDB()
)
//找出所有状态不为 超流量的打印机iccid卡
printers, _ := dao.GetPrinters(db, 0, "", 0, model.PrinterStatusNoFlow)
for _, v := range printers {
//查询前一日使用的流量数
if v.IccID != "" {
if getCardInfoResult, err := api.TibiotAPI.IotData(v.IccID, utils.Time2Str(utils.Time2Date(time.Now().AddDate(0, 0, -1)))); err == nil {
//表示还没有同步前一天的流量,只能自己算了
if getCardInfoResult == nil || getCardInfoResult.SyncStatus == "1" || getCardInfoResult.CardFlow == "0KB" { //未同步
//先查当月用的总的, 减去当月已经用的总的,就是昨天用的
if getCardInfoResultMonth, err2 := api.TibiotAPI.IotDataMonth(v.IccID); err2 == nil {
//表示当月用的总的也还没同步。只有去查卡信息中的总流量使用,减去所有总使用,就是昨天用的。。先不写
if getCardInfoResultMonth == nil || getCardInfoResultMonth.CardFlow == "" {
//api.TibiotAPI.BatchQueryCardInfo(1)
} else if getCardInfoResultMonth.CardFlow != "" {
}
}
} else if getCardInfoResult.CardFlow != "" {
}
}
}
}
}
//每月流量卡流量结算
func SimFlowMonthSettle(ctx *jxcontext.Context) {
var (
db = dao.GetDB()
)
//..每月1号结算上月
if time.Now().Day() != 1 {
return
}
dao.GetSimFlowExpend(db, "", utils.ZeroTimeValue, utils.ZeroTimeValue)
}