Пример #1
0
        protected override EndOfEventRD ProcessRequest(APIRequest <EndOfEventRP> pRequest)
        {
            var                rd   = new EndOfEventRD();
            var                para = pRequest.Parameters;
            var                loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            T_CTW_LEventBLL    bllCTWEvent        = new T_CTW_LEventBLL(loggingSessionInfo);
            T_CTW_LEventEntity entityCTWEvent     = new T_CTW_LEventEntity();

            entityCTWEvent        = bllCTWEvent.GetByID(para.CTWEventId);
            entityCTWEvent.Status = 40;
            bllCTWEvent.Update(entityCTWEvent, null);

            if (para.EventType == "Game")
            {
                T_CTW_LEventInteractionBLL bllEventInteraction = new T_CTW_LEventInteractionBLL(loggingSessionInfo);
                string strEventId = bllEventInteraction.QueryByEntity(new T_CTW_LEventInteractionEntity()
                {
                    CTWEventId = new Guid(para.CTWEventId)
                }, null).FirstOrDefault().LeventId;
                LEventsBLL bllEvent    = new LEventsBLL(loggingSessionInfo);
                var        entityEvent = bllEvent.GetByID(strEventId);
                entityEvent.EventStatus = 40;
                bllEvent.Update(entityEvent, false);
            }
            if (para.EventType == "Sales")
            {
                PanicbuyingEventBLL bllEvent = new PanicbuyingEventBLL(loggingSessionInfo);

                bllEvent.EndOfEvent(para.CTWEventId);
            }
            rd.CTWEventId = para.CTWEventId;
            return(rd);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
0
        public void PushWeiXin(string OpenId, LoggingSessionInfo loggingSessionInfo, string OrderId, string VipId)
        {
            string webUrl  = ConfigurationManager.AppSettings["website_url"];
            string msgUrl  = ConfigurationManager.AppSettings["push_weixin_msg_url"];;
            Random rad     = new Random();
            string msgText = "<a href='" + webUrl + "wap/Event/20131109/aboutEvent.htm'>点击查看本次活动议程</a>";
            string msgData = "<xml><OpenID><![CDATA[" + OpenId + "]]></OpenID>"
                             + "<Content><![CDATA[" + msgText + "]]></Content></xml>";

            //var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData);
            #region 发送日志
            MarketSendLogBLL    logServer = new MarketSendLogBLL(loggingSessionInfo);
            MarketSendLogEntity logInfo   = new MarketSendLogEntity();
            logInfo.LogId           = BaseService.NewGuidPub();
            logInfo.IsSuccess       = 1;
            logInfo.MarketEventId   = OrderId;
            logInfo.SendTypeId      = "2";
            logInfo.TemplateContent = msgData;
            logInfo.VipId           = VipId;
            logInfo.WeiXinUserId    = OpenId;
            logInfo.CreateTime      = System.DateTime.Now;
            logServer.Create(logInfo);
            #endregion

            #region
            msgText = "亲爱的,为答谢您参加本次活动,主办方推出多个奖品的刮刮卡等你来刮,快来试试运气,<a href='" + webUrl + "OnlineClothing/1109guagua.html?customerId="
                      + loggingSessionInfo.CurrentUser.customer_id
                      + "&userId="
                      + VipId
                      + "&openId="
                      + OpenId
                      + "&eventId=" + OrderId + "'>点击试试手气</a>";
            //msgData = "<xml><OpenID><![CDATA[" + OpenId + "]]></OpenID>"
            //                + "<Content><![CDATA[" + msgText + "]]></Content></xml>";
            LEventsBLL    eventServer = new LEventsBLL(loggingSessionInfo);
            LEventsEntity eventInfo   = new LEventsEntity();
            eventInfo = eventServer.GetByID(OrderId);
            if (eventInfo != null && eventInfo.EventID != null)
            {
                string picUrl1 = eventInfo.Content;
                string Url1    = "" + webUrl + "OnlineClothing/1109guagua.html?customerId="
                                 + loggingSessionInfo.CurrentUser.customer_id
                                 + "&userId="
                                 + VipId
                                 + "&openId="
                                 + OpenId
                                 + "&eventId=" + OrderId + "";
                msgData = "<xml>"
                          + "<OpenID><![CDATA[" + OpenId + "]]></OpenID>"
                          + "<MsgType><![CDATA[news]]></MsgType>"
                          + "<Articles>"
                          + "<item>"
                          + "<Title><![CDATA[活动刮刮卡,惊喜享不停!]]></Title> "
                          + "<Description><![CDATA[亲!为答谢您来参加本次活动,我们特别推出刮刮卡,大量精美奖品等你来取,快来试试运气吧。]]></Description> "
                          + "<Url><![CDATA[" + Url1 + "]]></Url> "
                          + "<PicUrl><![CDATA[" + picUrl1 + "]]></PicUrl> "
                          + "</item>"
                          + "</Articles>"
                          + "</xml>";

                var msgResult1 = Common.Utils.GetRemoteData(msgUrl, "POST", msgData);
            }
            #endregion

            #region 发送日志
            MarketSendLogEntity logInfo1 = new MarketSendLogEntity();
            logInfo1.LogId           = BaseService.NewGuidPub();
            logInfo1.IsSuccess       = 1;
            logInfo1.MarketEventId   = OrderId;
            logInfo1.SendTypeId      = "2";
            logInfo1.TemplateContent = msgData;
            logInfo1.VipId           = VipId;
            logInfo1.WeiXinUserId    = OpenId;
            logInfo1.CreateTime      = System.DateTime.Now;
            logServer.Create(logInfo1);
            #endregion
        }
Пример #6
0
        /// <summary>
        /// 活动报名表数据获取
        /// </summary>
        public string getEventApplyQues()
        {
            string ReqContent = string.Empty;
            string content    = string.Empty;
            var    respObj    = new getEventApplyQuesRespData();
            string respStr    = string.Empty;

            try
            {
                ReqContent = Request["ReqContent"];
                ReqContent = HttpUtility.HtmlDecode(ReqContent);
                var reqContentObj = ReqContent.DeserializeJSONTo <getEventApplyQuesReqData>();

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format(
                        "getEventApplyQues ReqContent:{0}",
                        ReqContent)
                });
                if (!string.IsNullOrEmpty(reqContentObj.common.customerId))
                {
                    customerId = reqContentObj.common.customerId;
                }
                LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");
                var service = new WEventUserMappingBLL(loggingSessionInfo);

                GetResponseParams <QuestionnaireEntity> returnDataObj = service.getEventApplyQues(
                    reqContentObj.special.eventId);

                var contentObj = new getEventApplyQuesRespContentData();
                respObj.code        = returnDataObj.Code;
                respObj.description = returnDataObj.Description;


                if (returnDataObj.Flag == "1" && returnDataObj.Params != null)
                {
                    contentObj.questionCount = Default.ToStr(returnDataObj.Params.QuestionCount);

                    // questions
                    if (returnDataObj.Params.QuesQuestionEntityList != null)
                    {
                        contentObj.questions = new List <getEventApplyQuesRespQuestionData>();
                        foreach (var tmpQuestion in returnDataObj.Params.QuesQuestionEntityList)
                        {
                            if (tmpQuestion == null)
                            {
                                continue;
                            }
                            var tmpQues = new getEventApplyQuesRespQuestionData();
                            tmpQues.questionId     = Default.ToStr(tmpQuestion.QuestionID);
                            tmpQues.isSaveOutEvent = Default.ToStr(tmpQuestion.IsSaveOutEvent);
                            tmpQues.cookieName     = Default.ToStr(tmpQuestion.CookieName);
                            tmpQues.questionText   = Default.ToStr(tmpQuestion.QuestionDesc);
                            tmpQues.questionType   = Default.ToStr(tmpQuestion.QuestionType);
                            tmpQues.minSelected    = Default.ToStr(tmpQuestion.MinSelected);
                            tmpQues.maxSelected    = Default.ToStr(tmpQuestion.MaxSelected);
                            tmpQues.isRequired     = Default.ToStr(tmpQuestion.IsRequired);
                            tmpQues.isFinished     = Default.ToStr(tmpQuestion.IsFinished);

                            // options
                            if (tmpQuestion.QuesOptionEntityList != null)
                            {
                                tmpQues.options = new List <getEventApplyQuesRespOptionData>();
                                foreach (var tmpOption in tmpQuestion.QuesOptionEntityList)
                                {
                                    if (tmpOption == null)
                                    {
                                        continue;
                                    }
                                    var tmpOp = new getEventApplyQuesRespOptionData();
                                    tmpOp.optionId   = Default.ToStr(tmpOption.OptionsID);
                                    tmpOp.optionText = Default.ToStr(tmpOption.OptionsText);
                                    tmpOp.isSelected = Default.ToStr(tmpOption.IsSelect);
                                    tmpQues.options.Add(tmpOp);
                                }
                            }

                            contentObj.questions.Add(tmpQues);
                        }
                    }
                }

                respObj.content = contentObj;
                LEventsBLL    eventServer = new LEventsBLL(loggingSessionInfo);
                LEventsEntity eventInfo   = new LEventsEntity();
                eventInfo = eventServer.GetByID(reqContentObj.special.eventId);
                respObj.content.imageUrl = eventInfo.URL;

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format(
                        "getEventApplyQues RespContent:{0}",
                        respObj.ToJSON())
                });
            }
            catch (Exception ex)
            {
                respObj.code        = "103";
                respObj.description = "数据库操作错误";
                //respObj.exception = ex.ToString();
            }
            content = respObj.ToJSON();
            return(content);
        }