Ejemplo n.º 1
0
        public void handler(IResponder responder)
        {
            string dateStr = SJSRequest.GetString("Date");

            DateTime dt = DateTime.Now;

            if (string.IsNullOrEmpty(dateStr) == false)
            {
                dt = Convert.ToDateTime(dateStr);
            }

            IList <Bookingshop> list;

            if (User.IsAdministrator(PageUtils.Utype))
            {
                list = BookingshopManager.GetBookingshop(dt);
            }
            else
            {
                list = BookingshopManager.GetBookingshop(dt, false);
            }

            string json = PageUtils.TranformJSON(list);

            responder.WriteSuccessed(json);
        }
Ejemplo n.º 2
0
        public void handler(IResponder responder)
        {
            string account = SJSRequest.GetString("Account");
            string passwd  = SJSRequest.GetString("Passwd");

            passwd = Utils.MD5(passwd);

            User user = UserManager.GetUser(account);

            if (user == null)
            {
                responder.WriteErroredMsg("此用户不存在!");
                return;
            }

            if (user.Passwd.Trim() != passwd)
            {
                responder.WriteErroredMsg("密码错误!");
                return;
            }

            //if (user.Enabled == false)
            //{
            //    responder.WriteErroredMsg("用户处于禁用状态,无法登陆!");
            //    return;
            //}

            Logined(user);

            responder.WriteSuccessedMsg("登陆成功");
        }
Ejemplo n.º 3
0
        public void handler(IResponder responder)
        {
            Trade trade = new Trade();

            trade.Shopid     = SJSRequest.GetInt("Shopid", 0);
            trade.Tradename  = SJSRequest.GetString("Tradename");
            trade.Tradevalue = SJSRequest.GetFloat("Tradevalue", 0);

            if (trade.Shopid <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            if (string.IsNullOrEmpty(trade.Tradename))
            {
                responder.WriteErroredMsg("菜单名称不能为空!");
                return;
            }

            int rlt = TradeManager.AddTrade(trade);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("新增菜单失败,数据库写入不成功!");
                return;
            }

            responder.WriteSuccessedMsg("新增菜单成功!");
        }
Ejemplo n.º 4
0
        public void handler(IResponder responder)
        {
            Bookingshop bookingshop = new Bookingshop();

            bookingshop.Bookingid   = SJSRequest.GetInt("Bookingid", 0);
            bookingshop.Bookingname = SJSRequest.GetString("Bookingname");
            bookingshop.Shopid      = SJSRequest.GetInt("Shopid", 0);
            bookingshop.Shopname    = SJSRequest.GetString("Shopname");
            bookingshop.Uid         = PageUtils.AccountID;
            bookingshop.Realname    = PageUtils.RealName.Trim();
            bookingshop.Isover      = false;
            //bookingshop.Begintime = DateTime.Now;// DateTime.UtcNow;

            if (bookingshop.Bookingid <= 0)
            {
                responder.WriteErroredMsg("预订参数错误!");
                return;
            }

            if (bookingshop.Shopid <= 0)
            {
                responder.WriteErroredMsg("店铺参数错误!");
                return;
            }

            Booking booking = BookingManager.GetBooking(bookingshop.Bookingid);

            if (booking == null)
            {
                responder.WriteErroredMsg("此预订不存在,无法加入!");
                return;
            }

            if (booking.Isbooking == false)
            {
                responder.WriteErroredMsg("此预订已结束,无法加入!");
                return;
            }

            Bookingshop confirm = BookingshopManager.GetBookingshop(bookingshop.Bookingid, bookingshop.Shopid, bookingshop.Uid);

            if (confirm != null)
            {
                responder.WriteErroredMsg("此店铺已存在于" + bookingshop.Bookingname + "的店铺列表,无法再次加入预订!");
                return;
            }

            bookingshop.Begintime = booking.Bookingtime;

            int rlt = BookingshopManager.AddBookingshop(bookingshop);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("店铺预订加入失败,数据库写入不成功!");
                return;
            }

            responder.WriteSuccessedMsg("加入预订成功!");
        }
Ejemplo n.º 5
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Shop shop = ShopManager.GetShop(id);

            if (shop == null)
            {
                responder.WriteErroredMsg("此店铺不存在,无法删除!");
                return;
            }

            int hasBookingCount = BookingshopManager.GetBookingshop(shop.Id, false, true);

            if (hasBookingCount > 0)
            {
                responder.WriteErroredMsg("此店铺正在接受预订,无法删除!");
                return;
            }

            using (DbTransaction trans = DbHelper.BeginTransaction())
            {
                bool writeError = false;
                try
                {
                    int rlt = ShopManager.DelShop(id, trans);

                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("店铺删除失败,数据库更新不成功!");
                        return;
                    }

                    TradeManager.DelTrade(id, trans);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    if (writeError == false)
                    {
                        responder.WriteErroredMsg("店铺删除失败,程序异常!");
                    }
                    return;
                }
            }

            responder.WriteSuccessedMsg("店铺删除成功!");
        }
