public async Task GetAgentTest() { using SimpleClicksSoapClient client = await new SimpleClicksSoapClient( new Uri(ServiceUri), new NetworkCredential(Username, Password)).Configure(); GetAgentsResponse getAgents = await client.Request <GetAgentsResponse>(new GetAgentsRequest()); GetAgentResponse getAgent = await client.Request <GetAgentResponse>(new GetAgentRequest(getAgents.Agents[0].AgentId)); TestContext.WriteLine(JsonSerializer.Serialize(getAgent, new JsonSerializerOptions() { WriteIndented = true })); Assert.IsNotNull(getAgents); }
public GetAgentResponse GetAgentByOpenIdOld(GetByOpenIdRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { var response = new GetAgentResponse(); var agent = _agentRepository.GetAgentByTopParentAgent(request.OpenId, request.TopParentAgent); if (agent != null) { response.agent = ToModel(agent, request.TopParentAgent); return(response); } else { response.ErrCode = -1;//无值 return(response); } }
/// <summary> /// 添加代理人信息 /// </summary> /// <param name="request"></param> /// <param name="pairs"></param> /// <returns></returns> public GetAgentResponse AddAgent(PostAddAgentRequest request, IEnumerable <KeyValuePair <string, string> > pairs) { var response = new GetAgentResponse(); bx_agent agent = new bx_agent(); //备注:临时屏蔽,暂时先不上 agent = _agentRepository.GetAgentIsTop(request.TopParentAgent); if (agent == null) { response.ErrCode = -4;//顶级代理人不存在 return(response); } if (!_agentRepository.IsContainSon(request.TopParentAgent, request.AgentId)) { response.ErrCode = -5;//顶级代理下面不包含子集代理 return(response); } agent = new bx_agent(); agent = _agentRepository.GetAgentByPhoneTopAgent(request.Mobile, request.TopParentAgent); if (agent != null) { response.ErrCode = -1;//手机号已存在 return(response); } agent = new bx_agent(); agent = _agentRepository.GetAgentByTopParentAgent(request.OpenId, request.TopParentAgent); if (agent != null) { response.ErrCode = -2;//OpenId已存在 response.agent = ToModel(agent, request.TopParentAgent); return(response); } int agentlevel = _agentRepository.GetAgentLevel(GetAgent(request.AgentId).ParentAgent); if (agentlevel > 2) { response.ErrCode = -3;//不允许新增下一级代理 return(response); } //插入bx_agent bx_agent model = new bx_agent(); model.AgentName = request.AgentName; model.Mobile = request.Mobile; model.OpenId = request.OpenId; model.ParentAgent = request.AgentId;//有问题 #region 分配默认值 model.CreateTime = DateTime.Now; model.IsBigAgent = 1; model.CommissionType = 0; model.IsUsed = 0; model.IsGenJin = 0; model.IsDaiLi = 0; model.IsShow = 0; model.IsShowCalc = 0; model.IsLiPei = 0; model.AgentType = 0; model.MessagePayType = 1; //发短信走当前代理人 model.RegType = 0; //小龙说默认走单店 暂无实际需要 model.IsQuote = 1; model.IsSubmit = 1; #endregion long agentId = _agentRepository.Add(model); if (agentId > 0) { //根据agentId更新ShareCode int update = 0; update = _agentRepository.Update(agentId); if (update > 0) { //存入缓存,并读取该记录 //string agentCacheKey = string.Format("agent_cacke_key-{0}-{1}", agentId, request.AgentId // ); var agentCache = _agentRepository.GetAgent((int)agentId); //HttpRuntime.Cache.Insert(agentCacheKey, agentCache, null, DateTime.Now.AddHours(12), TimeSpan.Zero, CacheItemPriority.High, null); response.agent = ToModel(agentCache, request.TopParentAgent); } } return(response); }