Пример #1
0
        protected override LotteryRD ProcessRequest(DTO.Base.APIRequest <LotteryRP> pRequest)
        {
            var rd       = new LotteryRD();//返回值
            var bllPrize = new LPrizesBLL(this.CurrentUserInfo);
            var para     = pRequest.Parameters;

            if (para.EventId != null && para.EventId != "")
            {
                try
                {
                    if (string.IsNullOrEmpty(para.ShareUserId))
                    {
                        rd.ResultMsg = "该活动未分享";
                        return(rd);
                    }
                    else
                    {
                        rd = bllPrize.CheckIsWinnerForShareForRedis(para.ShareUserId, para.EventId, para.Type, this.CurrentUserInfo);
                    }
                }
                catch (Exception ex)
                {
                    rd.ResultMsg = ex.Message.ToString();
                }
            }
            else
            {
                rd.ResultMsg = "参数EventId有误";
            }



            return(rd);
        }
Пример #2
0
        protected override LotteryRD ProcessRequest(DTO.Base.APIRequest <LotteryRP> pRequest)
        {
            var rd       = new LotteryRD();//返回值
            var bllPrize = new LPrizesBLL(this.CurrentUserInfo);
            var para     = pRequest.Parameters;

            if (para.EventId != null && para.EventId != "")
            {
                try
                {
                    rd = bllPrize.RedisRedPacket(pRequest.UserID, para.EventId, pRequest.CustomerID);
                }
                catch (Exception ex)
                {
                    rd.ErrCode   = -1;
                    rd.ResultMsg = ex.Message.ToString();
                }
            }
            else
            {
                rd.ErrCode   = -2;
                rd.ResultMsg = "参数EventId有误";
            }

            return(rd);
        }
Пример #3
0
        public void GetContact()
        {
            try
            {
                var                numCount              = 30;
                var                customerIDs           = CustomerBLL.Instance.GetCustomerList();
                CC_Connection      connection            = new CC_Connection();
                LoggingSessionInfo _loggingSessionInfo   = new LoggingSessionInfo();
                LoggingManager     CurrentLoggingManager = new LoggingManager();
                foreach (var customer in customerIDs)
                {
                    var count = RedisOpenAPI.Instance.CCContact().GetContactLength(new CC_Contact
                    {
                        CustomerId = customer.Key
                    });
                    if (count.Code != ResponseCode.Success)
                    {
                        continue;
                    }
                    if (count.Result <= 0)
                    {
                        continue;
                    }


                    _loggingSessionInfo.ClientID              = customer.Key;
                    CurrentLoggingManager.Connection_String   = customer.Value;
                    _loggingSessionInfo.CurrentLoggingManager = CurrentLoggingManager;
                    var lPrizeBll = new LPrizesBLL(_loggingSessionInfo);

                    if (count.Result < numCount)
                    {
                        numCount = Convert.ToInt32(count.Result);
                    }
                    BaseService.WriteLog("触点:" + customer.Key + "_" + customer.Value + ",数量" + numCount.ToString());
                    for (var i = 0; i < numCount; i++)
                    {
                        var response = RedisOpenAPI.Instance.CCContact().GetContact(new CC_Contact
                        {
                            CustomerId = customer.Key
                        });
                        if (response.Code == ResponseCode.Success)
                        {
                            lPrizeBll.CheckIsWinnerForShareForRedis(response.Result.VipId, response.Result.EventId, response.Result.ContactType, _loggingSessionInfo);
                        }
                    }
                    BaseService.WriteLog("触点结束");
                }
            }
            catch (Exception ex)
            {
                BaseService.WriteLog("触点异常" + ex.Message.ToString());
            }
        }
Пример #4
0
        public static void TestMethod(LoggingSessionInfo userinfo, string strUserId, string strEventId, string strCustomerId)
        {
            var bllPrize = new LPrizesBLL(userinfo);

            bllPrize.RedPacket2(strUserId, strEventId, strCustomerId);
        }
Пример #5
0
        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);
        }