Ejemplo n.º 6
0
        public void handler(IResponder responder)
        {
            int shopid = SJSRequest.GetInt("Id", 0);

            IList <Trade> list = TradeManager.GetTrade(shopid, true);

            string json = PageUtils.TranformJSON(list);

            responder.WriteSuccessed(json);
        }
Ejemplo n.º 7
0
        public void handler(IResponder responder)
        {
            int bookingshopid = SJSRequest.GetInt("Bookingshopid", 0);

            IList <Bookingtrade> list = BookingtradeManager.GetBookingtrade(bookingshopid, 0, 0);

            string json = PageUtils.TranformJSON(list);

            responder.WriteSuccessed(json);
        }
Ejemplo n.º 8
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Booking booking = BookingManager.GetBooking(id);

            if (booking == null)
            {
                responder.WriteErroredMsg("不存在此预订, 无法结束预订!");
                return;
            }

            if (booking.Isbooking == false)
            {
                responder.WriteErroredMsg("此预订已经结束,无法重复结束!");
                return;
            }

            if (booking.Uid != PageUtils.AccountID)
            {
                responder.WriteErroredMsg("没有权限结束其他人的预订!");
                return;
            }

            booking.Isbooking = false;

            int rlt = BookingManager.UpdateBooking(booking);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("结束预订失败,数据库更新不成功!");
                return;
            }

            IList <Bookingshop> list = BookingshopManager.GetBookingshop(booking.Id, true);

            foreach (Bookingshop item in list)
            {
                item.Isover = true;
                BookingshopManager.UpdateBookingshop(item);
            }

            BookingtradeManager.UpdateBookingtrade(booking.Id, !booking.Isbooking);

            responder.WriteSuccessedMsg("结束预订成功!");
        }
Ejemplo n.º 9
0
        public void handler(IResponder responder)
        {
            int uid = SJSRequest.GetInt("Uid", 0);

            if (uid <= 0)
            {
                uid = PageUtils.AccountID;
            }

            IList <Balance> list = BalanceManager.GetBalance(uid, true);

            string json = PageUtils.TranformJSON(list);

            responder.WriteSuccessed(json);
        }
Ejemplo n.º 10
0
        public void handler(IResponder responder)
        {
            int bookingId = SJSRequest.GetInt("Bookingid", 0);

            //if (bookingId <= 0)
            //{
            //    responder.WriteErroredMsg("请求参数错误!");
            //    return;
            //}

            IList <Bookingshop> list = BookingshopManager.GetBookingshop(bookingId, true);

            string json = PageUtils.TranformJSON(list);

            responder.WriteSuccessed(json);
        }
Ejemplo n.º 11
0
        public void handler(IResponder responder)
        {
            string isAdmin = SJSRequest.GetString("IsAdmin");
            User   user    = new User();

            user.Uid      = 0;
            user.Account  = SJSRequest.GetString("Account").Trim();
            user.Passwd   = SJSRequest.GetString("Passwd");
            user.Realname = SJSRequest.GetString("Realname");
            user.Balance  = 0;
            user.Type     = (isAdmin == "on" ? (int)eAuthority.AdminUser : (int)eAuthority.CommonUser);

            if (string.IsNullOrEmpty(user.Account))
            {
                responder.WriteErroredMsg("帐号不能为空");
                return;
            }

            if (string.IsNullOrEmpty(user.Passwd))
            {
                responder.WriteErroredMsg("密码不能为空");
                return;
            }
            else
            {
                user.Passwd = Utils.MD5(user.Passwd);
            }

            User confirm = UserManager.GetUser(user.Account);

            if (confirm != null)
            {
                responder.WriteErroredMsg("此用户名已存在!");
                return;
            }

            user.Uid = UserManager.AddUser(user);

            if (user.Uid > 0)
            {
                responder.WriteSuccessedMsg("新增用户成功!");
            }
            else
            {
                responder.WriteErroredMsg("新增用户失败,数据库写入不成功!");
            }
        }
