Exemplo n.º 1
0
        /// <summary>
        /// 活动抽奖日志列表
        /// </summary>
        /// <param name="EventID">活动ID</param>
        /// <param name="Page"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        public GetResponseParams <LLotteryLogEntity> GetEventLotteryLog(string EventID, int Page, int PageSize)
        {
            #region 判断对象不能为空
            if (EventID == null || EventID.ToString().Equals(""))
            {
                return(new GetResponseParams <LLotteryLogEntity>
                {
                    Flag = "0",
                    Code = "419",
                    Description = "活动ID不能为空",
                });
            }
            if (PageSize == 0)
            {
                PageSize = 15;
            }
            #endregion

            GetResponseParams <LLotteryLogEntity> response = new GetResponseParams <LLotteryLogEntity>();
            response.Flag        = "1";
            response.Code        = "200";
            response.Description = "成功";
            try
            {
                #region 业务处理
                LLotteryLogEntity usersInfo = new LLotteryLogEntity();

                usersInfo.ICount = _currentDAO.GetEventLotteryLogCount(EventID);

                IList <LLotteryLogEntity> usersInfoList = new List <LLotteryLogEntity>();
                if (usersInfo.ICount > 0)
                {
                    DataSet ds = new DataSet();
                    ds = _currentDAO.GetEventLotteryLogList(EventID, Page, PageSize);
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        usersInfoList = DataTableToObject.ConvertToList <LLotteryLogEntity>(ds.Tables[0]);
                    }
                }

                usersInfo.EntityList = usersInfoList;
                #endregion
                response.Params = usersInfo;
                return(response);
            }
            catch (Exception ex)
            {
                response.Flag        = "0";
                response.Code        = "103";
                response.Description = "错误:" + ex.ToString();
                return(response);
            }
        }