Пример #6
0
        protected override GetEventPrizesRD ProcessRequest(DTO.Base.APIRequest <GetEventPrizesRP> pRequest)
        {
            GetEventPrizesRD rd = new GetEventPrizesRD();

            string vipID = pRequest.UserID;

            //string vipID = "f3d925e364e34bf69dfda34fcedc58f8";
            string vipName           = string.Empty;
            string reCommandId       = pRequest.Parameters.RecommandId;
            string eventId           = pRequest.Parameters.EventId;
            float  longitude         = pRequest.Parameters.Longitude;
            float  latitude          = pRequest.Parameters.Latitude;
            string customerId        = this.CurrentUserInfo.ClientID;
            int    pointsLotteryFlag = pRequest.Parameters.PointsLotteryFlag;

            if (string.IsNullOrEmpty(customerId))
            {
                customerId = "f6a7da3d28f74f2abedfc3ea0cf65c01";
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

            #region 是否在活动现场
            //respData.content.isSite = "1";
            rd.content = new EventPrizesInfo {
                IsSite = 1
            };

            #endregion

            #region 判断活动是否需要注册

            var leventsBll = new LEventsBLL(this.CurrentUserInfo);

            var enableFlag = leventsBll.GetEnableFlagByEventId(eventId);

            var vipService = new VipBLL(loggingSessionInfo);
            rd.SignFlag = 1;
            //如果需要注册,则判断该会员有没有注册,没有返回
            if (enableFlag.Substring(0, 1) == "1")
            {
                var vipEntity = vipService.GetByID(vipID);
                if (vipEntity == null)
                {
                    rd.SignFlag = 0;
                    return(rd);
                }
                else
                {
                    rd.SignFlag = 1;
                    vipID       = vipEntity.VIPID;
                    vipName     = vipEntity.VipName;
                }
            }



            #endregion

            #region 获取VIPID

            #endregion



            #region

            Loggers.Debug(new DebugLogInfo()
            {
                Message = "vipName = " + vipName
                          + ",vipID =" + vipID
                          + ",eventId=" + eventId
                          + ",longitude" + longitude
                          + ",latitude" + latitude
                          + ",customerId" + customerId
                          + ",reCommandId" + reCommandId
            });
            LPrizePoolsBLL poolsServer = new LPrizePoolsBLL(loggingSessionInfo);
            var            ds          = poolsServer.GetEventWinningInfo(vipName, vipID, eventId, longitude, latitude, customerId, reCommandId, pointsLotteryFlag);

            int    isLottery  = Convert.ToInt32(ds.Tables[0].Rows[0]["IsLottery"]);
            int    winnerFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["WinnerFlag"]);//是否中奖
            string prizeName  = ds.Tables[0].Rows[0]["prizeName"].ToString();
            string prizesId   = ds.Tables[0].Rows[0]["prizesId"].ToString();


            rd.content.IsLottery      = isLottery;
            rd.content.IsWinning      = winnerFlag;
            rd.content.WinningDesc    = prizeName;
            rd.content.Remark         = ds.Tables[0].Rows[0]["Remark"].ToString();
            rd.content.WinningExplan  = ds.Tables[0].Rows[0]["PrizeDesc"].ToString();
            rd.content.EventRound     = ds.Tables[0].Rows[0]["EventRoundId"].ToString();
            rd.content.Status         = Convert.ToInt32(ds.Tables[0].Rows[0]["step"].ToString());
            rd.content.PrizesTypeName = ds.Tables[0].Rows[0]["prizeTypeName"].ToString();
            rd.content.PrizesName     = ds.Tables[0].Rows[0]["prizesName"].ToString();
            rd.content.EventPoints    = Convert.ToInt32(ds.Tables[0].Rows[0]["EventPoints"].ToString());

            #region update by wzq 2014/07/01 积分兑换标识(活动,个人)
            rd.content.PersonPointsLotteryFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["PersonPointsLotteryFlag"].ToString());
            rd.content.EventPointsLotteryFlag  = Convert.ToInt32(ds.Tables[0].Rows[0]["EventPointsLotteryFlag"].ToString());
            #endregion

            #endregion


            #region 推荐人
            //活动是否分享


            var isShare = leventsBll.GetIsShareByEventId(eventId);

            rd.IsShare = isShare;
            Loggers.Debug(new DebugLogInfo()
            {
                Message = "isShare = " + isShare
            });

            CouponBLL couponService = new CouponBLL(loggingSessionInfo);

            //Updated by Willie Yan on 2014-05-30   必须是新推荐的会员
            if (isShare == 1 && !couponService.IfRecordedRecommendTrace(vipID, reCommandId))
            {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "reCommandId = " + reCommandId + ", VipID = " + vipID
                });
                if (reCommandId != "" && !string.IsNullOrEmpty(reCommandId))
                {
                    if (reCommandId != vipID)
                    {
                        var vipEntity = vipService.GetByID(vipID);
                        vipEntity.HigherVipID = reCommandId;
                        vipService.Update(vipEntity);

                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = "Update HigherVipID = " + reCommandId + "for vipid=" + vipID
                        });

                        //查看推荐人成功推荐人数,满足条件给奖励

                        //TODO:added by zhangwei20141009,保存上下线记录
                        couponService.UpdateVipRecommandTrace(vipID, reCommandId);
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = "UpdateVipRecommandTrace vipid=" + vipID + ",reCommandId= " + reCommandId
                        });

                        couponService.RecommenderPrize(reCommandId, eventId);
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = "RecommenderPrize reCommandId= " + reCommandId
                        });
                    }
                }
            }

            //推荐人是否为空

            //推荐人跟vipId是否相同
            #endregion

            #region 奖品集合

            LPrizesBLL prizesService = new LPrizesBLL(loggingSessionInfo);

            var orderby = new List <OrderBy> {
                new OrderBy()
                {
                    FieldName = "DisplayIndex", Direction = OrderByDirections.Asc
                }
            };


            var prizesList = prizesService.QueryByEntity(new LPrizesEntity()
            {
                EventId = eventId
            }, orderby.ToArray());

            rd.content.PrizesList = new List <PrizesEntity>();
            if (prizesList != null && prizesList.Length > 0)
            {
                foreach (var item in prizesList)
                {
                    var entity = new PrizesEntity()
                    {
                        PrizesID     = item.PrizesID,
                        PrizeName    = item.PrizeName,
                        PrizeDesc    = item.PrizeDesc,
                        DisplayIndex = item.DisplayIndex.ToString(),
                        CountTotal   = item.CountTotal.ToString(),
                        ImageUrl     = item.ImageUrl,
                        Sponsor      = item.ContentText
                    };

                    if (prizesId == item.PrizesID)
                    {
                        rd.content.PrizeIndex = item.DisplayIndex;
                    }
                    rd.content.PrizesList.Add(entity);
                }
            }

            #endregion


            #region 中奖集合
            var winDs = poolsServer.GetPersonWinnerList(vipID, eventId);
            rd.content.WinnerList = new List <WinnerList>();
            if (winDs != null && winDs.Tables.Count > 0 && winDs.Tables[0].Rows.Count > 0)
            {
                rd.content.WinnerList = DataTableToObject.ConvertToList <WinnerList>(winDs.Tables[0]);
            }

            #endregion


            #region  新增字段



            var leventsInfoDs = leventsBll.GetLeventsInfoDataSet(eventId);

            if (leventsInfoDs.Tables[0].Rows.Count > 0)
            {
                rd.BootUrl        = leventsInfoDs.Tables[0].Rows[0]["BootUrl"].ToString();
                rd.OverRemark     = leventsInfoDs.Tables[0].Rows[0]["OverRemark"].ToString();
                rd.PosterImageUrl = leventsInfoDs.Tables[0].Rows[0]["PosterImageUrl"].ToString();
                rd.ShareRemark    = leventsInfoDs.Tables[0].Rows[0]["ShareRemark"].ToString();
                rd.ShareLogoUrl   = leventsInfoDs.Tables[0].Rows[0]["ShareLogoUrl"].ToString();
            }

            #endregion

            #region 添加引导页URL

            //var bootDs = leventsBll.GetBootUrlByEventId(eventId);

            //if (bootDs.Tables[0].Rows.Count > 0)
            //{
            //    rd.ShareRemark = bootDs.Tables[0].Rows[0]["ShareRemark"].ToString();
            //    rd.OverRemark = bootDs.Tables[0].Rows[0]["OverRemark"].ToString();
            //    rd.PosterImageUrl = bootDs.Tables[0].Rows[0]["PosterImageUrl"].ToString();
            //    rd.BootUrl = bootDs.Tables[0].Rows[0]["BootUrl"].ToString();
            //}

            #endregion
            return(rd);
        }