Ejemplo n.º 12
0
        public void handler(IResponder responder)
        {
            int uid = SJSRequest.GetInt("Uid", 0);

            if (uid <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            User user = UserManager.GetUser(uid);

            if (user == null)
            {
                responder.WriteErroredMsg("此用户不存在,无法禁用!");
                return;
            }

            if (user.Enabled)
            {
                responder.WriteErroredMsg("此用户当前为启用状态,无须更改!");
                return;
            }

            //if (user.Balance > 0)
            //{
            //    responder.WriteErroredMsg(string.Format("此用户还有余额{0}未返还,无法禁用!", user.Balance));
            //    return;
            //}
            //else if (user.Balance < 0)
            //{
            //    responder.WriteErroredMsg(string.Format("此用户欠费{0}元,无法禁用!", Math.Abs(user.Balance)));
            //    return;
            //}

            int rlt = UserManager.DisableUser(uid, false);

            if (rlt > 0)
            {
                responder.WriteSuccessedMsg("用户启用成功!");
            }
            else
            {
                responder.WriteErroredMsg("用户启用失败,数据库数据更新不成功");
            }
        }
Ejemplo n.º 13
0
        public void handler(IResponder responder)
        {
            string dateStr = SJSRequest.GetString("Date");

            DateTime dt = DateTime.Now;

            if (string.IsNullOrEmpty(dateStr) == false)
            {
                dt = Convert.ToDateTime(dateStr);
            }
            //IList<Bookingshop> list = BookingshopManager.GetBookingshop(dt, PageUtils.AccountID);
            IList <Bookingshop> list = BookingshopManager.GetBookingshop(dt, 0);

            string json = PageUtils.TranformJSON(list);

            responder.WriteSuccessed(json);
        }
Ejemplo n.º 14
0
        protected override void PageLoaded()
        {
            string method = SJSRequest.GetString("Method");

            if (string.IsNullOrEmpty(method))
            {
                WriteErroredMsg("请求出错,方法名不能为空!");
                return;
            }

            if (method != eHandlerTypes.GETUSERINFO && method != eHandlerTypes.GETCURRENTBOOKINGEDLIST && method != eHandlerTypes.INSTALLSYS)
            {
                if (PageUtils.IsLogined == false && method != eHandlerTypes.LOGIN)
                {
                    WriteErroredMsg("未登陆或登陆超时,请重新登陆!");
                    return;
                }
                else if (PageUtils.IsLogined && method == eHandlerTypes.LOGIN)
                {
                    WriteErroredMsg("已经登陆过,请不要重复登陆!");
                    return;
                }
            }


            IAjaxHandler handler = AjaxHandlerMgr.Instance.loadHandler(method);

            if (handler == null)
            {
                WriteErroredMsg("找不到对应的Handler!");
                return;
            }

            handler.handler(this);

            //try
            //{
            //    handler.handler(this);
            //}
            //catch (Exception ex)
            //{
            //    //Response.Clear();
            //    //WriteErroredMsg(string.Format("处理方法{0}时出错,{1}", method, ex.Message));
            //}
        }
Ejemplo n.º 15
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Shop shop = ShopManager.GetShop(id);

            if (shop == null)
            {
                responder.WriteErroredMsg("此店铺不存在,无法修改!");
                return;
            }

            int hasBookingCount = BookingshopManager.GetBookingshop(shop.Id, false, true);

            if (hasBookingCount > 0)
            {
                responder.WriteErroredMsg("此店铺正在接受预订,无法修改!");
                return;
            }

            shop.Shopname = SJSRequest.GetString("Shopname");
            shop.Phone    = SJSRequest.GetString("Phone");

            if (string.IsNullOrEmpty(shop.Shopname))
            {
                responder.WriteErroredMsg("店铺名称不能为空!");
                return;
            }

            int rlt = ShopManager.UpdateShop(shop);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("店铺修改失败,数据库更新不成功!");
                return;
            }

            responder.WriteSuccessedMsg("修改店铺成功!");
        }
Ejemplo n.º 16
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Trade trade = TradeManager.GetTrade(id);

            if (trade == null)
            {
                responder.WriteErroredMsg("此菜单不存在,无法修改!");
                return;
            }

            int hasBookingCount = BookingshopManager.GetBookingshop(trade.Shopid, false, true);

            if (hasBookingCount > 0)
            {
                responder.WriteErroredMsg("此店铺正在接受预订,无法修改此菜单!");
                return;
            }

            trade.Tradename  = SJSRequest.GetString("Tradename");
            trade.Tradevalue = SJSRequest.GetFloat("Tradevalue", 0);

            if (string.IsNullOrEmpty(trade.Tradename))
            {
                responder.WriteErroredMsg("菜单名称不能为空!");
                return;
            }

            int rlt = TradeManager.UpdateTrade(trade);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("菜单修改失败,数据库更新不成功!");
                return;
            }

            responder.WriteSuccessedMsg("修改菜单成功!");
        }
