diff --git a/model/model.go b/model/model.go index 7082785..93ba4d6 100644 --- a/model/model.go +++ b/model/model.go @@ -164,9 +164,9 @@ type SimFlowExpend struct { CreatedAt *time.Time `json:"created_at" db:"created_at"` UpdatedAt *time.Time `json:"updated_at" db:"updated_at"` LastOperator string `json:"last_operator" db:"last_operator"` - IccID string `json:"iccid" db:"icc_id"` //sim卡iccid - Flow float64 `json:"flow"` //流量数 - FlowUnit string `json:"flowUnit"` //流量单位 + IccID string `json:"iccid" db:"icc_id"` //sim卡iccid + Flow float64 `json:"flow"` //流量数 + FlowUnit string `json:"flowUnit" db:"flow_unit"` //流量单位 } //流量划入 @@ -175,8 +175,8 @@ type SimFlowIncome struct { CreatedAt *time.Time `json:"created_at" db:"created_at"` UpdatedAt *time.Time `json:"updated_at" db:"updated_at"` LastOperator string `json:"last_operator" db:"last_operator"` - IccID string `json:"iccid" db:"icc_id"` //sim卡iccid - Flow float64 `json:"flow"` //流量数 - FlowUnit string `json:"flowUnit"` //流量单位 - IncomeType int `json:"incomeType"` //1 表示系统每月自动划转,2 表示商户自己冲的 + IccID string `json:"iccid" db:"icc_id"` //sim卡iccid + Flow float64 `json:"flow"` //流量数 + FlowUnit string `json:"flowUnit" db:"flow_unit"` //流量单位 + IncomeType int `json:"incomeType" db:"income_type"` //1 表示系统每月自动划转,2 表示商户自己冲的 } diff --git a/services/sim.go b/services/sim.go index b54ef90..c97db9b 100644 --- a/services/sim.go +++ b/services/sim.go @@ -58,14 +58,14 @@ func SimFlowDaySettle() (err error) { flowExpend.Flow, flowExpend.FlowUnit = putils.SplitFlowAndUnit(getCardInfoResult.CardFlow) } } - dao.Insert(db, flowExpend) + err = dao.Insert(db, flowExpend) //算是否超了一个月的流量了 //一个月总的收入流量 - 一个月总的支出流量 <= 0 sumIncome, _ := dao.GetSimFlowIncomeSum(db, v.IccID, monthBegin, monthEnd) sumExpend, _ := dao.GetSimFlowExpendSum(db, v.IccID, monthBegin, monthEnd) if sumExpend.Flow-sumIncome.Flow <= 0 { v.FlowFlag = 1 - dao.Update(db, v, "flow_flag") + err = dao.Update(db, v, "flow_flag") } } }