|
|
@@ -210,12 +210,41 @@ func Register(c *gin.Context) { |
|
|
|
} |
|
|
|
insertAffected, err = db.Db.Insert(&MediumDivisionStrategyModel) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if insertAffected <= 0 { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, "新增 记录失败") |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//5、判断是否为渠道代理邀请 |
|
|
|
if req.AgentId != "" { |
|
|
|
agentDb := implement.NewAgentDb(engine) |
|
|
|
agent, err1 := agentDb.GetAgent(utils.StrToInt(req.AgentId)) |
|
|
|
if err1 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if agent != nil { |
|
|
|
//5.1 新增agent_with_medium记录 |
|
|
|
agentWithMediumDb := implement2.NewAgentWithMediumDb(engine) |
|
|
|
insertAffected, err = agentWithMediumDb.AgentWithMediumInsert(&model.AgentWithMedium{ |
|
|
|
AgentId: utils.StrToInt(req.AgentId), |
|
|
|
MediumId: utils.StrToInt(mediumId), |
|
|
|
CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if insertAffected <= 0 { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, "新增 agent_with_medium 记录失败") |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ip := utils.GetIP(c.Request) |
|
|
|
key := fmt.Sprintf(md.JwtTokenKey, ip, utils.AnyToString(mediumModel.Id)) |
|
|
|
token, err := svc.HandleLoginToken(key, &mediumModel) |
|
|
|