Ejemplo n.º 17
0
        public void handler(IResponder responder)
        {
            int uid = SJSRequest.GetInt("Uid", 0);

            if (uid <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            User user = UserManager.GetUser(uid);

            if (user == null)
            {
                responder.WriteErroredMsg("此用户不存在,无法删除!");
                return;
            }

            if (user.Balance > 0)
            {
                responder.WriteErroredMsg(string.Format("此用户还有余额{0}未返还,无法删除!", user.Balance));
                return;
            }
            else if (user.Balance < 0)
            {
                responder.WriteErroredMsg(string.Format("此用户欠费{0}元,无法删除!", Math.Abs(user.Balance)));
                return;
            }

            int rlt = UserManager.DelUser(uid);

            if (rlt > 0)
            {
                responder.WriteSuccessedMsg("用户删除成功!");
            }
            else
            {
                responder.WriteErroredMsg("用户删除失败,删除数据库数据不成功");
            }
        }
Ejemplo n.º 18
0
        public void handler(IResponder responder)
        {
            int uid = SJSRequest.GetInt("Uid", 0);

            if (uid <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            string passwd = SJSRequest.GetString("NewPasswd");

            if (string.IsNullOrEmpty(passwd))
            {
                responder.WriteErroredMsg("密码不能为空");
                return;
            }

            User user = UserManager.GetUser(uid);

            if (user == null)
            {
                responder.WriteErroredMsg("找不到此用户,无法重置密码!");
                return;
            }

            user.Passwd = Utils.MD5(passwd);

            int rlt = UserManager.UpdateUser(user);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("密码重置失败,数据为更新不成功!");
            }
            else
            {
                responder.WriteSuccessedMsg("密码重置成功!");
            }
        }
Ejemplo n.º 19
0
        public void handler(IResponder responder)
        {
            Booking booking = new Booking();

            booking.Bookingname = SJSRequest.GetString("Bookingname").Trim();
            DateTime dt    = DateTime.Now;
            string   dtStr = SJSRequest.GetString("Bookingtime");

            if (string.IsNullOrEmpty(dtStr) == false)
            {
                dt = Convert.ToDateTime(dtStr);
                dt = dt.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second);
            }
            booking.Bookingtime = dt;// DateTime.UtcNow;
            booking.Isbooking   = true;
            booking.Uid         = PageUtils.AccountID;
            booking.Realname    = PageUtils.RealName;
            booking.Issettle    = false;
            booking.Haserror    = false;

            if (string.IsNullOrEmpty(booking.Bookingname))
            {
                responder.WriteErroredMsg("预订名称不能为空!");
                return;
            }

            booking.Bookingname += "(" + booking.Bookingtime.Month + "-" + booking.Bookingtime.Day + ")";

            int rlt = BookingManager.AddBooking(booking);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("预订新建失败,数据库写入不成功!");
                return;
            }

            responder.WriteSuccessedMsg("新建预订成功!");
        }
Ejemplo n.º 20
0
        public void handler(IResponder responder)
        {
            int start = SJSRequest.GetInt("start", 0);
            int limit = SJSRequest.GetInt("limit", PageUtils.DefaultPageSize);

            if (start <= 0)
            {
                start = 0;
            }
            if (limit <= 0)
            {
                limit = PageUtils.DefaultPageSize;
            }

            int curPage = PageUtils.TranformCurrentPage(start, limit);

            int len = BookingtradeManager.GetBookingtradeCountByUid(PageUtils.AccountID);
            IList <Bookingtrade> list = BookingtradeManager.GetBookingtrade(PageUtils.AccountID, limit, curPage, (uint)0);

            string json = PageUtils.TranformJSON(list);

            responder.WritePagingList(len, json);
        }
        public void handler(IResponder responder)
        {
            int start = SJSRequest.GetInt("start", 0);
            int limit = SJSRequest.GetInt("limit", PageUtils.DefaultPageSize);

            if (start <= 0)
            {
                start = 0;
            }
            if (limit <= 0)
            {
                limit = PageUtils.DefaultPageSize;
            }

            int curPage = PageUtils.TranformCurrentPage(start, limit);

            int len = DeductionManager.GetDeductionCount(PageUtils.AccountID);
            IList <Deduction> list = DeductionManager.GetDeduction(PageUtils.AccountID, limit, curPage);

            string json = PageUtils.TranformJSON(list);

            responder.WritePagingList(len, json);
        }
Ejemplo n.º 22
0
        public void handler(IResponder responder)
        {
            Shop shop = new Shop();

            shop.Shopname = SJSRequest.GetString("Shopname");
            shop.Phone    = SJSRequest.GetString("Phone");

            if (string.IsNullOrEmpty(shop.Shopname))
            {
                responder.WriteErroredMsg("店铺名称不能为空!");
                return;
            }

            int rlt = ShopManager.AddShop(shop);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("新增店铺失败,数据库写入不成功!");
                return;
            }

            responder.WriteSuccessedMsg("新增店铺成功!");
        }
