cash limit
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
@@ -21,3 +23,31 @@ func GetUserBill(db *DaoDB, userID, billID string) (userBill *model.UserBill, er
|
||||
err = GetRow(db, &userBill, sql, sqlParams)
|
||||
return userBill, err
|
||||
}
|
||||
|
||||
func GetBillExpend(db *DaoDB, userID string, billType int, fromTime, toTime time.Time) (billExpends []*model.BillExpend, err error) {
|
||||
sql := `
|
||||
SELECT b.*
|
||||
FROM user_bill a
|
||||
JOIN bill_expend b ON b.bill_id = a.bill_id
|
||||
WHERE a.deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{utils.DefaultTimeValue}
|
||||
if userID != "" {
|
||||
sql += ` AND a.user_id = ?`
|
||||
sqlParams = append(sqlParams, userID)
|
||||
}
|
||||
if billType != 0 {
|
||||
sql += ` AND b.type = ?`
|
||||
sqlParams = append(sqlParams, billType)
|
||||
}
|
||||
if fromTime != utils.ZeroTimeValue {
|
||||
sql += ` AND b.created_at >= ?`
|
||||
sqlParams = append(sqlParams, fromTime)
|
||||
}
|
||||
if toTime != utils.ZeroTimeValue {
|
||||
sql += ` AND b.created_at <= ?`
|
||||
sqlParams = append(sqlParams, toTime)
|
||||
}
|
||||
err = GetRow(db, &billExpends, sql, sqlParams)
|
||||
return billExpends, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user