Esempio n. 1
0
        /// <summary>初始化默认跑商商圈</summary>
        public List <tg_user_area> InitArea(Int64 user_id)
        {
            var _r = Variable.BASE_RULE.FirstOrDefault(q => q.id == "1012");

            if (_r == null)
            {
                return(null);
            }
            var temp = _r.value;
            var list = new List <tg_user_area>();

            if (temp.Contains(','))
            {
                var list_area = temp.Split(',');
                foreach (var item in list_area)
                {
                    var entity = new tg_user_area()
                    {
                        user_id = user_id, area_id = Convert.ToInt32(item)
                    };
                    entity.Save();
                    list.Add(entity);
                }
            }
            else
            {
                var entity = new tg_user_area()
                {
                    user_id = user_id, area_id = Convert.ToInt32(temp)
                };
                entity.Save();
                list.Add(entity);
            }
            return(list);
        }
Esempio n. 2
0
        /// <summary>逻辑方法</summary>
        private ASObject Logic(Int32 tid, TGGSession session)
        {
            var player = session.Player.CloneEntity();

            var _area    = Variable.BASE_TING.FirstOrDefault(m => m.id == tid);
            var baserule = Variable.BASE_RULE.FirstOrDefault(q => q.id == "3015"); //获取基表数据
            var base_vip = Variable.BASE_VIP.FirstOrDefault(m => m.level == player.Vip.vip_level);

            if (baserule == null || _area == null || base_vip == null)
            {
                return(CommonHelper.ErrorResult((int)ResultType.BASE_TABLE_ERROR));
            }
            var cost = Convert.ToInt32(baserule.value);

            player.User.gold -= cost;

            var ishave = player.BusinessArea.Count(m => m.area_id == _area.areaId) > 0;

            if (ishave)
            {
                return(CommonHelper.ErrorResult((int)ResultType.BUSINESS_AREA_ISEXIST_ERROR));
            }

            var isnum = base_vip.area - player.Vip.area;

            if (isnum <= 0)
            {
                return(CommonHelper.ErrorResult((int)ResultType.BUSINESS_VIP_AREA_COUNR_ERROR));
            }

            var area = new tg_user_area
            {
                user_id = player.User.id,
                area_id = _area.areaId,
            };

            area.Save();

            player.BusinessArea.Add(area);
            player.Vip.area += 1;
            player.User.Save();
            player.Vip.Save();

            session.Player = player;
            //元宝更新推送
            (new Share.User()).REWARDS_API((int)GoodsType.TYPE_GOLD, session.Player.User);

            return(BuildData((int)ResultType.SUCCESS, area.area_id));
        }