Пример #7
0
        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);
        }
Пример #8
0
        /// <summary>
        /// 获取活动奖项信息
        /// </summary>
        public string getEventPrizes()
        {
            string content = string.Empty;

            var respData = new getEventPrizesRespData();

            try
            {
                string reqContent = Request["ReqContent"];
                var    reqObj     = reqContent.DeserializeJSONTo <getEventPrizesReqData>();

                string openId    = reqObj.common.openId;
                string weixinId  = reqObj.common.weiXinId ?? reqObj.common.openId;
                string eventId   = reqObj.special.eventId;  //活动ID
                string vipId     = reqObj.common.userId;
                string vipName   = string.Empty;
                string longitude = reqObj.special.longitude;   //经度
                string latitude  = reqObj.special.latitude;    //纬度

                if (string.IsNullOrEmpty(eventId))
                {
                    eventId = "E5A304D716D14CD2B96560EBD2B6A29C";
                }

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("getEventPrizes: {0}", reqContent)
                });

                //判断客户ID是否传递
                if (!string.IsNullOrEmpty(reqObj.common.customerId))
                {
                    customerId = reqObj.common.customerId;
                }
                var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                respData.content           = new getEventPrizesRespContentData();
                respData.content.prizeList = new List <PrizesEntity>();

                var eventList = new LEventsBLL(loggingSessionInfo).QueryByEntity(new LEventsEntity {
                    EventID = eventId
                }, null);

                if (eventList != null && eventList.Length > 0)
                {
                    var eventEntity = eventList.FirstOrDefault();

                    if (Convert.ToDateTime(eventEntity.EndTime).AddDays(1) > DateTime.Now)  //当天还是有效的   updated by Willie Yan on 2014-04-28
                    {
                        #region 获取VIPID

                        VipBLL vipService = new VipBLL(loggingSessionInfo);
                        var    vipList    = vipService.QueryByEntity(new VipEntity()
                        {
                            WeiXinUserId = openId
                        }, null);

                        if (vipList == null || vipList.Length == 0)
                        {
                            respData.code        = "103";
                            respData.description = "未查找到匹配的VIP信息";
                            return(respData.ToJSON());
                        }
                        else
                        {
                            vipId   = vipList.FirstOrDefault().VIPID;
                            vipName = vipList.FirstOrDefault().VipName;
                        }

                        #endregion

                        //查询抽奖日志
                        LLotteryLogBLL lotteryService = new LLotteryLogBLL(loggingSessionInfo);
                        var            lotteryList    = lotteryService.QueryByEntity(new LLotteryLogEntity()
                        {
                            EventId = eventId, VipId = vipId
                        }, null);

                        #region 奖品信息

                        LPrizesBLL prizesService = new LPrizesBLL(loggingSessionInfo);

                        var prizesList = prizesService.QueryByEntity(new LPrizesEntity()
                        {
                            EventId = eventId
                        },
                                                                     new OrderBy[] { new OrderBy {
                                                                                         FieldName = " DisplayIndex ", Direction = OrderByDirections.Asc
                                                                                     } });

                        if (prizesList != null && prizesList.Length > 0)
                        {
                            foreach (var item in prizesList)
                            {
                                var entity = new PrizesEntity()
                                {
                                    prizesID     = item.PrizesID,
                                    prizeName    = item.PrizeName,
                                    prizeDesc    = item.PrizeDesc,
                                    displayIndex = item.DisplayIndex.ToString(),
                                    countTotal   = item.CountTotal.ToString(),
                                    imageUrl     = item.ImageUrl
                                };

                                respData.content.prizeList.Add(entity);
                            }
                        }

                        #endregion

                        #region 抽奖信息

                        //respData.content.lotteryCount = eventEntity.PrizesCount.ToString();
                        respData.content.lotteryNumber = "0";
                        respData.content.validTime     = ConfigurationManager.AppSettings["ValidTime"];
                        int totalLotteryCount = 0;

                        //获取剩余抽奖次数
                        VwVipCenterInfoBLL vwVipCenterInfoBLL = new VwVipCenterInfoBLL(loggingSessionInfo);
                        var vwVipCenterInfo = vwVipCenterInfoBLL.GetByID(vipId);
                        totalLotteryCount = vwVipCenterInfo.LotteryCount ?? 0;

                        //获取已抽奖次数
                        if (lotteryList != null && lotteryList.Length > 0)
                        {
                            respData.content.lotteryNumber = lotteryList.FirstOrDefault().LotteryCount.ToString();
                        }
                        else
                        {
                            totalLotteryCount++; //如果未抽奖,活动默认有一次抽奖机会
                        }
                        //判断抽奖次数是否有效
                        if (Convert.ToInt32(respData.content.lotteryNumber) >= totalLotteryCount)
                        {
                            respData.content.isLottery   = "0";
                            respData.content.lotteryDesc = "您已经没有抽奖机会了,想得到更多抽奖机会,请在对话栏内发送中文“分享”给我们,获得图文消息后多多转发。详情关注“推荐有礼”菜单。";
                        }
                        else
                        {
                            //判断之前是否已经中奖
                            LPrizeWinnerBLL winnerService = new LPrizeWinnerBLL(loggingSessionInfo);
                            var             prize         = winnerService.GetWinnerInfo(vipId, eventId);

                            if (!prize.Read())
                            {
                                //抽奖
                                LPrizePoolsBLL poolsServer   = new LPrizePoolsBLL(loggingSessionInfo);
                                var            returnDataObj = poolsServer.SetShakeOffLottery(vipName, vipId, eventId, ToFloat(longitude), ToFloat(latitude));

                                if (returnDataObj.Params.result_code.Equals("1"))   //中奖
                                {
                                    //获取奖品信息
                                    prize = winnerService.GetWinnerInfo(vipId, eventId);
                                    if (prize.Read())
                                    {
                                        var prizeValue = GetPrizeValue(prize["PrizeShortDesc"].ToString());

                                        respData.content.isLottery    = "1";
                                        respData.content.lotteryDesc  = returnDataObj.Params.result_message;// "恭喜您中奖了";
                                        respData.content.isWinning    = "1";
                                        respData.content.winningValue = prizeValue;
                                    }
                                    //added by zhangwei 中奖后绑定推荐关系,设置奖项
                                    BindRecommender();
                                    setEventPrizes();
                                }
                                else    //没有中奖,一直能抽奖
                                {
                                    respData.content.isLottery    = "1";
                                    respData.content.isWinning    = "0";
                                    respData.content.winningValue = "0";
                                    respData.content.lotteryDesc  = "恭喜您中奖了";//张伟,为泸州老窖新人有礼前台判断使用
                                }
                            }
                            else
                            {
                                var prizeValue = GetPrizeValue(prize["PrizeShortDesc"].ToString());

                                respData.content.isLottery    = "1";
                                respData.content.lotteryDesc  = "恭喜您中奖了";
                                respData.content.isWinning    = "1";
                                respData.content.winningValue = prizeValue;
                            }
                            prize.Close();
                            respData.content.lotteryCount = totalLotteryCount.ToString();
                        }

                        #endregion
                    }
                    else
                    {
                        respData.content.isLottery   = "0";
                        respData.content.lotteryDesc = "活动已经结束";
                    }
                }
                else
                {
                    respData.content.isLottery   = "0";
                    respData.content.lotteryDesc = "指定的活动不存在";
                }
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "数据库操作错误";
                //respData.exception = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
