/// <summary> /// 获取邀请码 /// </summary> /// <param name="Area"></param> /// <returns></returns> public object GetInviteCode(string Area) { List <EnterpriseInviteCode> InviteCodes = Kily.Set <EnterpriseInviteCode>().Where(t => t.UseTypePath.Equals(Area)) .Where(t => t.IsDelete == false) .Where(t => t.EffectiveSt <= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"))) .Where(t => t.EffectiveEt >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"))).ToList(); EnterpriseInviteCode InviteCode = InviteCodes[(new Random()).Next(InviteCodes.Count)]; InviteCode.IsDelete = true; UpdateField <EnterpriseInviteCode>(InviteCode, "IsDelete"); return(Convert.ToBase64String(Encoding.Default.GetBytes(InviteCode.InviteCode))); }
public string CreateInviteCode() { EnterpriseInviteCode code = new EnterpriseInviteCode(); var Province = Kily.Set <SystemProvince>().ToList(); foreach (var item in Province) { code.InviteCode = $"{item.Code}-{DateTime.Now.Millisecond}-{ValidateCode.CreateValidateCode()}"; code.UseTypePath = item.Id.ToString(); code.EffectiveSt = DateTime.Parse("2019-09-16"); code.EffectiveEt = DateTime.Parse("2019-10-15"); Insert(code); } return(ServiceMessage.INSERTSUCCESS); }
/// <summary> /// 微信推广注册 /// </summary> /// <param name="Param"></param> /// <returns></returns> public object WeChatRegist(RequestEnterprise Param) { Param.InviteCode = Encoding.Default.GetString(Convert.FromBase64String(Param.InviteCode)); EnterpriseInviteCode InviteCode = Kily.Set <EnterpriseInviteCode>().Where(t => t.InviteCode.Equals(Param.InviteCode)).FirstOrDefault(); InviteCode.UseCompany = Param.CompanyName; InviteCode.UseCompanyType = Param.CompanyType; InviteCode.UsePhone = Param.CompanyPhone; InviteCode.UseTime = DateTime.Now; List <string> Fields = new List <string> { "UseCompany", "UseCompanyType", "UsePhone", "UseTime" }; UpdateField(InviteCode, null, Fields); EnterpriseInfo Info = Param.MapToEntity <EnterpriseInfo>(); return(Insert(Info) ? ServiceMessage.INSERTSUCCESS : ServiceMessage.INSERTFAIL); }