Ejemplo n.º 23
0
        public void handler(IResponder responder)
        {
            int uid = SJSRequest.GetInt("Uid", 0);

            if (uid <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            User user = UserManager.GetUser(uid);

            if (user == null)
            {
                responder.WriteErroredMsg("此用户不存在,设置失败!");
                return;
            }

            if (user.Type == (int)eAuthority.AdminUser)
            {
                responder.WriteSuccessedMsg(user.Realname + "已经是管理员,请不要重复设置!");
                return;
            }

            user.Type = (int)eAuthority.AdminUser;

            int rlt = UserManager.UpdateUser(user);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("设置失败,数据库更新数据不成功!");
            }
            else
            {
                responder.WriteSuccessedMsg("设置成功!");
            }
        }
Ejemplo n.º 24
0
        public void handler(IResponder responder)
        {
            int id = SJSRequest.GetInt("Id", 0);

            if (id <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            Trade trade = TradeManager.GetTrade(id);

            if (trade == null)
            {
                responder.WriteErroredMsg("此菜单不存在,无法删除!");
                return;
            }

            int hasBookingCount = BookingshopManager.GetBookingshop(trade.Shopid, false, true);

            if (hasBookingCount > 0)
            {
                responder.WriteErroredMsg("此店铺正在接受预订,无法删除此菜单!");
                return;
            }

            int rlt = TradeManager.DelTrade(id);

            if (rlt <= 0)
            {
                responder.WriteErroredMsg("菜单删除失败,数据库数据更新不成功!");
                return;
            }

            responder.WriteSuccessedMsg("菜单删除成功!");
        }
Ejemplo n.º 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string str = SJSRequest.GetString("import");

            if (str == "User")
            {
                importUser();
            }
            else if (str == "ShopAndTrade")
            {
                importShopAndTrade();
            }
            else if (str == "App")
            {
                importApp();
            }
            else
            {
                Response.Write("?import=[以下三个值之一]<br />");
                Response.Write("1.App : 设置初始化<br />");
                Response.Write("2.User : 导入用户数据(根目录下的User.xml文件内的数据)<br />");
                Response.Write("3.ShopAndTrade : 导入用户数据(根目录下的ShopAndTrade.xml文件内的数据)<br />");
            }
        }
Ejemplo n.º 26
0
        public void handler(IResponder responder)
        {
            int bookingtradeid = SJSRequest.GetInt("Id", 0);
            int tradecount     = SJSRequest.GetInt("Tradecount", 0);

            if (bookingtradeid <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            if (tradecount <= 0)
            {
                responder.WriteErroredMsg("取消数量应为正数!");
                return;
            }

            Bookingtrade bookingtrade = BookingtradeManager.GetBookingtrade(bookingtradeid);

            if (bookingtrade == null)
            {
                responder.WriteErroredMsg("不存在此预订项,无法取消!");
                return;
            }

            Booking booking = BookingManager.GetBooking(bookingtrade.Bookingid);

            if (booking == null)
            {
                responder.WriteErroredMsg("此预订不存在或已被删除,无法取消!");
                return;
            }

            if (booking.Isbooking == false && User.IsAdministrator(PageUtils.Utype) == false)
            {
                responder.WriteErroredMsg("此预订已结束,无法取消!");
                return;
            }
            int rlt = 0;

            using (DbTransaction trans = DbHelper.BeginTransaction())
            {
                bool writeError = false;
                try
                {
                    int hasCount = bookingtrade.Tradecount;

                    bookingtrade.Tradecount = Math.Max(0, bookingtrade.Tradecount - tradecount);
                    tradecount = hasCount - bookingtrade.Tradecount;

                    if (bookingtrade.Uid != PageUtils.AccountID)
                    {
                        bookingtrade.Remarks += string.Format(" 由{0}退订{1}份", PageUtils.RealName, tradecount);
                    }

                    User user = UserManager.GetUser(bookingtrade.Uid, trans);

                    rlt = UserManager.UpdateUserBalance(bookingtrade.Uid, -bookingtrade.Tradevalue * tradecount, trans);
                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("返还余额失败,数据库更新不成功!");
                        return;
                    }

                    Deduction deduction = new Deduction();
                    deduction.Deductionbalance = user.Balance + bookingtrade.Tradevalue * tradecount;
                    deduction.Deductioncount   = -tradecount;
                    deduction.Deductionname    = string.Format("取消{0}", bookingtrade.Tradename);
                    deduction.Deductiontime    = DateTime.Now;
                    deduction.Deductionvalue   = bookingtrade.Tradevalue * tradecount;
                    deduction.Uid      = bookingtrade.Uid;
                    deduction.Realname = bookingtrade.Realname;
                    deduction.Shopid   = bookingtrade.Shopid;
                    deduction.Shopname = bookingtrade.Shopname;
                    deduction.Remarks  = bookingtrade.Remarks;
                    rlt = DeductionManager.AddDeduction(deduction, trans);
                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("返还余额失败,数据库更新不成功!");
                        return;
                    }

                    if (bookingtrade.Tradecount > 0)
                    {
                        rlt = BookingtradeManager.UpdateBookingtrade(bookingtrade, trans);
                    }
                    else
                    {
                        rlt = BookingtradeManager.DelBookingtrade(bookingtrade.Id, trans);
                    }

                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("取消预订失败,数据库更新不成功!");
                        return;
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();

                    if (writeError == false)
                    {
                        responder.WriteErroredMsg("取消失败,程序异常!");
                    }
                    return;
                }
            }

            responder.WriteSuccessedMsg(string.Format("成功取消{0}个预订", tradecount));
        }