Пример #9
0
        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;
        }
    }
}
Пример #10
0
        /// <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);
                }
            }
        }
Пример #11
0
        protected override SetCTWEventRD ProcessRequest(APIRequest <SetCTWEventRP> pRequest)
        {
            //图文信息
            //微信 公共平台
            var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity
            {
                CustomerId = loggingSessionInfo.ClientID,
                IsDelete   = 0
            }, null).FirstOrDefault();//取默认的第一个微信

            if (wapentity == null)
            {
                throw new APIException("微信公众号未授权")
                      {
                          ErrorCode = 343
                      };
            }

            var rd = new SetCTWEventRD();

            var para = pRequest.Parameters;

            strCTWEventId = para.CTWEventId;
            string strThemeId       = string.Empty;
            string strStartDate     = string.Empty;
            string strEndDate       = string.Empty;
            string strGameEventGuid = string.Empty;
            string strPageParamJson = string.Empty;

            T_CTW_LEventBLL             bllCustomerEvent       = new T_CTW_LEventBLL(loggingSessionInfo);
            T_CTW_LEventThemeBLL        bllCustomerTheme       = new T_CTW_LEventThemeBLL(loggingSessionInfo);
            T_CTW_LEventInteractionBLL  bllCustomerInteraction = new T_CTW_LEventInteractionBLL(loggingSessionInfo);
            T_CTW_PanicbuyingEventKVBLL bllPanicbuyingEventKV  = new T_CTW_PanicbuyingEventKVBLL(loggingSessionInfo);
            T_CTW_SpreadSettingBLL      bllSpreadSetting       = new T_CTW_SpreadSettingBLL(loggingSessionInfo);
            LPrizesBLL      bllPrize = new LPrizesBLL(loggingSessionInfo);
            ObjectImagesBLL imageBll = new ObjectImagesBLL(loggingSessionInfo);


            entityCustomerEvent = bllCustomerEvent.GetByID(strCTWEventId);
            if (entityCustomerEvent != null)
            {
                ///风格
                entityTheme = bllCustomerTheme.QueryByEntity(new T_CTW_LEventThemeEntity()
                {
                    CTWEventId = new Guid(strCTWEventId), OriginalThemeId = new Guid(para.OriginalThemeId)
                }, null).FirstOrDefault();
                //互动方式
                entityInteraction = bllCustomerInteraction.QueryByEntity(new T_CTW_LEventInteractionEntity {
                    CTWEventId = new Guid(strCTWEventId), OriginalLeventId = new Guid(para.OriginalLeventId)
                }, null).FirstOrDefault();
            }
            //保存风格
            SaveAndUpdateTheme(para, entityTheme, out strThemeId);
            //互动类型--游戏
            if (para.InteractionType == 1 && para.GameEventInfo != null)
            {
                SaveGameEvent(para, bllPrize, bllCustomerInteraction, strThemeId, out strStartDate, out strEndDate, out strGameEventGuid);
                para.MaterialText.PageParamJson = "[{\"key\":\"eventId\",\"value\":\"" + strCTWEventId + "\"}]";
                strPageParamJson = "[{\"key\":\"eventId\",\"value\":\"" + strCTWEventId + "\"}]";
            }
            //互动类型--促销
            if (para.InteractionType == 2 && para.PanicbuyingEventInfo != null)
            {
                SavePanicbuyingEvent(para, bllPanicbuyingEventKV, imageBll, bllCustomerInteraction, strThemeId, out strStartDate, out strEndDate);
                string strEventType = string.Empty;
                switch (para.DrawMethodCode)
                {
                case "TG":
                    strEventType = "1";
                    break;

                case "QG":
                    strEventType = "2";
                    break;

                case "RX":
                    strEventType = "3";
                    break;

                default:
                    strEventType = "99";
                    break;
                }
                para.MaterialText.PageParamJson = "[{\"key\":\"CTWEventId\",\"value\":\"" + strCTWEventId + "\"},{\"key\":\"eventTypeId\",\"value\":\"" + strEventType + "\"}]";
                strPageParamJson = "[{\"key\":\"CTWEventId\",\"value\":\"" + strCTWEventId + "\"},{\"key\":\"eventTypeId\",\"value\":\"" + strEventType + "\"}]";


                //SaveAndUpdatePanicbuyingEvent(para,bllPrize,bllPanicbuyingEventKV,imageBll,bllCustomerInteraction, strThemeId, out strStartDate, out strEndDate);
            }
            string strFocesQRCodeUrl = string.Empty;

            //分享,推广
            if (para.SpreadSettingList.Count > 0)
            {
                SaveSpreadSetting(para, bllSpreadSetting, imageBll, wapentity, out strFocesQRCodeUrl);
            }
            ///推广关注的奖励设置入 触点活动数据表
            if (para.ContactPrizeList != null && para.ContactPrizeList.Count > 0)
            {
                SaveContactPrize(para, bllPrize, strStartDate, strEndDate);
            }
            string strOnlineQRCodeId     = string.Empty;
            string strOfflineQRCodeId    = string.Empty;
            string strOnlineQRCodeUrl    = string.Empty;
            string strOfflineQRCodeUrl   = string.Empty;
            string strOnlineRedirectUrl  = string.Empty;
            string strOfflineRedirectUrl = string.Empty;

            var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo);

            if (!string.IsNullOrEmpty(para.OfflineQRCodeId))
            {
                WQRCodeManagerbll.Delete(new WQRCodeManagerEntity()
                {
                    QRCodeId = new Guid(para.OfflineQRCodeId)
                });
            }
            if (!string.IsNullOrEmpty(para.OnlineQRCodeId))
            {
                WQRCodeManagerbll.Delete(new WQRCodeManagerEntity()
                {
                    QRCodeId = new Guid(para.OnlineQRCodeId)
                });
            }
            CreateQRCode(para, wapentity, strPageParamJson, out strOfflineQRCodeId, out strOfflineQRCodeUrl, out strOfflineRedirectUrl);
            CreateH5QRCode(para, wapentity, out strOnlineQRCodeId, out strOnlineQRCodeUrl, out strOnlineRedirectUrl);

            rd.OfflineQRCodeUrl   = strOfflineQRCodeUrl;
            rd.OnlineQRCodeUrl    = strOnlineQRCodeUrl;
            rd.OfflineRedirectUrl = strOfflineRedirectUrl;
            rd.OnlineRedirectUrl  = strOnlineRedirectUrl;//strFocesQRCodeUrl;

            if (entityCustomerEvent != null)
            {   //活动主表
                entityCustomerEvent.Name               = para.TemplateName;
                entityCustomerEvent.Desc               = para.TemplateDesc;
                entityCustomerEvent.InteractionType    = para.InteractionType;
                entityCustomerEvent.ActivityGroupId    = new Guid(para.ActivityGroupId);
                entityCustomerEvent.ImageURL           = para.TemplateImageURL;
                entityCustomerEvent.StartDate          = Convert.ToDateTime(strStartDate);
                entityCustomerEvent.EndDate            = Convert.ToDateTime(strEndDate);
                entityCustomerEvent.OnlineQRCodeId     = strOnlineQRCodeId;
                entityCustomerEvent.OfflineQRCodeId    = strOfflineQRCodeId;
                entityCustomerEvent.OffLineRedirectUrl = strOfflineRedirectUrl;
                entityCustomerEvent.OnLineRedirectUrl  = strOnlineRedirectUrl;
                bllCustomerEvent.Update(entityCustomerEvent);
            }
            else
            {
                entityCustomerEvent = new T_CTW_LEventEntity()
                {
                    CTWEventId         = new Guid(para.CTWEventId),
                    TemplateId         = new Guid(para.TemplateId),
                    Name               = para.TemplateName,
                    Desc               = para.TemplateDesc,
                    ActivityGroupId    = new Guid(para.ActivityGroupId),
                    InteractionType    = para.InteractionType,
                    ImageURL           = para.TemplateImageURL,
                    Status             = 10,
                    CustomerId         = loggingSessionInfo.ClientID,
                    StartDate          = Convert.ToDateTime(strStartDate),
                    EndDate            = Convert.ToDateTime(strEndDate),
                    OfflineQRCodeId    = strOfflineQRCodeId,
                    OnlineQRCodeId     = strOnlineQRCodeId,
                    OffLineRedirectUrl = strOfflineRedirectUrl,
                    OnLineRedirectUrl  = strOnlineRedirectUrl
                };
                bllCustomerEvent.Create(entityCustomerEvent);
            }
            return(rd);
        }
