コード例 #1
0
        /// <summary>
        /// 兑换礼品
        /// </summary>
        public void ExchangePresent(UserGetPrizeInfo info)
        {
            var    manage  = new UserIntegralManager();
            string Summary = string.Empty;

            if (info.PayInegral == 100000)
            {
                info.PrizeType = "10";
                Summary        = "用户10万积分,兑换IPhone5S手机一部";
            }
            else if (info.PayInegral == 1000000)
            {
                info.PrizeType = "20";
                Summary        = "用户100万积分,兑换QQ3汽车一辆";
            }
            if (!manage.UserIsPrize(info.UserId, info.PrizeType))//判断是否已兑换过礼品
            {
                UserGetPrize PrizeEntity = new UserGetPrize();
                PrizeEntity.GiveMoney  = 0;
                PrizeEntity.PayInegral = info.PayInegral;
                PrizeEntity.PrizeType  = info.PrizeType;
                PrizeEntity.Summary    = Summary;
                PrizeEntity.UserId     = info.UserId;
                PrizeEntity.CreateTime = DateTime.Now;
                manage.AddUserGetPrize(PrizeEntity);//增加用户领奖记录
            }
        }
コード例 #2
0
        /// <summary>
        /// 赠送彩金
        /// </summary>
        /// <param name="info"></param>
        public void GivePrizes(UserGetPrizeInfo info)
        {
            var manage = new UserIntegralManager();
            Dictionary <decimal, decimal> dic = new Dictionary <decimal, decimal>();

            dic.Add(100, 2);
            dic.Add(500, 5);
            dic.Add(2000, 10);
            dic.Add(10000, 50);
            dic.Add(100000, 588);
            dic.Add(500000, 2888);

            UserIntegralBalance entity = manage.GetUserIntegralBalance(info.UserId);
            var query = from s in dic where s.Key <= entity.CurrIntegralBalance select s;

            if (query != null)
            {
                foreach (var item in query)
                {
                    int vipLevel = 0;
                    //[10:IPHONE5s;20:QQ3;30:送2元;40:送5元;50:送10元;60:送58元;70:送588元;80:送2888元]
                    switch (item.Key.ToString())
                    {
                    case "100":
                        info.PrizeType = "30";
                        vipLevel       = 1;
                        break;

                    case "500":
                        info.PrizeType = "40";
                        vipLevel       = 2;
                        break;

                    case "2000":
                        info.PrizeType = "50";
                        vipLevel       = 3;
                        break;

                    case "10000":
                        info.PrizeType = "60";
                        vipLevel       = 4;
                        break;

                    case "100000":
                        info.PrizeType = "70";
                        vipLevel       = 5;
                        break;

                    case "500000":
                        info.PrizeType = "80";
                        vipLevel       = 6;
                        break;
                    }

                    if (!manage.UserIsPrize(info.UserId, info.PrizeType))//判断是否已赠送过彩金
                    {
                        UserGetPrize PrizeEntity = new UserGetPrize();
                        PrizeEntity.GiveMoney  = item.Value;
                        PrizeEntity.PayInegral = Convert.ToInt32(item.Key);
                        PrizeEntity.PrizeType  = info.PrizeType;
                        PrizeEntity.OrderMoney = info.OrderMoey;
                        PrizeEntity.Summary    = "用户积分满" + Convert.ToInt32(item.Key) + ",赠送彩金" + item.Value.ToString("N2") + "元";
                        PrizeEntity.UserId     = info.UserId;
                        PrizeEntity.CreateTime = DateTime.Now;
                        manage.AddUserGetPrize(PrizeEntity);//增加用户领奖记录

                        //BusinessHelper.Payin_2Balance(BusinessHelper.FundCategory_Activity, info.UserId, info.UserId, false, "", "", info.UserId, AccountType.Common, PrizeEntity.GiveMoney,
                        //     PrizeEntity.Summary);
                        manage.UpdateUserRegister(info.UserId, vipLevel);
                    }
                }
            }
        }