Ejemplo n.º 27
0
        public void handler(IResponder responder)
        {
            int uid = SJSRequest.GetInt("Uid", 0);

            double balance = SJSRequest.GetFloat("Balancemoney", 0);
            string remarks = SJSRequest.GetString("Remarks");

            if (uid <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            if (balance <= 0)
            {
                responder.WriteErroredMsg("充值金额不能小于或等于0!");
                return;
            }

            using (DbTransaction trans = DbHelper.BeginTransaction())
            {
                bool writeError = false;
                try
                {
                    User user = UserManager.GetUser(uid, trans);

                    if (user == null)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("此用户不存在,无法充值!");
                        return;
                    }

                    user.Balance += balance;

                    int rlt = UserManager.UpdateUserBalance(user.Uid, -balance, trans);

                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("充值失败,数据库数据更新不成功!");
                        return;
                    }

                    Balance balances = new Balance();

                    balances.Uid      = uid;
                    balances.Balances = balance;
                    balances.Remarks  = remarks;
                    balances.Btime    = DateTime.Now;// DateTime.UtcNow;

                    balances.Id = BalanceManager.AddBalance(balances, trans);

                    if (balances.Id <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg(user.Realname + "充值记录失败!");
                        return;
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    if (writeError == false)
                    {
                        responder.WriteErroredMsg("充值失败,程序异常!");
                    }
                    return;
                }
            }

            responder.WriteSuccessedMsg("充值成功!");
        }
