示例#1
0
        public string SaveRetailTrader(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SaveRetailTraderRP> >();

            if (rp.Parameters.RetailTraderInfo == null)
            {
                throw new APIException("缺少参数【RetailTraderInfo】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            if (rp.Parameters.IsNewHeadImg == null)
            {
                throw new APIException("缺少参数【IsNewHeadImg】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var bll = new RetailTraderBLL(loggingSessionInfo);
            var rd  = new SaveRetailTraderRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);
            //判断登陆名是否有重复的,要从ap库里取
            var ds = bll.getRetailTraderInfoByLogin2(rp.Parameters.RetailTraderInfo.RetailTraderLogin, "", loggingSessionInfo.ClientID);
            var retailTraderInfo = new RetailTraderInfo();

            //判断账号是否存在
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                var tempDt = ds.Tables[0];
                retailTraderInfo = DataTableToObject.ConvertToObject <RetailTraderInfo>(tempDt.Rows[0]); //直接根据所需要的字段反序列化
                if (retailTraderInfo.RetailTraderID != rp.Parameters.RetailTraderInfo.RetailTraderID)    //如果取出来的实体的id和传过来的参数的id不一样,说明不是同一个实体
                {
                    rsp.Message    = "该登陆账号已经存在,不能重复使用";
                    rsp.ResultCode = 137;
                    return(rsp.ToJSON());//这里要返回
                }
            }


            //从RetailTraderInfo转到RetailTraderEntity
            RetailTraderEntity en = new RetailTraderEntity();

            en.RetailTraderID = rp.Parameters.RetailTraderInfo.RetailTraderID;
            if (rp.Parameters.RetailTraderInfo.RetailTraderID == null || rp.Parameters.RetailTraderInfo.RetailTraderID.ToString() == "")
            {
                en.RetailTraderID = Guid.NewGuid().ToString();
                //获取当前最大的
                //如果是新增,则取本客户下的最大编号作为分销商编号
                en.RetailTraderCode = bll.getMaxRetailTraderCode(rp.CustomerID) + 1;

                en.CreateTime = DateTime.Now;
                en.CreateBy   = rp.UserID;
            }
            en.RetailTraderName  = rp.Parameters.RetailTraderInfo.RetailTraderName;
            en.RetailTraderLogin = rp.Parameters.RetailTraderInfo.RetailTraderLogin;
            if (!string.IsNullOrEmpty(rp.Parameters.RetailTraderInfo.RetailTraderPass))
            {
                en.RetailTraderPass = MD5Helper.Encryption(rp.Parameters.RetailTraderInfo.RetailTraderPass);
            }
            en.RetailTraderMan     = rp.Parameters.RetailTraderInfo.RetailTraderMan;
            en.RetailTraderPhone   = rp.Parameters.RetailTraderInfo.RetailTraderPhone;
            en.RetailTraderAddress = rp.Parameters.RetailTraderInfo.RetailTraderAddress;
            en.CooperateType       = rp.Parameters.RetailTraderInfo.CooperateType;
            en.SalesType           = rp.Parameters.RetailTraderInfo.SalesType;
            en.SellUserID          = rp.Parameters.RetailTraderInfo.SellUserID;
            en.UnitID = rp.Parameters.RetailTraderInfo.UnitID;
            en.Status = "1";//启用状态

            en.LastUpdateTime = DateTime.Now;
            en.LastUpdateBy   = rp.UserID;
            en.IsDelete       = 0;
            en.CustomerId     = rp.CustomerID;
            if (rp.Parameters.RetailTraderInfo.RetailTraderID == null || rp.Parameters.RetailTraderInfo.RetailTraderID.ToString() == "")
            {
                bll.Create(en);
                //  rp.Parameters.RetailTraderInfo.RetailTraderID = en.RetailTraderID;//为了返回数据时使用
            }
            else
            {
                bll.Update(en, null, false);//不更新空值的字段
            }
            //另外要保存到ap库里,这样才能登陆时从ap库里统一取出分销商信息,和对应的customerid
            if (rp.Parameters.RetailTraderInfo.RetailTraderID == null || rp.Parameters.RetailTraderInfo.RetailTraderID.ToString() == "")
            {
                bll.Create2Ap(en);                                                 //ap库里的RetailTraderID和商户里的RetailTraderID是一样的
                rp.Parameters.RetailTraderInfo.RetailTraderID = en.RetailTraderID; //为了返回数据时使用,到这里才赋值***
            }
            else
            {
                bll.Update2Ap(en, null, false);//不更新空值的字段
            }

            //如果IsNewHeadImg为1时,即上传图片时,则删除之前的关联图片(逻辑删除)
            if (rp.Parameters.IsNewHeadImg == 1)
            {
                ObjectImagesBLL    _ObjectImagesBLL = new ObjectImagesBLL(loggingSessionInfo);
                ObjectImagesEntity ObjectImagesEn   = new ObjectImagesEntity();

                _ObjectImagesBLL.DeleteByObjectID(en.RetailTraderID.ToString());
            }

            rd.RetailTraderInfo = rp.Parameters.RetailTraderInfo;


            return(rsp.ToJSON());
        }
示例#2
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);
        }