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