Exemplo n.º 2
0
        public void SetEventPrizes(string vipId, string eventId)
        {
            var tranHelper = new TransactionHelper(this.CurrentUserInfo);
            var tran       = tranHelper.CreateTransaction();

            using (tran.Connection)
            {
                LLotteryLogBLL lotteryService = new LLotteryLogBLL(this.CurrentUserInfo);
                var            lotterys       = lotteryService.QueryByEntity(new LLotteryLogEntity()
                {
                    EventId = eventId, VipId = vipId
                }, null);

                if (lotterys != null && lotterys.Length > 0)
                {
                    //更新
                    var lotteryEntity = lotterys.FirstOrDefault();
                    lotteryEntity.LotteryCount += 1;
                    lotteryService.Update(lotteryEntity, tran);
                }
                else
                {
                    //新增
                    var lotteryEntity = new LLotteryLogEntity()
                    {
                        LogId        = CPOS.Common.Utils.NewGuid(),
                        VipId        = vipId,
                        EventId      = eventId,
                        LotteryCount = 1
                    };
                    lotteryService.Create(lotteryEntity, tran);
                }

                //1、判断用户是否中奖
                //2、用户中奖 添加优惠券表(Coupon)和优惠券用户关系表(VipCouponMapping)
                //3、added by zhangwei用户中奖类型为积分则更新用户积分
                LPrizeWinnerBLL winnerService = new LPrizeWinnerBLL(this.CurrentUserInfo);
                var             prize         = winnerService.GetWinnerInfo(vipId, eventId);

                if (prize.Read())
                {
                    //取得奖品信息,看奖品类型是积分还是优惠券
                    var prizeMapping = winnerService.GetPrizeCouponTypeMapping(prize["PrizeWinnerID"].ToString(), tran);
                    if (prizeMapping.Tables[0].Rows.Count > 0)
                    {
                        //奖品如果是积分,则插入积分表
                        if (!string.IsNullOrEmpty(prizeMapping.Tables[0].Rows[0]["AwardPoints"].ToString()))
                        {
                            //新的积分方法 zhangwei2013-2-13
                            int IntegralSourceID = 16;
                            if (eventId.ToUpper() == "E5A304D716D14CD2B96560EBD2B6A29C")
                            {
                                IntegralSourceID = 16;
                            }
                            if (eventId.ToUpper() == "BFC41A8BF8564B6DB76AE8A8E43557BA")
                            {
                                IntegralSourceID = 17;
                            }
                            var objectID = prizeMapping.Tables[0].Rows[0]["PrizesID"].ToString();
                            if (!string.IsNullOrEmpty(objectID))
                            {
                                Loggers.DEFAULT.Debug(new DebugLogInfo
                                {
                                    Message = "抽奖成功:+IntegralSourceID:" + IntegralSourceID + "ClientID:" + CurrentUserInfo.ClientID + "VipID:" + vipId + "ObjectID:" + objectID
                                });
                                new VipIntegralBLL(CurrentUserInfo).ProcessPoint(IntegralSourceID,
                                                                                 CurrentUserInfo.ClientID, vipId,
                                                                                 objectID);
                            }
                            else
                            {
                                Loggers.DEFAULT.Debug(new DebugLogInfo
                                {
                                    Message = "抽奖失败:+IntegralSourceID:" + IntegralSourceID + "ClientID:" + CurrentUserInfo.ClientID + "VipID:" + vipId
                                });
                            }

                            /*
                             * //插入积分
                             * VipIntegralBLL vipIntegralBLL = new VipIntegralBLL(CurrentUserInfo);
                             * VipIntegralEntity vipIntegralEntity = new VipIntegralEntity();
                             * decimal integralValue = decimal.Parse(prizeMapping.Tables[0].Rows[0]["AwardPoints"].ToString());
                             * var vipIntegralDataList = vipIntegralBLL.QueryByEntity(
                             * new VipIntegralEntity() { VipID = vipId }, null);
                             * if (vipIntegralDataList == null || vipIntegralDataList.Length == 0 ||
                             *  vipIntegralDataList[0] == null)
                             * {
                             *
                             *  vipIntegralEntity.VipID = vipId;
                             *  vipIntegralEntity.InIntegral = integralValue; //累计积分
                             *  vipIntegralEntity.EndIntegral = integralValue; //积分余额
                             *  vipIntegralEntity.ValidIntegral = integralValue; // 当前有效积分
                             *  vipIntegralBLL.Create(vipIntegralEntity, tran);
                             * }
                             * else
                             * {
                             *  vipIntegralEntity = vipIntegralDataList[0];
                             *  vipIntegralEntity.VipID = vipId;
                             *  vipIntegralEntity.InIntegral = (vipIntegralEntity.InIntegral.HasValue ? vipIntegralEntity.InIntegral : 0) + integralValue; //累计积分
                             *  vipIntegralEntity.EndIntegral = (vipIntegralEntity.EndIntegral.HasValue ? vipIntegralEntity.EndIntegral : 0) + integralValue; //积分余额
                             *  vipIntegralEntity.ValidIntegral = (vipIntegralEntity.ValidIntegral.HasValue ? vipIntegralEntity.ValidIntegral : 0) + integralValue; // 当前有效积分
                             *  vipIntegralBLL.Update(vipIntegralEntity, false, tran);
                             * }
                             *
                             * //更新vip表积分记录
                             * VipBLL vipBll = new VipBLL(CurrentUserInfo);
                             * VipEntity vipEntity = vipBll.GetByID(vipId);
                             * if (vipEntity != null)
                             * {
                             *  vipEntity.Integration = (vipEntity.Integration.HasValue ? vipEntity.Integration.Value : 0) + integralValue;
                             *  vipBll.Update(vipEntity);
                             * }
                             *
                             *
                             * VipIntegralDetailBLL vipIntegralDetailBLL = new VipIntegralDetailBLL(CurrentUserInfo);
                             * VipIntegralDetailEntity vipIntegralDetailEntity = new VipIntegralDetailEntity();
                             * vipIntegralDetailEntity.VipIntegralDetailID = CPOS.Common.Utils.NewGuid();
                             * vipIntegralDetailEntity.VIPID = vipId;
                             * vipIntegralDetailEntity.FromVipID = vipId;
                             * vipIntegralDetailEntity.Integral = integralValue;
                             * if (eventId.ToUpper() == "E5A304D716D14CD2B96560EBD2B6A29C")
                             *  vipIntegralDetailEntity.IntegralSourceID = "16";
                             * if (eventId.ToUpper() == "BFC41A8BF8564B6DB76AE8A8E43557BA")
                             *  vipIntegralDetailEntity.IntegralSourceID = "17";
                             *
                             * vipIntegralDetailBLL.Create(vipIntegralDetailEntity);
                             */
                        }//奖品如果是优惠券
                        else if (!string.IsNullOrEmpty(prizeMapping.Tables[0].Rows[0]["CouponTypeID"].ToString()))
                        {
                            var couponId = Utils.NewGuid();

                            //生成优惠券
                            this._currentDAO.CreateCoupon(vipId, eventId, couponId, tran);

                            //添加优惠券用户关系
                            VipCouponMappingBLL mappingService = new VipCouponMappingBLL(this.CurrentUserInfo);
                            mappingService.Create(new VipCouponMappingEntity
                            {
                                VipCouponMapping = Utils.NewGuid(),
                                VIPID            = vipId,
                                CouponID         = couponId,
                                UrlInfo          = ""
                            }, tran);
                        }
                    }
                    //设置奖品为已兑换
                    var prizeWinner = winnerService.Query(new IWhereCondition[]
                    {
                        new EqualsCondition()
                        {
                            FieldName = "PrizeWinnerID",
                            Value     = prize["PrizeWinnerID"].ToString()
                        }
                    }, null).FirstOrDefault();

                    if (prizeWinner != null)
                    {
                        prizeWinner.HasConvert = 1;
                        winnerService.Update(prizeWinner, false, tran);
                    }
                }

                tran.Commit();
            }
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(LLotteryLogEntity pEntity, IDbTransaction pTran)
 {
     Update(pEntity, true, pTran);
 }
Exemplo n.º 5
0
 public void Update(LLotteryLogEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField, pTran);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(LLotteryLogEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 在事务内创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Create(LLotteryLogEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Create(pEntity, pTran);
 }
Exemplo n.º 8
0
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <LLotteryLogEntity> PagedQueryByEntity(LLotteryLogEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
Exemplo n.º 9
0
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public LLotteryLogEntity[] QueryByEntity(LLotteryLogEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
Exemplo n.º 10
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(LLotteryLogEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
Exemplo n.º 11
0
 public void Update(LLotteryLogEntity pEntity, bool pIsUpdateNullField)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField);
 }
Exemplo n.º 12
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(LLotteryLogEntity pEntity)
 {
     Update(pEntity, true);
 }