This commit is contained in:
suyl
2021-07-21 10:52:08 +08:00
parent c04fc21211
commit b58a49cc82
2 changed files with 6 additions and 6 deletions

View File

@@ -20,8 +20,9 @@ func GetSimFlowExpendSum(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd
sql := ` sql := `
SELECT SUM( SELECT SUM(
IF(flow_unit = 'KB', flow, IF(flow_unit = 'KB', flow,
IF(flow_unit = 'MB', ROUND(flow * 1024)), IF(flow_unit = 'MB', ROUND(flow * 1024),
IF(flow_unit = "GB", ROUND(flow * 1024 * 1024), 0) IF(flow_unit = "GB", ROUND(flow * 1024 * 1024), 0)
)
) )
) flow, icc_id, 'KB' flow_unit ) flow, icc_id, 'KB' flow_unit
FROM sim_flow_expend FROM sim_flow_expend
@@ -41,8 +42,6 @@ func GetSimFlowExpendSum(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd
sqlParams = append(sqlParams, createdAtEnd) sqlParams = append(sqlParams, createdAtEnd)
} }
sql += " GROUP BY 2, 3" sql += " GROUP BY 2, 3"
fmt.Println(sql)
fmt.Println(sqlParams)
if err = db.Select(&simFlowExpnds, sql, sqlParams); err == nil && len(simFlowExpnds) > 0 { if err = db.Select(&simFlowExpnds, sql, sqlParams); err == nil && len(simFlowExpnds) > 0 {
return simFlowExpnds[0], err return simFlowExpnds[0], err
} }
@@ -56,8 +55,9 @@ func GetSimFlowIncomeSum(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd
sql := ` sql := `
SELECT SUM( SELECT SUM(
IF(flow_unit = 'KB', flow, IF(flow_unit = 'KB', flow,
IF(flow_unit = 'MB', ROUND(flow * 1024)), IF(flow_unit = 'MB', ROUND(flow * 1024),
IF(flow_unit = "GB", ROUND(flow * 1024 * 1024), 0) IF(flow_unit = "GB", ROUND(flow * 1024 * 1024), 0)
)
) )
) flow, icc_id, 'KB' flow_unit ) flow, icc_id, 'KB' flow_unit
FROM sim_flow_income FROM sim_flow_income

View File

@@ -17,8 +17,8 @@ func SimFlowDaySettle() (err error) {
var ( var (
db = globals.GetDB() db = globals.GetDB()
now = time.Now() now = time.Now()
monthBegin = utils.Str2Time(utils.Int2Str(now.Year()) + "-" + utils.Int2Str(int(now.Month())) + "-01 00:00:00") monthBegin = utils.Str2Time(now.Format("2006-01") + "-01 00:00:00")
monthEnd = monthBegin.AddDate(0, 1, 0).AddDate(0, 0, -1) monthEnd = utils.Str2Time(monthBegin.AddDate(0, 1, 0).AddDate(0, 0, -1).Format("2006-01-02") + " 23:59:59")
) )
globals.SugarLogger.Debugf("SimFlowDaySettle Begin monthBegin %v, monthEnd %v", monthBegin, monthEnd) globals.SugarLogger.Debugf("SimFlowDaySettle Begin monthBegin %v, monthEnd %v", monthBegin, monthEnd)
//月末好像不用算超不超了 //月末好像不用算超不超了