go-common/app/admin/main/mcn/model/request_example.go
2019-04-22 18:49:16 +08:00

63 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"encoding/csv"
"fmt"
"time"
xtime "go-common/library/time"
)
// QueryActivityByIDReq arg
type QueryActivityByIDReq struct {
FromDate string `form:"from_date"` // 20180101
ToDate string `form:"to_date"` // 20180102 closed interval [20180101, 20180102]
ID int64 `form:"id"` // activity id, if not 0, FromDate and toDate not used
PageArg
ExportArg
}
//UpSummaryBonusInfo bonus for one up info
type UpSummaryBonusInfo struct {
Mid int64 `json:"mid"`
BilledMoney float64 `json:"billed_money"`
UnbilledMoney float64 `json:"unbilled_money"`
LastBillTime string `json:"last_bill_time"` // 20180101 最近结算时间
TmpBillTime xtime.Time `json:"-"` // 用来计算LastBillTime
TotalBonusMoney float64 `json:"total_bonus_money"` // 所有的中奖金额
}
//QueryUpBonusByMidResult query result
type QueryUpBonusByMidResult struct {
Result []*UpSummaryBonusInfo `json:"result"`
PageResult
}
//GetFileName get file name
func (q *QueryUpBonusByMidResult) GetFileName() string {
return fmt.Sprintf("%s_%s.csv", "结算记录", time.Now().Format(dateTimeFmt))
}
//ToCsv to buffer
func (q *QueryUpBonusByMidResult) ToCsv(writer *csv.Writer) {
var title = []string{
"UID",
"已结算",
"未结算",
"最近结算时间"}
writer.Write(title)
if q == nil {
return
}
for _, v := range q.Result {
var record []string
record = append(record,
intFormat(v.Mid),
floatFormat(v.BilledMoney),
floatFormat(v.UnbilledMoney),
v.LastBillTime,
)
writer.Write(record)
}
}