aa
This commit is contained in:
@@ -39,3 +39,32 @@ func GetSimFlowExpendSum(db *DaoDB, iccid string, createdAtBegin, createdAtEnd t
|
||||
err = GetRow(db, &simFlowExpnd, sql, sqlParams)
|
||||
return simFlowExpnd, err
|
||||
}
|
||||
|
||||
func GetSimFlowIncomeSum(db *DaoDB, iccid string, createdAtBegin, createdAtEnd time.Time) (simFlowIncome *model.SimFlowIncome, err error) {
|
||||
sql := `
|
||||
SELECT SUM(
|
||||
IF(flow_unit = 'KB', flow,
|
||||
IF(flow_unit = 'MB', ROUND(flow * 1024)),
|
||||
IF(flow_unit = "GB", ROUND(flow * 1024 * 1024), 0)
|
||||
)
|
||||
), icc_id, 'KB' flow_unit
|
||||
FROM sim_flow_income
|
||||
WHERE 1 = 1
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
if iccid != "" {
|
||||
sql += " AND icc_id = ?"
|
||||
sqlParams = append(sqlParams, iccid)
|
||||
}
|
||||
if !utils.IsTimeZero(createdAtBegin) {
|
||||
sql += " AND created_at > ?"
|
||||
sqlParams = append(sqlParams, createdAtBegin)
|
||||
}
|
||||
if !utils.IsTimeZero(createdAtEnd) {
|
||||
sql += " AND created_at < ?"
|
||||
sqlParams = append(sqlParams, createdAtEnd)
|
||||
}
|
||||
sql += " GROUP BY 2, 3"
|
||||
err = GetRow(db, &simFlowIncome, sql, sqlParams)
|
||||
return simFlowIncome, err
|
||||
}
|
||||
|
||||
@@ -70,9 +70,10 @@ func (v *SimFlowExpend) TableIndex() [][]string {
|
||||
type SimFlowIncome struct {
|
||||
ModelIDCUL
|
||||
|
||||
IccID string `orm:"column(icc_id)" json:"iccID"` //sim卡iccid
|
||||
Flow float64 `json:"flow"` //流量数
|
||||
FlowUnit string `json:"flowUnit"` //流量单位
|
||||
IccID string `orm:"column(icc_id)" json:"iccID"` //sim卡iccid
|
||||
Flow float64 `json:"flow"` //流量数
|
||||
FlowUnit string `json:"flowUnit"` //流量单位
|
||||
IncomeType int `json:"incomeType"` //1 表示系统每月自动划转,2 表示商户自己冲的
|
||||
}
|
||||
|
||||
func (v *SimFlowIncome) TableIndex() [][]string {
|
||||
|
||||
Reference in New Issue
Block a user