123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- package http
- import (
- "fmt"
- "net/http"
- "time"
- "go-common/library/log"
- bm "go-common/library/net/http/blademaster"
- "go-common/library/net/http/blademaster/render"
- )
- func upIncomeList(c *bm.Context) {
- v := new(struct {
- MIDs []int64 `form:"mids,split"`
- Type int `form:"type"`
- GroupType int `form:"group_type" default:"1"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- MinIncome int64 `form:"min_income"`
- MaxIncome int64 `form:"max_income"`
- From int `form:"from" validate:"min=0" default:"0"`
- Limit int `form:"limit" validate:"min=1" default:"20"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- data, total, err := incomeSvr.UpIncomeList(c, v.MIDs, v.Type, v.GroupType, v.FromTime, v.ToTime, v.MinIncome, v.MaxIncome, v.From, v.Limit)
- if err != nil {
- log.Error("growup incomeSvr.UpIncomeList error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 0,
- "message": "0",
- "result": data,
- "paging": map[string]int{
- "page_size": v.Limit,
- "total": total,
- },
- }))
- }
- func upIncomeListExport(c *bm.Context) {
- v := new(struct {
- MIDs []int64 `form:"mids,split"`
- Type int `form:"type"`
- GroupType int `form:"group_type" default:"1"`
- FromTime int64 `form:"from_time" validate:"min=1,required"`
- ToTime int64 `form:"to_time" validate:"min=1,required"`
- MinIncome int64 `form:"min_income"`
- MaxIncome int64 `form:"max_income"`
- From int `form:"from" validate:"min=0" default:"0"`
- Limit int `form:"limit" validate:"min=1" default:"20"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- content, err := incomeSvr.UpIncomeListExport(c, v.MIDs, v.Type, v.GroupType, v.FromTime, v.ToTime, v.MinIncome, v.MaxIncome, v.From, v.Limit)
- if err != nil {
- log.Error("growup incomeSvr.UpIncomeListExport error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.Render(http.StatusOK, CSV{
- Content: content,
- Title: fmt.Sprintf("%s-%s", time.Now().Format("2006-01-02"), "up_income"),
- })
- }
- func upIncomeStatis(c *bm.Context) {
- v := new(struct {
- MIDs []int64 `form:"mids,split"`
- Type int `form:"type"`
- GroupType int `form:"group_type" default:"1"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- data, err := incomeSvr.UpIncomeStatis(c, v.MIDs, v.Type, v.GroupType, v.FromTime, v.ToTime)
- if err != nil {
- log.Error("growup incomeSvr.UpIncomeStatis error(%v)", err)
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": err,
- "status": "fail",
- }))
- return
- }
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 0,
- "message": "0",
- "result": data,
- "status": "success",
- }))
- }
- func archiveStatis(c *bm.Context) {
- v := new(struct {
- CategoryID []int64 `form:"category_id,split"`
- Type int `form:"type"`
- GroupType int `form:"group_type" default:"1"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- data, err := incomeSvr.ArchiveStatis(c, v.CategoryID, v.Type, v.GroupType, v.FromTime, v.ToTime)
- if err != nil {
- log.Error("growup incomeSvr.ArchiveStatis error(%v)", err)
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": err,
- "status": "fail",
- }))
- return
- }
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 0,
- "message": "0",
- "result": data,
- "status": "success",
- }))
- }
- func archiveSection(c *bm.Context) {
- v := new(struct {
- CategoryID []int64 `form:"category_id,split"`
- Type int `form:"type"`
- GroupType int `form:"group_type" default:"1"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- data, err := incomeSvr.ArchiveSection(c, v.CategoryID, v.Type, v.GroupType, v.FromTime, v.ToTime)
- if err != nil {
- log.Error("growup incomeSvr.ArchiveSection error(%v)", err)
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": err,
- "status": "fail",
- }))
- return
- }
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 0,
- "message": "0",
- "result": data,
- "status": "success",
- }))
- }
- func archiveDetail(c *bm.Context) {
- v := new(struct {
- MID int64 `form:"mid" validate:"required"`
- Type int `form:"type"`
- GroupType int `form:"group_type" default:"1"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- data, err := incomeSvr.ArchiveDetail(c, v.MID, v.Type, v.GroupType, v.FromTime, v.ToTime)
- if err != nil {
- log.Error("growup incomeSvr.ArchiveDetail error(%v)", err)
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": err,
- "status": "fail",
- }))
- return
- }
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 0,
- "message": "0",
- "result": data,
- "status": "success",
- }))
- }
- func archiveTop(c *bm.Context) {
- v := new(struct {
- AIDs []int64 `form:"aids,split"`
- Type int `form:"type"`
- GroupType int `form:"group_type" default:"1"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- From int `form:"from" validate:"min=0" default:"0"`
- Limit int `form:"limit" validate:"min=1" default:"20"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- data, total, err := incomeSvr.ArchiveTop(c, v.AIDs, v.Type, v.GroupType, v.FromTime, v.ToTime, v.From, v.Limit)
- if err != nil {
- log.Error("growup incomeSvr.ArchiveTop error(%v)", err)
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": err,
- "status": "fail",
- }))
- return
- }
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 0,
- "message": "0",
- "result": data,
- "status": "success",
- "paging": map[string]int{
- "page_size": v.Limit,
- "total": total,
- },
- }))
- }
- func bgmDetail(c *bm.Context) {
- v := new(struct {
- SID int64 `form:"sid"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- From int `form:"from" validate:"min=0" default:"0"`
- Limit int `form:"limit" validate:"min=1" default:"20"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- data, total, err := incomeSvr.BgmDetail(c, v.SID, v.FromTime, v.ToTime, v.From, v.Limit)
- if err != nil {
- log.Error("growup incomeSvr.BgmDetail error(%v)", err)
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": err,
- "status": "fail",
- }))
- return
- }
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 0,
- "message": "0",
- "result": data,
- "status": "success",
- "paging": map[string]int{
- "page_size": v.Limit,
- "total": total,
- },
- }))
- }
- func archiveBreach(c *bm.Context) {
- username, _, err := checkCookie(c)
- if err != nil {
- c.JSON(nil, err)
- return
- }
- v := new(struct {
- Type int `form:"type"`
- AIDs []int64 `form:"aids,split" validate:"required"`
- MID int64 `form:"mid" validate:"required"`
- Reason string `form:"reason" validate:"required"`
- })
- if err = c.Bind(v); err != nil {
- return
- }
- err = incomeSvr.ArchiveBreach(c, v.Type, v.AIDs, v.MID, v.Reason, username)
- if err != nil {
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 500,
- "message": err.Error(),
- }))
- } else {
- c.JSON(nil, nil)
- }
- }
- func archiveBlack(c *bm.Context) {
- v := new(struct {
- Type int `form:"type"`
- AIDs []int64 `form:"aids,split" validate:"required"`
- MID int64 `form:"mid" validate:"required"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- err := incomeSvr.ArchiveBlack(c, v.Type, v.AIDs, v.MID)
- if err != nil {
- log.Error("growup incomeSvr.ArchiveBlack error(%v)", err)
- }
- c.JSON(nil, err)
- }
- func breachList(c *bm.Context) {
- v := new(struct {
- MIDs []int64 `form:"mids,split"`
- AIDs []int64 `form:"aids,split"`
- Type int `form:"type"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- Reason string `form:"reason"`
- From int `form:"from" validate:"min=0" default:"0"`
- Limit int `form:"limit" validate:"min=1" default:"20"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- data, total, err := incomeSvr.BreachList(c, v.MIDs, v.AIDs, v.Type, v.FromTime, v.ToTime, v.Reason, v.From, v.Limit)
- if err != nil {
- log.Error("growup incomeSvr.BreachList error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 0,
- "message": "0",
- "result": data,
- "paging": map[string]int{
- "page_size": v.Limit,
- "total": total,
- },
- }))
- }
- func breachStatis(c *bm.Context) {
- v := new(struct {
- MIDs []int64 `form:"mids,split"`
- AIDs []int64 `form:"aids,split"`
- Type int `form:"type"`
- GroupType int `form:"group_type"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- Reason string `form:"reason"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- data, err := incomeSvr.BreachStatis(c, v.MIDs, v.AIDs, v.Type, v.GroupType, v.FromTime, v.ToTime, v.Reason)
- if err != nil {
- log.Error("growup incomeSvr.BreachStatis error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
- "code": 0,
- "message": "0",
- "result": data,
- "status": "success",
- }))
- }
- func exportBreach(c *bm.Context) {
- v := new(struct {
- MIDs []int64 `form:"mids,split"`
- AIDs []int64 `form:"aids,split"`
- Type int `form:"type"`
- FromTime int64 `form:"from_time" validate:"required,min=1"`
- ToTime int64 `form:"to_time" validate:"required,min=1"`
- Reason string `form:"reason"`
- From int `form:"from" validate:"min=0" default:"0"`
- Limit int `form:"limit" validate:"min=1" default:"20"`
- })
- if err := c.Bind(v); err != nil {
- return
- }
- content, err := incomeSvr.ExportBreach(c, v.MIDs, v.AIDs, v.Type, v.FromTime, v.ToTime, v.Reason, v.From, v.Limit)
- if err != nil {
- log.Error("growup svr.ExportBreach error(%v)", err)
- c.JSON(nil, err)
- return
- }
- c.Render(http.StatusOK, CSV{
- Content: content,
- Title: fmt.Sprintf("%s-%s", time.Now().Format("2006-01-02"), "breach_record"),
- })
- }
|