public void OperatorAgent(Wechat_AgentEntity agentEntity) { OperatorAgent operators = new OperatorAgent(); operators.Id = agentEntity.Id; operators.Pid = agentEntity.Pid; operators.Tid = agentEntity.Tid; operators.OpenId = agentEntity.OpenId; operators.nickname = agentEntity.nickname; operators.Sex = agentEntity.Sex; operators.HeadimgUrl = agentEntity.HeadimgUrl; operators.Province = agentEntity.Province; operators.City = agentEntity.City; operators.Country = agentEntity.Country; operators.LV = agentEntity.LV; operators.profit = agentEntity.profit; operators.Cashout = agentEntity.Cashout; operators.EndDate = agentEntity.EndDate; operators.banner = agentEntity.banner; operators.realname = agentEntity.realname; operators.contact = agentEntity.contact; operators.alipay = agentEntity.alipay; operators.CreateDate = agentEntity.CreateDate; operators.IPAddress = Net.Ip; operators.IPAddressName = IPLocation.GetLocation(Net.Ip); operators.LogTime = DateTime.Now; operators.Token = DESEncrypt.Encrypt(Guid.NewGuid().ToString()); operators.FuDong = agentEntity.FuDong; operators.OrganizeId = agentEntity.OrganizeId; operators.Category = agentEntity.Category; OperatorAgentProvider.Provider.AddCurrent(operators); }
public ActionResult Index(int?id) { //1.2根据注册的微信id去用户表中匹配是否有此员工 Wechat_AgentEntity agentEntity = agentBll.GetEntityByOpenId(CurrentWxUser.OpenId);//"oQU_IwcWO42_aBNVXcVzungZA0uw" if (agentEntity == null) { int?tid = null; var pidEntity = agentBll.GetEntity(id);//上级 if (pidEntity != null) { if (!string.IsNullOrEmpty(pidEntity.Tid.ToString())) { tid = pidEntity.Tid; } else { tid = id; } } else { tid = id; } Wechat_AgentEntity agentEntityNew = new Wechat_AgentEntity() { OpenId = CurrentWxUser.OpenId, nickname = CurrentWxUser.NickName, Sex = CurrentWxUser.Users.Sex, HeadimgUrl = CurrentWxUser.Users.HeadimgUrl, Province = CurrentWxUser.Users.Province, City = CurrentWxUser.Users.City, //微信城市 Country = CurrentWxUser.Users.Country, Pid = id, //设置上级id为访问id Tid = tid, //获取上级中的顶级id LV = "普通代理" }; agentBll.SaveForm(null, agentEntityNew); //如果父级和顶级为null,坚决赋值,更新null为当前id,或者当前机构就是顶级员工 Wechat_AgentEntity agentEntity2 = agentBll.GetEntityByOpenId(CurrentWxUser.OpenId); if (agentEntity2 != null) { if (string.IsNullOrEmpty(agentEntity2.Pid.ToString())) { agentEntity2.Pid = agentEntity2.Id; agentEntity2.Tid = agentEntity2.Id; } else if (string.IsNullOrEmpty(agentEntity2.Tid.ToString())) { agentEntity2.Tid = agentEntity2.Pid; } } agentBll.SaveForm(agentEntity2.Id, agentEntity2); } OperatorAgent operators = new OperatorAgent(); operators.Id = agentEntity.Id; operators.Pid = agentEntity.Pid; operators.OpenId = agentEntity.OpenId; operators.nickname = agentEntity.nickname; operators.Sex = agentEntity.Sex; operators.HeadimgUrl = agentEntity.HeadimgUrl; operators.Province = agentEntity.Province; operators.City = agentEntity.City; operators.Country = agentEntity.Country; operators.LV = agentEntity.LV; operators.profit = agentEntity.profit; operators.Cashout = agentEntity.Cashout; operators.EndDate = agentEntity.EndDate; operators.banner = agentEntity.banner; operators.realname = agentEntity.realname; operators.contact = agentEntity.contact; operators.alipay = agentEntity.alipay; operators.CreateDate = agentEntity.CreateDate; operators.IPAddress = Net.Ip; operators.IPAddressName = IPLocation.GetLocation(Net.Ip); operators.LogTime = DateTime.Now; operators.Token = DESEncrypt.Encrypt(Guid.NewGuid().ToString()); OperatorAgentProvider.Provider.AddCurrent(operators); return(RedirectToAction("Index", "Agent", new { id = id })); }