Ejemplo n.º 28
0
        public void handler(IResponder responder)
        {
            int          withUid      = SJSRequest.GetInt("WithUid", 0);
            Bookingtrade bookingtrade = new Bookingtrade();

            bookingtrade.Tradeid       = SJSRequest.GetInt("Tradeid", 0);
            bookingtrade.Bookingshopid = SJSRequest.GetInt("Id", 0);
            bookingtrade.Tradecount    = SJSRequest.GetInt("Tradecount", 0);
            //bookingtrade.Remarks = SJSRequest.GetString("Remarks");

            if (bookingtrade.Tradecount <= 0)
            {
                responder.WriteErroredMsg("预订数量只能是正数!");
                return;
            }

            if (bookingtrade.Tradeid <= 0)
            {
                responder.WriteErroredMsg("菜单项请求参数错误!");
                return;
            }

            if (bookingtrade.Bookingshopid <= 0)
            {
                responder.WriteErroredMsg("预订店铺记录请求参数错误!");
                return;
            }

            Bookingshop bookingshop = BookingshopManager.GetBookingshop(bookingtrade.Bookingshopid);

            if (bookingshop == null)
            {
                responder.WriteErroredMsg("此店铺接受预订记录不存在,无法预订!");
                return;
            }

            Booking booking = BookingManager.GetBooking(bookingshop.Bookingid);

            if (booking == null)
            {
                responder.WriteErroredMsg("此预订不存在,无法预订!");
                return;
            }

            if (booking.Isbooking == false && User.IsAdministrator(PageUtils.Utype) == false)
            {
                responder.WriteErroredMsg("此预订已结束,无法预订!");
                return;
            }

            Trade trade = TradeManager.GetTrade(bookingtrade.Tradeid);

            if (trade == null)
            {
                responder.WriteErroredMsg("不存在此菜单项,无法预订!");
                return;
            }

            IList <Bookingtrade> confirmList = BookingtradeManager.GetBookingtrade(bookingshop.Id, trade.Id, true);

            Bookingtrade confirm = null;

            int    uid   = PageUtils.AccountID;
            string rname = PageUtils.RealName;

            for (int i = 0; i < confirmList.Count; i++)
            {
                if (withUid > 0 && withUid == confirmList[i].Uid)
                {
                    confirm = confirmList[i];
                    break;
                }

                if (withUid <= 0 && uid == confirmList[i].Uid)
                {
                    confirm = confirmList[i];
                    break;
                }
            }

            int  rlt   = 0;
            bool isAdd = false;

            using (DbTransaction trans = DbHelper.BeginTransaction())
            {
                bool writeError = false;
                try
                {
                    User      user       = null;
                    Deduction deduction  = new Deduction();
                    int       addedCount = 0;
                    if (confirm != null && (withUid <= 0 || withUid == confirm.Uid))
                    {
                        addedCount = bookingtrade.Tradecount;

                        user = UserManager.GetUser(confirm.Uid, trans);

                        if (user == null)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg("不存在此用户,无法预订!");
                            return;
                        }


                        if (user.Enabled == false)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg(user.Realname + " 处于禁用状态,无法预订!");
                            return;
                        }


                        uid   = user.Uid;
                        rname = user.Realname;

                        deduction.Deductionbalance = user.Balance - confirm.Tradevalue * addedCount;
                        deduction.Deductioncount   = addedCount;
                        deduction.Deductionname    = string.Format("预订{0}", confirm.Tradename);
                        deduction.Deductiontime    = DateTime.Now;
                        deduction.Deductionvalue   = -confirm.Tradevalue * addedCount;
                        deduction.Uid      = confirm.Uid;
                        deduction.Realname = confirm.Realname;
                        deduction.Shopid   = confirm.Shopid;
                        deduction.Shopname = confirm.Shopname;
                        deduction.Remarks  = confirm.Remarks;

                        confirm.Tradecount += addedCount;
                        bookingtrade        = confirm;

                        isAdd = false;
                    }
                    else
                    {
                        if (withUid > 0 && uid != withUid)
                        {
                            user = UserManager.GetUser(withUid, trans);
                        }
                        else
                        {
                            user = UserManager.GetUser(uid, trans);
                        }

                        if (user == null)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg("不存在此用户,无法预订!");
                            return;
                        }


                        if (user.Enabled == false)
                        {
                            writeError = true;
                            trans.Rollback();
                            responder.WriteErroredMsg(user.Realname + " 处于禁用状态,无法预订!");
                            return;
                        }


                        if (withUid > 0)
                        {
                            bookingtrade.Proxyid   = uid;
                            bookingtrade.Proxyname = rname;
                            bookingtrade.Remarks  += string.Format("由 {0} 代订", rname.Trim());
                        }

                        uid   = user.Uid;
                        rname = user.Realname;

                        bookingtrade.Bookingid   = booking.Id;
                        bookingtrade.Bookingname = booking.Bookingname;
                        bookingtrade.Handlerid   = bookingshop.Uid;
                        bookingtrade.Handlername = bookingshop.Realname;
                        bookingtrade.Uid         = uid;
                        bookingtrade.Realname    = rname;
                        bookingtrade.Shopid      = bookingshop.Shopid;
                        bookingtrade.Shopname    = bookingshop.Shopname;
                        bookingtrade.Tradename   = trade.Tradename;
                        bookingtrade.Tradevalue  = trade.Tradevalue;
                        bookingtrade.Issettle    = booking.Isbooking == false;
                        bookingtrade.Bookinttime = DateTime.Now;

                        if (booking.Bookingtime.Date.Equals(DateTime.Now.Date) == false)
                        {
                            bookingtrade.Bookinttime = new DateTime(booking.Bookingtime.Date.Ticks);
                            bookingtrade.Bookinttime = bookingtrade.Bookinttime.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute).AddSeconds(DateTime.Now.Second);
                        }

                        addedCount = bookingtrade.Tradecount;
                        deduction.Deductionbalance = user.Balance - trade.Tradevalue * addedCount;
                        deduction.Deductioncount   = addedCount;
                        deduction.Deductionname    = string.Format("预订{0}", bookingtrade.Tradename);
                        deduction.Deductiontime    = DateTime.Now;
                        deduction.Deductionvalue   = -bookingtrade.Tradevalue * addedCount;
                        deduction.Uid      = bookingtrade.Uid;
                        deduction.Realname = bookingtrade.Realname;
                        deduction.Shopid   = bookingtrade.Shopid;
                        deduction.Shopname = bookingtrade.Shopname;
                        deduction.Remarks  = bookingtrade.Remarks;

                        isAdd = true;
                    }

                    rlt = UserManager.UpdateUserBalance(uid, trade.Tradevalue * addedCount, trans);
                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("扣除余额失败,数据库更新不成功!");
                        return;
                    }

                    rlt = DeductionManager.AddDeduction(deduction, trans);
                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("扣款记录失败,数据库写入不成功!");
                        return;
                    }

                    if (isAdd)
                    {
                        rlt = BookingtradeManager.AddBookingtrade(bookingtrade, trans);
                    }
                    else
                    {
                        rlt = BookingtradeManager.UpdateBookingtrade(bookingtrade, trans);
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    if (writeError == false)
                    {
                        responder.WriteErroredMsg("预订失败,程序异常!");
                    }
                    return;
                }
            }

            if (rlt <= 0)
            {
                if (isAdd)
                {
                    responder.WriteErroredMsg("预订失败,数据库写入不成功!");
                }
                else
                {
                    responder.WriteErroredMsg("预订失败,数据库更新不成功!");
                }

                return;
            }

            if (isAdd)
            {
                responder.WriteSuccessedMsg("提交成功,预订项已添加!");
            }
            else
            {
                responder.WriteSuccessedMsg("提交成功,预订项已更新!");
            }
        }
