Exemple #1
0
        /// <summary>
        /// 发奖
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="prizeEntity"></param>
        /// <param name="specialItem"></param>
        /// <param name="addpoint"></param>
        /// <param name="addcoin"></param>
        /// <param name="isAddPackage"></param>
        /// <param name="package"></param>
        /// <param name="response"></param>
        /// <param name="record"></param>
        /// <returns></returns>
        MessageCode SendPrize(Guid managerId, ConfigTurntableprizeEntity prizeEntity, int specialItem, ref int addpoint, ref int addcoin, ref bool isAddPackage, ref ItemPackageFrame package, TurntableLuckDrawResponse response, TurntableLuckyrecordEntity record)
        {
            var messCode = MessageCode.Success;

            response.Data.PrizeCount = prizeEntity.ItemCount;
            switch (prizeEntity.PrizeType)
            {
            case (int)EnumTurntablePrizeType.Point:
                addpoint = prizeEntity.ItemCount;
                response.Data.PrizeCode = 0;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Point;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + prizeEntity.SubType + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Coin:
                addcoin = prizeEntity.ItemCount;
                response.Data.PrizeCode = 0;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Coin;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + prizeEntity.SubType + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Item:
                isAddPackage = true;
                messCode     = package.AddItems(prizeEntity.SubType, prizeEntity.ItemCount);
                if (messCode != MessageCode.Success)
                {
                    return(messCode);
                }
                response.Data.PrizeCode = prizeEntity.SubType;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Item;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + prizeEntity.SubType + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Random:
                isAddPackage = true;
                var itemCode  = CacheFactory.LotteryCache.LotteryByLib(prizeEntity.SubType);
                var itemCache = CacheFactory.ItemsdicCache.GetItem(itemCode);
                if (itemCache == null)
                {
                    return(MessageCode.ItemNotExists);
                }
                if (itemCache.ItemType == (int)EnumItemType.PlayerCard)
                {
                    messCode = package.AddPlayerCard(itemCode, 1, false, 1, false);
                }
                else
                {
                    messCode = package.AddItems(itemCode, prizeEntity.ItemCount);
                }
                if (messCode != MessageCode.Success)
                {
                    return(messCode);
                }
                response.Data.PrizeCode = itemCode;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Item;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + itemCode + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Turntable:
                record.LuckDrawString = (int)prizeEntity.PrizeType + "," + prizeEntity.SubType + "," + prizeEntity.ItemCount;
                break;

            case (int)EnumTurntablePrizeType.Special:
                isAddPackage = true;
                if (specialItem == 0)
                {
                    return(MessageCode.NbParameterError);
                }
                messCode = package.AddItems(specialItem, prizeEntity.ItemCount);
                if (messCode != MessageCode.Success)
                {
                    return(messCode);
                }
                response.Data.PrizeCode = specialItem;
                response.Data.PrizeType = (int)EnumTurntablePrizeType.Item;
                record.LuckDrawString   = (int)prizeEntity.PrizeType + "," + specialItem + "," + prizeEntity.ItemCount;
                break;

            default:
                break;
            }
            return(MessageCode.Success);
        }