public static void WinnerSubmit(WeiActivityWinModel winModel) { //添加中奖信息记录 WeiActivityWinInfo activityWinInfo = new WeiActivityWinInfo(); activityWinInfo.ActivityId = winModel.activityId; activityWinInfo.AddDate = DateTime.Now; activityWinInfo.UserId = winModel.userId; activityWinInfo.IsWin = winModel.isWin; if (activityWinInfo.IsWin) { if (winModel.awardType == WeiActivityAwardType.Integral)//积分 { activityWinInfo.AwardName = winModel.awardName + " 积分"; //新增积分记录 var factoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create; MemberIntegralRecord info = new MemberIntegralRecord(); info.UserName = _iMemberService.GetMember(activityWinInfo.UserId).UserName; info.MemberId = activityWinInfo.UserId; info.RecordDate = DateTime.Now; info.ReMark = "微信活动中奖"; info.TypeId = MemberIntegral.IntegralType.WeiActivity; var memberIntegral = factoryService.Create(MemberIntegral.IntegralType.WeiActivity, Convert.ToInt32(winModel.awardName));//winModel.integrals为消耗积分 此处不是用户总积分 _iMemberIntegralService.AddMemberIntegral(info, memberIntegral); } else if (winModel.awardType == WeiActivityAwardType.Bonus)//红包 { activityWinInfo.AwardName = winModel.awardName; _iBonusService.SetShareByUserId(winModel.bonusId, false, winModel.userId);//添加红包记录 _iBonusService.IncrReceiveCount(winModel.bonusId); } else { activityWinInfo.AwardName = winModel.awardName; //添加优惠券记录 CouponRecordInfo recordInfo = new CouponRecordInfo(); recordInfo.UserId = winModel.userId; recordInfo.UserName = _iMemberService.GetMember(winModel.userId).UserName; recordInfo.ShopId = _iCouponService.GetCouponInfo(winModel.couponId).ShopId; recordInfo.CouponId = winModel.couponId; _iCouponService.AddCouponRecord(recordInfo); } } else { activityWinInfo.AwardName = winModel.awardName; } activityWinInfo.AwardId = winModel.awardId; _iWeiActivityWinService.AddWinner(activityWinInfo); //消耗积分 if (winModel.integrals > 0) { var factoryService = ServiceProvider.Instance <IMemberIntegralConversionFactoryService> .Create; MemberIntegralRecord info = new MemberIntegralRecord(); info.UserName = _iMemberService.GetMember(activityWinInfo.UserId).UserName; info.MemberId = activityWinInfo.UserId; info.RecordDate = DateTime.Now; info.ReMark = "微信活动消耗"; info.TypeId = MemberIntegral.IntegralType.WeiActivity; var memberIntegral = factoryService.Create(MemberIntegral.IntegralType.WeiActivity, -winModel.integrals); _iMemberIntegralService.AddMemberIntegral(info, memberIntegral); } }
/// <summary> /// 刮刮卡新增红包 /// </summary> /// <param name="id"></param> /// <param name="isShare"></param> /// <param name="userId"></param> /// <param name="openId"></param> public static void SetShareByUserId(long id, bool isShare, long userId) { _iBonusService.SetShareByUserId(id, isShare, userId); }