public static void WinnerSubmit(WeiActivityWinModel winModel) { Entities.WeiActivityInfoInfo model = _iActivityInfoService.GetActivityModel(winModel.activityId); //添加中奖信息记录 Entities.WeiActivityWinInfoInfo activityWinInfo = new Entities.WeiActivityWinInfoInfo(); activityWinInfo.ActivityId = winModel.activityId; activityWinInfo.AddDate = DateTime.Now; activityWinInfo.UserId = winModel.userId; activityWinInfo.IsWin = winModel.isWin; //消耗积分 if (winModel.integrals > 0) { var factoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create; Mall.Entities.MemberIntegralRecordInfo info = new Mall.Entities.MemberIntegralRecordInfo(); info.UserName = MemberApplication.GetMember(activityWinInfo.UserId).UserName; info.MemberId = activityWinInfo.UserId; info.RecordDate = DateTime.Now; info.ReMark = ((WeiActivityType)model.ActivityType).ToDescription() + "消耗"; info.TypeId = Entities.MemberIntegralInfo.IntegralType.WeiActivity; var memberIntegral = factoryService.Create(Mall.Entities.MemberIntegralInfo.IntegralType.WeiActivity, -winModel.integrals); MemberIntegralApplication.AddMemberIntegral(info, memberIntegral); } if (activityWinInfo.IsWin) { if (winModel.awardType == WeiActivityAwardType.Integral)//积分 { activityWinInfo.AwardName = winModel.awardName + " 积分"; //新增积分记录 var factoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create; Entities.MemberIntegralRecordInfo info = new Entities.MemberIntegralRecordInfo(); info.UserName = MemberApplication.GetMember(activityWinInfo.UserId).UserName; info.MemberId = activityWinInfo.UserId; info.RecordDate = DateTime.Now; info.ReMark = ((WeiActivityType)model.ActivityType).ToDescription() + "中奖"; info.TypeId = Mall.Entities.MemberIntegralInfo.IntegralType.WeiActivity; var memberIntegral = factoryService.Create(Entities.MemberIntegralInfo.IntegralType.WeiActivity, Convert.ToInt32(winModel.awardName));//winModel.integrals为消耗积分 此处不是用户总积分 MemberIntegralApplication.AddMemberIntegral(info, memberIntegral); } else if (winModel.awardType == WeiActivityAwardType.Bonus)//红包 { activityWinInfo.AwardName = winModel.awardName; BonusApplication.SetShareByUserId(winModel.bonusId, false, winModel.userId);//添加红包记录 BonusApplication.IncrReceiveCount(winModel.bonusId); } else { activityWinInfo.AwardName = winModel.awardName; //添加优惠券记录 Entities.CouponRecordInfo recordInfo = new Entities.CouponRecordInfo(); recordInfo.UserId = winModel.userId; recordInfo.UserName = MemberApplication.GetMember(winModel.userId).UserName; recordInfo.ShopId = CouponApplication.GetCouponInfo(winModel.couponId).ShopId; recordInfo.CouponId = winModel.couponId; CouponApplication.AddCouponRecord(recordInfo); } } else { activityWinInfo.AwardName = winModel.awardName; } activityWinInfo.AwardId = winModel.awardId; _iWeiActivityWinService.AddWinner(activityWinInfo); }
public static WeiActivityModel GetActivityModelByBigWheel(long id) { Entities.WeiActivityInfoInfo model = Service.GetActivityModel(id); WeiActivityModel viewModel = new WeiActivityModel(); viewModel.Id = model.Id; viewModel.activityTitle = model.ActivityTitle; viewModel.activityType = (WeiActivityType)model.ActivityType; viewModel.activityDetails = model.ActivityDetails; viewModel.activityUrl = model.ActivityUrl; viewModel.beginTime = model.BeginTime; viewModel.endTime = model.EndTime; viewModel.participationType = (WeiParticipateType)model.ParticipationType; viewModel.participationCount = Convert.ToInt32(model.ParticipationCount); viewModel.consumePoint = model.ConsumePoint; viewModel.codeUrl = model.CodeUrl; viewModel.addDate = model.AddDate; List <WeiActivityAwardModel> listAwardModel = new List <WeiActivityAwardModel>(); var items = Service.GetActivityAwards(model.Id); int awardNum = 0;//获取奖等序号 int falg = 9 - items.Count(); for (int i = 0; i < 9; i++)//创建9宫格实体 { //放空值 ,未中奖 if (i % 2 == 0) { //最高奖等6 ,4以内奖等能均匀分布 if (items.Count() <= 4) { //获取奖项 WeiActivityAwardModel awardModel = new WeiActivityAwardModel(); listAwardModel.Add(awardModel); } else //大于4组奖项 未中奖显示不能均匀分布 { if (falg > 0) { //获取奖项 WeiActivityAwardModel awardModel = new WeiActivityAwardModel(); listAwardModel.Add(awardModel); falg--; } else { //获取奖项 WeiActivityAwardModel awardModel = new WeiActivityAwardModel(); awardModel.Id = items[awardNum].Id; awardModel.activityId = items[awardNum].ActivityId; awardModel.awardCount = items[awardNum].AwardCount; awardModel.awardLevel = items[awardNum].AwardLevel; awardModel.awardType = (WeiActivityAwardType)items[awardNum].AwardType; awardModel.bonusId = items[awardNum].BonusId; awardModel.couponId = items[awardNum].CouponId; awardModel.integral = items[awardNum].Integral; awardModel.couponId = items[awardNum].CouponId; awardModel.integral = items[awardNum].Integral; if (awardModel.couponId != 0) { awardModel.couponName = CouponApplication.GetCouponInfo(long.Parse(items[awardNum].CouponId.ToString())).CouponName; } awardModel.proportion = items[awardNum].Proportion; listAwardModel.Add(awardModel); awardNum++; } } } else { //奖等未取完 if (items.Count() > awardNum) { //获取奖项 WeiActivityAwardModel awardModel = new WeiActivityAwardModel(); awardModel.Id = items[awardNum].Id; awardModel.activityId = items[awardNum].ActivityId; awardModel.awardCount = items[awardNum].AwardCount; awardModel.awardLevel = items[awardNum].AwardLevel; awardModel.awardType = (WeiActivityAwardType)items[awardNum].AwardType; awardModel.bonusId = items[awardNum].BonusId; awardModel.couponId = items[awardNum].CouponId; awardModel.integral = items[awardNum].Integral; if (awardModel.couponId != 0) { awardModel.couponName = CouponApplication.GetCouponInfo(long.Parse(items[awardNum].CouponId.ToString())).CouponName; } awardModel.proportion = items[awardNum].Proportion; listAwardModel.Add(awardModel); awardNum++; } else { //获取奖项 WeiActivityAwardModel awardModel = new WeiActivityAwardModel(); listAwardModel.Add(awardModel); } } } viewModel.awards = listAwardModel; return(viewModel); }