SysCompanyAd GetNewCompanyAds( ) { SysCompanyAd ad = new SysCompanyAd { AdsClicked = 0, AdsCompanyID = AppContext.Company.Id, AdsDate = txtDate.Value, AdsEndDate = txtEndDate.Value, AdsPic = string.Empty, AdsTitle = txtAdsTitle.Text.Trim( ), AreaDepth = txtAreaDepth.MulitAreaDepth, IsDeleted = false, AdsPointSum = 0, SexLimit = GetSexLimit( ), AdsMemberLimit = GetMemberLimit( ), AdsClickLimit = GetAdsLimit( ), AdsDayLimitAmount = txtDayLimitAmount.Value, AdsDayLimitSum = Formatter.ToDecimal(txtDayLimitSum.Value), AdsQuestion = txtQuestion.Text.Trim( ), AdsAnswer1 = txtAnswerA.Text.Trim( ), AdsAnswer2 = txtAnswerB.Text.Trim( ), AdsAnswer3 = txtAnswerC.Text.Trim( ), AdsAnswer4 = txtAnswerD.Text.Trim( ), AdsRightAnswer = GetRightAnswer( ), IsPass = false }; return ad; }
public void Insert(string AdsTitle,int? AdsCompanyID,DateTime? AdsDate,DateTime? AdsEndDate,string AreaDepth,int? SexLimit,bool? IsDeleted,int? AdsClicked,string AdsPic,bool? IsPass,int? AdsClickLimit,int? AdsMemberLimit,int? AdsDayLimitAmount,decimal? AdsDayLimitSum,string AdsQuestion,string AdsAnswer1,string AdsAnswer2,string AdsAnswer3,string AdsAnswer4,int? AdsRightAnswer,decimal? AdsPointSum) { SysCompanyAd item = new SysCompanyAd(); item.AdsTitle = AdsTitle; item.AdsCompanyID = AdsCompanyID; item.AdsDate = AdsDate; item.AdsEndDate = AdsEndDate; item.AreaDepth = AreaDepth; item.SexLimit = SexLimit; item.IsDeleted = IsDeleted; item.AdsClicked = AdsClicked; item.AdsPic = AdsPic; item.IsPass = IsPass; item.AdsClickLimit = AdsClickLimit; item.AdsMemberLimit = AdsMemberLimit; item.AdsDayLimitAmount = AdsDayLimitAmount; item.AdsDayLimitSum = AdsDayLimitSum; item.AdsQuestion = AdsQuestion; item.AdsAnswer1 = AdsAnswer1; item.AdsAnswer2 = AdsAnswer2; item.AdsAnswer3 = AdsAnswer3; item.AdsAnswer4 = AdsAnswer4; item.AdsRightAnswer = AdsRightAnswer; item.AdsPointSum = AdsPointSum; item.Save(UserName); }
public static bool CheckCompanyAdsCanClick(SysMember user, SysCompanyAd item, SysCompany company, decimal userLastOrderSum, out string message) { if (item == null || company == null || user == null) { message = "参数错误!"; goto lbl_end; } if (item.IsDeleted.HasValue && item.IsDeleted.Value) { message = "此广告已经无效"; goto lbl_end; } //common double check int nCode = CompanyAdsBLL.ExecuteCheckFunc(user.Id, user.MemberSex, item.AdsID, userLastOrderSum); if (nCode < 0) { message = AdsCheckResult.ContainsKey(nCode) ? AdsCheckResult[nCode] : "你无权浏览此广告!"; goto lbl_end; } //检测是否达到每日最大浏览量限制 nCode = CheckUserAdsClickSettings(user.Id, userLastOrderSum); if (nCode != -1) { //message = nCode == -2 ? AdsCheckResult[-12] : string.Format("根据您上月消费额<br/>每天最多能看{0}条广告^_^", nCode); if (nCode == -2) message = AdsCheckResult[-12]; else if (nCode == -3) message = AdsCheckResult[-13]; else message = string.Format(AdsCheckResult[-14], nCode); goto lbl_end; } //当会员在第3个月,或者后续某个月份没有产生过消费, //if (user.MemberDate.HasValue) //{ // //注册月份的1号 // DateTime dtRegMonth = user.MemberDate.Value.Date.AddDays((double)(1 - user.MemberDate.Value.Day)); // DateTime dtNowMonth = DateTime.Today.AddDays((double)(1 - DateTime.Today.Day)); // if (dtNowMonth >= dtRegMonth.AddMonths(3) && userLastOrderSum == 0) // { // message = "您上月未消费过<br/>暂无权限浏览广告^_^"; // goto lbl_end; // } //} //检查是否符合设定的消费额 if (GetCompanyAdPoint(userLastOrderSum, item.AdsID) == 0) { message = AdsCheckResult[-10]; goto lbl_end; } //检测是否浏览仅限一次的广告 if (CheckUserOnceClickLimitAds(user.Id, company.Id)) { message = "你已浏览过此商家投放的广告!"; goto lbl_end; } message = string.Empty; return true; lbl_end: return false; }