package svc import ( "applet/app/e" "applet/app/md" "applet/app/utils" db "code.fnuoos.com/zhimeng/model.git/src" "code.fnuoos.com/zhimeng/model.git/src/super/implement" "github.com/gin-gonic/gin" ) func SettleCenterMediumList(c *gin.Context, req md.SettleCenterDataReq) md.SettleCenterDataRes { engine := db.Db NewOriginalWxAdDataDb := implement.NewMediumListDb(engine) appId := GetMediumByAccountId(c, req.Name, req.Account) MediumList, total, _ := NewOriginalWxAdDataDb.FindMediumListBySettleType(c.GetString("mid"), appId, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) data := make([]md.SettleCenterDataData, 0) if len(MediumList) > 0 { for _, v := range MediumList { var tmp = md.SettleCenterDataData{ Id: utils.IntToStr(v.MediumId), SettleType: utils.IntToStr(v.SettlementType), UpdateAt: v.UpdateAt, } tmpApplet := GetMediumInfo(c, v.MediumId) if tmpApplet["account"] != "" { tmp.Account = tmpApplet["account"] } if tmpApplet["name"] != "" { tmp.Name = tmpApplet["name"] } data = append(data, tmp) } } res := md.SettleCenterDataRes{ List: data, Total: total, State: md.AccountSettleState, } return res } func SettleCenterMediumSave(c *gin.Context, req md.SettleCenterDataSaveReq) { NewMediumListDb := implement.NewMediumListDb(db.Db) data, _ := NewMediumListDb.GetMediumList(utils.StrToInt(req.Id)) if data == nil { e.OutErr(c, 400, e.NewErr(400, "记录不存在")) return } data.SettlementType = utils.StrToInt(req.SettleType) db.Db.Where("id=?", data.Id).Cols("settlement_type").Update(data) e.OutSuc(c, "success", nil) return } func SettleCenterMediumDetail(c *gin.Context, req md.SettleCenterDataDetailReq) md.SettleCenterDataDetailRes { engine := db.Db NewMediumSettlementDb := implement.NewMediumSettlementDb(engine) MediumList, total, _ := NewMediumSettlementDb.FindMediumSettlementList(c.GetString("mid"), req.Id, "", "", "", req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) data := make([]md.SettleCenterDataDetailData, 0) if len(MediumList) > 0 { for _, v := range MediumList { var tmp = md.SettleCenterDataDetailData{ TimeStr: v.StartDate, BusinessKind: utils.IntToStr(v.BusinessKind), SettleType: utils.IntToStr(v.Kind), AllIncome: utils.Float64ToStr(float64(v.OtherIncome+v.BasicIncome) / 100), BasicIncome: utils.Float64ToStr(float64(v.BasicIncome) / 100), OtherIncome: utils.Float64ToStr(float64(v.OtherIncome) / 100), PayState: utils.IntToStr(v.PayState), State: utils.IntToStr(v.State), } if v.EndDate != "" && v.EndDate != "0000-00-00" { tmp.TimeStr += "~" + v.EndDate } data = append(data, tmp) } } res := md.SettleCenterDataDetailRes{ List: data, Total: total, SettleType: md.AccountSettleState, BusinessKind: md.BusinessKind, SettlePayState: md.SettlePayState, SettleState: md.SettleState, } return res }