Пример #12
0
        /// <summary>
        /// 保存更新游戏信息
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public void SaveGameEvent(SetCTWEventRP para, LPrizesBLL bllPrize, T_CTW_LEventInteractionBLL bllCustomerInteraction, string strThemeId, out string strStartDate, out string strEndDate, out string strGameEventGuid)
        {
            strGameEventGuid = string.Empty;

            var imageBll = new ObjectImagesBLL(loggingSessionInfo);

            LEventsBLL bllGameEvent = new LEventsBLL(loggingSessionInfo);

            var eventEntity = new LEventsEntity();

            strStartDate = para.GameEventInfo.BeginTime;
            strEndDate   = para.GameEventInfo.EndTime + " 23:59:59";
            if (string.IsNullOrEmpty(para.GameEventInfo.LeventId))
            {
                strGameEventGuid          = Guid.NewGuid().ToString();
                eventEntity.EventID       = strGameEventGuid;
                eventEntity.Title         = para.GameEventInfo.Title;
                eventEntity.BeginTime     = para.GameEventInfo.BeginTime;
                eventEntity.EndTime       = para.GameEventInfo.EndTime;
                eventEntity.DrawMethodId  = GetDrawMethodIdByDrawMethodCode(para.DrawMethodCode);
                eventEntity.PersonCount   = para.GameEventInfo.PersonCount;
                eventEntity.PointsLottery = para.GameEventInfo.PointsLottery;
                eventEntity.LotteryNum    = para.GameEventInfo.LotteryNum;
                eventEntity.IsDelete      = 0;

                if (DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.BeginTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) <= 0 && DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.EndTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) >= 0)
                {
                    eventEntity.EventStatus = 20;    //10=未开始,20=运行中,30=暂停,40=结束
                }
                else if (DateTime.Compare(Convert.ToDateTime(para.GameEventInfo.BeginTime), Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"))) > 0)
                {
                    eventEntity.EventStatus = 10;    //10=未开始,20=运行中,30=暂停,40=结束
                }
                eventEntity.IsCTW      = 1;
                eventEntity.CustomerId = loggingSessionInfo.ClientID;
                bllGameEvent.Create(eventEntity);
            }
            else
            {
                strGameEventGuid          = para.GameEventInfo.LeventId;
                eventEntity               = bllGameEvent.GetByID(strGameEventGuid);
                eventEntity.Title         = para.GameEventInfo.Title;
                eventEntity.BeginTime     = para.GameEventInfo.BeginTime;
                eventEntity.EndTime       = para.GameEventInfo.EndTime;
                eventEntity.DrawMethodId  = GetDrawMethodIdByDrawMethodCode(para.DrawMethodCode);
                eventEntity.PersonCount   = para.GameEventInfo.PersonCount;
                eventEntity.PointsLottery = para.GameEventInfo.PointsLottery;
                eventEntity.LotteryNum    = para.GameEventInfo.LotteryNum;

                bllGameEvent.Update(eventEntity);
            }

            ///图片
            if (para.GameEventInfo.ImageList.Count > 0)
            {
                imageBll.DeleteByObjectID(strGameEventGuid);

                foreach (var i in para.GameEventInfo.ImageList)
                {
                    imageEntity             = new ObjectImagesEntity();
                    imageEntity.ImageURL    = i.ImageURL;
                    imageEntity.ObjectId    = strGameEventGuid;
                    imageEntity.CreateBy    = loggingSessionInfo.UserID;
                    imageEntity.ImageId     = Guid.NewGuid().ToString();
                    imageEntity.BatId       = i.BatId;
                    imageEntity.RuleId      = para.GameEventInfo.RuleId ?? 1;
                    imageEntity.RuleContent = para.GameEventInfo.RuleContent;
                    imageEntity.IsDelete    = 0;
                    imageEntity.CustomerId  = loggingSessionInfo.ClientID;
                    imageBll.Create(imageEntity);
                }
            }
            //奖品信息
            var entityPrize        = new LPrizesEntity();
            var redisPrizePoolsBLL = new JIT.CPOS.BS.BLL.RedisOperationBLL.PrizePools.RedisPrizePoolsBLL();

            if (!string.IsNullOrEmpty(para.GameEventInfo.LeventId))
            {
                //bllPrize.Delete(new LPrizesEntity() { EventId = para.GameEventInfo.LeventId });
                bllPrize.DeletePrizesByEventId(para.GameEventInfo.LeventId);

                CC_PrizePool prizePool = new CC_PrizePool();
                prizePool.CustomerId = loggingSessionInfo.ClientID;
                prizePool.EventId    = para.GameEventInfo.LeventId;
                redisPrizePoolsBLL.DeletePrizePoolsList(prizePool);
            }
            if (para.GameEventInfo.PrizeList.Count > 0)
            {
                foreach (var i in para.GameEventInfo.PrizeList)
                {
                    entityPrize.EventId      = strGameEventGuid;
                    entityPrize.PrizeTypeId  = i.PrizeTypeId;
                    entityPrize.Point        = i.Point;
                    entityPrize.CouponTypeID = i.CouponTypeID;
                    entityPrize.PrizeName    = i.PrizeName;
                    entityPrize.CountTotal   = i.PrizeCount;
                    entityPrize.CreateBy     = loggingSessionInfo.UserID;
                    entityPrize.PrizesID     = Guid.NewGuid().ToString();

                    bllPrize.SavePrize(entityPrize);
                }

                //入奖品池队列
                LPrizePoolsBLL bllPools = new LPrizePoolsBLL(loggingSessionInfo);
                DataSet        dsPools  = bllPools.GetPrizePoolsByEvent(loggingSessionInfo.ClientID, strGameEventGuid);
                if (dsPools != null && dsPools.Tables.Count > 0 && dsPools.Tables[0].Rows.Count > 0)
                {
                    var poolTemp  = DataTableToObject.ConvertToList <CC_PrizePool>(dsPools.Tables[0]);
                    var poolsList = Utils.GetRandomList <CC_PrizePool>(poolTemp);   //随机列表
                    if (poolsList != null && poolsList.Count > 0)
                    {
                        CC_PrizePool prizePool = new CC_PrizePool();
                        prizePool.CustomerId = loggingSessionInfo.ClientID;
                        prizePool.EventId    = strGameEventGuid;

                        redisPrizePoolsBLL.DeletePrizePoolsList(prizePool);
                        redisPrizePoolsBLL.SetPrizePoolsToRedis(poolsList);
                    }
                }
            }
            if (!string.IsNullOrEmpty(para.CTWEventId))
            {
                bllCustomerInteraction.DeleteByCTWEventID(para.CTWEventId);
            }
            ///互动类型与(游戏或促销)关联
            entityInteraction = new T_CTW_LEventInteractionEntity()
            {
                CTWEventId       = new Guid(strCTWEventId),
                ThemeId          = new Guid(strThemeId),
                InteractionType  = para.InteractionType,
                DrawMethodCode   = para.DrawMethodCode,
                LeventId         = strGameEventGuid,
                OriginalLeventId = new Guid(para.OriginalLeventId),
                CustomerId       = loggingSessionInfo.ClientID
            };
            bllCustomerInteraction.Create(entityInteraction);
        }
