| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- package service
- import (
- "context"
- "encoding/json"
- "errors"
- "bet24.com/log"
- "bet24.com/servers/coreservice/agent"
- "bet24.com/servers/coreservice/client"
- )
- // 刷新配置
- func (s *Server) AgentRefreshConfig(ctx context.Context, args *client.Request, reply *client.Reply) error {
- agent.RefreshConfig()
- reply.Resp.RetCode = 1
- reply.Resp.Data = ""
- return nil
- }
- // 获取配置信息
- func (s *Server) AgentConfigs(ctx context.Context, args *client.Request, reply *client.Reply) error {
- info := agent.GetJsonConfigs()
- reply.Resp.RetCode = 1
- reply.Resp.Data = info
- return nil
- }
- // 代理申请
- func (s *Server) AgentApply(ctx context.Context, args *client.Request, reply *client.Reply) error {
- var req client.AgentApply_req
- if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
- log.Debug("Server.AgentApply unmarshal fail %v", err)
- return errors.New("unmarshal error")
- }
- retCode := agent.Apply(req.UserId, req.Memo)
- d, _ := json.Marshal(retCode)
- reply.Resp.RetCode = 1
- reply.Resp.Data = string(d)
- return nil
- }
- // 代理绑码
- func (s *Server) AgentBind(ctx context.Context, args *client.Request, reply *client.Reply) error {
- var req client.AgentBind_req
- if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
- log.Debug("Server.AgentBind unmarshal fail %v", err)
- return errors.New("unmarshal error")
- }
- var respData struct {
- RetCode int
- Items interface{}
- }
- respData.RetCode, respData.Items = agent.Bind(req.UserId, req.HigherUserId)
- d, _ := json.Marshal(respData)
- reply.Resp.RetCode = 1
- reply.Resp.Data = string(d)
- return nil
- }
- // 代理信息
- func (s *Server) AgentInfo(ctx context.Context, args *client.Request, reply *client.Reply) error {
- var req client.Request_base
- if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
- log.Debug("Server.AgentInfo unmarshal fail %v", err)
- return errors.New("unmarshal error")
- }
- info := agent.Info(req.UserId)
- d, _ := json.Marshal(info)
- reply.Resp.RetCode = 1
- reply.Resp.Data = string(d)
- return nil
- }
- // 会员
- func (s *Server) AgentMembers(ctx context.Context, args *client.Request, reply *client.Reply) error {
- var req client.Agent_req
- if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
- log.Debug("Server.AgentMembers unmarshal fail %v", err)
- return errors.New("unmarshal error")
- }
- info := agent.Members(req.UserId, req.PageIndex, req.PageSize)
- d, _ := json.Marshal(info)
- reply.Resp.RetCode = 1
- reply.Resp.Data = string(d)
- return nil
- }
- // 代理统计
- func (s *Server) AgentStat(ctx context.Context, args *client.Request, reply *client.Reply) error {
- var req client.Agent_req
- if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
- log.Debug("Server.AgentStat unmarshal fail %v", err)
- return errors.New("unmarshal error")
- }
- info := agent.Stat(req.UserId, req.PageIndex, req.PageSize)
- d, _ := json.Marshal(info)
- reply.Resp.RetCode = 1
- reply.Resp.Data = string(d)
- return nil
- }
- // 收益记录
- func (s *Server) AgentCommissionLog(ctx context.Context, args *client.Request, reply *client.Reply) error {
- var req client.Agent_req
- if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
- log.Debug("Server.AgentCommissionLog unmarshal fail %v", err)
- return errors.New("unmarshal error")
- }
- info := agent.CommissionLog(req.UserId, req.FromUserId, req.PageIndex, req.PageSize)
- d, _ := json.Marshal(info)
- reply.Resp.RetCode = 1
- reply.Resp.Data = string(d)
- return nil
- }
- // 提取收益
- func (s *Server) AgentCommissionToAmount(ctx context.Context, args *client.Request, reply *client.Reply) error {
- var req client.Request_base
- if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
- log.Debug("Server.AgentCommissionToAmount unmarshal fail %v", err)
- return errors.New("unmarshal error")
- }
- var info struct {
- RetCode int
- Commission int
- }
- info.RetCode, info.Commission = agent.CommissionToAmount(req.UserId, req.IpAddress)
- d, _ := json.Marshal(info)
- reply.Resp.RetCode = 1
- reply.Resp.Data = string(d)
- return nil
- }
- // 获取群组
- func (s *Server) AgentGetGroup(ctx context.Context, args *client.Request, reply *client.Reply) error {
- var req client.Request_base
- if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
- log.Debug("Server.AgentGroup json unmarshal fail %v", err)
- return errors.New("unmarshal error")
- }
- ret := agent.GetGroup(req.UserId)
- d, _ := json.Marshal(ret)
- reply.Resp.RetCode = 1
- reply.Resp.Data = string(d)
- return nil
- }
- // 修改群组
- func (s *Server) AgentUpdateGroup(ctx context.Context, args *client.Request, reply *client.Reply) error {
- var req client.AgentGroup_req
- if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
- log.Debug("Server.AgentUpdateGroup json unmarshal fail %v", err)
- return errors.New("unmarshal error")
- }
- ret := agent.UpdateGroup(req.UserId, req.Id, req.Name, req.Url)
- d, _ := json.Marshal(ret)
- reply.Resp.RetCode = 1
- reply.Resp.Data = string(d)
- return nil
- }
|