protected override ChangeContactEventStatusRD ProcessRequest(DTO.Base.APIRequest <ChangeContactEventStatusRP> pRequest) { var rd = new ChangeContactEventStatusRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var bllContactEvent = new ContactEventBLL(loggingSessionInfo); try { ContactEventEntity entityContactEvent = new ContactEventEntity(); entityContactEvent = bllContactEvent.GetByID(para.ContactEventId); if (entityContactEvent == null) { throw new APIException("未找到相关触点活动,请确认参数") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } else { entityContactEvent.Status = para.Status; bllContactEvent.Update(entityContactEvent); rd.ContactEventId = entityContactEvent.ContactEventId.ToString(); rd.Status = entityContactEvent.Status; } } catch (APIException apiEx) { throw new APIException(apiEx.ErrorCode, apiEx.Message); } return(rd); }
protected override GetContactEventListRD ProcessRequest(DTO.Base.APIRequest <GetContactEventListRP> pRequest) { var rd = new GetContactEventListRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var bllContactEvent = new ContactEventBLL(loggingSessionInfo); DataSet ds = bllContactEvent.GetContactEventList(para.PageSize, para.PageIndex); if (ds.Tables[0].Rows.Count > 0) { rd.ContactEventList = DataTableToObject.ConvertToList <JIT.CPOS.DTO.Module.Event.ContactEvent.Response.ContactEvent>(ds.Tables[0]); rd.TotalCount = Convert.ToInt32(ds.Tables[1].Rows[0]["TotalCount"]); rd.TotalPage = Convert.ToInt32(ds.Tables[1].Rows[0]["TotalPage"]); } return(rd); }
protected override GetContactEventDetailRD ProcessRequest(DTO.Base.APIRequest <GetContactEventDetailRP> pRequest) { var rd = new GetContactEventDetailRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var bllContactEvent = new ContactEventBLL(loggingSessionInfo); try { ContactEventEntity entityContactEvent = new ContactEventEntity(); entityContactEvent = bllContactEvent.GetByID(para.ContactEventId); if (entityContactEvent != null) { throw new APIException("未找到相关触点活动,请确认参数") { ErrorCode = ERROR_CODES.INVALID_BUSINESS }; } else { rd.ContactEventId = entityContactEvent.ContactEventId; rd.ContactEventName = entityContactEvent.ContactEventName; rd.ContactTypeCode = entityContactEvent.ContactTypeCode; rd.PrizeType = entityContactEvent.PrizeType; rd.BeginDate = entityContactEvent.BeginDate.ToString(); rd.EndDate = entityContactEvent.EndDate.ToString(); rd.CouponTypeID = entityContactEvent.CouponTypeID; rd.Integral = entityContactEvent.Integral; rd.ChanceCount = entityContactEvent.ChanceCount; rd.EventId = entityContactEvent.EventId; rd.ShareEventId = entityContactEvent.ShareEventId; rd.ShareEventName = entityContactEvent.ShareEventName; rd.EventName = entityContactEvent.EventName; rd.CouponTypeName = entityContactEvent.CouponTypeName; rd.UnLimited = Convert.ToInt32(entityContactEvent.UnLimited); } } catch (APIException apiEx) { throw new APIException(apiEx.ErrorCode, apiEx.Message); } return(rd); }
protected override CTWEventShareLogRD ProcessRequest(DTO.Base.APIRequest <CTWEventShareLogRP> pRequest) { var rd = new CTWEventShareLogRD();//返回值 var para = pRequest.Parameters; if (!string.IsNullOrEmpty(para.CTWEventId) && !string.IsNullOrEmpty(para.Sender) && !string.IsNullOrEmpty(para.OpenId)) { var bllLeventShareLog = new T_LEventsSharePersonLogBLL(this.CurrentUserInfo); var entityLeventShareLog = new T_LEventsSharePersonLogEntity(); entityLeventShareLog.ShareVipID = para.Sender; entityLeventShareLog.ShareOpenID = para.OpenId; entityLeventShareLog.BeShareOpenID = para.BeSharedOpenId; entityLeventShareLog.BeShareVipID = para.BEsharedUserId; entityLeventShareLog.BusTypeCode = "CTW"; entityLeventShareLog.ObjectId = para.CTWEventId; entityLeventShareLog.ShareURL = para.ShareURL; entityLeventShareLog.ShareVipType = 3; bllLeventShareLog.Create(entityLeventShareLog); //是否分享给自己 if (para.Sender == para.BEsharedUserId) { return(rd); } //触点奖励 ContactEventBLL bllContactEvent = new ContactEventBLL(this.CurrentUserInfo); var entityContact = bllContactEvent.QueryByEntity(new ContactEventEntity() { EventId = para.CTWEventId, IsDelete = 0, IsCTW = 1, ContactTypeCode = "Share" }, null).SingleOrDefault(); if (entityContact != null) { LPrizesBLL bllPrize = new LPrizesBLL(this.CurrentUserInfo); LPrizeWinnerBLL bllPrizeWinner = new LPrizeWinnerBLL(this.CurrentUserInfo); LLotteryLogBLL bllLottery = new LLotteryLogBLL(this.CurrentUserInfo); ///判断是否已经获得奖励 int intLogCount = bllLottery.GetEventLotteryLogByEventId(entityContact.ContactEventId.ToString(), para.Sender); if (intLogCount > 0) { return(rd); } var prize = DataTableToObject.ConvertToList <LPrizesEntity>(bllPrize.GetCouponTypeIDByEventId(entityContact.ContactEventId.ToString()).Tables[0]).FirstOrDefault(); if (prize != null) { CouponBLL bllCoupon = new CouponBLL(this.CurrentUserInfo); if (prize.PrizeTypeId == "Coupon") { bllCoupon.CouponBindVip(para.Sender, prize.CouponTypeID, entityContact.ContactEventId.ToString(), "Share"); DataSet ds = bllPrize.GetAllCouponTypeByPrize(prize.PrizesID); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { var redisVipMappingCouponBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.Coupon.RedisVipMappingCouponBLL(); foreach (DataRow dr in ds.Tables[0].Rows) { redisVipMappingCouponBLL.SetVipMappingCoupon(new CC_Coupon() { CustomerId = this.CurrentUserInfo.ClientID, CouponTypeId = dr["CouponTypeID"].ToString() }, entityContact.ContactEventId.ToString(), para.Sender, "Share"); } } } if (prize.PrizeTypeId == "Point") { #region 调用积分统一接口 var salesReturnBLL = new T_SalesReturnBLL(this.CurrentUserInfo); VipIntegralBLL bllVipIntegral = new VipIntegralBLL(this.CurrentUserInfo); var vipBLL = new VipBLL(this.CurrentUserInfo); var vipInfo = vipBLL.GetByID(para.Sender); var IntegralDetail = new VipIntegralDetailEntity() { Integral = prize.Point, IntegralSourceID = "28", ObjectId = entityContact.ContactEventId.ToString() }; //变动前积分 string OldIntegral = (vipInfo.Integration ?? 0).ToString(); //变动积分 string ChangeIntegral = (IntegralDetail.Integral ?? 0).ToString(); var vipIntegralDetailId = bllVipIntegral.AddIntegral(ref vipInfo, null, IntegralDetail, null, this.CurrentUserInfo); //发送微信积分变动通知模板消息 if (!string.IsNullOrWhiteSpace(vipIntegralDetailId)) { var CommonBLL = new CommonBLL(); CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, this.CurrentUserInfo); } #endregion } #region 奖励日志 LPrizeWinnerEntity entityPrizeWinner = new LPrizeWinnerEntity() { PrizeWinnerID = Guid.NewGuid().ToString(), VipID = para.Sender, PrizeID = prize.PrizesID, PrizeName = prize.PrizeName, PrizePoolID = "", CreateBy = this.CurrentUserInfo.UserID, CreateTime = DateTime.Now, IsDelete = 0 }; bllPrizeWinner.Create(entityPrizeWinner); LLotteryLogEntity lotteryEntity = new LLotteryLogEntity() { LogId = Guid.NewGuid().ToString(), VipId = para.Sender, EventId = entityContact.ContactEventId.ToString(), LotteryCount = 1, IsDelete = 0 }; bllLottery.Create(lotteryEntity); #endregion } } } return(rd); }
protected override GetImageRD ProcessRequest(APIRequest <GetImageRP> pRequest) { var rd = new GetImageRD(); ObjectImagesBLL bllImage = new ObjectImagesBLL(this.CurrentUserInfo); LEventsBLL bllEvent = new LEventsBLL(this.CurrentUserInfo); LCoverBLL bllCover = new LCoverBLL(CurrentUserInfo); string strEventId = pRequest.Parameters.EventId; string strCTWEventId = string.Empty; string strOnLineRedirectUrl = string.Empty; rd.EventId = strEventId; rd.IsCTW = 0; //if (!string.IsNullOrEmpty(pRequest.Parameters.CTWEventId)) //{ T_CTW_LEventInteractionBLL bllLEventInteraction = new T_CTW_LEventInteractionBLL(this.CurrentUserInfo); DataSet ds = bllLEventInteraction.GetCTWLEventInteraction(strEventId); if (ds != null && ds.Tables[0].Rows.Count > 0) { strEventId = ds.Tables[0].Rows[0]["LeventId"].ToString(); strCTWEventId = ds.Tables[0].Rows[0]["CTWEventId"].ToString(); strOnLineRedirectUrl = ds.Tables[0].Rows[0]["OnLineRedirectUrl"].ToString(); ContactEventBLL bllContact = new ContactEventBLL(this.CurrentUserInfo); LPrizesBLL bllPrize = new LPrizesBLL(this.CurrentUserInfo); var contactList = bllContact.QueryByEntity(new ContactEventEntity() { EventId = strCTWEventId, IsCTW = 1, IsDelete = 0 }, null).ToList(); T_CTW_SpreadSettingBLL bllSpreadSetting = new T_CTW_SpreadSettingBLL(this.CurrentUserInfo); DataSet dsFocus = bllSpreadSetting.GetSpreadSettingQRImageByCTWEventId(strCTWEventId, "Focus"); var regContact = contactList.Where(a => a.ContactTypeCode == "Reg").SingleOrDefault(); ButtonInfo reg = new ButtonInfo(); reg.Text = "注册"; if (regContact != null) { if (dsFocus != null && dsFocus.Tables[0].Rows.Count > 0) { reg.Text = dsFocus.Tables[0].Rows[0]["LeadPageRegPromptText"].ToString(); } if (bllPrize.QueryByEntity(new LPrizesEntity() { EventId = regContact.EventId }, null).SingleOrDefault() != null) { reg.Text = "注册有惊喜"; } } rd.Reg = reg; ButtonInfo share = new ButtonInfo(); share.Text = "分享"; DataSet dsShare = bllSpreadSetting.GetSpreadSettingQRImageByCTWEventId(strCTWEventId, "Share"); if (dsShare != null && dsShare.Tables.Count > 0 && dsShare.Tables[0].Rows.Count > 0) { share.Title = dsShare.Tables[0].Rows[0]["Title"].ToString(); share.Summary = dsShare.Tables[0].Rows[0]["Summary"].ToString(); share.BGImageUrl = dsShare.Tables[0].Rows[0]["BGImageUrl"].ToString(); } var shareContact = contactList.Where(a => a.ContactTypeCode == "Share").SingleOrDefault(); if (shareContact != null) { if (bllPrize.QueryByEntity(new LPrizesEntity() { EventId = shareContact.EventId }, null).SingleOrDefault() != null) { share.Text = "分享有惊喜"; } //if (dsFocus != null && dsFocus.Tables[0].Rows.Count > 0) //{ // share.Text = dsFocus.Tables[0].Rows[0]["LeadPageSharePromptText"].ToString(); //} } rd.Share = share; ButtonInfo focus = new ButtonInfo(); focus.Text = "扫码关注"; if (dsFocus != null && dsFocus.Tables.Count > 0 && dsFocus.Tables[0].Rows.Count > 0) { focus.BGImageUrl = dsFocus.Tables[0].Rows[0]["BGImageUrl"].ToString(); focus.LeadPageQRCodeImageUrl = dsFocus.Tables[0].Rows[0]["LeadPageQRCodeImageUrl"].ToString(); var focusContact = contactList.Where(a => a.ContactTypeCode == "Focus").SingleOrDefault(); if (focusContact != null) { focus.Text = dsFocus.Tables[0].Rows[0]["LeadPageFocusPromptText"].ToString(); } } rd.Focus = focus; rd.IsCTW = 1; rd.CTWEventId = strCTWEventId; rd.EventId = strEventId; rd.OnLineRedirectUrl = strOnLineRedirectUrl; } //} var image = bllImage.QueryByEntity(new ObjectImagesEntity() { ObjectId = strEventId, IsDelete = 0 }, null).ToList(); var eventInfo = bllEvent.GetByID(strEventId); if (image.Count != 0) { foreach (var i in image) { if (i.BatId == "BackGround") { rd.BackGround = i.ImageURL; } if (i.BatId == "BeforeGround") { rd.BeforeGround = i.ImageURL; } if (i.BatId == "Logo") { rd.Logo = i.ImageURL; } if (i.BatId == "Rule") { rd.Rule = i.ImageURL; } if (i.BatId == "LT_kvPic") { rd.LT_kvPic = i.ImageURL; } if (i.BatId == "LT_Rule") { rd.LT_Rule = i.ImageURL; } if (i.BatId == "LT_bgpic1") { rd.LT_bgpic1 = i.ImageURL; } if (i.BatId == "LT_bgpic2") { rd.LT_bgpic2 = i.ImageURL; } if (i.BatId == "LT_regularpic") { rd.LT_regularpic = i.ImageURL; } if (i.BatId == "Receive") { rd.Receive = i.ImageURL; } if (i.BatId == "NotReceive") { rd.NotReceive = i.ImageURL; } } ; rd.RuleContent = image.FirstOrDefault().RuleContent; rd.RuleId = image.FirstOrDefault().RuleId ?? 0; rd.ImageList = bllImage.QueryByEntity(new ObjectImagesEntity() { ObjectId = strEventId, BatId = "list", IsDelete = 0 }, null).ToList(); } rd.EventTitle = eventInfo.Title; rd.EventContent = eventInfo.Content; rd.BootUrl = eventInfo.BootURL; rd.ShareRemark = eventInfo.ShareRemark; rd.PosterImageUrl = eventInfo.PosterImageUrl; rd.OverRemark = eventInfo.OverRemark; rd.ShareLogoUrl = eventInfo.ShareLogoUrl; rd.IsShare = eventInfo.IsShare == null ? 0 : (int)eventInfo.IsShare; var entityCover = bllCover.QueryByEntity(new LCoverEntity() { EventId = strEventId, IsDelete = 0, IsShow = 1 }, null).FirstOrDefault(); if (entityCover != null) { rd.CoverInfo = entityCover; } return(rd); }
const int MEMBER_HAVECARDNOTIPS = 320; //领取成功 不提示 但跳到实体卡 #endregion protected override AuthCodeLoginRD ProcessRequest(DTO.Base.APIRequest <AuthCodeLoginRP> pRequest) { var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo); //参数验证 if (string.IsNullOrEmpty(pRequest.Parameters.Mobile)) { throw new APIException("请求参数中缺少Mobile或值为空.") { ErrorCode = ERROR_LACK_MOBILE }; } if (pRequest.Parameters.VipSource.HasValue == false) { pRequest.Parameters.VipSource = 1; //throw new APIException("请求参数中缺少VipSource或值为空.") { ErrorCode = ERROR_LACK_VIP_SOURCE }; } // AuthCodeLoginRD rd = new AuthCodeLoginRD(); var bll = new VipBLL(this.CurrentUserInfo); var codebll = new RegisterValidationCodeBLL(base.CurrentUserInfo); VipEntity vipByID = null; //根据VIP ID查找出来的VIP记录 VipEntity vipByPhone = null; //根据手机号查找出来的VIP记录 //var list = codebll.QueryByEntity(new RegisterValidationCodeEntity() //{ // Mobile = pRequest.Parameters.Mobile //}, null); //bool b = false; //if (list != null) //{ // foreach (var entity in list) // { // if (entity == null) // throw new APIException("未找到此手机的验证信息") {ErrorCode = ERROR_AUTHCODE_NOTEXISTS}; // //if (entity.IsValidated.Value == 1) // // throw new APIException("此验证码已被使用") {ErrorCode = ERROR_AUTHCODE_WAS_USED}; // //if (entity.Expires.Value < DateTime.Now) // // throw new APIException("此验证码已失效") {ErrorCode = ERROR_AUTHCODE_INVALID}; // if (entity.Code == pRequest.Parameters.AuthCode) // b = true; // } //} //if (!b) //{ // throw new APIException("验证码不正确.") { ErrorCode = ERROR_AUTHCODE_NOT_EQUALS }; //} #region 验证验证码 var entity = codebll.GetByMobile(pRequest.Parameters.Mobile); if (entity == null) { throw new APIException("未找到此手机的验证信息") { ErrorCode = ERROR_AUTHCODE_NOTEXISTS } } ; if (entity.IsValidated.Value == 1) { throw new APIException("此验证码已被使用") { ErrorCode = ERROR_AUTHCODE_WAS_USED } } ; if (entity.Expires.Value < DateTime.Now) { throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_INVALID } } ; if (entity.Code != pRequest.Parameters.AuthCode) { throw new APIException("验证码不正确.") { ErrorCode = ERROR_AUTHCODE_NOT_EQUALS } } ; #endregion #region 获取会员权益 var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); var memberBenefit = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID); var bllPrize = new LPrizesBLL(CurrentUserInfo); #endregion //自定义没有实体卡,有实体卡时变为1 int HaveVipcard = 0; //要发送给rabbitmq的信息 var eventService = new EventService(); EventContract vipMsg = null; switch (pRequest.Parameters.VipSource.Value) { case 3: //来源是微信时,做自动合并 { #region 根据手机号查找下,看下是否存在同样手机号的VIP记录 { List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); //潜在或者正式会员 wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipByPhone = result[0]; } if (vipByPhone != null && vipByPhone.VipSourceId == "3" && vipByPhone.Status.Value >= 2) { throw new APIException("会员已经注册") { ErrorCode = ERROR_MEMBER_REGISTERED }; } } #endregion #region 根据VIP ID查找下,看下是否存在该VIP的记录 if (!string.IsNullOrEmpty(pRequest.UserID)) { List <IWhereCondition> wheres = new List <IWhereCondition>(); //wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = true }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = pRequest.UserID }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipByID = result[0]; } } else { //如果前端未指定VIP ID则后台指定 pRequest.UserID = Guid.NewGuid().ToString("N"); } //判断用户是从点击领取过来的 还是从点击绑定实体卡过来的 int?RegisterType = 0; if (pRequest.Parameters.registerType != null) { RegisterType = pRequest.Parameters.registerType; } //当手机号不为空时需要查询是否存在实体卡 if (!string.IsNullOrEmpty(pRequest.Parameters.Mobile) && (!string.IsNullOrEmpty(pRequest.UserID) || !string.IsNullOrEmpty(vipByPhone.VIPID))) { List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); wheres.Add(new DirectCondition("VipID!='" + pRequest.UserID + "'")); var vipInfo = bll.Query(wheres.ToArray(), null); //若是从绑定实体卡进入,进行实体卡的判断,并不注册成功 if (RegisterType == 2) { if (vipInfo == null || vipInfo.Length == 0) { throw new APIException("未检测到实体卡") { ErrorCode = MEMBER_HAVENOCARD }; } else { vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); HaveVipcard = 1; //需要给绑定实体卡的提示 } } else { vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); //若是从"点击领取"进入则进行判断有没有实体卡 有没有实体卡都进行领卡成功的提示 if (vipInfo != null && vipInfo.Length > 0) { HaveVipcard = 1; //需要给绑定实体卡的提示 } else { HaveVipcard = 2; //注册成功但没有实体卡 } } } if (vipByID == null && vipByPhone == null) //根据vipid查不出记录,并且根据手机号也查不出记录 新增一条vip { //如果不存在则首先创建一条VIP记录,补充记录 vipByID = new VipEntity() { Phone = pRequest.Parameters.Mobile, VipName = pRequest.Parameters.Mobile, UserName = pRequest.Parameters.Mobile, VipRealName = pRequest.Parameters.VipRealName, VIPID = pRequest.UserID, Status = 2, ClientID = pRequest.CustomerID, VipCode = "Vip" + bll.GetNewVipCode(pRequest.CustomerID), VipSourceId = pRequest.Parameters.VipSource.ToString(), WeiXinUserId = string.IsNullOrWhiteSpace(pRequest.UserID) ? Guid.NewGuid().ToString("N") : pRequest.UserID, RegistrationTime = DateTime.Now }; bll.Create(vipByID); #region 注册会员触点活动奖励 //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Reg"); RedisContactBLL redisContactBll = new RedisContactBLL(); redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact() { CustomerId = CurrentUserInfo.ClientID, ContactType = "Reg", VipId = CurrentUserInfo.UserID }); #endregion } else if (vipByID != null) { VipEntity vipUpdateInfo = new VipEntity(); List <IWhereCondition> wheres = new List <IWhereCondition>(); //wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = true }); wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = pRequest.UserID }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipUpdateInfo = result[0]; } vipUpdateInfo.Phone = pRequest.Parameters.Mobile; if (!string.IsNullOrEmpty(pRequest.Parameters.VipRealName)) { vipUpdateInfo.VipRealName = pRequest.Parameters.VipRealName; } vipUpdateInfo.Status = 2; vipUpdateInfo.RegistrationTime = DateTime.Now; bll.Update(vipUpdateInfo); #region 注册会员触点活动奖励 //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Reg"); RedisContactBLL redisContactBll = new RedisContactBLL(); redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact() { CustomerId = CurrentUserInfo.ClientID, ContactType = "Reg", VipId = CurrentUserInfo.UserID }); #endregion #region 会员金矿、注册集客奖励 bll.SetOffActionReg(vipByID); #endregion } #endregion #region 根据VIP ID及手机号查询出的结果,尝试自动合并会员 (因目前会员注册不自动绑卡,实现用户自行选择绑卡业务故将绑卡业务注释掉) //if (vipByPhone == null) //{//如果未有相同手机号的用户,则无须绑定,直接使用VIP ID对应的VIP记录作为当前注册用户的记录 // rd.MemberInfo = new MemberInfo() // { // Mobile = vipByID.Phone // , // VipID = vipByID.VIPID // , // Name = vipByID.UserName // , // VipName = vipByID.VipName // , // VipNo = vipByID.VipCode // , // MemberBenefits = memberBenefit // , // IsActivate = vipByID.IsActivate.HasValue && vipByID.IsActivate.Value == 1 ? true : false // }; // //处理绑卡业务 add by Henry 2015/10/28 // vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); //} //else //{//否则调用存储过程,做自动会员合并 // //如果会员已经注册过,并且来源是微信的则表示该帐号已经被注册过不能再次绑定 // if (vipByPhone.VipSourceId == "3" && vipByPhone.Status.Value >= 2) // { // throw new APIException("会员已经注册") { ErrorCode = ERROR_MEMBER_REGISTERED }; // } // //否则做会员合并 // if (!bll.MergeVipInfo(pRequest.CustomerID, pRequest.UserID, pRequest.Parameters.Mobile)) // { // throw new APIException("自动绑定会员信息失败") { ErrorCode = ERROR_AUTO_MERGE_MEMBER_FAILED }; // } // //合并成功后重新读取信息 // List<IWhereCondition> wheres = new List<IWhereCondition>(); // wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); // wheres.Add(new EqualsCondition() { FieldName = "vipid", Value = pRequest.UserID }); // wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); // var result = bll.Query(wheres.ToArray(), null); // vipByID = result[0]; // rd.MemberInfo = new MemberInfo() // { // Mobile = vipByID.Phone // , // VipID = vipByID.VIPID // , // Name = vipByID.UserName // , // VipName = vipByID.VipName // , // VipNo = vipByID.VipCode // , // MemberBenefits = memberBenefit // , // IsActivate = vipByID.IsActivate.HasValue && vipByID.IsActivate.Value == 1 ? true : false // }; // //处理绑卡业务 add by Henry 2015/10/28 // vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); //} #endregion } //注册会员信息发布到rabbitmq vipMsg = new EventContract { Operation = OptEnum.Create, EntityType = EntityTypeEnum.Vip, Id = pRequest.UserID }; eventService.PublishMsg(vipMsg); break; default: //其他来源则为自动注册 { #region 根据手机号查找下,看下是否存在同样手机号的VIP记录 { List <IWhereCondition> wheres = new List <IWhereCondition>(); wheres.Add(new MoreThanCondition() { FieldName = "status", Value = 0, IncludeEquals = false }); wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); var result = bll.Query(wheres.ToArray(), null); if (result != null && result.Length > 0) { vipByPhone = result[0]; } if (vipByPhone != null && vipByPhone.Status.Value >= 2) { throw new APIException("会员已经注册") { ErrorCode = ERROR_MEMBER_REGISTERED }; } } #endregion #region 没有找到相同电话的会员则自动注册 if (vipByPhone == null) { //没有找到相同电话的会员则自动注册 vipByPhone = new VipEntity() { Phone = pRequest.Parameters.Mobile, VipName = pRequest.Parameters.Mobile, UserName = pRequest.Parameters.Mobile, VipRealName = pRequest.Parameters.VipRealName, VIPID = string.IsNullOrWhiteSpace(pRequest.UserID) ? Guid.NewGuid().ToString("N") : pRequest.UserID, Status = 2, //状态为注册 VipCode = "Vip" + bll.GetNewVipCode(pRequest.CustomerID), ClientID = pRequest.CustomerID, VipSourceId = pRequest.Parameters.VipSource.ToString(), WeiXinUserId = string.IsNullOrWhiteSpace(pRequest.UserID) ? Guid.NewGuid().ToString("N") : pRequest.UserID, RegistrationTime = DateTime.Now }; bll.Create(vipByPhone); #region 注册会员触点活动奖励 //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Reg"); RedisContactBLL redisContactBll = new RedisContactBLL(); redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact() { CustomerId = CurrentUserInfo.ClientID, ContactType = "Reg", VipId = CurrentUserInfo.UserID }); #endregion } #endregion #region decimal EndAmount = 0; VipAmountBLL AmountBLL = new VipAmountBLL(this.CurrentUserInfo); VipAmountEntity amountEntity = AmountBLL.GetByID(vipByPhone.VIPID); if (amountEntity != null) { EndAmount = amountEntity.EndAmount.HasValue ? amountEntity.EndAmount ?? 0 : 0; } #endregion #region 返回用户信息 rd.MemberInfo = new MemberInfo() { Mobile = vipByPhone.Phone , VipID = vipByPhone.VIPID , Name = vipByPhone.UserName , VipName = vipByPhone.VipName , VipRealName = vipByPhone.VipRealName , VipNo = vipByPhone.VipCode , MemberBenefits = memberBenefit , IsActivate = false , Integration = vipByPhone.Integration ?? 0 , Balance = EndAmount }; #endregion } //注册会员信息发布到rabbitmq vipMsg = new EventContract { Operation = OptEnum.Create, EntityType = EntityTypeEnum.Vip, Id = rd.MemberInfo.VipID }; eventService.PublishMsg(vipMsg); break; } T_LEventsRegVipLogBLL lEventRegVipLogBll = new T_LEventsRegVipLogBLL(CurrentUserInfo); if (!string.IsNullOrEmpty(pRequest.Parameters.CTWEventId)) { lEventRegVipLogBll.CTWRegOrFocusLog(pRequest.Parameters.CTWEventId, pRequest.UserID, "", CurrentUserInfo, "Reg"); } //如果是通过优惠券进来的就有couponId 新注册的需要加记录 if (!string.IsNullOrEmpty(pRequest.Parameters.couponId)) { lEventRegVipLogBll.CouponRegOrFocusLog(pRequest.Parameters.couponId, pRequest.UserID, "", CurrentUserInfo, "Reg"); } //当手机号不为空时需要查询是否存在实体卡 //if (!string.IsNullOrEmpty(pRequest.Parameters.Mobile) && (!string.IsNullOrEmpty(pRequest.UserID) || !string.IsNullOrEmpty(vipByPhone.VIPID))) //{ // List<IWhereCondition> wheres = new List<IWhereCondition>(); // wheres.Add(new EqualsCondition() { FieldName = "phone", Value = pRequest.Parameters.Mobile }); // wheres.Add(new EqualsCondition() { FieldName = "clientid", Value = pRequest.CustomerID }); // wheres.Add(new DirectCondition("VipID!='" + pRequest.UserID + "'")); // var vipInfo = bll.Query(wheres.ToArray(), null); // if (vipInfo != null && vipInfo.Length > 0) // { // throw new APIException("检测到会员相关实体卡") { ErrorCode = MEMBER_HAVECARD }; // } // else // { // //如果会员当前没有实体卡,则默认绑定等级为1的卡 // vipCardVipMappingBLL.BindVipCard(vipByID.VIPID, vipByID.VipCode, vipByID.CouponInfo); // throw new APIException("未检测到实体卡") { ErrorCode = MEMBER_HAVENOCARD }; // } //} //判定是否有可绑卡的定义 1=有可绑卡 if (HaveVipcard == 1 || HaveVipcard == 2) { //有积分的话给相应领取成功的积分提示 var contactEventBLL = new ContactEventBLL(CurrentUserInfo); int sendIntegral = 0; if (!string.IsNullOrEmpty(pRequest.Parameters.CTWEventId)) { sendIntegral = contactEventBLL.GetContactEventIntegral(CurrentUserInfo.ClientID, "Reg", "Point", 1); } else { sendIntegral = contactEventBLL.GetContactEventIntegral(CurrentUserInfo.ClientID, "Reg", "Point", 0); } if (sendIntegral > 0) { if (pRequest.Parameters.registerType != 2 && HaveVipcard == 2) { throw new APIException("恭喜您领取成功并获得" + sendIntegral + "注册积分") { ErrorCode = MEMBER_GETSUCCESS }; //领取成功不跳转跳转到实体卡 } else if (pRequest.Parameters.registerType == 2 && HaveVipcard == 1) { throw new APIException("恭喜您领取成功并获得" + sendIntegral + "注册积分") { ErrorCode = MEMBER_HAVECARD_Integral }; //检测到有相关实体卡前端不提示领取成功 并跳到实体卡列表 } else { throw new APIException("恭喜您领取成功并获得" + sendIntegral + "注册积分") { ErrorCode = MEMBER_HAVECARD }; //领取成功,提示领取成功,并跳到相关实体卡 } } else { if (pRequest.Parameters.registerType != 2 && HaveVipcard == 2) { throw new APIException("领取成功") { ErrorCode = MEMBER_GETSUCCESS }; //领取成功不跳转跳转到实体卡 } else if (pRequest.Parameters.registerType == 2 && HaveVipcard == 1) { throw new APIException("检测到有相关实体卡") { ErrorCode = MEMBER_HAVECARD }; //检测到有相关实体卡前端不提示领取成功 并跳到实体卡列表 } else if (pRequest.Parameters.registerType != 2 && HaveVipcard == 1) { throw new APIException("领取成功") { ErrorCode = MEMBER_HAVECARD }; //领取成功有实体卡,并跳转 } else { throw new APIException("检测到有相关实体卡") { ErrorCode = MEMBER_HAVECARD }; //领取成功,提示领取成功,并跳到相关实体卡 } } } #region 将验证码设置为已验证 //entity.IsValidated = 1; //codebll.Update(entity); #endregion return(rd); //AuthCodeLoginRD rd = new AuthCodeLoginRD(); //rd.MemberInfo = new MemberInfo(); //var codebll = new RegisterValidationCodeBLL(base.CurrentUserInfo); //var entity = codebll.GetByMobile(pRequest.Parameters.Mobile); //if (entity == null) // throw new APIException("未找到此手机的验证信息") { ErrorCode = ERROR_AUTHCODE_NOTEXISTS }; //if (entity.IsValidated.Value == 1) // throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_FAILURE }; //if (entity.Expires.Value < DateTime.Now) // throw new APIException("此验证码已失效") { ErrorCode = ERROR_AUTHCODE_FAILURE }; //var vipbll = new VipBLL(base.CurrentUserInfo); //var vipinfo = vipbll.GetByMobile(pRequest.Parameters.Mobile, pRequest.CustomerID); //#region VIP来源更新 //switch (pRequest.Parameters.VipSource.Value) //{ // case 4: // case 9: // vipinfo.VipSourceId = pRequest.Parameters.VipSource.ToString(); // vipbll.Update(vipinfo); // break; //} //#endregion //if (string.IsNullOrEmpty(vipinfo.ClientID)) //{ // vipinfo.ClientID = pRequest.CustomerID; // vipbll.Update(vipinfo); //} //rd.MemberInfo.Mobile = vipinfo.Phone; //rd.MemberInfo.Name = vipinfo.UserName; //rd.MemberInfo.VipID = vipinfo.VIPID; //rd.MemberInfo.VipName = vipinfo.VipName; //var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo); //rd.MemberInfo.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID); //entity.IsValidated = 1; //codebll.Update(entity); //return rd; } } }
/// <summary> /// 保存触点奖励 /// </summary> /// <param name="para"></param> /// <param name="bllPrize"></param> /// <param name="strStartDate"></param> /// <param name="strEndDate"></param> public void SaveContactPrize(SetCTWEventRP para, LPrizesBLL bllPrize, string strStartDate, string strEndDate) { var bllContactEvent = new ContactEventBLL(loggingSessionInfo); if (!string.IsNullOrEmpty(para.CTWEventId)) { bllContactEvent.DeleteContact(para.CTWEventId); } foreach (var cItem in para.ContactPrizeList) { ContactEventEntity contactEvent = new ContactEventEntity(); int PrizeCount = 0; if (cItem.PrizeList != null && cItem.PrizeList.Count > 0) { foreach (var ItemPrize in cItem.PrizeList) { PrizeCount = PrizeCount + ItemPrize.PrizeCount; } contactEvent.PrizeCount = PrizeCount; contactEvent.ContactTypeCode = cItem.ContactTypeCode; contactEvent.ContactEventName = cItem.ContactTypeCode; contactEvent.BeginDate = Convert.ToDateTime(strStartDate); contactEvent.EndDate = Convert.ToDateTime(strEndDate); contactEvent.PrizeType = ""; contactEvent.CustomerID = loggingSessionInfo.ClientID; contactEvent.RewardNumber = "OnlyOne"; contactEvent.EventId = strCTWEventId; if (cItem.ContactTypeCode == "Share") { contactEvent.ShareEventId = strCTWEventId; } contactEvent.Status = 1; contactEvent.IsCTW = 1; bllContactEvent.Create(contactEvent); ///保存奖品 生成奖品池 var entityPrize = new LPrizesEntity(); //entityPrize.EventId = contactEvent.ContactEventId.ToString(); //entityPrize.PrizeName = cItem.ContactTypeCode; //entityPrize.PrizeTypeId = cItem.PrizeType; //entityPrize.Point = cItem.Point; //entityPrize.CountTotal = PrizeCount; //entityPrize.CreateBy = loggingSessionInfo.UserID; //entityPrize.PrizesID = Guid.NewGuid().ToString(); //bllPrize.Create(entityPrize); //if (cItem.PrizeType == "Coupon") //{ bllContactEvent.DeleteContactPrize(contactEvent.ContactEventId.ToString()); foreach (var ItemPrize in cItem.PrizeList) { entityPrize = new LPrizesEntity(); entityPrize.EventId = contactEvent.ContactEventId.ToString(); entityPrize.PrizeName = ItemPrize.PrizeName; entityPrize.PrizeTypeId = ItemPrize.PrizeTypeId; entityPrize.Point = ItemPrize.Point; entityPrize.CouponTypeID = ItemPrize.CouponTypeID; entityPrize.CountTotal = ItemPrize.PrizeCount; entityPrize.CreateBy = loggingSessionInfo.UserID; entityPrize.PrizesID = Guid.NewGuid().ToString(); //bllContactEvent.AddContactEventPrizeForCTW(entityPrize); bllContactEvent.AddContactEventPrize(entityPrize); } //} } else { contactEvent.PrizeCount = 0; contactEvent.ContactTypeCode = cItem.ContactTypeCode; contactEvent.ContactEventName = cItem.ContactTypeCode; contactEvent.BeginDate = Convert.ToDateTime(strStartDate); contactEvent.EndDate = Convert.ToDateTime(strEndDate); contactEvent.PrizeType = ""; contactEvent.CustomerID = loggingSessionInfo.ClientID; contactEvent.RewardNumber = "OnlyOne"; contactEvent.EventId = strCTWEventId; contactEvent.Status = 1; contactEvent.IsCTW = 1; bllContactEvent.Create(contactEvent); } } }
protected override SetContactEventRD ProcessRequest(DTO.Base.APIRequest <SetContactEventRP> pRequest) { var rd = new SetContactEventRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var bllContactEvent = new ContactEventBLL(loggingSessionInfo); var bllEvent = new LEventsBLL(loggingSessionInfo); var bllPrizes = new LPrizesBLL(loggingSessionInfo); string strErrMsg = string.Empty; try { string[] CouponTypeIdList = para.CouponTypeID; if (para.ContactEventId != null && para.ContactEventId != "") { var contactEvent = bllContactEvent.GetByID(para.ContactEventId); //if (contactEvent.Status == 2 || contactEvent.Status==3)//状态为运行时只可追加数量 if (para.Method == "Append") { contactEvent.PrizeCount = (contactEvent.PrizeCount == null ? 0 : contactEvent.PrizeCount) + para.PrizeCount; LPrizesBLL bllPrize = new LPrizesBLL(loggingSessionInfo); var entityPrize = bllPrize.QueryByEntity(new LPrizesEntity() { EventId = para.ContactEventId, IsDelete = 0 }, null).FirstOrDefault(); var CouponTypeTemp = bllContactEvent.QueryByEntity(new ContactEventEntity() { ContactEventId = new Guid(para.ContactEventId), IsDelete = 0 }, null).SingleOrDefault().CouponTypeID; if (CouponTypeTemp != null) { CouponTypeIdList = CouponTypeTemp.Split(','); if (CouponTypeIdList != null && CouponTypeIdList.Count() > 0) { var bllCoupon = new CouponBLL(loggingSessionInfo); foreach (var cou in CouponTypeIdList) { //优惠券未被使用了的数量 int intHaveCout = (int)entityPrize.CountTotal; DataSet ds = bllCoupon.GetCouponCountByCouponTypeID(cou); if (ds != null & ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { int intUnUsedCouponCount = Convert.ToInt32(ds.Tables[0].Rows[0]["RemainCount"].ToString()); if ((para.PrizeCount + intHaveCout) > intUnUsedCouponCount) { strErrMsg += ds.Tables[0].Rows[0]["CouponTypeName"].ToString() + "奖品总数量超过未使用优惠券数量,未使用量:" + intUnUsedCouponCount.ToString() + "<br/>"; } } } if (!string.IsNullOrEmpty(strErrMsg) && strErrMsg.Length > 0) { throw new APIException(strErrMsg) { ErrorCode = 342 }; } } } entityPrize.CountTotal = para.PrizeCount; entityPrize.LastUpdateBy = loggingSessionInfo.UserID; bllPrize.AppendPrize(entityPrize); //入奖品池队列 LPrizePoolsBLL bllPools = new LPrizePoolsBLL(loggingSessionInfo); DataSet dsPools = bllPools.GetPrizePoolsByEvent(loggingSessionInfo.ClientID, para.ContactEventId); if (dsPools != null && dsPools.Tables.Count > 0 && dsPools.Tables[0].Rows.Count > 0) { var poolsList = DataTableToObject.ConvertToList <CC_PrizePool>(dsPools.Tables[0]); if (poolsList != null && poolsList.Count > 0) { var redisPrizePoolsBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.PrizePools.RedisPrizePoolsBLL(); CC_PrizePool prizePool = new CC_PrizePool(); prizePool.CustomerId = loggingSessionInfo.ClientID; prizePool.EventId = para.ContactEventId; redisPrizePoolsBLL.DeletePrizePoolsList(prizePool); redisPrizePoolsBLL.SetPrizePoolsToRedis(poolsList); } } } else { if (para.PrizeType == "Point") { contactEvent.Integral = para.Integral; } if (para.PrizeType == "Coupon") { contactEvent.CouponTypeID = string.Join(",", para.CouponTypeID); var bllCoupon = new CouponBLL(loggingSessionInfo); if (CouponTypeIdList != null && CouponTypeIdList.Count() > 0) { foreach (var cou in CouponTypeIdList) { //优惠券未被使用了的数量 DataSet ds = bllCoupon.GetCouponCountByCouponTypeID(cou); if (ds != null & ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { int intUnUsedCouponCount = Convert.ToInt32(ds.Tables[0].Rows[0]["RemainCount"].ToString()); if (para.PrizeCount > intUnUsedCouponCount) { strErrMsg += ds.Tables[0].Rows[0]["CouponTypeName"].ToString() + "奖品总数量超过未使用优惠券数量,未使用量:" + intUnUsedCouponCount.ToString() + "<br/>"; } } } } if (!string.IsNullOrEmpty(strErrMsg) && strErrMsg.Length > 0) { throw new APIException(strErrMsg) { ErrorCode = 342 }; } } if (para.PrizeType == "Chance") { contactEvent.EventId = para.EventId; contactEvent.ChanceCount = para.ChanceCount; } contactEvent.PrizeCount = para.PrizeCount; contactEvent.ContactTypeCode = para.ContactTypeCode; contactEvent.ContactEventName = para.ContactEventName; contactEvent.BeginDate = para.BeginDate; contactEvent.EndDate = para.EndDate; contactEvent.PrizeType = para.PrizeType; contactEvent.CustomerID = CurrentUserInfo.ClientID; contactEvent.RewardNumber = para.RewardNumber; contactEvent.ShareEventId = para.ShareEventId; contactEvent.UnLimited = para.UnLimited; contactEvent.IsCTW = 0; if (para.ContactTypeCode == "Share" && para.ShareEventId != null && para.ShareEventId != "") { bllEvent.UpdateEventIsShare(para.ShareEventId); } //开始日期是当天的 状态直接变为运行中 if (DateTime.Compare(Convert.ToDateTime(para.BeginDate), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0 && DateTime.Compare(Convert.ToDateTime(para.EndDate), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) >= 0) { contactEvent.Status = 2; } } bllContactEvent.Update(contactEvent); rd.ContactEventId = para.ContactEventId.ToString(); rd.ErrMsg = "操作成功"; rd.Success = true; } else { ContactEventEntity entityContactEvent = new ContactEventEntity(); //RewardType:Point,Coupon,Chance if (para.PrizeType == "Point") { entityContactEvent.Integral = para.Integral; } if (para.PrizeType == "Coupon") { entityContactEvent.CouponTypeID = string.Join(",", para.CouponTypeID);; var bllCoupon = new CouponBLL(loggingSessionInfo); if (CouponTypeIdList != null && CouponTypeIdList.Count() > 0) { foreach (var cou in CouponTypeIdList) { //优惠券未被使用了的数量 DataSet ds = bllCoupon.GetCouponCountByCouponTypeID(cou); if (ds != null & ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { int intUnUsedCouponCount = Convert.ToInt32(ds.Tables[0].Rows[0]["RemainCount"].ToString()); if (para.PrizeCount > intUnUsedCouponCount) { strErrMsg += ds.Tables[0].Rows[0]["CouponTypeName"].ToString() + "奖品总数量超过未使用优惠券数量,未使用量:" + intUnUsedCouponCount.ToString() + "<br/>"; } } } } if (!string.IsNullOrEmpty(strErrMsg) && strErrMsg.Length > 0) { throw new APIException(strErrMsg) { ErrorCode = 342 }; } } if (para.PrizeType == "Chance") { entityContactEvent.EventId = para.EventId; entityContactEvent.ChanceCount = para.ChanceCount; } if (bllContactEvent.ExistsContact(para.ContactTypeCode, string.IsNullOrEmpty(para.ShareEventId) == true ? "" : para.ShareEventId) > 0) { if (para.ContactTypeCode == "Share" && para.ShareEventId != null && para.ShareEventId.Length > 0) { rd.ErrMsg = "该分享活动已存在"; } else { rd.ErrMsg = "该触点活动类型已存在"; } rd.Success = false; return(rd); } if (para.ShareEventId != null && para.ShareEventId.Length > 0) { //判断触点中的分享设置的开始时间和结束时间是否在被分享的活动时间范围内 var entityEvent = bllEvent.GetByID(para.ShareEventId); if (DateTime.Compare(Convert.ToDateTime(para.BeginDate), Convert.ToDateTime(entityEvent.BeginTime)) < 0 || DateTime.Compare(Convert.ToDateTime(para.EndDate), Convert.ToDateTime(entityEvent.EndTime)) > 0) { rd.Success = false; rd.ErrMsg = "活动的时间不在被分享的活动时间范围内"; return(rd); } entityContactEvent.ShareEventId = para.ShareEventId; entityEvent.IsShare = 1; bllEvent.Update(entityEvent, false); } entityContactEvent.PrizeCount = para.PrizeCount; entityContactEvent.ContactTypeCode = para.ContactTypeCode; entityContactEvent.ContactEventName = para.ContactEventName; entityContactEvent.BeginDate = para.BeginDate; entityContactEvent.EndDate = para.EndDate; entityContactEvent.PrizeType = para.PrizeType; entityContactEvent.CustomerID = CurrentUserInfo.ClientID; entityContactEvent.RewardNumber = para.RewardNumber; entityContactEvent.UnLimited = para.UnLimited; entityContactEvent.IsCTW = 0; //开始日期是当天的 状态直接变为运行中 if (DateTime.Compare(Convert.ToDateTime(para.BeginDate), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0 && DateTime.Compare(Convert.ToDateTime(para.EndDate), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) >= 0) { entityContactEvent.Status = 2; } else { entityContactEvent.Status = 1; } bllContactEvent.Create(entityContactEvent); ///保存奖品 生成奖品池 var entityPrize = new LPrizesEntity(); entityPrize.EventId = entityContactEvent.ContactEventId.ToString(); entityPrize.PrizeName = para.ContactEventName; entityPrize.PrizeTypeId = para.PrizeType; entityPrize.Point = para.Integral; entityPrize.CouponTypeID = string.Join(",", para.CouponTypeID);; entityPrize.CountTotal = para.PrizeCount; entityPrize.CreateBy = loggingSessionInfo.UserID; bllContactEvent.DeleteContactPrize(entityContactEvent.ContactEventId.ToString()); bllContactEvent.AddContactEventPrize(entityPrize); //入奖品池队列 LPrizePoolsBLL bllPools = new LPrizePoolsBLL(loggingSessionInfo); DataSet dsPools = bllPools.GetPrizePoolsByEvent(loggingSessionInfo.ClientID, entityContactEvent.ContactEventId.ToString()); if (dsPools != null && dsPools.Tables.Count > 0 && dsPools.Tables[0].Rows.Count > 0) { var poolsList = DataTableToObject.ConvertToList <CC_PrizePool>(dsPools.Tables[0]); if (poolsList != null && poolsList.Count > 0) { var redisPrizePoolsBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.PrizePools.RedisPrizePoolsBLL(); CC_PrizePool prizePool = new CC_PrizePool(); prizePool.CustomerId = loggingSessionInfo.ClientID; prizePool.EventId = entityContactEvent.ContactEventId.ToString(); redisPrizePoolsBLL.DeletePrizePoolsList(prizePool); redisPrizePoolsBLL.SetPrizePoolsToRedis(poolsList); } } rd.ContactEventId = entityContactEvent.ContactEventId.ToString(); rd.ErrMsg = "操作成功"; rd.Success = true; } } catch (APIException apiEx) { rd.Success = false; rd.ErrMsg = apiEx.Message; throw new APIException(apiEx.ErrorCode, apiEx.Message); } return(rd); }
protected override TemplateDetailRD ProcessRequest(APIRequest <TemplateDetailRP> pRequest) { var rd = new TemplateDetailRD(); var para = pRequest.Parameters; var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; CTW_LEventThemeBLL bllTheme = new CTW_LEventThemeBLL(loggingSessionInfo); CTW_LEventInteractionBLL bllInteraction = new CTW_LEventInteractionBLL(loggingSessionInfo); CTW_SpreadSettingBLL bllSpreadSetting = new CTW_SpreadSettingBLL(loggingSessionInfo); T_CTW_LEventsBLL bllEvents = new T_CTW_LEventsBLL(loggingSessionInfo); T_CTW_PanicbuyingEventBLL bllPanicbuying = new T_CTW_PanicbuyingEventBLL(loggingSessionInfo); //更新模板点击数量 T_CTW_LEventTemplateBLL bllTemplate = new T_CTW_LEventTemplateBLL(loggingSessionInfo); try { bllTemplate.UpdateTemplateInfo(para.TemplateId, 2); } catch { } ///获取模版信息 DataSet dsInteraction = bllInteraction.GetEventInteractionByTemplateId(para.TemplateId); if (dsInteraction != null && dsInteraction.Tables[0].Rows.Count > 0) { var entityInteraction = DataTableToObject.ConvertToList <EventInteractionInfo>(dsInteraction.Tables[0]); var entityTheme = DataTableToObject.ConvertToList <CTW_LEventThemeEntity>(bllTheme.GetThemeInfo(para.TemplateId).Tables[0]);//.QueryByEntity(new CTW_LEventThemeEntity() { TemplateId = new Guid(para.TemplateId), IsDelete = 0 }, null); List <CTW_LEventThemeEntity> listTheme = new List <CTW_LEventThemeEntity>(); foreach (var theme in entityTheme) { List <EventInteractionInfo> listEventInteractionInfo = new List <EventInteractionInfo>(); ///互动信息 foreach (var itemAction in entityInteraction.Where(a => a.ThemeId == theme.ThemeId.ToString() && a.TemplateId == theme.TemplateId.ToString())) { listEventInteractionInfo.Add(itemAction); if (itemAction.InteractionType == 1) { itemAction.GameEventImageList = DataTableToObject.ConvertToList <GameEventImageInfo>(bllEvents.GetImageList(itemAction.LeventId).Tables[0]); } if (itemAction.InteractionType == 2)//促销 { itemAction.PanicbuyingEventImage = DataTableToObject.ConvertToObject <PanicbuyingEventImageInfo>(bllPanicbuying.GetPanicbuyingEventImage(itemAction.LeventId).Tables[0].Rows[0]); } theme.EventInteractionList = listEventInteractionInfo; } ; listTheme.Add(theme); rd.TemplateThemeList = listTheme; } rd.ActivityGroupId = entityTheme.FirstOrDefault().ActivityGroupId; rd.TemplateId = entityTheme.FirstOrDefault().TemplateId.ToString(); rd.TemplateName = entityTheme.FirstOrDefault().TemplateName; rd.ImageURL = dsInteraction.Tables[0].Rows[0]["ImageURL"].ToString(); //推广设置 DataSet dsSpresd = bllSpreadSetting.GetSpreadSettingInfoByTemplateId(para.TemplateId); if (dsSpresd != null && dsSpresd.Tables[0].Rows.Count > 0) { rd.TemplateSpreadSettingList = DataTableToObject.ConvertToList <CTW_SpreadSettingEntity>(dsSpresd.Tables[0]); } ///获取商户所有信息 if (!string.IsNullOrEmpty(para.CTWEventId)) { T_CTW_LEventBLL bllCTWEvent = new T_CTW_LEventBLL(loggingSessionInfo); DataSet dsCTWEvent = bllCTWEvent.GetLeventInfoByCTWEventId(para.CTWEventId); ObjectImagesBLL bllImage = new ObjectImagesBLL(loggingSessionInfo); var bllPrizes = new LPrizesBLL(loggingSessionInfo); T_CTW_SpreadSettingBLL bllCustomerSpreadSetting = new T_CTW_SpreadSettingBLL(loggingSessionInfo); if (dsCTWEvent != null && dsCTWEvent.Tables.Count > 0 && dsCTWEvent.Tables[0].Rows.Count > 0) { rd.CustomerCTWEventInfo = DataTableToObject.ConvertToObject <CustomerCTWEventInfo>(dsCTWEvent.Tables[0].Rows[0]); //游戏活动信息 if (dsCTWEvent.Tables[0].Rows[0]["InteractionType"].ToString() == "1") { LEventsBLL bllLevents = new LEventsBLL(loggingSessionInfo); string strEventId = dsCTWEvent.Tables[0].Rows[0]["LeventId"].ToString(); var ds = bllLevents.GetNewEventInfo(strEventId); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { rd.CustomerCTWEventInfo.EventInfo = DataTableToObject.ConvertToObject <LEventsInfo>(ds.Tables[0].Rows[0]);//直接根据所需要的字段反序列化 } DataSet dsPrizes = bllPrizes.GetPirzeList(strEventId); if (dsPrizes.Tables != null && dsPrizes.Tables.Count > 0 && dsPrizes.Tables[0] != null && dsPrizes.Tables[0].Rows.Count > 0) { rd.CustomerCTWEventInfo.EventInfo.PrizeList = DataTableToObject.ConvertToList <Prize>(dsPrizes.Tables[0]); } rd.CustomerCTWEventInfo.EventInfo.ImageList = bllImage.QueryByEntity(new ObjectImagesEntity() { ObjectId = strEventId, IsDelete = 0 }, null).ToList(); } //促销活动信息 if (dsCTWEvent.Tables[0].Rows[0]["InteractionType"].ToString() == "2") { T_CTW_PanicbuyingEventKVBLL bllPanicbuyingEventKV = new T_CTW_PanicbuyingEventKVBLL(loggingSessionInfo); rd.CustomerCTWEventInfo.PanicbuyingEventInfo = DataTableToObject.ConvertToObject <T_CTW_PanicbuyingEventKVEntity>(bllPanicbuyingEventKV.GetPanicbuyingEventKV(para.CTWEventId).Tables[0].Rows[0]); T_CTW_LEventInteractionBLL bllEventInteraction = new T_CTW_LEventInteractionBLL(loggingSessionInfo); DataSet dsP = bllEventInteraction.GetPanicbuyingEventId(para.CTWEventId); if (dsP != null && dsP.Tables.Count > 0 && dsP.Tables[0].Rows.Count > 0) { rd.CustomerCTWEventInfo.PanicbuyingEventInfo.PanicbuyingEventList = DataTableToObject.ConvertToList <PanicbuyingEventId>(dsP.Tables[0]); } } //图文信息 var ds2 = bllCTWEvent.GetMaterialTextInfo(dsCTWEvent.Tables[0].Rows[0]["OnlineQRCodeId"].ToString());//活动图文素材对应的keyword其实是这个活动的标识,也就是生成二维码的关键字 if (ds2 != null && ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0) { rd.CustomerCTWEventInfo.MaterialText = DataTableToObject.ConvertToObject <WMaterialTextEntity>(ds2.Tables[0].Rows[0]);//直接根据所需要的字段反序列化 rd.CustomerCTWEventInfo.MappingId = ds2.Tables[0].Rows[0]["MappingId"].ToString(); } //推广设置 DataSet dsCustomerSpread = bllCustomerSpreadSetting.GetSpreadSettingByCTWEventId(para.CTWEventId); if (dsCustomerSpread != null && dsCustomerSpread.Tables[0].Rows.Count > 0) { rd.CustomerCTWEventInfo.SpreadSettingList = DataTableToObject.ConvertToList <T_CTW_SpreadSettingEntity>(dsCustomerSpread.Tables[0]); } //触点 ContactEventBLL bllContactEvent = new ContactEventBLL(loggingSessionInfo); DataSet dsContact = bllContactEvent.GetContactEventByCTWEventId(para.CTWEventId); if (dsContact != null && dsContact.Tables[0].Rows.Count > 0) { List <ContactEventInfo> ContactInfoList = new List <ContactEventInfo>(); ContactEventInfo ContactInfo = new ContactEventInfo(); foreach (DataRow dr in dsContact.Tables[0].Rows) { ContactInfo = new ContactEventInfo(); ContactInfo.ContactTypeCode = dr["ContactTypeCode"].ToString(); DataSet dsPrizes = bllPrizes.GetPirzeListForCTW(dr["ContactEventId"].ToString()); if (dsPrizes.Tables != null && dsPrizes.Tables.Count > 0 && dsPrizes.Tables[0] != null && dsPrizes.Tables[0].Rows.Count > 0) { ContactInfo.ContactPrizeList = DataTableToObject.ConvertToList <Prize>(dsPrizes.Tables[0]); } ContactInfoList.Add(ContactInfo); } rd.CustomerCTWEventInfo.ContactEventList = ContactInfoList; } } rd.CTWEventId = para.CTWEventId; } else { rd.CTWEventId = Guid.NewGuid().ToString(); } } return(rd); }