Пример #13
0
        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);
        }
Пример #14
0
        protected override SetEvaluationRD ProcessRequest(APIRequest <SetEvaluationItemRP> pRequest)
        {
            SetEvaluationRD rd    = new SetEvaluationRD();
            var             bll   = new ObjectEvaluationBLL(CurrentUserInfo);
            var             pTran = bll.GetTran();//事务

            using (pTran.Connection)
            {
                try
                {
                    SetEvaluationItemRP rp = pRequest.Parameters;
                    var inoutBll           = new T_InoutBLL(CurrentUserInfo);
                    //评论订单
                    var entity = new ObjectEvaluationEntity()
                    {
                        EvaluationID = Guid.NewGuid().ToString(),
                        CustomerID   = pRequest.CustomerID,
                        VipID        = pRequest.UserID,
                        ObjectID     = rp.OrderID,
                        OrderID      = rp.OrderID,
                        Type         = rp.Type,
                        Content      = rp.Content,
                        StarLevel    = rp.StarLevel,
                        StarLevel1   = rp.StarLevel1,
                        StarLevel2   = rp.StarLevel2,
                        StarLevel3   = rp.StarLevel3,
                        StarLevel4   = rp.StarLevel4,
                        StarLevel5   = rp.StarLevel5,
                        Platform     = rp.Platform,
                        IsAnonymity  = rp.IsAnonymity
                    };
                    bll.Create(entity, pTran);

                    //批量评论商品
                    if (rp.ItemEvaluationInfo != null)
                    {
                        ObjectEvaluationEntity evaluation = null;
                        foreach (var item in rp.ItemEvaluationInfo)
                        {
                            evaluation             = new ObjectEvaluationEntity();
                            evaluation.ObjectID    = item.ObjectID;
                            evaluation.StarLevel   = item.StarLevel;
                            evaluation.Content     = item.Content;
                            evaluation.Remark      = item.Remark;
                            evaluation.CustomerID  = pRequest.CustomerID;
                            evaluation.IsAnonymity = rp.IsAnonymity;
                            evaluation.OrderID     = rp.OrderID;
                            evaluation.Type        = rp.Type;
                            evaluation.VipID       = pRequest.UserID;
                            bll.Create(evaluation, pTran);
                        }
                    }

                    //修改订单评论状态
                    var order = inoutBll.GetByID(rp.OrderID);
                    if (order != null)
                    {
                        order.IsEvaluation = 1;
                        inoutBll.Update(order, pTran);
                    }
                    pTran.Commit(); //提交事物

                    #region 评论触点活动奖励

                    var bllPrize = new LPrizesBLL(CurrentUserInfo);
                    //bllPrize.CheckIsWinnerForShare(CurrentUserInfo.UserID, "", "Comment");

                    RedisContactBLL redisContactBll = new RedisContactBLL();
                    redisContactBll.SetRedisContact(new RedisOpenAPIClient.Models.CC.CC_Contact()
                    {
                        CustomerId  = CurrentUserInfo.ClientID,
                        ContactType = "Comment",
                        VipId       = CurrentUserInfo.UserID
                    });

                    #endregion

                    try
                    {
                        var msg = new EventContract
                        {
                            Operation  = OptEnum.Create,
                            EntityType = EntityTypeEnum.OrderComment,
                            Id         = rp.OrderID
                        };
                        var eventService = new EventService();
                        eventService.PublishMsg(msg);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
                catch (Exception ex)
                {
                    pTran.Rollback();
                    throw new APIException(ex.Message);
                }
            }

            return(rd);
        }
Пример #15
0
        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);
        }