public ActionResult CouponConfigInfo(Guid?activityId) { NewCouponManager manager = new NewCouponManager(); NewCouponActivity result = new NewCouponActivity(); ViewBag.ActivityId = activityId ?? Guid.Empty; if (activityId != null && activityId != Guid.Empty) { result = manager.GetNewCouponConfigByActivityId(activityId.Value); } return(View(result)); }
public NewCouponActivity GetNewCouponConfigByActivityId(Guid activityId) { NewCouponActivity result = new NewCouponActivity(); List <RecommendActivityConfig> recommendActivity = new List <RecommendActivityConfig>(); List <CouponRulesConfig> couponRules = new List <CouponRulesConfig>(); List <SE_GetPromotionActivityCouponInfoConfig> activityCouponInfo = new List <SE_GetPromotionActivityCouponInfoConfig>(); try { dbScopeReadManager.Execute(conn => { result = DALNewCoupon.SelectNewCouponConfig(conn, activityId, "", 1, 99).FirstOrDefault(); recommendActivity = DALNewCoupon.SelectRecommendActivityConfig(conn, activityId); couponRules = DALNewCoupon.SelectCouponRulesConfig(conn, activityId); if (couponRules != null && couponRules.Any()) { activityCouponInfo = DALNewCoupon.SelectActivityCouponInfo(conn, string.Join(",", couponRules.Select(x => x.RulesGUID))); } }); if (result != null) { result.RecommendActivityForInit = recommendActivity.Where(x => x.ActivityType.Equals(RecommendActivityType.InitActivity)).ToList(); result.RecommendActivityForSuccess = recommendActivity.Where(x => x.ActivityType.Equals(RecommendActivityType.SuccessActivity)).ToList(); if (activityCouponInfo != null && activityCouponInfo.Any()) { result.CouponRulesConfig = (from c in couponRules join s in activityCouponInfo on c.RulesGUID equals s.GetRuleGUID into temp from t in temp.DefaultIfEmpty() select new CouponRulesConfig() { RulesGUID = c.RulesGUID, ValidDays = t.ValidDays, ValidStartDateTime = t.ValidStartDateTime, ValidEndDateTime = t.ValidEndDateTime, MinMoney = t.MinMoney, Description = t.Description, Quantity = t.Quantity, SingleQuantity = t.SingleQuantity, UserType = t.UserType }).ToList(); } } } catch (Exception ex) { logger.Error(ex); } return(result); }
public static int UpdateNewCouponConfig(SqlConnection conn, NewCouponActivity data, string user) { var sql = @"UPDATE Activity..CouponActivityConfig SET IsEnabled = @IsEnabled , ActivityName = @ActivityName , Channel = @Channel , StartTime = @StartTime , EndTime = @EndTime , ValidDays = @ValidDays , QuantityPerUser = @QuantityPerUser , DailyQuantityPerUser = @DailyQuantityPerUser , PageQuantity = @PageQuantity , IsNewUser = @IsNewUser , HeadImgUrl = @HeadImgUrl , BottomImgUrl = @BottomImgUrl , Description = @Description , VerifyCodeNum = @VerifyCodeNum , VerifyImgNum = @VerifyImgNum , AutoEndNum = @AutoEndNum , VerifyCodeErrorNum = @VerifyCodeErrorNum , MobileLockTime = @MobileLockTime , IsDefaultPage = @IsDefaultPage , IsShowLuckFriends = @IsShowLuckFriends , SuccessHeadImgUrl = @SuccessHeadImgUrl , SuccessBottomImgUrl = @SuccessBottomImgUrl , ButtonText = @ButtonText , ButtonUrl = @ButtonUrl , DefaultFailText = @DefaultFailText, DefaultFailUrl = @DefaultFailUrl, SuccessButtonUrl = @SuccessButtonUrl , FailButtonUrl = @FailButtonUrl , SuccessMsg = @SuccessMsg , NoStartMsg = @NoStartMsg , OverdueMsg = @OverdueMsg , NoCouponMsg = @NoCouponMsg , PageClosedMsg = @PageClosedMsg , DuplicateAttemptMsg = @DuplicateAttemptMsg , ServiceExceptionsMsg = @ServiceExceptionsMsg , BlackHouseMsg = @BlackHouseMsg , LastUpdateUser = @LastUpdateUser , LastUpdateDateTime = GETDATE() , Owner = @Owner , PageType = @PageType , IsRandom = @IsRandom , RandomGroupId = @RandomGroupId , AppShareId = @AppShareId , RandomBigGroupId =@RandomBigGroupId, RandomMinPos = @RandomMinPos, RandomMaxPos = @RandomMaxPos, FinishCount = @FinishCount, ActivityDesc =@ActivityDesc WHERE ActivityId = @ActivityId ;"; return(conn.Execute(sql, new { ActivityId = data.ActivityId, IsEnabled = data.IsEnabled, ActivityName = data.ActivityName, Channel = data.Channel, StartTime = data.StartTime, EndTime = data.EndTime, ValidDays = data.ValidDays, QuantityPerUser = data.QuantityPerUser, DailyQuantityPerUser = data.DailyQuantityPerUser, PageQuantity = data.PageQuantity, IsNewUser = data.IsNewUser, HeadImgUrl = data.HeadImgUrl, BottomImgUrl = data.BottomImgUrl, Description = data.Description, VerifyCodeNum = data.VerifyCodeNum, VerifyImgNum = data.VerifyImgNum, AutoEndNum = data.AutoEndNum, VerifyCodeErrorNum = data.VerifyCodeErrorNum, MobileLockTime = data.MobileLockTime, IsDefaultPage = data.IsDefaultPage, IsShowLuckFriends = data.IsShowLuckFriends, SuccessHeadImgUrl = data.SuccessHeadImgUrl, SuccessBottomImgUrl = data.SuccessBottomImgUrl, ButtonText = data.ButtonText, ButtonUrl = data.ButtonUrl, DefaultFailText = data.DefaultFailText, DefaultFailUrl = data.DefaultFailUrl, SuccessButtonUrl = data.SuccessButtonUrl, FailButtonUrl = data.FailButtonUrl, SuccessMsg = data.SuccessMsg, NoStartMsg = data.NoStartMsg, OverdueMsg = data.OverdueMsg, NoCouponMsg = data.NoCouponMsg, PageClosedMsg = data.PageClosedMsg, DuplicateAttemptMsg = data.DuplicateAttemptMsg, ServiceExceptionsMsg = data.ServiceExceptionsMsg, BlackHouseMsg = data.BlackHouseMsg, LastUpdateUser = user, Owner = data.Owner, PageType = data.PageType, IsRandom = data.IsRandom, RandomGroupId = data.RandomGroupId, AppShareId = data.AppShareId, RandomBigGroupId = data.RandomBigGroupId, RandomMinPos = data.RandomMinPos, RandomMaxPos = data.RandomMaxPos, FinishCount = data.FinishCount, ActivityDesc = data.ActivityDesc }, commandType: CommandType.Text)); }
public bool UpsertNewConponConfig(NewCouponActivity model, string user) { var result = false; var msg = string.Empty; try { dbScopeManager.CreateTransaction(conn => { var flag = false; if (model != null) { if (model.ActivityId != Guid.Empty) { msg = "更新配置"; flag = DALNewCoupon.UpdateNewCouponConfig(conn, model, user) > 0; } else { msg = "添加配置"; model.ActivityId = Guid.NewGuid(); flag = DALNewCoupon.InsertNewCouponConfig(conn, model, user) > 0; } if (model.RecommendActivityForInit != null && model.RecommendActivityForInit.Any()) { model.AllRecommendActivity.AddRange(model.RecommendActivityForInit); } if (model.RecommendActivityForSuccess != null && model.RecommendActivityForSuccess.Any()) { model.AllRecommendActivity.AddRange(model.RecommendActivityForSuccess); } if (flag) { DALNewCoupon.DeleteRecommendActivityByActivityId(conn, model.ActivityId); DALNewCoupon.DeleteCouponRulesConfig(conn, model.ActivityId); if (model.AllRecommendActivity != null && model.AllRecommendActivity.Any()) { foreach (var item in model.AllRecommendActivity) { item.ActivityId = model.ActivityId; DALNewCoupon.InsertRecommendActivityConfig(conn, item); } } if (model.CouponRulesConfig != null && model.CouponRulesConfig.Any()) { foreach (var item in model.CouponRulesConfig) { item.ActivityId = model.ActivityId; DALNewCoupon.InsertCouponRulesConfig(conn, item); } } } result = true; } }); if (result) { model.AllRecommendActivity = new List <RecommendActivityConfig>(); InsertLog("UpsertNewConponConfig", model.ActivityId.ToString(), JsonConvert.SerializeObject(model), msg, user, LogType); Thread.Sleep(2000); RefreshRandomCouponCache(model.ActivityId); } } catch (Exception ex) { logger.Error(ex); } return(result); }