This commit is contained in:
suyl
2021-07-21 14:00:05 +08:00
parent 1e9ddfd5fb
commit 474d35b7e0
2 changed files with 10 additions and 6 deletions

View File

@@ -7,14 +7,20 @@ import (
"time" "time"
) )
type FlowSum struct {
Flow float64 `json:"flow" db:"flow"`
IccID string `json:"icc_id" db:"icc_id"`
FlowUnit string `json:"flow_unit" db:"flow_unit"`
}
func GetSimFlowExpend(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd time.Time) (simFlowExpnd []*model.SimFlowExpend, err error) { func GetSimFlowExpend(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd time.Time) (simFlowExpnd []*model.SimFlowExpend, err error) {
return simFlowExpnd, err return simFlowExpnd, err
} }
func GetSimFlowExpendSum(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd time.Time) (simFlowExpnd *model.SimFlowExpend, err error) { func GetSimFlowExpendSum(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd time.Time) (simFlowExpnd *FlowSum, err error) {
var ( var (
simFlowExpnds []*model.SimFlowExpend simFlowExpnds []*FlowSum
) )
sql := ` sql := `
SELECT SUM( SELECT SUM(
@@ -47,9 +53,9 @@ func GetSimFlowExpendSum(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd
return simFlowExpnd, err return simFlowExpnd, err
} }
func GetSimFlowIncomeSum(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd time.Time) (simFlowIncome *model.SimFlowIncome, err error) { func GetSimFlowIncomeSum(db *sqlx.DB, iccid string, createdAtBegin, createdAtEnd time.Time) (simFlowIncome *FlowSum, err error) {
var ( var (
simFlowIncomes []*model.SimFlowIncome simFlowIncomes []*FlowSum
) )
sql := ` sql := `
SELECT SUM( SELECT SUM(

View File

@@ -1,7 +1,6 @@
package services package services
import ( import (
"fmt"
"git.rosy.net.cn/baseapi/platformapi/tibiotapi" "git.rosy.net.cn/baseapi/platformapi/tibiotapi"
"git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-print/dao" "git.rosy.net.cn/jx-print/dao"
@@ -51,7 +50,6 @@ func SimFlowDaySettle() (err error) {
//api.TibiotAPI.BatchQueryCardInfo(1) //api.TibiotAPI.BatchQueryCardInfo(1)
} else { } else {
sumExpend, _ := dao.GetSimFlowExpendSum(db, v.IccID, monthBegin, monthEnd) sumExpend, _ := dao.GetSimFlowExpendSum(db, v.IccID, monthBegin, monthEnd)
fmt.Println("qqqqqqqqqqqqqqqqqqqqqqqqq", utils.Format4Output(sumExpend, true))
cardFlow := putils.Flow2KB(putils.SplitFlowAndUnit(getCardInfoResultMonth.CardFlow)) cardFlow := putils.Flow2KB(putils.SplitFlowAndUnit(getCardInfoResultMonth.CardFlow))
flowExpend.Flow, flowExpend.FlowUnit = putils.FlowKB2Other(cardFlow - sumExpend.Flow) flowExpend.Flow, flowExpend.FlowUnit = putils.FlowKB2Other(cardFlow - sumExpend.Flow)
} }