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 SettleCenterAgentList(c *gin.Context, req md.SettleCenterDataReq) md.SettleCenterDataRes { engine := db.Db NewOriginalWxAdDataDb := implement.NewAgentListDb(engine) user := GetUser(c) appId := GetAgentIdStr(c, user.AdmId, req.Name, req.Account) AgentList, total, _ := NewOriginalWxAdDataDb.FindAgentListBySettleType(c.GetString("mid"), appId, req.State, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) data := make([]md.SettleCenterDataData, 0) if len(AgentList) > 0 { for _, v := range AgentList { var tmp = md.SettleCenterDataData{ Id: utils.IntToStr(v.AgentId), SettleType: utils.IntToStr(v.SettlementType), UpdateAt: v.UpdateAt, } tmpApplet := GetAgentInfo(c, v.AgentId) 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 SettleCenterAgentSave(c *gin.Context, req md.SettleCenterDataSaveReq) { NewAgentListDb := implement.NewAgentListDb(db.Db) data, _ := NewAgentListDb.GetAgentList(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 SettleCenterAgentDetail(c *gin.Context, req md.SettleCenterDataDetailReq) md.SettleCenterDataDetailRes { engine := db.Db NewAgentSettlementDb := implement.NewAgentSettlementDb(engine) AgentList, total, _ := NewAgentSettlementDb.FindAgentSettlementList(c.GetString("mid"), req.Id, "", "", "", req.StartTime, req.EndTime, utils.StrToInt(req.Page), utils.StrToInt(req.Limit)) data := make([]md.SettleCenterDataDetailData, 0) if len(AgentList) > 0 { for _, v := range AgentList { 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 }