Ejemplo n.º 29
0
        public void handler(IResponder responder)
        {
            int uid = SJSRequest.GetInt("Uid", 0);

            if (uid <= 0)
            {
                responder.WriteErroredMsg("请求参数错误!");
                return;
            }

            User user;

            using (DbTransaction trans = DbHelper.BeginTransaction())
            {
                bool writeError = false;
                try
                {
                    user = UserManager.GetUser(uid, trans);

                    if (user == null)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("不存在此用户,无法返还现金!");
                        return;
                    }

                    if (user.Balance == 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("返还失败,当前用户余额已为零!");
                        return;
                    }

                    if (user.Balance < 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("返还失败,欠费用户无法返还现金!");
                        return;
                    }

                    int rlt = UserManager.UpdateUserBalance(user.Uid, user.Balance, trans);
                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("返还失败,余额清零不成功!");
                        return;
                    }

                    Deduction deduction = new Deduction();
                    deduction.Deductionbalance = 0;
                    deduction.Deductioncount   = 1;
                    deduction.Deductionname    = "返还现金";
                    deduction.Deductiontime    = DateTime.Now;
                    deduction.Deductionvalue   = user.Balance;
                    deduction.Uid      = user.Uid;
                    deduction.Realname = user.Realname;
                    deduction.Shopid   = 0;
                    deduction.Shopname = "余额清零";
                    deduction.Remarks  = "余额清零";

                    rlt = DeductionManager.AddDeduction(deduction, trans);
                    if (rlt <= 0)
                    {
                        writeError = true;
                        trans.Rollback();
                        responder.WriteErroredMsg("返还失败,扣款记录不成功!");
                        return;
                    }

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    if (writeError == false)
                    {
                        responder.WriteErroredMsg("返还失败,程序异常");
                    }
                    return;
                }
            }


            responder.WriteSuccessedMsg(string.Format("返还现金成功,应返还金额:{0}元!", user.Balance));
        }
Ejemplo n.º 30
0
        public void handler(IResponder responder)
        {
            IList <App> list = AppManager.GetApp();

            if (list.Count > 0)
            {
                responder.WriteErroredMsg("系统已初始化,请不要重复初始化!");
                return;
            }

            App app = new App();

            app.Isinstall = true;

            app.Id = AppManager.AddApp(app);
            if (app.Id <= 0)
            {
                responder.WriteErroredMsg("初始化失败,系统写入失败!");
                return;
            }

            User user = new User();

            user.Account  = SJSRequest.GetString("Account").Trim();
            user.Passwd   = SJSRequest.GetString("Passwd");
            user.Realname = SJSRequest.GetString("Realname");
            user.Balance  = 0;
            user.Type     = (int)eAuthority.AdminUser;


            if (string.IsNullOrEmpty(user.Account))
            {
                responder.WriteErroredMsg("帐号不能为空");
                return;
            }

            if (string.IsNullOrEmpty(user.Passwd))
            {
                responder.WriteErroredMsg("密码不能为空");
                return;
            }
            else
            {
                user.Passwd = Utils.MD5(user.Passwd);
            }

            User confirm = UserManager.GetUser(user.Account);

            if (confirm != null)
            {
                responder.WriteErroredMsg("此用户名已存在!");
                return;
            }

            user.Uid = UserManager.AddUser(user);

            if (user.Uid > 0)
            {
                LoginAjaxHandler.Logined(user);
                responder.WriteSuccessedMsg("初始化成功!");
            }
            else
            {
                responder.WriteErroredMsg("初始化失败,数据库写入不成功!");
            }
        }