商家联盟会员管理系统 后台密码忘了的解决方法

因为拿到的是半开源的代码,登录部分被封装了。所以只能修改代码,先登录,再修改管理员密码。再用原代码。


直接替换下面的文件,使用admin/admin登陆:

C:\Program Files\Tencent\QQLite\Users\345139427\FileRecv\MobileFile\大型会员管理系统源码带微信功能\商家联盟连锁店会员系统源码\商家联盟连锁店会员系统源码-\商家联盟会员消费系统源码\00828\主系统源码\ChainStock\Service\AjaxService.ashx.cs

using Chain.BLL;
using Chain.Common;
using Chain.Common.DEncrypt;
using Chain.DBUtility;
using Chain.Model;
using Resources;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.SessionState;
using WebTest;



namespace ChainStock.Service
{
    /// 
    /// AjaxService 的摘要说明
    /// 
    public class AjaxService : IHttpHandler, IRequiresSessionState
    {
        private Chain.BLL.GoodsAllotDetail bllAllotDetail = new Chain.BLL.GoodsAllotDetail();
        private Chain.BLL.MemCount bllCount = new Chain.BLL.MemCount();
        private Chain.BLL.MemCountDetail bllCountDetail = new Chain.BLL.MemCountDetail();
        private Chain.BLL.OrderDetail bllDetail = new Chain.BLL.OrderDetail();
        private Chain.BLL.GoodsClass bllGdClass = new Chain.BLL.GoodsClass();
        private Chain.BLL.GiftClass bllGiftClass = new Chain.BLL.GiftClass();
        private Chain.BLL.Goods bllGoods = new Chain.BLL.Goods();
        private Chain.BLL.GoodsAllot bllGoodsAllot = new Chain.BLL.GoodsAllot();
        private Chain.BLL.GoodsLogDetail bllGoodsDetail = new Chain.BLL.GoodsLogDetail();
        private Chain.BLL.GoodsLog bllGoodsLog = new Chain.BLL.GoodsLog();
        private Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
        private Chain.BLL.Message bllMessage = new Chain.BLL.Message();
        private Chain.BLL.GoodsNumber bllNumber = new Chain.BLL.GoodsNumber();
        private Chain.BLL.OrderLog bllOrderLog = new Chain.BLL.OrderLog();
        private Chain.BLL.OrderTime bllOrderTime = new Chain.BLL.OrderTime();
        private Chain.BLL.PointLog bllPoint = new Chain.BLL.PointLog();
        private Chain.BLL.StaffMoney bllStaffMoney = new Chain.BLL.StaffMoney();
        private HttpContext Context;
        private Chain.Model.GoodsAllotDetail modelAllotDetail = new Chain.Model.GoodsAllotDetail();
        private Chain.Model.MemCount modelCount = new Chain.Model.MemCount();
        private Chain.Model.MemCountDetail modelCountDetail = new Chain.Model.MemCountDetail();
        private Chain.Model.OrderDetail modelDetail = new Chain.Model.OrderDetail();
        private Chain.Model.GoodsClass modelGdClass = new Chain.Model.GoodsClass();
        private Chain.Model.GiftClass modelGiftClass = new Chain.Model.GiftClass();
        private Chain.Model.Goods modelGoods = new Chain.Model.Goods();
        private Chain.Model.GoodsAllot modelGoodsAllot = new Chain.Model.GoodsAllot();
        private Chain.Model.GoodsLogDetail modelGoodsDetail = new Chain.Model.GoodsLogDetail();
        private Chain.Model.GoodsLog modelGoodsLog = new Chain.Model.GoodsLog();
        private Chain.Model.Mem modelMem = new Chain.Model.Mem();
        private Chain.Model.Message modelMessage = new Chain.Model.Message();
        private Chain.Model.GoodsNumber modelNumber = new Chain.Model.GoodsNumber();
        private Chain.Model.OrderLog modelOrderLog = new Chain.Model.OrderLog();
        private Chain.Model.OrderTime modelOrderTime = new Chain.Model.OrderTime();
        private Chain.Model.PointLog modelPoint = new Chain.Model.PointLog();
        private Chain.Model.StaffMoney modelStaffMoney = new Chain.Model.StaffMoney();
        private HttpRequest Request;
        private HttpResponse Response;
        private HttpServerUtility Server;
        private HttpSessionState Session;
        public void AddMemberExplanation()
        {
            int num = 0;
            try
            {
                Chain.BLL.MemberExplanation explanation = new Chain.BLL.MemberExplanation();
                Chain.Model.MemberExplanation model = new Chain.Model.MemberExplanation();
                string str = this.Request["MemberExplanationDesc"];
                model.MemberExplanationTime = DateTime.Now;
                model.MemberExplanationDesc = str;
                num = explanation.Add(model);
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void AddMenu()
        {
            int num = 0;
            try
            {
                string str = this.Request["MenuName"];
                int num2 = Convert.ToInt32(this.Request["MenuType"]);
                string str2 = this.Request["MenuKey"];
                string str3 = this.Request["MenuUrl"];
                int num3 = Convert.ToInt32(this.Request["parentMenuID"]);
                if (num2 == 1)
                {
                    str3 = "";
                }
                else
                {
                    str2 = "";
                }
                Chain.BLL.WeiXinMenu menu = new Chain.BLL.WeiXinMenu();
                Chain.Model.WeiXinMenu menu3 = new Chain.Model.WeiXinMenu();
                menu3.MenuKey = str2;
                menu3.MenuName = str;
                menu3.MenuType = num2;
                menu3.MenuUrl = str3;
                menu3.parentMenuID = num3;
                Chain.Model.WeiXinMenu model = menu3;
                num = menu.Add(model);
            }
            catch (Exception)
            {
            }
            this.Response.Write(num);
        }

        public void AddOrEditGoodsClass()
        {
            int num = 0;
            try
            {
                Chain.BLL.MicroWebsiteGoodsClass class2 = new Chain.BLL.MicroWebsiteGoodsClass();
                Chain.Model.MicroWebsiteGoodsClass model = new Chain.Model.MicroWebsiteGoodsClass();
                string str = this.Request["GoodsClassName"].ToString();
                string str2 = this.Request["GoodsClassRemark"].ToString();
                int num2 = !string.IsNullOrEmpty(this.Request["ClassShopID"]) ? int.Parse(this.Request["ClassShopID"].ToString()) : 0;
                int num3 = !string.IsNullOrEmpty(this.Request["GoodsClassID"]) ? int.Parse(this.Request["GoodsClassID"].ToString()) : 0;
                model.MicroGoodsClassName = str;
                model.MicroGoodsClassRemark = str2;
                model.MicroGoodsClassShopID = 1;
                if (num3 == 0)
                {
                    num = class2.Add(model);
                }
                else
                {
                    model.MicroGoodsClassID = num3;
                    if (class2.Update(model))
                    {
                        num = 1;
                    }
                }
            }
            catch
            {
                num = -1;
            }
            this.Response.Write(num);
        }

        public void AddProduct()
        {
            int num = 0;
            try
            {
                Chain.Model.ProductCenter model = new Chain.Model.ProductCenter();
                Chain.BLL.ProductCenter center2 = new Chain.BLL.ProductCenter();
                string str = this.Request["ProductName"];
                string str2 = "../Upload/MicroWebsite/MicroWebsiteProductCenter/" + this.Request["ProductPhoto"];
                string str3 = this.Request["ProductDesc"];
                model.ProductName = str;
                model.ProductPhoto = str2;
                model.ProductDesc = str3;
                model.ProductCreateTime = new DateTime?(DateTime.Now);
                num = center2.Add(model);
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void AddPromotions()
        {
            int num = 0;
            try
            {
                string str = this.Request["PromotionsTitle"];
                int num2 = int.Parse(this.Request["PromotionsType"]);
                int num3 = int.Parse(this.Request["PromotionsMemLevel"]);
                DateTime time = DateTime.Parse((this.Request["PromotionsStart"] == "") ? "1900-1-1" : this.Request["PromotionsStart"]);
                DateTime time2 = DateTime.Parse((this.Request["PromotionsEnd"] == "") ? "1900-1-1" : this.Request["PromotionsEnd"]);
                Chain.BLL.Promotions promotions = new Chain.BLL.Promotions();
                Chain.Model.Promotions model = new Chain.Model.Promotions();
                model.PromotionsTitle = str;
                model.PromotionsType = num2;
                model.PromotionsStart = time;
                model.PromotionsEnd = time2;
                model.PromotionsMemLevel = num3;
                model.PromotionsTime = DateTime.Now;
                num = promotions.Add(model);
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void AddSymbol()
        {
            int num = 0;
            try
            {
                Chain.Model.SymbolShow model = new Chain.Model.SymbolShow();
                Chain.BLL.SymbolShow show2 = new Chain.BLL.SymbolShow();
                string str = this.Request["SymbolTitle"];
                string str2 = "../Upload/MicroWebsite/MicroWebsiteSymbol/" + this.Request["SymbolPhoto"];
                string str3 = this.Request["SymbolDesc"];
                model.SymbolTitle = str;
                model.SymbolPhoto = str2;
                model.SymbolDesc = str3;
                model.SymbolTime = DateTime.Now;
                num = show2.Add(model);
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void AddUserWork()
        {
            int num = 0;
            try
            {
                Chain.BLL.SysUser user = new Chain.BLL.SysUser();
                Chain.Model.SysUserWork model = new Chain.Model.SysUserWork();
                Chain.BLL.SysUserWork work2 = new Chain.BLL.SysUserWork();
                model.UserID = Convert.ToInt32(this.Request["hdUserID"].ToString());
                model.StartTime = Convert.ToDateTime(this.Request["hdStartTime"]);
                model.EedTime = DateTime.Now;
                model.AddNewUser = Convert.ToInt32(this.Request["lblMemNumber"].ToString().Replace("名", ""));
                model.CardMoney = Convert.ToDecimal(this.Request["lblCardMoney"].ToString().Replace("¥", ""));
                model.ExpenseSumMoneys = Convert.ToDecimal(this.Request["lblExpenseSumMoneys"].ToString().Replace("¥", ""));
                model.ExpenseBinkMoneys = Convert.ToDecimal(this.Request["lblExpenseBinkMoneys"].ToString().Replace("¥", ""));
                model.ExpenseCouponMoneys = Convert.ToDecimal(this.Request["lblExpenseCouponMoneys"].ToString().Replace("¥", ""));
                model.SRechargeMoney = Convert.ToDecimal(this.Request["lblSRechargeMoney"].ToString().Replace("¥", ""));
                model.FRechargeMoney = Convert.ToDecimal(this.Request["lblFRechargeMoney"].ToString().Replace("¥", ""));
                model.RechargeBank = Convert.ToDecimal(this.Request["lblRechargeBank"].ToString().Replace("¥", ""));
                model.FRechargeGiveMoney = Convert.ToDecimal(this.Request["lblFRechargeGiveMoney"].ToString().Replace("¥", ""));
                model.AllMoneys = Convert.ToDecimal(this.Request["hdyjjg"]);
                model.sjMoneys = Convert.ToDecimal(this.Request["txtsjMoneys"]);
                model.HandoverUserID = Convert.ToInt32(this.Request["hdjjid"]);
                model.Arrearage = Convert.ToDecimal(this.Request["hdye"]);
                model.Ispay = false;
                num = work2.Add(model);
                if (num > 0)
                {
                    num = 1;
                    DbHelperSQL.ExecuteSql(string.Format("update SysUserWork set ispay = '1' where HandoverUserID = '{0}'", Convert.ToInt32(this.Request["hdUserID"].ToString())));
                    PubFunction.SaveSysLog(Convert.ToInt32(this.Request["hdUserID"].ToString()), 1, "管理员换班", "管理员换班,接班人:[" + user.GetModel(Convert.ToInt32(this.Request["hdjjid"])).UserName + "]", Convert.ToInt32(this.Request["hdShopID"]), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
            }
            this.Context.Response.Write(num);
        }

        public void AllowExchange()
        {
            int num = 0;
            try
            {
                int exchangeID = int.Parse(this.Request["ID"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                Chain.Model.GiftExchange model = new Chain.Model.GiftExchange();
                Chain.BLL.GiftExchange exchange2 = new Chain.BLL.GiftExchange();
                model = exchange2.GetModel(exchangeID);
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem memInfo = new Chain.Model.Mem();
                memInfo = mem.GetModel(model.MemID);
                Chain.BLL.PointLog log = new Chain.BLL.PointLog();
                Chain.Model.PointLog log2 = new Chain.Model.PointLog();
                Chain.BLL.PointGift gift = new Chain.BLL.PointGift();
                Chain.Model.PointGift gift2 = new Chain.Model.PointGift();
                Chain.BLL.GiftExchangeDetail detail = new Chain.BLL.GiftExchangeDetail();
                Chain.Model.GiftExchangeDetail detail2 = new Chain.Model.GiftExchangeDetail();
                if (model.ExchangeAllPoint > memInfo.MemPoint)
                {
                    num = -1;
                }
                else
                {
                    int num5;
                    int num6;
                    string strWhere = string.Format(" GiftExchangeDetail.ExchangeGiftID=PointGift.GiftID and  ExchangeID={0} ", exchangeID);
                    DataTable table = detail.GetList(strWhere).Tables[0];
                    for (num5 = 0; num5 < table.Rows.Count; num5++)
                    {
                        num6 = int.Parse(table.Rows[num5]["ExchangeNumber"].ToString());
                        gift2 = gift.GetModel(int.Parse(table.Rows[num5]["ExchangeGiftID"].ToString()));
                        if (num6 > gift2.GiftStockNumber)
                        {
                            num = -2;
                            break;
                        }
                    }
                    if (num == 0)
                    {
                        for (num5 = 0; num5 < table.Rows.Count; num5++)
                        {
                            num6 = int.Parse(table.Rows[num5]["ExchangeNumber"].ToString());
                            gift.UpdateGiftNumber(int.Parse(table.Rows[num5]["ExchangeGiftID"].ToString()), num6);
                        }
                        mem.UpdatePoint(model.MemID, model.ExchangeAllPoint * -1);
                        memInfo = new Chain.BLL.Mem().GetModel(model.MemID);
                        PubFunction.UpdateMemLevel(memInfo);
                        model.ExchangeStatus = 2;
                        model.ExchangeUserID = userID;
                        model.ExchangeTime = DateTime.Now;
                        if (exchange2.Update(model))
                        {
                            num = 1;
                            log2.PointMemID = memInfo.MemID;
                            log2.PointNumber = model.ExchangeAllPoint;
                            log2.PointChangeType = 1;
                            log2.PointRemark = "自助兑换审核通过,扣减积分[" + model.ExchangeAllPoint + "]";
                            log2.PointShopID = shopID;
                            log2.PointCreateTime = DateTime.Now;
                            log2.PointUserID = userID;
                            log2.PointOrderCode = model.ExchangeAccount;
                            log.Add(log2);
                            PubFunction.SaveSysLog(userID, 4, "兑换审核", string.Concat(new object[] { "审核通过,会员卡号:[", memInfo.MemCard, "],姓名:[", memInfo.MemName, "],总积分:[", model.ExchangeAllPoint, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                        }
                    }
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void CarllerMem()
        {
            int num = 0;
            try
            {
                string str = this.Request["Mobile"];
                int num2 = (this.Request["MemID"] != "") ? int.Parse(this.Request["MemID"]) : 0;
                string str2 = this.Request["State"];
                string str3 = (this.Request["Time"] != "") ? this.Request["Time"] : "00:00";
                string str4 = (this.Request["Remark"] != "") ? this.Request["Remark"] : "无";
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                Chain.Model.ScreenPopUp model = new Chain.Model.ScreenPopUp();
                model.CallerMemID = num2;
                if (num2 != 0)
                {
                    model.CallerIsMem = "会员";
                }
                else
                {
                    model.CallerIsMem = "非会员";
                }
                if (str2 == "未接来电.....")
                {
                    str2 = "未接来电";
                }
                else if (str2 == "本地电话机挂机.....")
                {
                    str2 = "已接来电";
                }
                if ((str2 == "来电振铃中.....") && (str3 == "暂未接通"))
                {
                    str2 = "未接来电";
                }
                if (str3 == "暂未接通")
                {
                    str3 = "00:00";
                }
                model.CallerMobile = str;
                model.CallerState = str2;
                model.CallerDuration = str3;
                model.CallerRemark = str4;
                model.CallerCreateTime = DateTime.Now;
                model.CallerUserID = userID;
                model.CallerShopID = shopID;
                new Chain.BLL.ScreenPopUp().Add(model);
                PubFunction.SaveSysLog(userID, 4, "来电弹屏", model.CallerIsMem + "来电,来电时间:" + model.CallerCreateTime, shopID, DateTime.Now, PubFunction.ipAdress);
                num = 1;
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void ChangeCard()
        {
            int num = -1;
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            int num4 = (this.Request["memID"].ToString() != "") ? int.Parse(this.Request["memID"]) : 0;
            string memCard = (this.Request["newCard"].ToString() != "") ? this.Request["newCard"].ToString() : "";
            string str2 = (this.Request["copyPwd"].ToString() != "") ? this.Request["copyPwd"].ToString() : "";
            string text = (this.Request["oldPwd"].ToString() != "") ? this.Request["oldPwd"].ToString() : "";
            string memPassword = (this.Request["newPwd"].ToString() != "") ? this.Request["newPwd"].ToString() : "";
            string memCardNumber = (this.Request["newCardNumber"].ToString() != "") ? this.Request["newCardNumber"].ToString() : "";
            string str6 = (this.Request["remark"].ToString() != "") ? this.Request["remark"].ToString() : "无";
            try
            {
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem model = mem.GetModel(int.Parse(this.Request["memID"]));
                text = DESEncrypt.Encrypt(text);
                if ((text != model.MemPassword) && PubFunction.curParameter.bolPwd)
                {
                    num = -3;
                }
                else if (mem.Exists(model.MemID, memCard, "", memCardNumber) != 1)
                {
                    num = -4;
                }
                else if (PubFunction.IsCanRegisterCard(shopID, memCard, memCardNumber))
                {
                    if (PubFunction.curParameter.bolPwd)
                    {
                        if (str2 == "true")
                        {
                            memPassword = text;
                        }
                        else
                        {
                            memPassword = DESEncrypt.Encrypt(memPassword);
                        }
                    }
                    else if (str2 == "true")
                    {
                        memPassword = model.MemPassword;
                    }
                    else
                    {
                        memPassword = DESEncrypt.Encrypt(memPassword);
                    }
                    if (mem.ChangeCard(model, memCard, memPassword, memCardNumber))
                    {
                        num = 1;
                        PubFunction.SaveSysLog(userID, 3, "会员换卡", "会员换卡,会员卡号:[" + model.MemCard + "],会员姓名:[" + model.MemName + "],卡号更换为:[" + memCard + "],备注:" + str6, shopID, DateTime.Now, PubFunction.ipAdress);
                    }
                    else
                    {
                        num = 0;
                    }
                }
                else
                {
                    num = -7;
                }
            }
            catch
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void ChangePwd()
        {
            int num = 0;
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            int memID = (this.Request["memID"].ToString() != "") ? int.Parse(this.Request["memID"]) : 0;
            string text = (this.Request["oldPwd"].ToString() != "") ? this.Request["oldPwd"].ToString() : "";
            string str2 = (this.Request["newPwd"].ToString() != "") ? this.Request["newPwd"].ToString() : "";
            string str3 = (this.Request["remark"].ToString() != "") ? this.Request["remark"].ToString() : "无";
            int checkPwd = Convert.ToInt32(this.Request["checkPwd"]);
            try
            {
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem model = mem.GetModel(memID);
                text = DESEncrypt.Encrypt(text);
                str2 = DESEncrypt.Encrypt(str2);
                num = mem.UpdateMemPwd(model.MemID, str2, text, checkPwd);
                PubFunction.SaveSysLog(userID, 3, "会员修改密码", "修改会员密码,会员卡号:[" + model.MemCard + "],会员姓名:[" + model.MemName + "],备注:" + str3, shopID, DateTime.Now, PubFunction.ipAdress);
            }
            catch
            {
                num = -2;
            }
            this.Context.Response.Write(num);
        }

        public void CheckCustomFieldRemind()
        {
            string s = "";
            DataTable dt = new Chain.BLL.SysCustomRemind().GetCustomField().Tables[0];
            if (dt.Rows.Count > 0)
            {
                s = JsonPlus.ToJson(dt, "CustomRemindDetail");
                this.Context.Response.Write(s);
            }
        }

        public void CheckHardwareID()
        {
            string str = this.Request["Safety"].ToString();
            Hashtable hashtable = (Hashtable)this.Context.Application.Get("HardwareID");
            if (hashtable.ContainsValue(str))
            {
                this.Context.Response.Write(0);
            }
            else
            {
                this.Context.Response.Write(1);
            }
        }

        public void CheckOnlineUser()
        {
            if (!OnlineBiz.IsValid(int.Parse(this.Session["UID"].ToString()), this.Context.Session.SessionID))
            {
                this.Context.Session.Clear();
                this.Context.Response.Write(this.Context.Request.QueryString["jsoncallback"] + "({result: 0})");
            }
            else
            {
                string s = "{\"result\": \"" + this.Session["UID"].ToString() + "\",\"Session\": \"" + this.Context.Session.SessionID + "\"}";
                this.Context.Response.Write(s);
            }
        }
        public static Chain.Model.SysUser CheckUserLogin(string UserAccount, string Pwd)
        {
            Chain.Model.SysUser user = new Chain.Model.SysUser();
                 user.UserAccount=UserAccount;
         user.UserCreateTime= DateTime.Now; 
        user.UserGroupID =1;
         user.UserID=1;
          user.UserLock=false;
        user.UserName =UserAccount;
        user.UserNumber ="12";
        user.UserPassword =Pwd;
        user.UserRemark ="";
        user.UserShopID=1;
        user.UserTelephone = "18910620895";

            return user;
        }
        public void CheckUserLogin()
        {
            int num = 0;
            try
            {
                string str = this.Request["Account"].ToString();
                string pwd = this.Request["password"].ToString();
            //    Chain.Model.SysUser user = PubFunction.CheckUserLogin(str.Trim(), pwd);
                Chain.Model.SysUser user =CheckUserLogin(str.Trim(), pwd);
                if (user != null)
                {
                    num = 2;
                    if (!new Chain.BLL.SysShop().GetModel(user.UserShopID).ShopState && !user.UserLock)
                    {
                        num = 1;
                        this.Session["User"] = user;
                        this.Session["UID"] = user.UserID;
                        this.Session["UserAccount"] = user.UserAccount;
                        this.Session["UserName"] = user.UserName;
                        this.Session["UserGroupID"] = user.UserGroupID;
                        this.Session["UserShopID"] = user.UserShopID;
                        this.Session["UserAuthority"] = PubFunction.GetUserAuthority(user.UserGroupID);
                        Chain.BLL.SysParameter parameter = new Chain.BLL.SysParameter();
                        DataTable table = parameter.GetList(string.Format(" ShopID = '{0}'", user.UserShopID)).Tables[0];
                        this.Session["CurrentParameter"] = PubFunction.LoadSysParameter(Convert.ToInt32(table.Rows[0]["ParameterID"]));
                        OnlineBiz.Add(user.UserID, this.Session.SessionID, this.Request.UserHostAddress);
                        PubFunction.SysUpdateMemIsPast();
                        PubFunction.SysEdition(PubFunction.curParameter.istry);
                        PubFunction.ipAdress = this.Request.UserHostAddress;
                        PubFunction.SaveSysLog(user.UserID, 4, "系统登录", "系统登录,账号:[" + user.UserAccount + "] 姓名:[" + user.UserName + "]", user.UserShopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
            }
            catch
            {
                num = 3;
            }
            this.Context.Response.Write(num);
        }

        public void CleanSysError()
        {
            int num;
            try
            {
                Chain.BLL.SysError error = new Chain.BLL.SysError();
                int strDay = int.Parse(this.Request["cleanTime"].ToString());
                if (error.CleadSysError(strDay) > 0)
                {
                    num = 1;
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 2, "系统日志", "系统日志清理", int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -1;
            }
        }

        public void CleanSysLog()
        {
            int num;
            try
            {
                Chain.BLL.SysLog log = new Chain.BLL.SysLog();
                int strDay = int.Parse(this.Request["cleanTime"].ToString());
                if (log.CleadSysLog(strDay) > 0)
                {
                    num = 1;
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 2, "系统日志", "系统日志清理", int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -1;
            }
        }

        public void CouponAdd()
        {
            int num = 0;
            try
            {
                Chain.BLL.Coupon coupon = new Chain.BLL.Coupon();
                Chain.Model.Coupon model = new Chain.Model.Coupon();
                int num2 = int.Parse(this.Request["spCouponID"]);
                int num3 = int.Parse(this.Request["CouponPredictNu"]);
                int num4 = int.Parse(this.Request["CouponType"]);
                int num5 = int.Parse(this.Request["CouponDayNum"]);
                int num6 = int.Parse(this.Request["CouPonYX"]);
                decimal num7 = decimal.Parse(this.Request["CouponNumber"]);
                decimal num8 = decimal.Parse(this.Request["CouponMinMoney"]);
                string str = this.Request["CouponTitle"];
                string str2 = this.Request["CouponContent"];
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                if (this.Request["CouPonStart"] != "")
                {
                    DateTime time = DateTime.Parse(this.Request["CouPonStart"]);
                    model.CouponStart = new DateTime?(time);
                }
                if (this.Request["CouPonEnd"] != "")
                {
                    DateTime time2 = DateTime.Parse(this.Request["CouPonEnd"]);
                    model.CouponEnd = new DateTime?(time2);
                }
                model.CouponTitle = str;
                model.CouponType = num4;
                model.CouponNumber = num7;
                model.CouponPredictNu = num3;
                model.CouponMinMoney = num8;
                model.CouponDayNum = num5;
                model.CouponEffective = num6;
                model.CouponContent = str2;
                model.CouponYF = 0;
                model.CouponSY = 0;
                model.CouponShopID = int.Parse(this.Session["UserShopID"].ToString());
                num = coupon.Add(model);
                if (num > 0)
                {
                    Chain.BLL.CouponList list = new Chain.BLL.CouponList();
                    Chain.Model.CouponList list2 = new Chain.Model.CouponList();
                    for (int i = 0; i < num3; i++)
                    {
                        list2.CouPon = PubFunction.CreateRandomNumber(5);
                        list2.CouPonID = num;
                        list.Add(list2);
                    }
                    PubFunction.SaveSysLog(userID, 1, "优惠劵新增", string.Concat(new object[] { "新增电子优惠劵,名称:[", str, "],预发:", num3, "张" }), shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void CreateMenu()
        {
            int num = 0;
            try
            {
                string str = this.Request["CreateMenu"];
                if (string.IsNullOrEmpty(PubFunction.curParameter.strWeiXinAppID))
                {
                    num = 1;
                }
                else if (string.IsNullOrEmpty(PubFunction.curParameter.strWeiXinAppSecret))
                {
                    num = 2;
                }
                else
                {
                    string strWeiXinAppID = PubFunction.curParameter.strWeiXinAppID;
                    string strWeiXinAppSecret = PubFunction.curParameter.strWeiXinAppSecret;
                    string address = string.Format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}", strWeiXinAppID, strWeiXinAppSecret);
                    WebClient client = new WebClient();
                    client.Encoding = Encoding.UTF8;
                    string input = client.DownloadString(address);
                    string str6 = string.Empty;
                    string pattern = "{\"access_token\":\"(.+)\",\"expires_in\":7200}";
                    Match match = Regex.Match(input, pattern);
                    if (match.Success)
                    {
                        str6 = match.Groups[1].Value;
                    }
                    else
                    {
                        num = 3;
                    }
                    if (!string.IsNullOrEmpty(str6))
                    {
                        Chain.BLL.WeiXinMenu menu = new Chain.BLL.WeiXinMenu();
                        DataTable dtMenu = menu.GetList("").Tables[0];
                        string s = ResponseSendStr.Menu(dtMenu);
                        address = string.Format("https://api.weixin.qq.com/cgi-bin/menu/create?access_token={0}", str6);
                        using (MemoryStream stream = new MemoryStream())
                        {
                            byte[] bytes = Encoding.UTF8.GetBytes(s);
                            stream.Write(bytes, 0, bytes.Length);
                            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
                            request.Method = "POST";
                            request.ContentLength = stream.Length;
                            request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
                            request.KeepAlive = true;
                            request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36";
                            if (stream != null)
                            {
                                stream.Position = 0L;
                                Stream requestStream = request.GetRequestStream();
                                byte[] buffer2 = new byte[0x400];
                                int count = 0;
                                while ((count = stream.Read(bytes, 0, bytes.Length)) != 0)
                                {
                                    requestStream.Write(bytes, 0, count);
                                }
                                stream.Close();
                            }
                            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                            using (Stream stream3 = response.GetResponseStream())
                            {
                                using (StreamReader reader = new StreamReader(stream3, Encoding.GetEncoding("utf-8")))
                                {
                                    if (reader.ReadToEnd() == "{\"errcode\":0,\"errmsg\":\"ok\"}")
                                    {
                                        num = 4;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            this.Response.Write(num);
        }

        public void CustomFieldAdd()
        {
            int num = 0;
            try
            {
                Chain.Model.MemCustomField model = new Chain.Model.MemCustomField();
                string str = this.Request["CustomFieldType"].ToString();
                model.CustomType = int.Parse(this.Request["CustomType"]);
                model.CustomFieldName = this.Request["CustomName"].ToString();
                model.CustomField = this.Request["CustomCode"].ToString();
                model.CustomFieldType = str;
                model.CustomFieldIsNull = this.Request["isNull"] == "true";
                model.CustomFieldIsShow = this.Request["isShow"] == "true";
                model.CustomFieldCreateTime = DateTime.Now;
                model.CustomFieldShopID = int.Parse(this.Session["UserShopID"].ToString());
                model.CustomFieldUserID = int.Parse(this.Session["UID"].ToString());
                model.CustomFieldInfo = this.Request["CustomInfo"].ToString();
                num = new Chain.BLL.MemCustomField().Add(model);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(model.CustomFieldUserID, 1, "自定义属性新增", "新增自定义属性,属性名称:[" + model.CustomFieldName + "] ,代码:[" + model.CustomField + "]", model.CustomFieldShopID, model.CustomFieldCreateTime, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void CustomFieldDel()
        {
            int num = 0;
            try
            {
                int customFieldID = int.Parse(this.Request["CustomFieldID"].ToString());
                Chain.BLL.MemCustomField field = new Chain.BLL.MemCustomField();
                Chain.Model.MemCustomField model = field.GetModel(customFieldID);
                DataTable table = new DataTable();
                if (model.CustomType == 1)
                {
                    table = new Chain.BLL.Mem().GetList("len(" + model.CustomField + ")!=0 and " + model.CustomField + " is not null").Tables[0];
                }
                else
                {
                    table = new Chain.BLL.Goods().GetList("len(" + model.CustomField + ")!=0 and " + model.CustomField + " is not null").Tables[0];
                }
                if (table.Rows.Count > 0)
                {
                    num = -2;
                }
                else if (field.Delete(customFieldID))
                {
                    num = 1;
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 2, "自定义属性删除", "删除自定义属性,字段名称:" + model.CustomFieldName, int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void CustomFieldEdit()
        {
            int num = 0;
            try
            {
                Chain.Model.MemCustomField model = new Chain.Model.MemCustomField();
                model.CustomFieldID = int.Parse(this.Request["CustomFieldID"]);
                model.CustomType = int.Parse(this.Request["CustomType"]);
                model.CustomFieldName = this.Request["CustomName"].ToString();
                model.CustomField = this.Request["CustomCode"].ToString();
                model.CustomFieldType = this.Request["CustomFieldType"].ToString();
                model.CustomFieldIsNull = this.Request["isNull"] == "true";
                model.CustomFieldIsShow = this.Request["isShow"] == "true";
                model.CustomFieldCreateTime = DateTime.Now;
                model.CustomFieldShopID = int.Parse(this.Session["UserShopID"].ToString());
                model.CustomFieldUserID = int.Parse(this.Session["UID"].ToString());
                model.CustomFieldInfo = this.Request["CustomInfo"].ToString();
                num = new Chain.BLL.MemCustomField().Update(model);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(model.CustomFieldUserID, 3, "自定义属性编辑", "自定义属性编辑,属性名称:[" + model.CustomFieldName + "] ,代码:[" + model.CustomField + "]", model.CustomFieldShopID, model.CustomFieldCreateTime, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void CustomRemindAdd()
        {
            try
            {
                string str = this.Request["CustomReminder"].ToString();
                str = str.Remove(str.LastIndexOf(","), 1);
                Chain.Model.SysCustomRemind model = new Chain.Model.SysCustomRemind();
                model.CustomRemindTitle = this.Request["CustomRemindTitle"].ToString();
                model.CustomRemindDetail = this.Request["CustomRemindDetail"].ToString();
                model.CustomReminder = str;
                model.CustomRemindTime = DateTime.Parse(this.Request["CustomRemindTime"].ToString());
                model.CustomRemindCreateTime = DateTime.Now;
                model.CustomRemindShopID = int.Parse(this.Session["UserShopID"].ToString());
                model.CustomRemindUserID = int.Parse(this.Session["UID"].ToString());
                if (new Chain.BLL.SysCustomRemind().Add(model) > 0)
                {
                    PubFunction.SaveSysLog(model.CustomRemindUserID, 1, "自定义提醒新增", string.Concat(new object[] { "新增自定义提醒,标题:[", model.CustomRemindTitle, "] ,创建时间:[", model.CustomRemindCreateTime, "]" }), model.CustomRemindShopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
            }
        }

        public void CustomRemindDel()
        {
            int num = 0;
            try
            {
                int customRemindID = int.Parse(this.Request["CustomRemindID"]);
                Chain.BLL.SysCustomRemind remind = new Chain.BLL.SysCustomRemind();
                Chain.Model.SysCustomRemind model = remind.GetModel(customRemindID);
                if (remind.Delete(customRemindID))
                {
                    num = 1;
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 2, "自定义提醒删除", "删除自定义提醒,标题:" + model.CustomRemindTitle, int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void DataBakUp()
        {
            string str = this.Request["bakUpName"].ToString() + "_" + DateTime.Now.ToString("yyMMddHHmmss");
            Chain.BLL.SysParameter parameter = new Chain.BLL.SysParameter();
            string path = this.Server.MapPath("../AppData/DataBase/");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            this.Context.Response.Write(parameter.DataBakUp(PubFunction.curParameter.DataBaseName, path + @"\" + str + ".bak"));
        }

        public void DataBakUpDel()
        {
            string str = this.Request["bakUpName"].ToString();
            string str2 = this.Server.MapPath("../AppData/DataBase/");
            if (System.IO.File.Exists(str2 + str))
            {
                System.IO.File.Delete(str2 + str);
            }
            this.Context.Response.Write(1);
        }

        public void DBInit()
        {
            int num = 0;
            try
            {
                string[] strArray2;
                string detail = "";
                string str2 = this.Request["type"].ToString();
                ArrayList arrSql = new ArrayList();
                Chain.BLL.SysLog log = new Chain.BLL.SysLog();
                string str4 = str2;
                if (str4 != null)
                {
                    if (!(str4 == "empty"))
                    {
                        if (str4 == "Restore")
                        {
                            goto Label_0109;
                        }
                    }
                    else
                    {
                        string[] strArray = new string[1];
                        if (PubFunction.curParameter.sameGoods)
                        {
                            strArray = Regex.Split(Resource.ClearSameTable, @"\r\n");
                        }
                        else
                        {
                            strArray = Regex.Split(Resource.ClearTable, @"\r\n");
                        }
                        detail = "系统数据全部清空";
                        foreach (string str3 in strArray)
                        {
                            if ((str3.IndexOf("--") != 0) && (str3.Trim() != ""))
                            {
                                arrSql.Add(str3.Trim());
                            }
                        }
                    }
                }
                goto Label_01B4;
            Label_0109:
                strArray2 = new string[1];
                if (PubFunction.curParameter.sameGoods)
                {
                    strArray2 = Regex.Split(Resource.TestSameGoodsData, @"\r\n");
                }
                else
                {
                    strArray2 = Regex.Split(Resource.TestData, @"\r\n");
                }
                detail = "系统数据还原到测试数据";
                foreach (string str3 in strArray2)
                {
                    if ((str3.IndexOf("--") != 0) && (str3.Trim() != ""))
                    {
                        arrSql.Add(str3.Trim());
                    }
                }
            Label_01B4:
                if (log.DataBaseInit(arrSql))
                {
                    num = 1;
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 4, "系统数据", detail, int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void DelayTime()
        {
            int num = -1;
            try
            {
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int memID = (this.Request["memID"].ToString() != "") ? int.Parse(this.Request["memID"].ToString()) : 0;
                DateTime pastTime = DateTime.Parse(this.Request["newPastTime"]);
                string str = (this.Request["remark"] != "") ? this.Request["remark"].ToString() : "无";
                Chain.Model.Mem model = new Chain.BLL.Mem().GetModel(memID);
                num = new Chain.BLL.Mem().UpdateMemPastTime(memID, pastTime);
                PubFunction.SaveSysLog(userID, 3, "会员延期", "会员延期,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "],延期到:[" + pastTime.ToShortDateString() + "],备注:" + str, shopID, DateTime.Now, PubFunction.ipAdress);
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void DeleteEmptyBills()
        {
            string s = "0";
            try
            {
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int memID = int.Parse(this.Request["memID"].ToString());
                int orderID = int.Parse(this.Request["orderID"].ToString());
                this.modelOrderLog = this.bllOrderLog.GetModel(orderID);
                Chain.Model.Mem model = new Chain.BLL.Mem().GetModel(memID);
                DataTable table = this.bllDetail.GetList(" OrderID=" + orderID).Tables[0];
                this.modelGoodsLog.GoodsAccount = this.modelOrderLog.OrderAccount;
                this.modelGoodsLog.Type = 4;
                this.modelGoodsLog.TotalPrice = this.modelOrderLog.OrderDiscountMoney;
                this.modelGoodsLog.InShopID = shopID;
                this.modelGoodsLog.OutShopID = shopID;
                this.modelGoodsLog.Remark = "商品挂单撤销入库";
                this.modelGoodsLog.CreateTime = DateTime.Now;
                this.modelGoodsLog.ShopID = shopID;
                this.modelGoodsLog.UserID = userID;
                int num5 = this.bllGoodsLog.Add(this.modelGoodsLog);
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    this.modelGoods = this.bllGoods.GetModel(int.Parse(table.Rows[i]["GoodsID"].ToString()));
                    if (float.Parse(table.Rows[i]["OrderDetailNumber"].ToString()) < 0f)
                    {
                        int intNumber = Math.Abs(int.Parse(table.Rows[i]["OrderDetailNumber"].ToString()));
                        DataTable table2 = this.bllCountDetail.GetList(-1, string.Concat(new object[] { " CountDetailGoodsID=", this.modelGoods.GoodsID, " and CountDetailMemID=", memID }), "CountCreateTime").Tables[0];
                        for (int j = 0; j < table2.Rows.Count; j++)
                        {
                            if ((int.Parse(table2.Rows[j]["CountDetailNumber"].ToString()) + intNumber) < int.Parse(table2.Rows[j]["CountDetailTotalNumber"].ToString()))
                            {
                                intNumber *= -1;
                                this.bllCountDetail.UpdateCountDetailNumber(intNumber, int.Parse(table2.Rows[j]["CountDetailID"].ToString()));
                            }
                            else
                            {
                                int num9 = int.Parse(table2.Rows[j]["CountDetailTotalNumber"].ToString()) - int.Parse(table2.Rows[j]["CountDetailNumber"].ToString());
                                num9 *= -1;
                                this.bllCountDetail.UpdateCountDetailNumber(num9, int.Parse(table2.Rows[j]["CountDetailID"].ToString()));
                                intNumber -= int.Parse(table2.Rows[j]["CountDetailNumber"].ToString());
                            }
                        }
                    }
                    else if (this.modelGoods.GoodsType == 0)
                    {
                        this.modelNumber.GoodsID = int.Parse(table.Rows[i]["GoodsID"].ToString());
                        this.modelNumber.ShopID = this.modelOrderLog.OrderShopID;
                        this.modelNumber.Number = int.Parse(table.Rows[i]["OrderDetailNumber"].ToString());
                        this.bllNumber.UpdataGoodsNumber(this.modelNumber);
                        this.modelGoodsDetail.GoodsLogID = num5;
                        this.modelGoodsDetail.GoodsID = this.modelNumber.GoodsID;
                        this.modelGoodsDetail.GoodsInPrice = 0M;
                        this.modelGoodsDetail.GoodsOutPrice = 0M;
                        this.modelGoodsDetail.GoodsNumber = this.modelNumber.Number;
                        this.bllGoodsDetail.Add(this.modelGoodsDetail);
                    }
                }
                DataTable table3 = this.bllStaffMoney.GetList(" StaffOrderCode='" + this.modelOrderLog.OrderAccount + "'").Tables[0];
                if (table3.Rows.Count > 0)
                {
                    this.bllStaffMoney.DeleteStaff(this.modelOrderLog.OrderAccount);
                }
                int num10 = this.bllDetail.DeleteDetail(orderID);
                if ((num10 > 0) && this.bllOrderLog.Delete(orderID))
                {
                    model = new Chain.BLL.Mem().GetModel(memID);
                    string str2 = PubFunction.UpdateMemLevel(model);
                    PubFunction.SaveSysLog(userID, 4, "会员消费", "会员挂单撤销,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "],订单号:[" + this.modelOrderLog.OrderAccount + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                    s = string.Concat(new object[] { "{\"Success\":\"", num10, "\",\"strUpdateMemLevel\":\"", str2, "\"}" });
                }
            }
            catch (Exception)
            {
                s = "-1";
            }
            this.Context.Response.Write(s);
        }

        public void DelGoodsClass()
        {
            int num = 0;
            try
            {
                Chain.BLL.MicroWebsiteGoodsClass class2 = new Chain.BLL.MicroWebsiteGoodsClass();
                Chain.Model.MicroWebsiteGoodsClass class3 = new Chain.Model.MicroWebsiteGoodsClass();
                int microGoodsClassID = !string.IsNullOrEmpty(this.Request["classID"]) ? int.Parse(this.Request["classID"].ToString()) : 0;
                if (microGoodsClassID != 0)
                {
                    DataTable table = new Chain.BLL.MicroWebsiteGoods().GetList(" MicroGoodsClassID=" + microGoodsClassID).Tables[0];
                    if (table.Rows.Count > 0)
                    {
                        num = -1;
                    }
                    else if (class2.Delete(microGoodsClassID))
                    {
                        num = 1;
                    }
                    else
                    {
                        num = -2;
                    }
                }
            }
            catch
            {
                num = -2;
            }
            this.Response.Write(num);
        }

        public void DelMemberExplanation()
        {
            int num = 0;
            try
            {
                int memberExplanationID = int.Parse(this.Request["MemberExplanationID"]);
                Chain.BLL.MemberExplanation explanation = new Chain.BLL.MemberExplanation();
                num = explanation.Delete(memberExplanationID) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void DelMenu()
        {
            int num = 0;
            try
            {
                int menuID = Convert.ToInt32(this.Request["MenuID"]);
                Chain.BLL.WeiXinMenu menu = new Chain.BLL.WeiXinMenu();
                num = menu.Delete(menuID) ? 1 : 0;
            }
            catch (Exception)
            {
            }
            this.Response.Write(num);
        }

        public void DelMicroGoods()
        {
            int num = 0;
            try
            {
                int microGoodsID = int.Parse(this.Request["goodsID"]);
                if (new Chain.BLL.MicroWebsiteGoods().Delete(microGoodsID))
                {
                    num = 1;
                }
            }
            catch
            {
                num = 0;
            }
            this.Response.Write(num);
        }

        public void DelProduct()
        {
            int num = 0;
            try
            {
                int productID = int.Parse(this.Request["ProductID"]);
                num = new Chain.BLL.ProductCenter().Delete(productID) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void DelPromotions()
        {
            int num = 0;
            try
            {
                int promotionsID = int.Parse(this.Request["PromotionsID"]);
                num = new Chain.BLL.Promotions().Delete(promotionsID) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void DelSymbol()
        {
            int num = 0;
            try
            {
                int symbolID = int.Parse(this.Request["SymbolID"]);
                num = new Chain.BLL.SymbolShow().Delete(symbolID) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void DrawMoney()
        {
            int num = -1;
            int userID = int.Parse(this.Session["UID"].ToString());
            int intShopID = int.Parse(this.Session["UserShopID"].ToString());
            string str = this.Request["account"].ToString();
            int memID = (this.Request["memID"].ToString() != "") ? int.Parse(this.Request["memID"]) : 0;
            decimal num5 = (this.Request["money"].ToString() != "") ? decimal.Parse(this.Request["money"].ToString()) : 0M;
            decimal num6 = (this.Request["actualmoney"].ToString() != "") ? decimal.Parse(this.Request["actualmoney"].ToString()) : 0M;
            string str2 = (this.Request["remark"].ToString() != "") ? this.Request["remark"].ToString() : "";
            bool flag = this.Request["sendSMS"] == "true";
            try
            {
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem model = mem.GetModel(memID);
                Chain.Model.MemDrawMoney money = new Chain.Model.MemDrawMoney();
                Chain.BLL.MemDrawMoney money2 = new Chain.BLL.MemDrawMoney();
                string detail = "会员账户提现,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "],提现扣减金额:[" + num6.ToString() + "],备注:" + str2;
                money.DrawMoneyMemID = memID;
                money.DrawMoneyAccount = str;
                money.DrawMoney = num5;
                money.DrawActualMoney = num6;
                money.DrawMoneyRemark = str2;
                money.DrawMoneyShopID = intShopID;
                money.DrawMoneyUserID = userID;
                money.DrawMoneyCreateTime = DateTime.Now;
                if (money2.Add(money) > 0)
                {
                    num = mem.DrawMoney(model.MemID, num6);
                    if (flag)
                    {
                        if (Convert.ToInt32(SMSInfo.GetBalance(false)) <= 0)
                        {
                            num = -2;
                        }
                        else if (PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length))
                        {
                            SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                            smsTemplateParameter.strCardID = model.MemCard;
                            smsTemplateParameter.strName = model.MemName;
                            smsTemplateParameter.dclTempMoney = num5;
                            smsTemplateParameter.dclMoney = model.MemMoney - num5;
                            smsTemplateParameter.intTempPoint = 0;
                            smsTemplateParameter.intPoint = model.MemPoint;
                            smsTemplateParameter.OldLevelID = model.MemLevelID;
                            smsTemplateParameter.NewLevelID = model.MemLevelID;
                            string content = SMSInfo.GetSendContent(3, smsTemplateParameter, intShopID);
                            SMSInfo.Send_GXSMS(model.MemMobile, content, "");
                            Chain.Model.SmsLog log = new Chain.Model.SmsLog();
                            log.SmsMemID = model.MemID;
                            log.SmsMobile = model.MemMobile;
                            log.SmsContent = content;
                            log.SmsTime = DateTime.Now;
                            log.SmsShopID = intShopID;
                            log.SmsUserID = userID;
                            log.SmsAmount = PubFunction.GetSmsAmount(content);
                            log.SmsAllAmount = log.SmsAmount;
                            new Chain.BLL.SmsLog().Add(log);
                            PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length, 2);
                        }
                        else
                        {
                            num = -5;
                        }
                    }
                    PubFunction.SaveSysLog(userID, 4, "会员账户提现", detail, intShopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void EditMemberExplanation()
        {
            int num = 0;
            try
            {
                int memberExplanationID = int.Parse(this.Request["MemberExplanationID"]);
                string str = this.Request["MemberExplanationDesc"];
                Chain.BLL.MemberExplanation explanation = new Chain.BLL.MemberExplanation();
                Chain.Model.MemberExplanation model = explanation.GetModel(memberExplanationID);
                model.MemberExplanationTime = DateTime.Now;
                model.MemberExplanationDesc = str;
                num = explanation.Update(model) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void EditMenu()
        {
            int num = 0;
            try
            {
                string str = this.Request["MenuName"];
                int num2 = Convert.ToInt32(this.Request["MenuType"]);
                string str2 = this.Request["MenuKey"];
                string str3 = this.Request["MenuUrl"];
                int num3 = Convert.ToInt32(this.Request["parentMenuID"]);
                int num4 = Convert.ToInt32(this.Request["MenuID"]);
                if (num2 == 1)
                {
                    str3 = "";
                }
                else
                {
                    str2 = "";
                }
                Chain.BLL.WeiXinMenu menu = new Chain.BLL.WeiXinMenu();
                Chain.Model.WeiXinMenu menu3 = new Chain.Model.WeiXinMenu();
                menu3.MenuKey = str2;
                menu3.MenuName = str;
                menu3.MenuType = num2;
                menu3.MenuUrl = str3;
                menu3.parentMenuID = num3;
                menu3.MenuID = num4;
                Chain.Model.WeiXinMenu model = menu3;
                num = menu.Update(model) ? 1 : 0;
            }
            catch (Exception)
            {
            }
            this.Response.Write(num);
        }

        public void EditModule()
        {
            int num = 0;
            try
            {
                int merchantID = int.Parse(this.Request["MerchantID"]);
                string str = this.Request["MerchantDesc"];
                string str2 = this.Request["MerchantRemark"];
                Chain.BLL.MerchantSite site = new Chain.BLL.MerchantSite();
                Chain.Model.MerchantSite model = site.GetModel(merchantID);
                model.MerchantDesc = str;
                model.MerchantRemark = str2;
                num = site.Update(model) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void EditProduct()
        {
            int num = 0;
            try
            {
                Chain.BLL.ProductCenter center = new Chain.BLL.ProductCenter();
                int productID = int.Parse(this.Request["ProductID"]);
                string str = this.Request["ProductName"];
                string str2 = "../Upload/MicroWebsite/MicroWebsiteProductCenter/" + Path.GetFileName(this.Request["ProductPhoto"]);
                string str3 = this.Request["ProductDesc"];
                Chain.Model.ProductCenter model = center.GetModel(productID);
                model.ProductName = str;
                model.ProductPhoto = str2;
                model.ProductDesc = str3;
                num = center.Update(model) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void EditPromotions()
        {
            int num = 0;
            try
            {
                int promotionsID = int.Parse(this.Request["PromotionsID"]);
                string str = this.Request["PromotionsTitle"];
                int num3 = int.Parse(this.Request["PromotionsType"]);
                int num4 = int.Parse(this.Request["PromotionsMemLevel"]);
                DateTime time = DateTime.Parse((this.Request["PromotionsStart"] == "") ? "1900-1-1" : this.Request["PromotionsStart"]);
                DateTime time2 = DateTime.Parse((this.Request["PromotionsEnd"] == "") ? "1900-1-1" : this.Request["PromotionsEnd"]);
                Chain.BLL.Promotions promotions = new Chain.BLL.Promotions();
                Chain.Model.Promotions model = promotions.GetModel(promotionsID);
                model.PromotionsTitle = str;
                model.PromotionsType = num3;
                model.PromotionsStart = time;
                model.PromotionsEnd = time2;
                model.PromotionsMemLevel = num4;
                model.PromotionsTime = DateTime.Now;
                num = promotions.Update(model) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void EditSymbol()
        {
            int num = 0;
            try
            {
                Chain.BLL.SymbolShow show = new Chain.BLL.SymbolShow();
                int symbolID = int.Parse(this.Request["SymbolID"]);
                string str = this.Request["SymbolTitle"];
                string str2 = "../Upload/MicroWebsite/MicroWebsiteSymbol/" + Path.GetFileName(this.Request["SymbolPhoto"]);
                string str3 = this.Request["SymbolDesc"];
                Chain.Model.SymbolShow model = show.GetModel(symbolID);
                model.SymbolTitle = str;
                model.SymbolPhoto = str2;
                model.SymbolDesc = str3;
                num = show.Update(model) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void EmptyBillsSubmit()
        {
            string s = "0";
            try
            {
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                decimal num3 = (this.Request["parameter[0][CardMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CardMoney]"]) : 0M;
                decimal num4 = (this.Request["parameter[0][CashMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CashMoney]"]) : 0M;
                decimal num5 = (this.Request["parameter[0][BinkMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][BinkMoney]"]) : 0M;
                decimal num6 = (this.Request["parameter[0][CouponMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CouponMoney]"]) : 0M;
                int orderID = int.Parse(this.Request["orderId"].ToString());
                decimal num8 = decimal.Parse(this.Request["totalDiscount"].ToString());
                string str2 = this.Request["orderCode"].ToString();
                bool flag = bool.Parse(this.Request["parameter[0][IsCard]"]);
                bool flag2 = bool.Parse(this.Request["parameter[0][IsCash]"]);
                bool flag3 = bool.Parse(this.Request["parameter[0][IsBink]"]);
                this.modelOrderLog = this.bllOrderLog.GetModel(orderID);
                this.modelOrderLog.OrderPayType = 0;
                this.modelOrderLog.OrderDiscountMoney = num8;
                this.modelOrderLog.OrderIsCard = flag;
                this.modelOrderLog.OrderPayCard = num3;
                this.modelOrderLog.OrderIsCash = flag2;
                this.modelOrderLog.OrderPayCash = num4;
                this.modelOrderLog.OrderIsBink = flag3;
                this.modelOrderLog.OrderPayBink = num5;
                this.modelOrderLog.OrderPayCoupon = num6;
                this.modelOrderLog.OrderType = 2;
                int orderPoint = this.modelOrderLog.OrderPoint;
                if (PubFunction.IsShopPoint(shopID, ref orderPoint))
                {
                    this.modelOrderLog.OrderPoint = orderPoint;
                    int num10 = this.bllOrderLog.UpdateOrderLog(this.modelOrderLog);
                    if (num10 > 0)
                    {
                        Chain.BLL.Mem mem = new Chain.BLL.Mem();
                        Chain.Model.Mem model = mem.GetModel(this.modelOrderLog.OrderMemID);
                        this.modelPoint.PointMemID = this.modelOrderLog.OrderMemID;
                        this.modelPoint.PointNumber = this.modelOrderLog.OrderPoint;
                        this.modelPoint.PointChangeType = 1;
                        this.modelPoint.PointRemark = "会员商品消费成功,消费总额:" + num8;
                        this.modelPoint.PointShopID = shopID;
                        this.modelPoint.PointUserID = userID;
                        this.modelPoint.PointCreateTime = DateTime.Now;
                        this.modelPoint.PointOrderCode = str2;
                        if (this.bllPoint.Add(this.modelPoint) > 0)
                        {
                            decimal dclMemMoney = model.MemMoney - num3;
                            model.MemConsumeMoney += num8;
                            model.MemPoint += this.modelOrderLog.OrderPoint;
                            model.MemConsumeLastTime = DateTime.Now;
                            model.MemConsumeCount++;
                            int num12 = mem.ExpenseUpdateMem(this.modelOrderLog.OrderMemID, dclMemMoney, model.MemConsumeMoney, model.MemPoint, DateTime.Now, model.MemConsumeCount);
                            MEMPointUpdate.MEMPointRate(model, this.modelOrderLog.OrderPoint, this.modelOrderLog.OrderAccount, 1);
                            PubFunction.SetShopPoint(userID, shopID, this.modelOrderLog.OrderPoint, "会员挂单消费,扣除店铺积分", 2);
                            model = new Chain.BLL.Mem().GetModel(this.modelOrderLog.OrderMemID);
                            string str3 = PubFunction.UpdateMemLevel(model);
                            s = string.Concat(new object[] { "{\"Success\":\"", num10, "\",\"strUpdateMemLevel\":\"", str3, "\"}" });
                            PubFunction.SaveSysLog(userID, 4, "会员消费", "会员挂单结算,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "],订单号:[" + str2 + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                        }
                    }
                }
                else
                {
                    s = "-6";
                }
            }
            catch (Exception)
            {
                s = "-1";
            }
            this.Context.Response.Write(s);
        }

        public void Expense()
        {
            string s = "-1";
            string detail = "";
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            int memID = (this.Request["memID"] != null) ? int.Parse(this.Request["memID"].ToString()) : 0;
            int point = (this.Request["point"].ToString() != "") ? int.Parse(this.Request["point"].ToString()) : 0;
            bool flag = this.Request["chkNoMember"].ToString() == "true";
            int num5 = int.Parse(this.Request["isTimeExpense"].ToString());
            decimal num6 = (this.Request["money"].ToString() != "") ? decimal.Parse(this.Request["money"].ToString()) : 0M;
            decimal num7 = decimal.Parse(this.Request["parameter[0][DiscountMoney]"]);
            decimal num8 = (this.Request["parameter[0][CardMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CardMoney]"]) : 0M;
            decimal num9 = (this.Request["parameter[0][CashMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CashMoney]"]) : 0M;
            decimal num10 = (this.Request["parameter[0][BinkMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][BinkMoney]"]) : 0M;
            decimal num11 = (this.Request["parameter[0][CouponMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CouponMoney]"]) : 0M;
            string str3 = (this.Request["orderAccount"].ToString() != "") ? this.Request["orderAccount"].ToString() : "";
            string str4 = this.Request["remark"].ToString();
            bool flag2 = this.Request["sendSMS"] == "true";
            bool flag3 = bool.Parse(this.Request["parameter[0][IsCard]"]);
            bool flag4 = bool.Parse(this.Request["parameter[0][IsCash]"]);
            bool flag5 = bool.Parse(this.Request["parameter[0][IsBink]"]);
            Chain.BLL.Mem mem = new Chain.BLL.Mem();
            Chain.Model.Mem model = mem.GetModel(memID);
            int memLevelID = model.MemLevelID;
            if (memID != 0)
            {
                detail = string.Concat(new object[] { "会员快速消费,会员卡号:[", model.MemCard, "],姓名:[", model.MemName, "],订单号:[", str3, "],消费金额:[", num7, "],获得积分:[", point, "],备注:", str4 });
            }
            else
            {
                detail = string.Concat(new object[] { "散客快速消费,订单号:[", str3, "],消费金额:[", num7, "],备注:", str4 });
            }
            if (PubFunction.IsShopPoint(shopID, ref point) || flag)
            {
                try
                {
                    int num13;
                    Chain.Model.OrderLog log = new Chain.Model.OrderLog();
                    Chain.Model.SysLog log2 = new Chain.Model.SysLog();
                    Chain.Model.PointLog log3 = new Chain.Model.PointLog();
                    if (!flag)
                    {
                        log.OrderMemID = memID;
                        log.OrderType = 0;
                        log.OrderPoint = point;
                        log.OrderTotalMoney = num6;
                        log.OrderDiscountMoney = num7;
                        log.OrderIsCard = flag3;
                        log.OrderPayCard = num8;
                        log.OrderIsCash = flag4;
                        log.OrderPayCash = num9;
                        log.OrderIsBink = flag5;
                        log.OrderPayBink = num10;
                        log.OrderPayCoupon = num11;
                        log.OrderAccount = str3;
                        log.OrderShopID = shopID;
                        log.OrderUserID = userID;
                        log.OrderRemark = str4;
                        log.OrderCreateTime = DateTime.Now;
                        log.OrderPayType = 0;
                        if (num5 == 1)
                        {
                            log.OrderType = 1;
                        }
                        Chain.BLL.OrderLog log4 = new Chain.BLL.OrderLog();
                        num13 = log4.Add(log);
                        if (num13 > 0)
                        {
                            decimal dclMemMoney = model.MemMoney - num8;
                            model.MemConsumeMoney += log.OrderDiscountMoney;
                            model.MemPoint += log.OrderPoint;
                            model.MemConsumeLastTime = DateTime.Now;
                            model.MemConsumeCount++;
                            int num15 = mem.ExpenseUpdateMem(memID, dclMemMoney, model.MemConsumeMoney, model.MemPoint, DateTime.Now, model.MemConsumeCount);
                            log3.PointMemID = memID;
                            log3.PointNumber = point;
                            log3.PointChangeType = 2;
                            log3.PointRemark = string.Concat(new object[] { "会员快速消费,消费金额:[", num7, "],获得积分:", point, "]" });
                            if (num5 == 1)
                            {
                                log3.PointChangeType = 10;
                                log3.PointRemark = string.Concat(new object[] { "会员计时消费,消费金额:[", num7, "],获得积分:", point, "]" });
                            }
                            log3.PointShopID = shopID;
                            log3.PointCreateTime = DateTime.Now;
                            log3.PointUserID = userID;
                            log3.PointOrderCode = str3;
                            this.bllPoint.Add(log3);
                            PubFunction.SetShopPoint(userID, shopID, point, "会员快速消费扣除店铺积分", 2);
                            MEMPointUpdate.MEMPointRate(model, log.OrderPoint, log.OrderAccount, 2);
                            model = new Chain.BLL.Mem().GetModel(memID);
                            string str5 = PubFunction.UpdateMemLevel(model);
                            s = string.Concat(new object[] { "{\"Success\":\"", num13, "\",\"strUpdateMemLevel\":\"", str5, "\"}" });
                            if (flag2)
                            {
                                if (Convert.ToInt32(SMSInfo.GetBalance(false)) <= 0)
                                {
                                    s = "-2";
                                }
                                else
                                {
                                    if (PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length))
                                    {
                                        SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                                        smsTemplateParameter.strCardID = model.MemCard;
                                        smsTemplateParameter.strName = model.MemName;
                                        smsTemplateParameter.dclTempMoney = num7;
                                        smsTemplateParameter.dclMoney = model.MemMoney;
                                        smsTemplateParameter.intPoint = model.MemPoint;
                                        smsTemplateParameter.OldLevelID = memLevelID;
                                        model = new Chain.BLL.Mem().GetModel(memID);
                                        smsTemplateParameter.NewLevelID = model.MemLevelID;
                                        string content = SMSInfo.GetSendContent(5, smsTemplateParameter, shopID);
                                        SMSInfo.Send_GXSMS(model.MemMobile, content, "");
                                        Chain.Model.SmsLog log5 = new Chain.Model.SmsLog();
                                        log5.SmsMemID = model.MemID;
                                        log5.SmsMobile = model.MemMobile;
                                        log5.SmsContent = content;
                                        log5.SmsTime = DateTime.Now;
                                        log5.SmsShopID = shopID;
                                        log5.SmsUserID = userID;
                                        log5.SmsAmount = PubFunction.GetSmsAmount(content);
                                        log5.SmsAllAmount = log5.SmsAmount;
                                        new Chain.BLL.SmsLog().Add(log5);
                                        PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length, 2);
                                    }
                                    else
                                    {
                                        s = "-5";
                                    }
                                    PubFunction.SaveSysLog(userID, 4, "会员消费-快速消费", "快速消费发短信成功,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                                }
                            }
                            PubFunction.SaveSysLog(userID, 4, "会员消费", detail, shopID, DateTime.Now, PubFunction.ipAdress);
                        }
                    }
                    else
                    {
                        log.OrderMemID = memID;
                        log.OrderType = 0;
                        log.OrderPoint = point;
                        log.OrderTotalMoney = num6;
                        log.OrderDiscountMoney = num7;
                        log.OrderIsCard = flag3;
                        log.OrderPayCard = num8;
                        log.OrderIsCash = flag4;
                        log.OrderPayCash = num9;
                        log.OrderIsBink = flag5;
                        log.OrderPayBink = num10;
                        log.OrderPayCoupon = num11;
                        log.OrderAccount = str3;
                        log.OrderShopID = shopID;
                        log.OrderUserID = userID;
                        log.OrderRemark = str4;
                        log.OrderCreateTime = DateTime.Now;
                        log.OrderPayType = 0;
                        if (num5 == 1)
                        {
                            log.OrderType = 1;
                        }
                        num13 = new Chain.BLL.OrderLog().Add(log);
                        if (num13 > 0)
                        {
                            PubFunction.SaveSysLog(userID, 4, "会员管理", detail, shopID, DateTime.Now, PubFunction.ipAdress);
                            s = "{\"Success\":\"" + num13 + "\",\"strUpdateMemLevel\":\"\"}";
                        }
                    }
                }
                catch
                {
                    s = "-1";
                }
            }
            else
            {
                s = "-6";
            }
            this.Context.Response.Write(s);
        }

        public void GetAllMemList()
        {
            string s = "";
            try
            {
                string str2 = (this.Request["Condition"].ToString() != "") ? this.Request["Condition"].ToString() : "";
                string str3 = "";
                DataTable table = new Chain.BLL.MemCustomField().GetList(" CustomType=1").Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str3 = str3 + row["CustomField"].ToString() + ",";
                }
                int resCount = 0;
                str2 = str2 + " and Mem.MemShopID = SysShop.ShopID and Mem.MemLevelID = MemLevel.LevelID and Mem.MemUserID = SysUser.UserID and Mem.MemShopID = SysShopMemLevel.ShopID and Mem.MemLevelID = SysShopMemLevel.MemLevelID ";
                DataTable dt = new Chain.BLL.Mem().GetListSP(0x186a0, 1, out resCount, new string[] { str2 }).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "MemID,MemCard,MemPassword,MemName,MemSex,MemIdentityCard,MemMobile,MemPhoto,MemBirthday,MemIsPast,MemPastTime,MemPoint,MemMoney,MemConsumeMoney,MemConsumeLastTime,MemConsumeCount,MemEmail,MemAddress,MemState,MemRecommendID,MemCreateTime,MemRemark,MemLevelID,MemShopID,MemUserID,ShopName," + str3 + "LevelID,LevelName,LevelPoint,LevelDiscountPercent,LevelPointPercent,UserName,MemTelePhone");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetAllStock()
        {
            string s = "";
            try
            {
                int num = (this.Request["goodsID"] != "") ? int.Parse(this.Request["goodsID"].ToString()) : 0;
                int num2 = int.Parse(this.Session["UserShopID"].ToString());
                string str2 = " GoodsID=" + num;
                if (PubFunction.curParameter.sameGoods)
                {
                    object obj2 = str2;
                    str2 = string.Concat(new object[] { obj2, " and ShopID!=", num2, " and ShopID>0" });
                }
                else
                {
                    str2 = str2 + " and ShopID!=" + num2;
                }
                if (num != 0)
                {
                    int num3;
                    DataTable dt = this.bllGoods.GetGoodsList(0x2710, 1, out num3, new string[] { str2.ToString() }).Tables[0];
                    if (dt != null)
                    {
                        string str3 = JsonPlus.ToJson(dt, "GoodsID,Name,Number,NameCode,ShopName");
                        s = string.Concat(new object[] { "{\"RecordCount\":", num3, ",\"List\":", str3, "}" });
                    }
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetCommonData()
        {
            string s = "";
            StringBuilder builder = new StringBuilder();
            DataTable table = new Chain.BLL.MemLevel().GetList("").Tables[0];
            foreach (DataRow row in table.Rows)
            {
                if (builder.ToString() != "")
                {
                    builder.Append(",");
                }
                builder.Append("{\"LevelID\":" + row["LevelID"].ToString() + ",\"LevelName\":\"" + row["LevelName"].ToString() + "\",\"Point\":\"" + row["LevelPoint"].ToString() + "\",\"Percent\":\"" + row["LevelDiscountPercent"].ToString() + "\"}");
            }
            s = builder.ToString();
            this.Context.Response.Write(s);
        }

        public void GetCoupon()
        {
            string s = "";
            try
            {
                int num = (this.Request["CouponID"].ToString() != "") ? int.Parse(this.Request["CouponID"].ToString()) : 0;
                Chain.BLL.Coupon coupon = new Chain.BLL.Coupon();
                DataTable dt = coupon.GetList(" ID=" + num).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "ID,CouponTitle,CouponType,CouponNumber,CouponPredictNu,CouponEffective,CouponStart,CouponEnd,CouponDayNum,CouponMinMoney,CouponContent,CouponYF,CouponSY");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetCouponDetail()
        {
            string s = "";
            try
            {
                string str2 = this.Request["CouPon"].ToString();
                string str3 = this.Request["MemID"].ToString();
                Chain.BLL.CouponList list = new Chain.BLL.CouponList();
                DataTable dt = list.GetCouponDetail(" CouPonID=ID and CouPonMID = " + str3 + " AND CouponList.CouPonYF='True' and CouPon='" + str2 + "' AND CouponShopID = '" + this.Session["UserShopID"].ToString() + "'").Tables[0];
                if (dt != null)
                {
                    int num = 0;
                    DataTable table2 = list.GetCouponDetail(" CouPonID=ID and CouPonMID=" + str3 + " and CouPonID=" + dt.Rows[0]["CouPonID"].ToString() + " AND CouponShopID = '" + this.Session["UserShopID"].ToString() + "' and datediff(day,ConPonUseTime,getdate())=0").Tables[0];
                    int num2 = int.Parse(dt.Rows[0]["CouponDayNum"].ToString());
                    if ((num2 != 0) && (table2.Rows.Count >= num2))
                    {
                        num = 1;
                    }
                    string str4 = JsonPlus.ToJson(dt, "ID,CouponTitle,CouponType,CouponNumber,CouponPredictNu,CouponEffective,CouponStart,CouponEnd,CouponDayNum,CouponMinMoney,CouponContent,CID,CouPonID,CouPon,CouPonYF,CouPonSY,CouPonMID,ConPonSendTime,ConPonUseTime,CouPonOrderAccount,MemName");
                    s = string.Concat(new object[] { "{\"msgResult\":", num, ",\"msgData\":", str4, "}" });
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetCouponMoney()
        {
            string s = "";
            try
            {
                int orderID = int.Parse(this.Request["orderID"].ToString());
                this.modelOrderLog = this.bllOrderLog.GetModel(orderID);
                s = "{\"couponMoney\":" + this.modelOrderLog.OrderPayCoupon + "}";
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetCustomField()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["CustomFieldID"]);
                DataTable table = new Chain.BLL.MemCustomField().GetList(" CustomFieldID=" + num).Tables[0];
                s = JsonPlus.ToJson(table.Rows[0], "");
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetCustomRemindList()
        {
            string s = "";
            int userID = int.Parse(this.Session["UID"].ToString());
            DataTable dt = new Chain.BLL.SysCustomRemind().GetList(" CustomReminder like '%" + PubFunction.UserIDTOName(userID) + "%' and DATEDIFF(day,CustomRemindTime,getdate())<=0 ").Tables[0];
            if (dt != null)
            {
                s = JsonPlus.ToJson(dt, "CustomRemindTitle,CustomRemindDetail,CustomRemindTime,CustomRemindCreateTime,ShopName,UserName");
            }
            this.Context.Response.Write(s);
        }

        public void GetDrawMoney()
        {
            string s = "";
            DateTime date = Convert.ToDateTime(this.Request["StartTime"]).Date;
            DateTime endtime = Convert.ToDateTime(this.Request["EndTime"]).Date;
            string str2 = this.Request["ShopID"].ToString();
            string str3 = "";
            string str4 = "";
            string str5 = date.ToString("yyyy-MM-dd") + "到" + endtime.ToString("yyyy-MM-dd") + "会员提现统计";
            string strwhere = PubFunction.GetShopAuthority(int.Parse(this.Session["UserShopID"].ToString()), "DrawMoneyShopID", " and 1=1 ");
            if (!string.IsNullOrEmpty(str2))
            {
                strwhere = strwhere + string.Format(" AND DrawMoneyShopID = '{0}' ", str2);
            }
            try
            {
                DataTable table = new Chain.BLL.MemDrawMoney().GetDataByTime(date, endtime, strwhere).Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str4 = str4 + row["AllMoney"].ToString() + ",";
                }
                str4 = str4.Remove(str4.Length - 1);
                while (date <= endtime)
                {
                    str3 = str3 + date.ToString("yyyy-MM-dd") + ",";
                    date = date.AddDays(1.0);
                }
                str3 = str3.Remove(str3.Length - 1);
                s = string.Concat(new object[] { "{\"Success\":\"", 1, "\",\"Interval\":\"", str3, "\",\"Mydata\":\"", str4, "\",\"title\":\"", str5, "\"}" });
                this.Context.Response.Write(s);
            }
            catch
            {
                this.Context.Response.Write("");
            }
        }

        public void GetExpenseDetail()
        {
            string s = "";
            string str2 = "";
            int num = int.Parse(this.Request["orderID"].ToString());
            string strWhere = " OrderDetail.OrderID=OrderLog.OrderID and OrderDetail.GoodsID=Goods.GoodsID";
            strWhere = strWhere + " and OrderDetail.OrderID=" + num;
            Chain.BLL.OrderDetail detail = new Chain.BLL.OrderDetail();
            DataTable dt = detail.GetListSP(strWhere).Tables[0];
            if (dt != null)
            {
                str2 = JsonPlus.ToJson(dt, "");
                s = "{\"MemInfoExpenseDeatil\":" + str2 + "}";
            }
            this.Context.Response.Write(s);
        }

        public void GetGiftClassModel()
        {
            string s = "0";
            try
            {
                int classID = int.Parse(this.Request["ClassID"]);
                DataTable item = this.bllGiftClass.GetItem(classID);
                if (item.Rows.Count != 1)
                {
                    s = "-1";
                }
                else
                {
                    string str2 = JsonPlus.ToJson(item.Rows[0], "");
                    int num2 = int.Parse(item.Rows[0]["GiftParentID"].ToString());
                    string str3 = "{}";
                    if (num2 != 0)
                    {
                        DataTable table2 = this.bllGiftClass.GetItem(num2);
                        if (table2.Rows.Count != 1)
                        {
                            s = "-2";
                        }
                        else
                        {
                            str3 = JsonPlus.ToJson(table2.Rows[0], "");
                        }
                    }
                    s = "{\"ClassModel\":" + str2 + ",\"ParentModel\":" + str3 + "}";
                }
            }
            catch
            {
                s = "-3";
            }
            this.Context.Response.Write(s);
        }

        public void GetGiftExchangeChart()
        {
            string s = "";
            DateTime date = Convert.ToDateTime(this.Request["StartTime"]).Date;
            DateTime endtime = Convert.ToDateTime(this.Request["EndTime"]).Date;
            string str2 = this.Request["ShopID"].ToString();
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = date.ToString("yyyy-MM-dd") + "到" + endtime.ToString("yyyy-MM-dd") + "积分兑换统计";
            string strwhere = PubFunction.GetShopAuthority(int.Parse(this.Session["UserShopID"].ToString()), "UserShopID", " and 1=1 ");
            if (!string.IsNullOrEmpty(str2))
            {
                strwhere = strwhere + string.Format(" AND UserShopID = '{0}' ", str2);
            }
            try
            {
                DataTable table = new Chain.BLL.GiftExchange().GetGiftExchangeByTime(date, endtime, strwhere).Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str4 = str4 + row["AllPoint"].ToString() + ",";
                    str5 = str5 + row["MainPoint"].ToString() + ",";
                    str6 = str6 + row["SelfPoint"].ToString() + ",";
                }
                str4 = str4.Remove(str4.Length - 1);
                str5 = str5.Remove(str5.Length - 1);
                str6 = str6.Remove(str6.Length - 1);
                while (date <= endtime)
                {
                    str3 = str3 + date.ToString("yyyy-MM-dd") + ",";
                    date = date.AddDays(1.0);
                }
                str3 = str3.Remove(str3.Length - 1);
                s = string.Concat(new object[] { "{\"Success\":\"", 1, "\",\"Interval\":\"", str3, "\",\"AllPoint\":\"", str4, "\",\"MainPoint\":\"", str5, "\",\"SelfPoint\":\"", str6, "\",\"title\":\"", str7, "\"}" });
                this.Context.Response.Write(s);
            }
            catch
            {
                this.Context.Response.Write("");
            }
        }

        public void GetGiftList()
        {
            string s = "";
            try
            {
                string str2 = (this.Request["key"] != null) ? this.Request["key"].ToString() : "";
                int num = int.Parse(this.Session["UserShopID"].ToString());
                StringBuilder builder = new StringBuilder();
                builder.Append("GiftStockNumber > 0 ");
                if (ConfigHelper.GetValue("GiftShare") == "false")
                {
                    builder.Append("and GiftShopID=" + num.ToString());
                }
                if ((str2 != null) && (str2 != ""))
                {
                    builder.AppendFormat(" and ((GiftCode like '{0}') or (GiftName like '{0}'))", str2);
                }
                DataTable dt = new Chain.BLL.PointGift().GetList(builder.ToString()).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "GiftID,GiftName,GiftCode,GiftClassID,GiftExchangePoint,GiftStockNumber,GiftExchangeNumber");
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetGiftModel()
        {
            string s = "";
            try
            {
                int giftID = int.Parse(this.Request["GiftID"]);
                DataTable table = new Chain.BLL.PointGift().GetItemModel(giftID).Tables[0];
                s = JsonPlus.ToJson(table.Rows[0], "");
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodClassTree(int intParentID, int intLevel, DataTable dt, DataTable dtSource)
        {
            DataRow[] rowArray = dtSource.Select(" ParentID=" + intParentID);
            for (int i = 0; i < rowArray.Length; i++)
            {
                rowArray[i]["ClassName"] = new string('-', intLevel * 3).ToString() + rowArray[i]["ClassName"].ToString();
                dt.Rows.Add(dt.NewRow());
                dt.Rows[dt.Rows.Count - 1]["ClassID"] = rowArray[i]["ClassID"];
                dt.Rows[dt.Rows.Count - 1]["ClassName"] = rowArray[i]["ClassName"];
                this.GetGoodClassTree(Convert.ToInt32(rowArray[i]["ClassID"]), intLevel + 1, dt, dtSource);
            }
        }

        public void GetGoodsByCodeDelServe()
        {
            string s = "";
            try
            {
                string strGoodsCode = this.Request["barCode"].ToString();
                int intShopID = int.Parse(this.Session["UserShopID"].ToString());
                DataTable dt = this.bllNumber.GetGoodsNumberDelServe(strGoodsCode, intShopID).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    s = JsonPlus.ToJson(dt, "");
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsClassDiscount()
        {
            string s = "";
            try
            {
                int classDiscountID = (this.Request["ClassDiscountID"] == null) ? 0 : int.Parse(this.Request["ClassDiscountID"].Trim());
                DataTable dt = new Chain.BLL.GoodsClassDiscount().GetListByClassDiscountID(classDiscountID).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "LevelPoint,ClassDiscountPercent,ClassPointPercent,ClassName,ClassDiscountID");
                }
            }
            catch
            {
            }
            this.Response.Write(s);
        }

        public void GetGoodsClassList()
        {
            string s = "0";
            try
            {
                int num = int.Parse(this.Request["ShopID"]);
                DataTable dtSource = this.bllGdClass.GetList(string.Format("ShopID=" + num, new object[0])).Tables[0];
                DataTable dt = dtSource.Clone();
                this.GetGoodClassTree(0, 0, dt, dtSource);
                if (dt.Rows.Count == 0)
                {
                    s = "-1";
                }
                else
                {
                    s = JsonPlus.ToJson(dt, "");
                }
            }
            catch
            {
                s = "-3";
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsClassModel()
        {
            string s = "0";
            try
            {
                int classID = int.Parse(this.Request["ClassID"]);
                DataTable item = this.bllGdClass.GetItem(classID);
                if (item.Rows.Count != 1)
                {
                    s = "-1";
                }
                else
                {
                    string str2 = JsonPlus.ToJson(item.Rows[0], "");
                    int num2 = int.Parse(item.Rows[0]["ParentID"].ToString());
                    string str3 = "{}";
                    if (num2 != 0)
                    {
                        DataTable table2 = this.bllGdClass.GetItem(num2);
                        if (table2.Rows.Count != 1)
                        {
                            s = "-2";
                        }
                        else
                        {
                            str3 = JsonPlus.ToJson(table2.Rows[0], "");
                        }
                    }
                    s = "{\"ClassModel\":" + str2 + ",\"ParentModel\":" + str3 + "}";
                }
            }
            catch
            {
                s = "-3";
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsExpenseChart()
        {
            string s = "";
            DateTime date = Convert.ToDateTime(this.Request["StartTime"]).Date;
            DateTime endtime = Convert.ToDateTime(this.Request["EndTime"]).Date;
            string str2 = this.Request["GoodsCode"].ToString();
            string str3 = this.Request["ShopID"].ToString();
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = date.ToString("yyyy-MM-dd") + "到" + endtime.ToString("yyyy-MM-dd") + "商品消费统计";
            string strwhere = PubFunction.GetShopAuthority(int.Parse(this.Session["UserShopID"].ToString()), "OrderShopID", " and 1=1 ");
            if (!string.IsNullOrEmpty(str3))
            {
                strwhere = strwhere + string.Format(" AND OrderShopID = '{0}' ", str3);
            }
            try
            {
                Chain.BLL.Goods goods = new Chain.BLL.Goods();
                if (!(string.IsNullOrEmpty(str2) || goods.Exists(str2)))
                {
                    s = "0";
                }
                else
                {
                    DataTable table = new Chain.BLL.OrderLog().GetGoodsExpense(date, endtime, str2, strwhere).Tables[0];
                    foreach (DataRow row in table.Rows)
                    {
                        str5 = str5 + Convert.ToDecimal(row["AllMoney"]).ToString("F2") + ",";
                        str6 = str6 + Convert.ToDecimal(row["GeneralMoney"]).ToString("F2") + ",";
                        str7 = str7 + Convert.ToDecimal(row["ServeMoney"]).ToString("F2") + ",";
                    }
                    str5 = str5.Remove(str5.Length - 1);
                    str6 = str6.Remove(str6.Length - 1);
                    str7 = str7.Remove(str7.Length - 1);
                    while (date <= endtime)
                    {
                        str4 = str4 + date.ToString("yyyy-MM-dd") + ",";
                        date = date.AddDays(1.0);
                    }
                    str4 = str4.Remove(str4.Length - 1);
                    s = string.Concat(new object[] { "{\"Success\":\"", 1, "\",\"Interval\":\"", str4, "\",\"Mydata\":\"", str5, "\",\"GeneralMoney\":\"", str6, "\",\"ServeMoney\":\"", str7, "\",\"title\":\"", str8, "\"}" });
                }
                this.Context.Response.Write(s);
            }
            catch
            {
                this.Context.Response.Write("");
            }
        }

        public void GetGoodsExpenseDetail()
        {
            string s = "";
            try
            {
                int num = (this.Request["goodsID"] != "") ? int.Parse(this.Request["goodsID"].ToString()) : 0;
                int num2 = int.Parse(this.Session["UserShopID"].ToString());
                string str2 = " OrderDetail.OrderID = OrderLog.OrderID and OrderLog.OrderMemID=Mem.MemID  ";
                int pageSiza = !string.IsNullOrEmpty(this.Request["pageSize"]) ? Convert.ToInt32(this.Request["pageSize"].ToString()) : 0;
                int pageIndex = !string.IsNullOrEmpty(this.Request["currentPage"]) ? Convert.ToInt32(this.Request["currentPage"].ToString()) : 0;
                if (num != 0)
                {
                    int num5;
                    str2 = str2 + " and OrderDetail.GoodsID=" + num;
                    DataTable dt = this.bllDetail.GetExpenseDetail(pageSiza, pageIndex, out num5, new string[] { str2.ToString() }).Tables[0];
                    if (dt != null)
                    {
                        string str3 = JsonPlus.ToJson(dt, "");
                        s = string.Concat(new object[] { "{\"RecordCount\":", num5, ",\"List\":", str3, "}" });
                    }
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsInfo()
        {
            string s = "";
            try
            {
                int intGoodsID = int.Parse(this.Request["goodsID"]);
                int intShopID = int.Parse(this.Session["UserShopID"].ToString());
                int memLevelID = (this.Request["MemLevelID"] == null) ? 0 : int.Parse(this.Request["MemLevelID"]);
                DataTable dt = null;
                if (memLevelID == -1)
                {
                    dt = this.bllNumber.GetGoodsNumber(intGoodsID, intShopID).Tables[0];
                }
                else
                {
                    dt = this.bllNumber.GetGoodsNumberByMembey(intGoodsID, intShopID, memLevelID).Tables[0];
                }
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsList()
        {
            string s = "";
            try
            {
                int num6;
                int pageSize = (this.Request["size"].ToString() != "") ? int.Parse(this.Request["size"].ToString()) : 0;
                int pageIndex = (this.Request["index"].ToString() != "") ? int.Parse(this.Request["index"].ToString()) : 0;
                string str2 = this.Request["key"].ToString();
                int num3 = (this.Request["shopID"] != "") ? int.Parse(this.Request["shopID"].ToString()) : -1;
                bool flag = bool.Parse(this.Request["bolGoodsExpense"].ToString());
                bool flag2 = bool.Parse(this.Request["IsCheckStock"].ToString());
                int id = (this.Request["ClassID"] != "") ? int.Parse(this.Request["ClassID"].ToString()) : 0;
                int num5 = (this.Request["MemLevelID"] == null) ? -1 : int.Parse(this.Request["MemLevelID"]);
                StringBuilder builder = new StringBuilder();
                builder.Append(" 1=1 ");
                if (str2 != "")
                {
                    builder.AppendFormat(" and (Name like '%{0}%' or NameCode like '%{0}%' or GoodsCode='{0}')", str2);
                }
                if (num3 != -1)
                {
                    builder.AppendFormat(" and ShopID={0}", num3);
                }
                if (!flag)
                {
                    builder.Append(" and GoodsType=0");
                }
                if (id != 0)
                {
                    builder.AppendFormat(" and GoodsClassID in ({0}) ", PubFunction.GetClassID(id));
                }
                if (flag2)
                {
                    builder.Append("and ((Number>0 and GoodsType=0) or GoodsType=1) ");
                }
                DataTable dt = null;
                if (num5 == -1)
                {
                    dt = this.bllGoods.GetGoodsListByNoMember(pageSize, pageIndex, out num6, new string[] { builder.ToString() }).Tables[0];
                }
                else
                {
                    builder.AppendFormat(" and MemLevelId={0} ", num5);
                    dt = this.bllGoods.GetGoodsListByMember(pageSize, pageIndex, out num6, new string[] { builder.ToString() }).Tables[0];
                }
                if (dt != null)
                {
                    string str3;
                    if (num5 == -1)
                    {
                        str3 = JsonPlus.ToJson(dt, "GoodsID,Name,Price,GoodsBidPrice,Number,GoodsCode,Point,MinPercent,SalePercet,GoodsType,NameCode,ShopName");
                        s = string.Concat(new object[] { "{\"RecordCount\":", num6, ",\"List\":", str3, "}" });
                    }
                    else
                    {
                        str3 = JsonPlus.ToJson(dt, "GoodsID,Name,Price,GoodsBidPrice,Number,GoodsCode,Point,MinPercent,SalePercet,GoodsType,NameCode,ShopName,ClassDiscountPercent,ClassPointPercent");
                        s = string.Concat(new object[] { "{\"RecordCount\":", num6, ",\"List\":", str3, "}" });
                    }
                }
            }
            catch (Exception)
            {
                s = "-1";
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsModelByBarCode()
        {
            string s = "";
            try
            {
                string strGoodsCode = this.Request["barCode"].ToString();
                int intShopID = int.Parse(this.Session["UserShopID"].ToString());
                DataTable dt = this.bllNumber.GetGoodsNumber(strGoodsCode, intShopID).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    s = JsonPlus.ToJson(dt, "");
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsNumber()
        {
            string s = "";
            try
            {
                int intGoodsID = int.Parse(this.Request["goodsID"].ToString());
                int intShopID = int.Parse(this.Request["shopID"].ToString());
                DataTable dt = this.bllNumber.GetGoodsNumber(intGoodsID, intShopID).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "");
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsProductList()
        {
            int num3;
            string s = "";
            int pageSiza = int.Parse(this.Request["size"].ToString());
            int pageIndex = int.Parse(this.Request["index"].ToString());
            string str2 = (this.Request["key"] != "") ? this.Request["key"].ToString() : "";
            StringBuilder builder = new StringBuilder();
            builder.Append(" 1=1 ");
            if (str2 != "")
            {
                builder.AppendFormat(" and (Name like '%{0}%' or NameCode like '%{0}%' or GoodsCode='{0}')", str2);
            }
            DataTable dt = this.bllGoods.GetList(pageSiza, pageIndex, out num3, new string[] { builder.ToString() }).Tables[0];
            if (dt != null)
            {
                string str3 = JsonPlus.ToJson(dt, "GoodsID,Name,Price,MinPercent,Point,CommissionNumber,CommissionType,GoodsType");
                s = string.Concat(new object[] { "{\"RecordCount\":", num3, ",\"List\":", str3, "}" });
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsStockOut()
        {
            string s = "";
            try
            {
                int num = Convert.ToInt32(this.Request["myday"]);
                DataTable dt = new Chain.BLL.Goods().GetStockRemind(string.Format("Number < = '{0}' and GoodsType = '0' and ShopID = '{1}'", num, int.Parse(this.Session["UserShopID"].ToString()))).Tables[0];
                s = JsonPlus.ToJson(dt, "");
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetGoodsStockTotal()
        {
            string s = "";
            try
            {
                int num4;
                int pageSiza = (this.Request["size"].ToString() != "") ? int.Parse(this.Request["size"].ToString()) : 0;
                int pageIndex = (this.Request["index"].ToString() != "") ? int.Parse(this.Request["index"].ToString()) : 0;
                string str2 = this.Request["key"].ToString();
                bool flag = bool.Parse(this.Request["bolGoodsExpense"].ToString());
                int id = (this.Request["ClassID"] != "") ? int.Parse(this.Request["ClassID"].ToString()) : 0;
                string str3 = this.Request["ShopID"].ToString();
                StringBuilder builder = new StringBuilder();
                builder.Append(" 1=1 ");
                if (str2 != "")
                {
                    builder.AppendFormat(" and (Name like '%{0}%' or NameCode like '%{0}%' or GoodsCode='{0}')", str2);
                }
                if (!flag)
                {
                    builder.Append(" and GoodsType=0");
                }
                if (id != 0)
                {
                    builder.AppendFormat(" and GoodsClassID in ({0}) ", PubFunction.GetClassID(id));
                }
                if (str3 != "")
                {
                    builder.AppendFormat(" and ShopID={0}", int.Parse(str3));
                }
                else
                {
                    builder.Append(" and ShopID>0");
                }
                DataTable dt = this.bllGoods.GetGoodsList(pageSiza, pageIndex, out num4, new string[] { builder.ToString() }).Tables[0];
                if (dt != null)
                {
                    string str4 = JsonPlus.ToJson(dt, "GoodsID,Name,Price,GoodsBidPrice,Number,GoodsCode,Point,MinPercent,GoodsType,NameCode,ShopName");
                    s = string.Concat(new object[] { "{\"RecordCount\":", num4, ",\"List\":", str4, "}" });
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetIsParentID()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["parentID"].ToString());
                DataTable table = new Chain.BLL.GoodsClass().GetList(" ParentID=" + num).Tables[0];
                if (table.Rows.Count > 0)
                {
                    s = "{\"IsParent\":\"" + 1 + "\"}";
                }
                else
                {
                    s = "{\"IsParent\":\"" + 0 + "\"}";
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetMem()
        {
            string s = "";
            try
            {
                string str2 = (this.Request["memCard"].ToString() != "") ? this.Request["memCard"].ToString() : "";
                int num = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
                StringBuilder builder = new StringBuilder();
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                string str3 = "";
                DataTable table = new Chain.BLL.MemCustomField().GetList(" CustomType=1").Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str3 = str3 + row["CustomField"].ToString() + ",";
                }
                builder.Append(" 1=1 ");
                if (str2 != "")
                {
                    builder.AppendFormat(" and (MemCard='{0}' or MemName ='{0}' or  MemMobile='{0}' or  MemCardNumber='{0}')", str2);
                }
                builder.Append(" and Mem.MemShopID = SysShop.ShopID and Mem.MemLevelID = MemLevel.LevelID and Mem.MemUserID=SysUser.UserID and Mem.MemLevelID = SysShopMemLevel.MemLevelID");
                builder.AppendFormat(" and SysShopMemLevel.ShopID = '{0}'", num);
                builder.Append(" and Mem.MemID>0");
                builder.AppendFormat(" and (Mem.MemExpenseShop IS NULL or Mem.MemExpenseShop NOT LIKE '%,{0},%')", num);
                int resCount = 0;
                DataTable dt = mem.GetListSP(20, 1, out resCount, new string[] { builder.ToString() }).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "MemID,MemCard,MemPassword,MemName,MemSex,MemIdentityCard,MemMobile,MemPhoto,MemBirthday,MemIsPast,MemPastTime,MemPoint,MemMoney,MemConsumeMoney,MemConsumeLastTime,MemConsumeCount,MemEmail,MemAddress,MemState,MemRecommendID,MemCreateTime,MemRemark,MemLevelID,MemShopID,MemUserID,ShopName," + str3 + "LevelID,LevelName,LevelPoint,LevelDiscountPercent,LevelPointPercent,UserName,MemTelePhone,MemQRCode,MemProvinceName,MemCityName,MemCountyName,MemVillageName,MemCardNumber");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetMemBirthday()
        {
            string s = "";
            int day = (this.Request["day"] != null) ? int.Parse(this.Request["day"]) : 0;
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            DataTable dt = new Chain.BLL.Mem().GetBirthdayList(day, shopID).Tables[0];
            if (dt != null)
            {
                s = JsonPlus.ToJson(dt, "MemID,MemCard,MemName,MemMobile,MemBirthday,LevelName,MemPoint,ShopName");
            }
            this.Context.Response.Write(s);
        }

        public void GetMemByMobile()
        {
            int num = 0;
            string str = this.Request["mobile"];
            string str2 = "";
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(" MemMobile='{0}' or MemMobile='{1}'", str, str.TrimStart(new char[] { '0' }));
            DataTable table = new Chain.BLL.Mem().GetList(builder.ToString()).Tables[0];
            if (table.Rows.Count > 0)
            {
                num = 1;
                str2 = table.Rows[0]["MemMobile"].ToString();
            }
            else
            {
                num = -1;
                str2 = str;
            }
            string s = string.Concat(new object[] { "{\"flag\":\"", num, "\",\"RealModile\":\"", str2, "\"}" });
            this.Context.Response.Write(s);
        }

        public void GetMemChart()
        {
            string s = "";
            DateTime date = Convert.ToDateTime(this.Request["StartTime"]).Date;
            DateTime endtime = Convert.ToDateTime(this.Request["EndTime"]).Date;
            string str2 = this.Request["ShopID"].ToString();
            string str3 = "";
            string str4 = "";
            string str5 = date.ToString("yyyy-MM-dd") + "到" + endtime.ToString("yyyy-MM-dd") + "新增会员数统计";
            string strwhere = PubFunction.GetShopAuthority(int.Parse(this.Session["UserShopID"].ToString()), "MemShopID", " and 1=1 ");
            if (!string.IsNullOrEmpty(str2))
            {
                strwhere = strwhere + string.Format(" AND MemShopID = '{0}' ", str2);
            }
            try
            {
                DataTable table = new Chain.BLL.Mem().GetDataByTime(date, endtime, strwhere).Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str4 = str4 + row["Number"].ToString() + ",";
                }
                str4 = str4.Remove(str4.Length - 1);
                while (date <= endtime)
                {
                    str3 = str3 + date.ToString("yyyy-MM-dd") + ",";
                    date = date.AddDays(1.0);
                }
                str3 = str3.Remove(str3.Length - 1);
                s = string.Concat(new object[] { "{\"Success\":\"", 1, "\",\"Interval\":\"", str3, "\",\"Mydata\":\"", str4, "\",\"title\":\"", str5, "\"}" });
                this.Context.Response.Write(s);
            }
            catch
            {
                this.Context.Response.Write("");
            }
        }

        public void GetMemExpenseDetail()
        {
            string s = "";
            try
            {
                int num3;
                int pageSize = !string.IsNullOrEmpty(this.Request["pageSize"]) ? Convert.ToInt32(this.Request["pageSize"].ToString()) : 0;
                int pageIndex = !string.IsNullOrEmpty(this.Request["currentPage"]) ? Convert.ToInt32(this.Request["currentPage"].ToString()) : 0;
                StringBuilder builder = new StringBuilder();
                builder.Append(" MemID=" + this.Request["MemID"].ToString());
                builder.Append(" and OrderType <> 3");
                if (this.Request["StartTime"].ToString() != "")
                {
                    builder.AppendFormat(" and OrderCreateTime>='{0}'", Convert.ToDateTime(this.Request["StartTime"]));
                }
                if (this.Request["EndTime"].ToString() != "")
                {
                    builder.AppendFormat(" and OrderCreateTime<='{0}'", Convert.ToDateTime(this.Request["EndTime"]));
                }
                DataTable dt = new Chain.BLL.Mem().GetListSPMemExpense(pageSize, pageIndex, out num3, new string[] { builder.ToString() }).Tables[0];
                if (dt != null)
                {
                    string str2 = JsonPlus.ToJson(dt, "");
                    s = string.Concat(new object[] { "{\"RecordCount\":", num3, ",\"List\":", str2, "}" });
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetMemLevel()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["LevelID"].ToString());
                Chain.BLL.MemLevel level = new Chain.BLL.MemLevel();
                DataTable dt = level.GetList("LevelID=" + num).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "LevelID,LevelName,LevelPoint,LevelDiscountPercent,LevelPointPercent,LevellLock");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetMemLevelList()
        {
            string s = "";
            try
            {
                Chain.BLL.MemLevel level = new Chain.BLL.MemLevel();
                DataTable dt = level.GetList("").Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "LevelID,LevelName,LevelPoint,LevelDiscountPercent");
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetMemList()
        {
            string s = "";
            try
            {
                string str2 = (this.Request["memCard"].ToString() != "") ? this.Request["memCard"].ToString() : "";
                int num = (this.Request["memLevelID"].ToString() != "") ? int.Parse(this.Request["memLevelID"].ToString()) : 0;
                int num2 = (this.Request["memShopID"].ToString() != "") ? int.Parse(this.Request["memShopID"].ToString()) : 0;
                int intShopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
                StringBuilder builder = new StringBuilder();
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                builder.Append("1=1");
                if (str2 != "")
                {
                    builder.AppendFormat(" and (MemCard ='{0}' or MemName like '%{0}%' or MemMobile='{0}')", str2);
                }
                if (num != 0)
                {
                    builder.AppendFormat(" and MemLevelID={0}", num);
                }
                if (num2 != 0)
                {
                    builder.AppendFormat(" and MemShopID={0}", num2);
                }
                builder.Append(" and Mem.MemShopID = SysShop.ShopID and Mem.MemLevelID = MemLevel.LevelID and Mem.MemUserID=SysUser.UserID and Mem.MemShopID = SysShopMemLevel.ShopID and Mem.MemLevelID = SysShopMemLevel.MemLevelID");
                int resCount = 1;
                DataTable dt = mem.GetListSP(0x186a0, 1, out resCount, new string[] { PubFunction.GetShopAuthority(intShopID, "MemShopID", builder.ToString()) }).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "MemID,MemCard,MemName,MemMobile,MemLevelID,MemShopID,ShopName,LevelID,LevelName,LevelPoint,LevelDiscountPercent,LevelPointPercent");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetMemPointReset()
        {
            string s = "";
            int num = (this.Request["time"] != null) ? int.Parse(this.Request["time"]) : 0;
            StringBuilder builder = new StringBuilder();
            builder.Append("MemID<>''");
            if (num >= 0)
            {
                builder.AppendFormat(" and MemPoint>0 and  DATEDIFF(day,isnull(MemConsumeLastTime,MemCreateTime),getdate()) >= '{0}' and MemShopID = '{1}' ", num, this.Session["UserShopID"].ToString());
            }
            DataTable dt = new Chain.BLL.Mem().GetMemPointReset(builder.ToString()).Tables[0];
            if (dt != null)
            {
                s = JsonPlus.ToJson(dt, "MemID,MemCard,MemName,LevelName,MemPoint,MemMobile,MemPastTime,MemConsumeLastTime,MemConsumeCount,ShopName");
            }
            this.Context.Response.Write(s);
        }

        public void GetMemRecommend()
        {
            string s = "";
            try
            {
                int memID = (this.Request["MemID"].ToString() != "") ? int.Parse(this.Request["MemID"].ToString()) : 0;
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem mem2 = new Chain.Model.Mem();
                s = mem.GetModel(memID).MemCard;
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetMenuFirstList()
        {
            int num = Convert.ToInt32(this.Request["MenuID"]);
            StringBuilder builder = new StringBuilder();
            builder.Append("");
            this.Response.Write(builder.ToString());
        }

        public void GetMenuList()
        {
            string s = "";
            int num = Convert.ToInt32(this.Request["MenuID"]);
            Chain.BLL.WeiXinMenu menu = new Chain.BLL.WeiXinMenu();
            DataTable dt = menu.GetList("MenuID=" + num).Tables[0];
            s = JsonPlus.ToJson(dt, "MenuID,MenuName,MenuType,MenuKey,MenuUrl,parentMenuID");
            this.Response.Write(s);
        }

        public void GetMessageListPage()
        {
            int num2;
            string s = "";
            string str2 = (this.Request["size"] != null) ? this.Request["size"].ToString() : "";
            string str3 = (this.Request["index"] != null) ? this.Request["index"].ToString() : "";
            int num = (this.Request["memID"] != null) ? int.Parse(this.Request["memID"].ToString()) : 0;
            string str4 = " MessageMemID=" + num.ToString() + " and [Message].MessageMemID = Mem.MemID ";
            DataTable dt = this.bllMessage.GetListSP(int.Parse(str2), int.Parse(str3), out num2, new string[] { str4.ToString() }).Tables[0];
            if (dt != null)
            {
                string str5 = JsonPlus.ToJson(dt, "");
                s = string.Concat(new object[] { "{\"RecordCount\":", num2, ",\"List\":", str5, "}" });
            }
            this.Context.Response.Write(s);
        }

        public void GetMicroGoodsInfo()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["goodsID"]);
                int num2 = int.Parse(this.Session["UserShopID"].ToString());
                DataTable dt = new Chain.BLL.MicroWebsiteGoods().GetList(" MicroGoodsID=" + num).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetMMSBalance()
        {
            string strUserID = this.Request["MMSSeries"].ToString();
            string strUserPwd = this.Request["MMSSerialPwd"].ToString();
            string balance = WebTest.SendMessage.GetBalance(strUserID, strUserPwd);
            this.Context.Response.Write(balance);
        }

        public void GetModelByMemCard()
        {
            string s = "1";
            string memCard = this.Context.Request["memCard"];
            try
            {
                s = (new Chain.BLL.Mem().GetModelByMemCard(memCard) == null) ? "0" : "1";
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetNewsRuleByID()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["NewsID"]);
                DataTable dt = new Chain.BLL.WeiXinNews().GetList("NewsID=" + num + " ").Tables[0];
                dt.Rows[0]["NewsLinkContent"] = dt.Rows[0]["NewsLinkContent"].ToString();
                s = JsonPlus.ToJson(dt, "");
            }
            catch
            {
            }
            this.Response.Write(s);
        }

        public void GetNextName()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["pid"].ToString());
                DataTable dt = new Chain.BLL.SysArea().GetList("PID=" + num).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    s = JsonPlus.ToJson(dt, "");
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetNoticeInfo()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["NoticeID"]);
                DataTable dt = new Chain.BLL.SysNotice().GetList(" SysNoticeID=" + num).Tables[0];
                s = JsonPlus.ToJson(dt, "");
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetOrderChart()
        {
            string s = "";
            DateTime date = Convert.ToDateTime(this.Request["StartTime"]).Date;
            DateTime endtime = Convert.ToDateTime(this.Request["EndTime"]).Date;
            string str2 = this.Request["ShopID"].ToString();
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = date.ToString("yyyy-MM-dd") + "到" + endtime.ToString("yyyy-MM-dd") + "会员消费统计";
            string strwhere = PubFunction.GetShopAuthority(int.Parse(this.Session["UserShopID"].ToString()), "OrderShopID", " and 1=1 ");
            if (!string.IsNullOrEmpty(str2))
            {
                strwhere = strwhere + string.Format(" AND OrderShopID = '{0}' ", str2);
            }
            try
            {
                DataTable table = new Chain.BLL.OrderLog().GetOrderByTime(date, endtime, strwhere).Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str4 = str4 + row["TotalMoney"].ToString() + ",";
                    str5 = str5 + row["TotalDiscount"].ToString() + ",";
                    str6 = str6 + row["Coupon"].ToString() + ",";
                    str7 = str7 + row["Point"].ToString() + ",";
                }
                str4 = str4.Remove(str4.Length - 1);
                str5 = str5.Remove(str5.Length - 1);
                str6 = str6.Remove(str6.Length - 1);
                str7 = str7.Remove(str7.Length - 1);
                while (date <= endtime)
                {
                    str3 = str3 + date.ToString("yyyy-MM-dd") + ",";
                    date = date.AddDays(1.0);
                }
                str3 = str3.Remove(str3.Length - 1);
                s = string.Concat(new object[] { "{\"Success\":\"", 1, "\",\"Interval\":\"", str3, "\",\"TotalMoney\":\"", str4, "\",\"TotalDiscount\":\"", str5, "\",\"Coupon\":\"", str6, "\",\"Point\":\"", str7, "\",\"title\":\"", str8, "\"}" });
                this.Context.Response.Write(s);
            }
            catch
            {
                this.Context.Response.Write("");
            }
        }

        public void GetOrderDetail()
        {
            string s = "";
            int intOrderID = int.Parse(this.Request["orderID"].ToString());
            DataTable dt = this.bllDetail.GetDetail(intOrderID).Tables[0];
            if (dt != null)
            {
                s = JsonPlus.ToJson(dt, "");
            }
            this.Context.Response.Write(s);
        }

        public void GetPointChart()
        {
            string s = "";
            DateTime date = Convert.ToDateTime(this.Request["StartTime"]).Date;
            DateTime endtime = Convert.ToDateTime(this.Request["EndTime"]).Date;
            string str2 = this.Request["ShopID"].ToString();
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = date.ToString("yyyy-MM-dd") + "到" + endtime.ToString("yyyy-MM-dd") + "积分变动统计";
            string strwhere = PubFunction.GetShopAuthority(int.Parse(this.Session["UserShopID"].ToString()), "PointShopID", " and 1=1 ");
            if (!string.IsNullOrEmpty(str2))
            {
                strwhere = strwhere + string.Format(" AND PointShopID = '{0}' ", str2);
            }
            try
            {
                DataTable table = new Chain.BLL.PointLog().GetPointByTime(date, endtime, strwhere).Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str4 = str4 + row["NewPoint"].ToString() + ",";
                    str5 = str5 + row["CutPoint"].ToString() + ",";
                }
                str4 = str4.Remove(str4.Length - 1);
                str5 = str5.Remove(str5.Length - 1);
                while (date <= endtime)
                {
                    str3 = str3 + date.ToString("yyyy-MM-dd") + ",";
                    date = date.AddDays(1.0);
                }
                str3 = str3.Remove(str3.Length - 1);
                s = string.Concat(new object[] { "{\"Success\":\"", 1, "\",\"Interval\":\"", str3, "\",\"NewPoint\":\"", str4, "\",\"CutPoint\":\"", str5, "\",\"title\":\"", str6, "\"}" });
                this.Context.Response.Write(s);
            }
            catch
            {
                this.Context.Response.Write("");
            }
        }

        public void GetPointRate()
        {
            string s = "";
            DataRow dataRow = new Chain.BLL.PointRate().GetDataRow();
            if (dataRow != null)
            {
                s = JsonPlus.ToJson(dataRow, "");
            }
            else
            {
                s = "";
            }
            this.Context.Response.Write(s);
        }

        public void GetQueryMem()
        {
            string s = "";
            try
            {
                string str2 = (this.Request["memCard"].ToString() != "") ? this.Request["memCard"].ToString() : "";
                int num = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
                StringBuilder builder = new StringBuilder();
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                string str3 = "";
                DataTable table = new Chain.BLL.MemCustomField().GetList(" CustomType=1").Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str3 = str3 + row["CustomField"].ToString() + ",";
                }
                builder.Append(" 1=1 ");
                if (str2 != "")
                {
                    builder.AppendFormat(" and (MemCard like '%{0}%' or MemName like '%{0}%' or  MemMobile like '%{0}%')", str2);
                }
                builder.Append(" and Mem.MemShopID = SysShop.ShopID and Mem.MemLevelID = MemLevel.LevelID and Mem.MemUserID=SysUser.UserID and Mem.MemLevelID = SysShopMemLevel.MemLevelID");
                builder.AppendFormat(" and SysShopMemLevel.ShopID = '{0}'", num);
                builder.Append(" and Mem.MemID>0");
                builder.AppendFormat(" and (Mem.MemExpenseShop IS NULL or Mem.MemExpenseShop NOT LIKE '%,{0},%')", num);
                int resCount = 0;
                DataTable dt = mem.GetListSP(20, 1, out resCount, new string[] { PubFunction.GetMemListShopAuthority(num, "MemShopID", builder.ToString()) }).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "MemID,MemCard,MemPassword,MemName,MemSex,MemIdentityCard,MemMobile,MemPhoto,MemBirthday,MemIsPast,MemPastTime,MemPoint,MemMoney,MemConsumeMoney,MemConsumeLastTime,MemConsumeCount,MemEmail,MemAddress,MemState,MemRecommendID,MemCreateTime,MemRemark,MemLevelID,MemShopID,MemUserID,ShopName," + str3 + "LevelID,LevelName,LevelPoint,LevelDiscountPercent,LevelPointPercent,UserName,MemTelePhone,MemQRCode");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetRecharge()
        {
            string s = "";
            DateTime date = Convert.ToDateTime(this.Request["StartTime"]).Date;
            DateTime endtime = Convert.ToDateTime(this.Request["EndTime"]).Date;
            string str2 = this.Request["ShopID"].ToString();
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = date.ToString("yyyy-MM-dd") + "到" + endtime.ToString("yyyy-MM-dd") + "会员充值统计";
            string strwhere = PubFunction.GetShopAuthority(int.Parse(this.Session["UserShopID"].ToString()), "RechargeShopID", " and 1=1 ");
            if (!string.IsNullOrEmpty(str2))
            {
                strwhere = strwhere + string.Format(" AND RechargeShopID = '{0}' ", str2);
            }
            try
            {
                DataTable table = new Chain.BLL.MemRecharge().GetRechargeByTime(date, endtime, strwhere).Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str4 = str4 + row["AllMoney"].ToString() + ",";
                    str5 = str5 + row["Cshcz"].ToString() + ",";
                    str6 = str6 + row["PayBink"].ToString() + ",";
                    str7 = str7 + row["PayCash"].ToString() + ",";
                }
                str4 = str4.Remove(str4.Length - 1);
                str5 = str5.Remove(str5.Length - 1);
                str6 = str6.Remove(str6.Length - 1);
                str7 = str7.Remove(str7.Length - 1);
                while (date <= endtime)
                {
                    str3 = str3 + date.ToString("yyyy-MM-dd") + ",";
                    date = date.AddDays(1.0);
                }
                str3 = str3.Remove(str3.Length - 1);
                s = string.Concat(new object[] { "{\"Success\":\"", 1, "\",\"Interval\":\"", str3, "\",\"Mydata\":\"", str4, "\",\"MyCshcz\":\"", str5, "\",\"MyPayBink\":\"", str6, "\",\"MyPayCash\":\"", str7, "\",\"title\":\"", str8, "\"}" });
                this.Context.Response.Write(s);
            }
            catch
            {
                this.Context.Response.Write("");
            }
        }

        public void GetRechargeCountDetail()
        {
            string s = "";
            try
            {
                string str2 = "";
                int num = int.Parse(this.Request["CountID"].ToString());
                string strWhere = " MemCountDetail.CountDetailCountID=MemCount.CountID and MemCountDetail.CountDetailGoodsID=Goods.GoodsID";
                strWhere = strWhere + " and MemCountDetail.CountDetailCountID=" + num;
                DataTable dt = new Chain.BLL.MemCountDetail().GetList(strWhere).Tables[0];
                if (dt != null)
                {
                    str2 = JsonPlus.ToJson(dt, "");
                    s = "{\"MemInfoRechargeCountDeatil\":" + str2 + "}";
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetRptTotal()
        {
            string s = "0";
            try
            {
                string str2 = "";
                DateTime now = DateTime.Now;
                DateTime result = DateTime.Now;
                string str3 = (this.Request["checkRadion"] != null) ? this.Request["checkRadion"].ToString() : "";
                string str4 = (this.Request["txttimeStart"] != null) ? this.Request["txttimeStart"].ToString() : "";
                string str5 = (this.Request["txttimeEnd"] != null) ? this.Request["txttimeEnd"].ToString() : "";
                string str6 = (this.Request["ShopID"] != null) ? this.Request["ShopID"].ToString() : "";
                string str7 = (this.Request["UserID"] != null) ? this.Request["UserID"].ToString() : "";
                int intShopID = int.Parse(this.Session["UserShopID"].ToString());
                int num2 = int.Parse(this.Session["UID"].ToString());
                if ((str7 == "") || (str7 == null))
                {
                    str2 = "所有操作员";
                }
                else
                {
                    str2 = PubFunction.UserIDTOName(int.Parse(str7));
                }
                switch (str3)
                {
                    case "1":
                        now = DateTime.Today;
                        result = DateTime.Today.AddHours(23.0).AddMinutes(59.0).AddSeconds(59.0);
                        break;

                    case "2":
                        now = DateTime.Today.AddDays(-1.0);
                        result = DateTime.Today.AddDays(-1.0).AddHours(23.0).AddMinutes(59.0).AddSeconds(59.0);
                        break;

                    case "3":
                        now = DateTime.Today.AddDays(-7.0);
                        result = DateTime.Today.AddHours(23.0).AddMinutes(59.0).AddSeconds(59.0);
                        break;

                    case "4":
                        now = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                        result = DateTime.Today.AddHours(23.0).AddMinutes(59.0).AddSeconds(59.0);
                        break;

                    case "5":
                        now = DateTime.Today.AddDays(-30.0);
                        result = DateTime.Today.AddHours(23.0).AddMinutes(59.0).AddSeconds(59.0);
                        break;

                    case "6":
                        {
                            string str8 = str4;
                            if (!DateTime.TryParse(str8, out now))
                            {
                                s = "-1";
                                return;
                            }
                            string str9 = str5;
                            if (!DateTime.TryParse(str9, out result))
                            {
                                s = "-1";
                                return;
                            }
                            now = DateTime.Parse(str4);
                            result = DateTime.Parse(str5).AddSeconds(59.0);
                            break;
                        }
                }
                string sqlWhere = " 1=1 ";
                string str11 = " 1=1 ";
                string str12 = " 1=1 ";
                string str13 = " 1=1 ";
                string str14 = "1=1";
                if (str6 != "")
                {
                    sqlWhere = sqlWhere + " and MemShopID=" + str6;
                    str11 = str11 + " and RechargeShopID=" + str6;
                    str12 = str12 + " and OrderShopID=" + str6;
                    str13 = str13 + " and CountShopID=" + str6;
                    str14 = str14 + " and DrawMoneyShopID =" + str6;
                }
                else
                {
                    sqlWhere = PubFunction.GetShopAuthority(intShopID, "MemShopID", sqlWhere);
                    str11 = PubFunction.GetShopAuthority(intShopID, "RechargeShopID", str11);
                    str12 = PubFunction.GetShopAuthority(intShopID, "OrderShopID", str12);
                    str13 = PubFunction.GetShopAuthority(intShopID, "CountShopID", str13);
                    str14 = PubFunction.GetShopAuthority(intShopID, "DrawMoneyShopID", str14);
                }
                if (str7 != "")
                {
                    sqlWhere = sqlWhere + ((sqlWhere != "") ? " and" : "") + " MemUserID=" + str7;
                    str11 = str11 + ((str11 != "") ? " and" : "") + "  RechargeUserID=" + str7;
                    str12 = str12 + ((str12 != "") ? " and" : "") + "  OrderUserID=" + str7;
                    str13 = str13 + ((str13 != "") ? " and" : "") + "  CountUserID=" + str7;
                    str14 = str14 + " and DrawMoneyUserID =" + str7;
                }
                if ((now.ToString() != "") && (result.ToString() != ""))
                {
                    sqlWhere = sqlWhere + ((sqlWhere != "") ? " and" : "") + string.Format("  MemCreateTime between '{0}' and '{1}'", now, result);
                    str11 = str11 + ((str11 != "") ? " and" : "") + string.Format(" RechargeCreateTime between '{0}' and '{1}' ", now, result);
                    str12 = str12 + ((str12 != "") ? " and" : "") + string.Format(" OrderCreateTime between '{0}' and '{1}' ", now, result);
                    str13 = str13 + ((str13 != "") ? " and" : "") + string.Format(" CountCreateTime between '{0}' and '{1}' ", now, result);
                    str14 = str14 + string.Format(" AND DrawMoneyCreateTime between '{0}' and '{1}' ", now, result);
                }
                DataSet set = new Chain.BLL.SysShop().GetTotalRptData(sqlWhere, str11, str12, str13, str14);
                int num3 = 0;
                StringBuilder builder = new StringBuilder();
                foreach (DataRow row in set.Tables[0].Rows)
                {
                    num3 += int.Parse(row["MemNumber"].ToString());
                    builder.Append(PubFunction.LevelIDToName(int.Parse(row["LevelID"].ToString())) + ":" + row["MemNumber"].ToString() + "名 ");
                }
                decimal num4 = 0M;
                DataRow[] rowArray = set.Tables[1].Select(" RechargeType=1 ");
                if (rowArray.Length == 1)
                {
                    num4 += decimal.Parse(rowArray[0][0].ToString());
                }
                decimal num5 = 0M;
                for (int i = 0; i < set.Tables[1].Rows.Count; i++)
                {
                    num5 += decimal.Parse(set.Tables[1].Rows[i][1].ToString());
                }
                decimal num7 = 0M;
                rowArray = set.Tables[1].Select(" RechargeType=2 ");
                if (rowArray.Length == 1)
                {
                    num7 += decimal.Parse(rowArray[0][0].ToString());
                }
                decimal num8 = 0M;
                rowArray = set.Tables[1].Select(" RechargeType=3 ");
                if (rowArray.Length == 1)
                {
                    num8 += decimal.Parse(rowArray[0][0].ToString());
                }
                decimal num9 = 0M;
                decimal num10 = 0M;
                decimal num11 = 0M;
                decimal num12 = 0M;
                decimal num13 = 0M;
                foreach (DataRow row2 in set.Tables[2].Rows)
                {
                    num11 += decimal.Parse(row2["OrderPayCard"].ToString());
                    num10 += decimal.Parse(row2["OrderPayCash"].ToString());
                    num9 += decimal.Parse(row2["OrderPayBink"].ToString());
                    num12 += decimal.Parse(row2["OrderPayCoupon"].ToString());
                    num13 += (((decimal.Parse(row2["OrderPayCard"].ToString()) + decimal.Parse(row2["OrderPayBink"].ToString())) + decimal.Parse(row2["OrderPayCash"].ToString())) + decimal.Parse(row2["OrderPayCoupon"].ToString())) - decimal.Parse(row2["OrderDiscountMoney"].ToString());
                }
                decimal num14 = 0M;
                decimal num15 = 0M;
                decimal num16 = 0M;
                decimal num17 = 0M;
                decimal num18 = 0M;
                foreach (DataRow row2 in set.Tables[3].Rows)
                {
                    num16 += decimal.Parse(row2["CountPayCard"].ToString());
                    num15 += decimal.Parse(row2["CountPayCash"].ToString());
                    num14 += decimal.Parse(row2["CountPayBink"].ToString());
                    num17 += decimal.Parse(row2["CountPayCoupon"].ToString());
                    num18 += (((decimal.Parse(row2["CountPayCard"].ToString()) + decimal.Parse(row2["CountPayBink"].ToString())) + decimal.Parse(row2["CountPayCash"].ToString())) + decimal.Parse(row2["CountPayCoupon"].ToString())) - decimal.Parse(row2["CountDiscountMoney"].ToString());
                }
                decimal num19 = num10 - num13;
                decimal num20 = num15 - num18;
                decimal num21 = (((num4 + num7) + num19) + num20) - Convert.ToDecimal(set.Tables[4].Rows[0]["AllDrawMoney"]);
                decimal num22 = (((num4 + num7) + num19) + num20) - Convert.ToDecimal(set.Tables[4].Rows[0]["AllDrawMoney"]);
                s = string.Concat(new object[] { 
                    "{\"timeRadion\":\"", now, " 至 ", result, "\",\"intNumber\":\"", num3, "名\",\"memSRechargeMoney\":\"", num4.ToString("#0.00"), "\",\"memFRechargeMoney\":\"", num7.ToString("#0.00"), "\",\"expenseSumMoneys\":\"", num19.ToString("#0.00"), "\",\"expenseBankSumMoneys\":\"", num8.ToString("#0.00"), "\",\"payCard\":\"", num11.ToString("#0.00"), 
                    "\",\"payBink\":\"", num9.ToString("#0.00"), "\",\"payCoupon\":\"", num12.ToString("#0.00"), "\",\"FRechargeGiveMoney\":\"", num5.ToString("#0.00"), "\",\"allMoney\":\"", num21.ToString("#0.00"), "\",\"MemDetial\":\"", builder, "\",\"strUserName\":\"", str2, "\",\"doWorkallMoney\":\"", num22, "\",\"countSumMoneys\":\"", num20.ToString("#0.00"), 
                    "\",\"countPayCard\":\"", num16.ToString("#0.00"), "\",\"countPayBink\":\"", num14.ToString("#0.00"), "\",\"countpayCoupon\":\"", num17.ToString("#0.00"), "\",\"AllDrawMoney\":\"", Convert.ToDecimal(set.Tables[4].Rows[0]["AllDrawMoney"]).ToString("F2"), "\",\"AllDrawActualMoney\":\"", Convert.ToDecimal(set.Tables[4].Rows[0]["AllDrawActualMoney"]).ToString("F2"), "\"}"
                 });
            }
            catch
            {
                s = "-3";
            }
            this.Context.Response.Write(s);
        }

        public void GetServiceList()
        {
            int num5;
            string s = "";
            int pageSize = int.Parse(this.Request["size"].ToString());
            int pageIndex = int.Parse(this.Request["index"].ToString());
            string str2 = (this.Request["key"] != "") ? this.Request["key"].ToString() : "";
            int num3 = !string.IsNullOrEmpty(this.Request["shopID"].ToString()) ? int.Parse(this.Request["shopID"].ToString()) : -1;
            int num4 = (this.Request["MemLevelID"] == null) ? -1 : int.Parse(this.Request["MemLevelID"]);
            StringBuilder builder = new StringBuilder();
            builder.Append(" GoodsType=1 ");
            if (str2 != "")
            {
                builder.AppendFormat(" and (Name like '%{0}%' or NameCode like '%{0}%' or GoodsCode='{0}')", str2);
            }
            if (num3 != -1)
            {
                builder.AppendFormat(" and ShopID={0}", num3);
            }
            DataTable dt = null;
            if (num4 == -1)
            {
                dt = this.bllGoods.GetGoodsListByNoMember(pageSize, pageIndex, out num5, new string[] { builder.ToString() }).Tables[0];
            }
            else
            {
                builder.AppendFormat(" and MemLevelId={0} ", num4);
                dt = this.bllGoods.GetGoodsListByMember(pageSize, pageIndex, out num5, new string[] { builder.ToString() }).Tables[0];
            }
            if (dt != null)
            {
                string str3;
                if (num4 == -1)
                {
                    str3 = JsonPlus.ToJson(dt, "GoodsID,Name,Price,GoodsBidPrice,Number,GoodsCode,Point,MinPercent,SalePercet,GoodsType,NameCode,ShopName");
                    s = string.Concat(new object[] { "{\"RecordCount\":", num5, ",\"List\":", str3, "}" });
                }
                else
                {
                    str3 = JsonPlus.ToJson(dt, "GoodsID,Name,Price,GoodsBidPrice,Number,GoodsCode,Point,MinPercent,SalePercet,GoodsType,NameCode,ShopName,ClassDiscountPercent,ClassPointPercent");
                    s = string.Concat(new object[] { "{\"RecordCount\":", num5, ",\"List\":", str3, "}" });
                }
            }
            this.Context.Response.Write(s);
        }

        public void GetServingProductList()
        {
            int num4;
            string s = "";
            int pageSize = int.Parse(this.Request["size"].ToString());
            int pageIndex = int.Parse(this.Request["index"].ToString());
            int num3 = int.Parse(this.Request["memID"]);
            StringBuilder builder = new StringBuilder();
            builder.Append(" Number > 0 AND CountDetailMemID= " + num3);
            if (!PubFunction.curParameter.sameGoods)
            {
                builder.AppendFormat(" AND ShopID = '{0}'", this.Session["UserShopID"].ToString());
            }
            DataTable dt = this.bllCountDetail.GetMemCountList(pageSize, pageIndex, out num4, new string[] { builder.ToString() }).Tables[0];
            if (dt != null)
            {
                string str2 = JsonPlus.ToJson(dt, "");
                s = string.Concat(new object[] { "{\"RecordCount\":", num4, ",\"List\":", str2, "}" });
            }
            this.Context.Response.Write(s);
        }

        public void GetShopInfo()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["shopID"]);
                DataTable table = new Chain.BLL.SysShop().GetList(" ShopID=" + num).Tables[0];
                s = JsonPlus.ToJson(table.Rows[0], "");
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetShopMemLevel()
        {
            string s = "";
            try
            {
                DataTable dt = new Chain.BLL.SysShopMemLevel().GetDataByShopMemLevelID(this.Request["ShopMemLevelID"].ToString()).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "LevelPoint,ClassDiscountPercent,ClassPointPercent,ShopName,ShopMemLevelID");
                }
            }
            catch
            {
            }
            this.Response.Write(s);
        }

        public void GetShopPonit()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["shopID"]);
                DataTable table = new Chain.BLL.SysShop().GetList(string.Format(" ShopID = '{0}'", num)).Tables[0];
                s = JsonPlus.ToJson(table.Rows[0], "");
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetShopSettlement()
        {
            string s = "";
            string str2 = this.Request["ID"].ToString();
            DataTable table = new Chain.BLL.SysShopSettlement().GetList(string.Format(" id = '{0}'", str2)).Tables[0];
            try
            {
                s = JsonPlus.ToJson(table.Rows[0], "");
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetSltStaff()
        {
            string s = "";
            StringBuilder builder = new StringBuilder();
            int num = int.Parse(this.Session["UserShopID"].ToString());
            string strWhere = " SysShop.ShopID = StaffClass.ClassShopID and StaffClass.ClassID=Staff.StaffClassID ";
            strWhere = strWhere + " and ClassShopID=" + num;
            Chain.BLL.Staff staff = new Chain.BLL.Staff();
            DataTable table = staff.GetList(strWhere).Tables[0];
            DataView defaultView = table.DefaultView;
            defaultView.Sort = " StaffClassID ASC";
            table = defaultView.ToTable();
            builder.Append("");
            s = "{\"sltStaffDetail\":\"" + builder + "\"}";
            this.Context.Response.Write(s);
        }

        public void GetSmsBalance()
        {
            string balance = SMSInfo.GetBalance(false);
            this.Context.Response.Write(balance);
        }

        public void GetSmsTemplate()
        {
            string s = "";
            try
            {
                int num = (this.Request["templateID"].ToString() != "") ? int.Parse(this.Request["templateID"].ToString()) : 0;
                Chain.BLL.SmsTemplate template = new Chain.BLL.SmsTemplate();
                DataTable dt = template.GetList("TemplateID=" + num).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "TemplateID,TemplateName,TemplateContent");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetStaff()
        {
            string s = "";
            try
            {
                int num = (this.Request["StaffID"].ToString() != "") ? int.Parse(this.Request["StaffID"].ToString()) : 0;
                Chain.BLL.Staff staff = new Chain.BLL.Staff();
                DataTable dt = staff.GetList(" StaffID=" + num + " and Staff.StaffClassID=StaffClass.ClassID and  StaffClass.ClassShopID=SysShop.ShopID").Tables[0];
                if (dt.Rows.Count > 0)
                {
                    s = JsonPlus.ToJson(dt, "StaffID,StaffNumber,StaffName,StaffSex,StaffMobile,StaffAddress,StaffClassID,ClassName,ShopName,StaffRemark");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetStaffClass()
        {
            string s = "";
            try
            {
                int num = (this.Request["ClassID"].ToString() != "") ? int.Parse(this.Request["ClassID"].ToString()) : 0;
                Chain.BLL.StaffClass class2 = new Chain.BLL.StaffClass();
                DataTable dt = class2.GetList(" ClassID=" + num + " and StaffClass.ClassShopID=SysShop.ShopID").Tables[0];
                if (dt.Rows.Count > 0)
                {
                    s = JsonPlus.ToJson(dt, "ClassID,ClassName,ClassType,ClassPercent,ClassShopID,ClassRemark,ShopName");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetStaffList()
        {
            string s = "";
            try
            {
                string str2 = this.Request["txtQuery"].ToString();
                string str3 = this.Request["ShopID"].ToString();
                string str4 = this.Request["ClassID"].ToString();
                int intShopID = int.Parse(this.Session["UserShopID"].ToString());
                StringBuilder builder = new StringBuilder();
                builder.Append(PubFunction.GetShopAuthority(intShopID, "StaffClass.ClassShopID", " Staff.StaffClassID=StaffClass.ClassID and  StaffClass.ClassShopID=SysShop.ShopID "));
                if (str2 != "")
                {
                    builder.AppendFormat(" and ((StaffName like '{0}') or (StaffNumber like '{0}') or (StaffMobile like '{0}')) ", str2);
                }
                if (str3 != "")
                {
                    builder.AppendFormat(" and ClassShopID={0} ", str3);
                }
                if (str4 != "")
                {
                    builder.AppendFormat(" and ClassID={0} ", str4);
                }
                Chain.BLL.Staff staff = new Chain.BLL.Staff();
                DataTable dt = staff.GetList(builder.ToString()).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    s = JsonPlus.ToJson(dt, "StaffID,StaffNumber,StaffName,StaffSex,StaffMobile,StaffAddress,ClassName,ShopName,StaffRemark");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetStaffMoneyChart()
        {
            string s = "";
            DateTime date = Convert.ToDateTime(this.Request["StartTime"]).Date;
            DateTime endtime = Convert.ToDateTime(this.Request["EndTime"]).Date;
            string str2 = this.Request["ShopID"].ToString();
            string str3 = "";
            string str4 = "";
            string str5 = date.ToString("yyyy-MM-dd") + "到" + endtime.ToString("yyyy-MM-dd") + "员工提成统计";
            string strwhere = PubFunction.GetShopAuthority(int.Parse(this.Session["UserShopID"].ToString()), "ShopID", " and 1=1 ");
            if (!string.IsNullOrEmpty(str2))
            {
                strwhere = strwhere + string.Format(" AND ShopID = '{0}' ", str2);
            }
            try
            {
                DataTable table = new Chain.BLL.StaffMoney().GetStaffMoneyByTime(date, endtime, strwhere).Tables[0];
                foreach (DataRow row in table.Rows)
                {
                    str4 = str4 + row["AllMoney"].ToString() + ",";
                }
                str4 = str4.Remove(str4.Length - 1);
                while (date <= endtime)
                {
                    str3 = str3 + date.ToString("yyyy-MM-dd") + ",";
                    date = date.AddDays(1.0);
                }
                str3 = str3.Remove(str3.Length - 1);
                s = string.Concat(new object[] { "{\"Success\":\"", 1, "\",\"Interval\":\"", str3, "\",\"Mydata\":\"", str4, "\",\"title\":\"", str5, "\"}" });
                this.Context.Response.Write(s);
            }
            catch
            {
                this.Context.Response.Write("");
            }
        }

        public void GetStaffMoneyDetail()
        {
            string s = "";
            try
            {
                int num3;
                int pageSize = !string.IsNullOrEmpty(this.Request["pageSize"]) ? Convert.ToInt32(this.Request["pageSize"].ToString()) : 0;
                int pageIndex = !string.IsNullOrEmpty(this.Request["currentPage"]) ? Convert.ToInt32(this.Request["currentPage"].ToString()) : 0;
                StringBuilder builder = new StringBuilder();
                builder.Append(" StaffID=" + this.Request["StaffID"].ToString());
                if (this.Request["StartTime"].ToString() != "")
                {
                    builder.AppendFormat(" and StaffCreateTime>='{0}'", Convert.ToDateTime(this.Request["StartTime"]));
                }
                if (this.Request["EndTime"].ToString() != "")
                {
                    builder.AppendFormat(" and StaffCreateTime<='{0}'", Convert.ToDateTime(this.Request["EndTime"]));
                }
                DataTable dt = new Chain.BLL.StaffMoney().GetListPage(pageSize, pageIndex, out num3, new string[] { builder.ToString() }).Tables[0];
                if (dt != null)
                {
                    string str2 = JsonPlus.ToJson(dt, "");
                    s = string.Concat(new object[] { "{\"RecordCount\":", num3, ",\"List\":", str2, "}" });
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetSysError()
        {
            string s = "";
            try
            {
                Chain.BLL.SysError error = new Chain.BLL.SysError();
                int iD = Convert.ToInt32(this.Request["ID"]);
                s = error.GetModel(iD).ErrorContent;
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetTextRuleByID()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["RuleID"]);
                DataTable dt = new Chain.BLL.WeiXinRule().GetList("RuleID=" + num + " ").Tables[0];
                s = JsonPlus.ToJson(dt, "");
            }
            catch
            {
            }
            this.Response.Write(s);
        }

        public void GetUserInfo()
        {
            string s = "";
            try
            {
                int num = int.Parse(this.Request["userID"]);
                DataTable table = new Chain.BLL.SysUser().GetList(" UserID=" + num).Tables[0];
                s = JsonPlus.ToJson(table.Rows[0], "");
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(s);
        }

        public void GetUserName()
        {
            string s = "";
            try
            {
                string str2 = (this.Request["Number"].Length < 0) ? "" : this.Request["Number"].ToString();
                Chain.BLL.SysUser user = new Chain.BLL.SysUser();
                DataTable dt = user.GetList(string.Format(" UserNumber = '{0}'", str2)).Tables[0];
                s = JsonPlus.ToJson(dt, "");
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void GiftAdd()
        {
            int num = 0;
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            try
            {
                Chain.Model.PointGift model = new Chain.Model.PointGift();
                Chain.BLL.PointGift gift2 = new Chain.BLL.PointGift();
                model.GiftName = this.Request["giftName"];
                model.GiftCode = this.Request["giftCode"];
                model.GiftClassID = int.Parse(this.Request["giftClassID"].ToString());
                model.GiftStockNumber = int.Parse(this.Request["giftStockNumber"]);
                model.GiftExchangePoint = int.Parse(this.Request["giftExchangePoint"]);
                model.GiftShopID = shopID;
                model.GiftRemark = this.Request["giftRemark"];
                model.GiftPhoto = this.Request["giftPhoto"].ToString();
                num = gift2.Add(model);
                if (num > 0)
                {
                    Chain.Model.SysShop shop = new Chain.BLL.SysShop().GetModel(shopID);
                    PubFunction.SaveSysLog(userID, 1, "礼品新增", string.Concat(new object[] { "新增礼品,礼品名称:[", model.GiftName, "],库存数量:[", model.GiftStockNumber, "],所需积分:[", model.GiftExchangePoint, "],所属店铺:[", shop.ShopName, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void GiftApplication()
        {
            int num = 0;
            try
            {
                int num2 = Convert.ToInt32(this.Request["MemID"]);
                string str = this.Request["MemName"];
                string str2 = this.Request["ExchangeTelePhone"];
                string str3 = this.Request["ExchangeAddress"];
                int num3 = Convert.ToInt32(this.Request["ExchangeAllPoint"]);
                string[] strArray = HttpUtility.UrlDecode(this.Request.Cookies["giftlist"].Value).Trim().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                int num4 = 0;
                foreach (string str5 in strArray)
                {
                    num4 += Convert.ToInt32(str5.Split(new char[] { ',' })[1]);
                }
                Chain.BLL.MicroWebsiteGiftExchange exchange = new Chain.BLL.MicroWebsiteGiftExchange();
                Chain.Model.MicroWebsiteGiftExchange model = new Chain.Model.MicroWebsiteGiftExchange();
                model.MemID = num2;
                model.ExchangeTelePhone = str2;
                model.ExchangeAddress = str3;
                model.ExchangeAccount = PubFunction.curParameter.strGiftExchangePrefix + DateTime.Now.ToString("yyMMddHHmmssffff");
                model.ExchangeAllNumber = num4;
                model.ExchangeAllPoint = num3;
                model.ApplicationTime = DateTime.Now;
                model.ExchangeStatus = 1;
                model.ExchangeType = 4;
                model.ShopID = 1;
                model.MemName = str;
                num = exchange.Add(model);
                Chain.BLL.PointGift gift = new Chain.BLL.PointGift();
                Chain.Model.MicroWebsiteGiftExchangeDetail detail = new Chain.Model.MicroWebsiteGiftExchangeDetail();
                Chain.BLL.MicroWebsiteGiftExchangeDetail detail2 = new Chain.BLL.MicroWebsiteGiftExchangeDetail();
                foreach (string str5 in strArray)
                {
                    int giftID = Convert.ToInt32(str5.Split(new char[] { ',' })[0]);
                    int num6 = Convert.ToInt32(str5.Split(new char[] { ',' })[1]);
                    Chain.Model.PointGift gift2 = gift.GetModel(giftID);
                    detail.ExchangeID = num;
                    detail.ExchangeGiftID = giftID;
                    detail.ExchangeNumber = num6;
                    detail.ExchangePoint = num6 * gift2.GiftExchangePoint;
                    detail.GiftName = gift2.GiftName;
                    detail2.Add(detail);
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void GiftClassAdd()
        {
            int num = 0;
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            try
            {
                string field = this.Request["ClassName"];
                field = PubFunction.RemoveSpace(field);
                string str2 = (this.Request["ClassRemark"] != "") ? this.Request["ClassRemark"].ToString() : "";
                str2 = PubFunction.RemoveSpace(str2);
                this.modelGiftClass.GiftClassName = field;
                this.modelGiftClass.GiftParentID = int.Parse(this.Request["ParentID"]);
                this.modelGiftClass.GiftClassRemark = str2;
                num = this.bllGiftClass.Add(this.modelGiftClass);
                if (num > 0)
                {
                    Chain.Model.SysShop model = new Chain.BLL.SysShop().GetModel(shopID);
                    PubFunction.SaveSysLog(userID, 1, "礼品分类", "新增礼品分类,分类名称:[" + this.modelGiftClass.GiftClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void GiftClassDel()
        {
            int num = 0;
            try
            {
                DataTable table;
                Chain.Model.SysShop model;
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int giftClassID = int.Parse(this.Request["ClassID"]);
                this.modelGiftClass = this.bllGiftClass.GetModel(giftClassID);
                if (this.modelGiftClass.GiftParentID != 0)
                {
                    table = new Chain.BLL.PointGift().GetList("GiftClassID=" + giftClassID).Tables[0];
                    if (table.Rows.Count > 0)
                    {
                        num = -2;
                    }
                    else
                    {
                        this.modelGiftClass = this.bllGiftClass.GetModel(giftClassID);
                        if (this.bllGiftClass.Delete(giftClassID))
                        {
                            num = 1;
                            model = new Chain.BLL.SysShop().GetModel(shopID);
                            PubFunction.SaveSysLog(userID, 1, "礼品分类", "删除礼品分类,分类名称:[" + this.modelGiftClass.GiftClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                        }
                    }
                }
                else
                {
                    DataTable table2;
                    table = this.bllGiftClass.GetList(" GiftParentID=" + giftClassID).Tables[0];
                    if (table.Rows.Count > 0)
                    {
                        string str = "";
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            str = str + table.Rows[i]["GiftClassID"] + ",";
                        }
                        int length = str.Length;
                        str = str.Substring(0, length - 1);
                        table2 = new Chain.BLL.PointGift().GetList(" GiftClassID in (" + str + ")").Tables[0];
                        if (table2.Rows.Count > 0)
                        {
                            num = -2;
                        }
                        else
                        {
                            this.modelGiftClass = this.bllGiftClass.GetModel(giftClassID);
                            if (this.bllGiftClass.Delete(giftClassID))
                            {
                                this.bllGiftClass.DeleteByParentID(giftClassID);
                                num = 1;
                                model = new Chain.BLL.SysShop().GetModel(shopID);
                                PubFunction.SaveSysLog(userID, 1, "礼品分类", "删除礼品分类,分类名称:[" + this.modelGiftClass.GiftClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                            }
                        }
                    }
                    else
                    {
                        table2 = new Chain.BLL.PointGift().GetList(" GiftClassID = (" + giftClassID + ")").Tables[0];
                        if (table2.Rows.Count > 0)
                        {
                            num = -2;
                        }
                        else if (this.bllGiftClass.Delete(giftClassID))
                        {
                            this.bllGiftClass.DeleteByParentID(giftClassID);
                            num = 1;
                            model = new Chain.BLL.SysShop().GetModel(shopID);
                            PubFunction.SaveSysLog(userID, 1, "礼品分类", "删除礼品分类,分类名称:[" + this.modelGiftClass.GiftClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                        }
                    }
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void GiftClassEdit()
        {
            int num = 0;
            try
            {
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int num4 = int.Parse(this.Request["ClassID"].ToString());
                int num5 = int.Parse(this.Request["ParentID"].ToString());
                string str = this.Request["ClassName"].ToString();
                string str2 = (this.Request["ClassRemark"] != "") ? this.Request["ClassRemark"].ToString() : "";
                this.modelGiftClass.GiftClassID = num4;
                this.modelGiftClass.GiftClassName = str;
                this.modelGiftClass.GiftClassRemark = str2;
                this.modelGiftClass.GiftParentID = num5;
                num = this.bllGiftClass.Update(this.modelGiftClass);
                if (num > 0)
                {
                    Chain.Model.SysShop model = new Chain.BLL.SysShop().GetModel(shopID);
                    PubFunction.SaveSysLog(userID, 1, "礼品分类", "编辑礼品分类,分类名称:[" + this.modelGiftClass.GiftClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void GiftDel()
        {
            int num = 0;
            try
            {
                int giftID = int.Parse(this.Request["GiftID"].ToString());
                Chain.BLL.PointGift gift = new Chain.BLL.PointGift();
                Chain.Model.PointGift model = gift.GetModel(giftID);
                DataTable table = new Chain.BLL.GiftExchangeDetail().GetList("ExchangeGiftID=" + giftID).Tables[0];
                if (table.Rows.Count > 0)
                {
                    num = -4;
                }
                else if (gift.Delete(giftID))
                {
                    num = 1;
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 2, "礼品删除", string.Concat(new object[] { "删除礼品,礼品名称:", model.GiftName, ",库存数量:", model.GiftStockNumber, ",所需积分:", model.GiftExchangePoint, ",所属店铺:", PubFunction.ShopIDToName(int.Parse(this.Session["UserShopID"].ToString())) }), int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void GiftEdit()
        {
            int num = 0;
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            try
            {
                Chain.Model.PointGift model = new Chain.Model.PointGift();
                Chain.BLL.PointGift gift2 = new Chain.BLL.PointGift();
                model.GiftID = int.Parse(this.Request["giftID"]);
                model.GiftName = this.Request["giftName"];
                model.GiftCode = this.Request["giftCode"];
                model.GiftClassID = int.Parse(this.Request["giftClassID"].ToString());
                model.GiftStockNumber = int.Parse(this.Request["giftStockNumber"]);
                model.GiftExchangePoint = int.Parse(this.Request["giftExchangePoint"]);
                model.GiftShopID = shopID;
                model.GiftExchangeNumber = int.Parse(this.Request["giftExchangeNumber"]);
                model.GiftRemark = this.Request["giftRemark"];
                model.GiftPhoto = this.Request["giftPhoto"].ToString();
                num = gift2.Update(model);
                if (num > 0)
                {
                    Chain.Model.SysShop shop = new Chain.BLL.SysShop().GetModel(model.GiftShopID);
                    PubFunction.SaveSysLog(userID, 3, "礼品编辑", string.Concat(new object[] { "编辑礼品成功,礼品名称:[", model.GiftName, "],库存数量:[", model.GiftStockNumber, "],所需积分:[", model.GiftExchangePoint, "],所属店铺:[", shop.ShopName, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void GiftExchange()
        {
            string s = "0";
            int num = 0;
            int memID = int.Parse(this.Request["memID"]);
            int point = int.Parse(this.Request["sumPoint"]);
            int num4 = int.Parse(this.Request["sumNumber"]);
            int num5 = int.Parse(this.Request["giftcount"]);
            int userID = int.Parse(this.Session["UID"].ToString());
            int intShopID = int.Parse(this.Session["UserShopID"].ToString());
            bool flag = this.Request["sendSMS"] == "true";
            string str2 = this.Request["Account"].ToString();
            try
            {
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem model = mem.GetModel(memID);
                Chain.Model.PointLog log = new Chain.Model.PointLog();
                Chain.BLL.PointLog log2 = new Chain.BLL.PointLog();
                Chain.Model.GiftExchange exchange = new Chain.Model.GiftExchange();
                Chain.BLL.GiftExchange exchange2 = new Chain.BLL.GiftExchange();
                Chain.Model.GiftExchangeDetail detail = new Chain.Model.GiftExchangeDetail();
                Chain.BLL.GiftExchangeDetail detail2 = new Chain.BLL.GiftExchangeDetail();
                int memLevelID = model.MemLevelID;
                if (model.MemState != 0)
                {
                    s = "-1";
                }
                else
                {
                    exchange.MemID = memID;
                    exchange.ExchangeTelePhone = model.MemTelePhone;
                    exchange.ExchangeAddress = "";
                    exchange.ExchangeAccount = str2;
                    exchange.ExchangeAllNumber = num4;
                    exchange.ExchangeAllPoint = point;
                    exchange.ApplicationTime = DateTime.Now;
                    exchange.ExchangeStatus = 2;
                    exchange.ExchangeTime = DateTime.Now;
                    exchange.ExchangeUserID = userID;
                    exchange.ExchangeType = 1;
                    num = exchange2.MainSystemAdd(exchange);
                    if (num > 0)
                    {
                        for (int i = 0; i < num5; i++)
                        {
                            detail.ExchangeID = num;
                            detail.ExchangeGiftID = int.Parse(this.Request["GiftList[" + i + "][GiftID]"].ToString());
                            detail.ExchangeNumber = int.Parse(this.Request["GiftList[" + i + "][ExcNumber]"].ToString());
                            detail.Giftname = this.Request["GiftList[" + i + "][Giftname]"].ToString();
                            int num10 = int.Parse(this.Request["GiftList[" + i + "][GiftExchangePoint]"].ToString());
                            detail.ExchangePoint = num10 * detail.ExchangeNumber;
                            detail2.Add(detail);
                            new Chain.BLL.PointGift().UpdateGiftNumber(detail.ExchangeGiftID, detail.ExchangeNumber);
                        }
                        log.PointMemID = model.MemID;
                        log.PointNumber = point;
                        log.PointChangeType = 4;
                        log.PointRemark = "实体店兑换礼品成功,扣减积分[" + point + "]";
                        log.PointShopID = intShopID;
                        log.PointCreateTime = DateTime.Now;
                        log.PointUserID = userID;
                        log.PointOrderCode = str2;
                        log2.Add(log);
                        int num11 = point;
                        point *= -1;
                        mem.UpdatePoint(memID, point);
                        model = new Chain.BLL.Mem().GetModel(memID);
                        string str3 = PubFunction.UpdateMemLevel(model);
                        s = string.Concat(new object[] { "{\"Success\":\"", num, "\",\"strUpdateMemLevel\":\"", str3, "\"}" });
                        if (flag)
                        {
                            if (Convert.ToInt32(SMSInfo.GetBalance(false)) <= 0)
                            {
                                s = "-2";
                            }
                            else if (PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length))
                            {
                                SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                                smsTemplateParameter.strCardID = model.MemCard;
                                smsTemplateParameter.strName = model.MemName;
                                smsTemplateParameter.dclTempMoney = 0M;
                                smsTemplateParameter.dclMoney = model.MemMoney;
                                smsTemplateParameter.intTempPoint = -point;
                                smsTemplateParameter.intPoint = model.MemPoint + point;
                                smsTemplateParameter.OldLevelID = memLevelID;
                                model = new Chain.BLL.Mem().GetModel(memID);
                                smsTemplateParameter.NewLevelID = model.MemLevelID;
                                string content = SMSInfo.GetSendContent(4, smsTemplateParameter, intShopID);
                                SMSInfo.Send_GXSMS(model.MemMobile, content, "");
                                Chain.Model.SmsLog log3 = new Chain.Model.SmsLog();
                                log3.SmsMemID = model.MemID;
                                log3.SmsMobile = model.MemMobile;
                                log3.SmsContent = content;
                                log3.SmsTime = DateTime.Now;
                                log3.SmsShopID = intShopID;
                                log3.SmsUserID = userID;
                                log3.SmsAmount = PubFunction.GetSmsAmount(content);
                                log3.SmsAllAmount = log3.SmsAmount;
                                new Chain.BLL.SmsLog().Add(log3);
                                PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length, 2);
                            }
                            else
                            {
                                s = "-5";
                            }
                        }
                        PubFunction.SaveSysLog(userID, 4, "礼品兑换", string.Concat(new object[] { "积分兑换,会员卡号:[", model.MemCard, "],姓名:[", model.MemName, "],礼品总数:[", num4, "],总积分:[", num4, "]" }), intShopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
            }
            catch
            {
                s = "0";
            }
            this.Context.Response.Write(s);
        }

        public void GoodApplication()
        {
            int num = 0;
            try
            {
                int memID = Convert.ToInt32(this.Request["MemID"]);
                string str = this.Request["MemName"];
                string str2 = this.Request["ExchangeTelePhone"];
                string str3 = this.Request["ExchangeAddress"];
                decimal num3 = Convert.ToDecimal(this.Request["MicroOrderDiscountMoney"]);
                int num4 = Convert.ToInt32(this.Request["MicroOrderPoint"]);
                string[] strArray = HttpUtility.UrlDecode(this.Request.Cookies["goodlist"].Value).Trim().Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                Chain.Model.Mem model = new Chain.BLL.Mem().GetModel(memID);
                Chain.BLL.MicroWebsiteOrderLog log = new Chain.BLL.MicroWebsiteOrderLog();
                Chain.Model.MicroWebsiteOrderLog log2 = new Chain.Model.MicroWebsiteOrderLog();
                log2.MicroOrderAccount = PubFunction.curParameter.strGoodsExpensePrefix + DateTime.Now.ToString("yyMMddHHmmssffff");
                log2.MicroOrderType = 0;
                log2.MicroOrderMemID = memID;
                log2.MicroOrderTotalMoney = num3;
                log2.MicroOrderDiscountMoney = num3;
                log2.MicroOrderIsCard = false;
                log2.MicroOrderPayCard = 0M;
                log2.MicroOrderIsCash = false;
                log2.MicroOrderPayCash = 0M;
                log2.MicroOrderIsBink = false;
                log2.MicroOrderPayBink = 0M;
                log2.MicroOrderPayCoupon = 0M;
                log2.MicroOrderPoint = num4;
                log2.MicroOrderRemark = "";
                log2.MicroOrderShopID = 1;
                log2.MicroOrderUserID = 0;
                log2.MicroOrderCreateTime = DateTime.Now;
                log2.MicroOldAccount = "";
                log2.MicroOrderCardBalance = model.MemMoney;
                log2.MicroOrderCardPoint = model.MemPoint;
                log2.MicroOrderName = str;
                log2.MicroOrderMobile = str2;
                log2.MicroOrderAdress = str3;
                log2.MicroOrderStatus = 1;
                log2.MicroOrderPassCreateTime = DateTime.Now;
                log2.MicroOrderMark = "";
                log2.MicroOrderPayCreateTime = DateTime.Now;
                num = log.Add(log2);
                if (num > 0)
                {
                    Chain.BLL.MicroWebsiteOrderLogDetail detail = new Chain.BLL.MicroWebsiteOrderLogDetail();
                    Chain.Model.MicroWebsiteOrderLogDetail detail2 = new Chain.Model.MicroWebsiteOrderLogDetail();
                    detail2.MicroOrderID = num;
                    Chain.BLL.MicroWebsiteGoods goods = new Chain.BLL.MicroWebsiteGoods();
                    Chain.Model.MicroWebsiteGoods goods2 = new Chain.Model.MicroWebsiteGoods();
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        int microGoodsID = Convert.ToInt32(strArray[i].Split(new char[] { ',' })[0]);
                        int num7 = Convert.ToInt32(strArray[i].Split(new char[] { ',' })[1]);
                        goods2 = goods.GetModel(microGoodsID);
                        detail2.MicroGoodsID = microGoodsID;
                        detail2.MicroOrderDetailPrice = goods2.MicroSalePrice;
                        detail2.MicroOrderDetailPoint = detail2.MicroOrderDetailPoint;
                        detail2.MicroOrderDetailDiscountPrice = detail2.MicroOrderDetailDiscountPrice;
                        detail2.MicroOrderDetailNumber = num7;
                        detail.Add(detail2);
                    }
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void GoodPay()
        {
            int num = 0;
            int memID = Convert.ToInt32(this.Request["MemID"]);
            int microOrderID = Convert.ToInt32(this.Request["MicroOrderID"]);
            decimal num4 = Convert.ToDecimal(this.Request["payMoney"]);
            Chain.BLL.Mem mem = new Chain.BLL.Mem();
            Chain.Model.Mem model = mem.GetModel(memID);
            if (num4 > model.MemMoney)
            {
                num = -1;
            }
            else
            {
                Chain.BLL.MicroWebsiteOrderLog log = new Chain.BLL.MicroWebsiteOrderLog();
                Chain.Model.MicroWebsiteOrderLog log2 = log.GetModel(microOrderID);
                log2.MicroOrderIsCard = true;
                log2.MicroOrderPayCard = num4;
                log2.MicroOrderStatus = 4;
                log2.MicroOrderPayCreateTime = DateTime.Now;
                if (log.Update(log2))
                {
                    mem.ExpenseUpdateMem(model.MemID, model.MemMoney - num4, model.MemConsumeMoney + num4, model.MemPoint + log2.MicroOrderPoint, DateTime.Now, model.MemConsumeCount + 1);
                    PubFunction.UpdateMemLevel(model);
                    MEMPointUpdate.MEMPointRate(model, log2.MicroOrderPoint, log2.MicroOrderAccount, 1);
                    Chain.Model.PointLog log4 = new Chain.Model.PointLog();
                    log4.PointMemID = memID;
                    log4.PointNumber = log2.MicroOrderPoint;
                    log4.PointChangeType = 1;
                    log4.PointRemark = "会员微网站商品消费成功,消费总额:[" + num4 + "]";
                    log4.PointShopID = 1;
                    log4.PointCreateTime = DateTime.Now;
                    log4.PointUserID = 1;
                    log4.PointGiveMemID = 0;
                    log4.PointOrderCode = log2.MicroOrderAccount;
                    Chain.Model.PointLog log3 = log4;
                    new Chain.BLL.PointLog().Add(log3);
                    num = 1;
                }
            }
            this.Response.Write(num);
        }

        public void GoodsAddAndEdit()
        {
            int num = 0;
            try
            {
                int num5;
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int goodsID = (this.Request["txtGoodsID"] != "") ? int.Parse(this.Request["txtGoodsID"].ToString()) : 0;
                string s = this.Request["txtGoodsNumber"].ToString();
                if (this.Request["hdShopID"].ToString() != "")
                {
                    num5 = int.Parse(this.Request["hdShopID"].ToString());
                }
                else
                {
                    num5 = 0;
                }
                this.modelGoods.GoodsCode = this.Request["txtGoodsCode"].ToString();
                bool flag = (this.Request["chkService"] != null) && (this.Request["chkService"] == "on");
                this.modelGoods.Name = this.Request["txtGoodsName"].ToString();
                this.modelGoods.NameCode = this.Request["txtGoodsNameCode"].ToString();
                this.modelGoods.GoodsClassID = int.Parse(this.Request["sltGoodsClass"].ToString());
                if (!((this.Request["sltShopList"] == null) || string.IsNullOrEmpty(this.Request["sltShopList"].ToString())))
                {
                    this.modelGoods.ShopID = int.Parse(this.Request["sltShopList"].ToString());
                }
                else
                {
                    this.modelGoods.ShopID = int.Parse(this.Request["txtShopID"].ToString());
                }
                this.modelGoods.Unit = this.Request["sltjldw"].ToString();
                this.modelGoods.CommissionType = int.Parse(this.Request["sltCommissionType"].ToString());
                this.modelGoods.CommissionNumber = decimal.Parse(this.Request["txtCommissionNumber"].ToString());
                this.modelGoods.Price = decimal.Parse(this.Request["txtGoodsPrice"].ToString());
                this.modelGoods.Point = (this.Request["txtGoodsPoint"] != "") ? int.Parse(this.Request["txtGoodsPoint"].ToString()) : -1;
                this.modelGoods.GoodsBidPrice = (this.Request["txtGoodsBidPrice"] != "") ? decimal.Parse(this.Request["txtGoodsBidPrice"].ToString()) : 0M;
                this.modelGoods.MinPercent = decimal.Parse(this.Request["txtGoodsMinPercent"].ToString());
                string str2 = PubFunction.RemoveSpace(this.Request["txtGoodsRemark"].ToString());
                this.modelGoods.GoodsRemark = str2;
                this.modelGoods.GoodsPicture = "";
                this.modelGoods.GoodsCreateTime = DateTime.Now;
                this.modelGoods.SalePercet = decimal.Parse(this.Request["txtGoodsSalePercent"].ToString());
                if (flag)
                {
                    this.modelGoods.GoodsType = 1;
                }
                else
                {
                    this.modelGoods.GoodsType = 0;
                }
                if (goodsID == 0)
                {
                    int intGoodsID = this.bllGoods.Add(this.modelGoods);
                    if (intGoodsID < 0)
                    {
                        num = intGoodsID;
                    }
                    if (intGoodsID > 0)
                    {
                        num = 1;
                        if (this.modelGoods.ShopID == 0)
                        {
                            this.bllNumber.InsertGoodsNumber(intGoodsID);
                        }
                        else
                        {
                            this.bllNumber.InsertGoodsNumber(intGoodsID, this.modelGoods.ShopID);
                        }
                        PubFunction.SaveSysLog(userID, 1, "商品新增", "新增商品,商品名称:[" + this.modelGoods.Name + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
                else
                {
                    this.modelGoods.GoodsID = goodsID;
                    num = this.bllGoods.Update(this.modelGoods);
                    if (num > 0)
                    {
                        if (this.bllNumber.UpdateGoodsNumber(goodsID, int.Parse(s), num5) > 0)
                        {
                            this.modelGoodsLog.GoodsAccount = "BJ" + DateTime.Now.ToString("yyMMddHHmmssffff");
                            this.modelGoodsLog.Type = 8;
                            this.modelGoodsLog.GoodsID = goodsID;
                            this.modelGoodsLog.TotalPrice = decimal.Parse(this.Request["txtGoodsPrice"].ToString());
                            this.modelGoodsLog.InPrice = 0M;
                            this.modelGoodsLog.Outprice = 0M;
                            this.modelGoodsLog.GoodsNumber = 0;
                            this.modelGoodsLog.InShopID = shopID;
                            this.modelGoodsLog.OutShopID = shopID;
                            this.modelGoodsLog.Remark = "商品库存编辑";
                            this.modelGoodsLog.CreateTime = DateTime.Now;
                            this.modelGoodsLog.ShopID = shopID;
                            this.modelGoodsLog.UserID = userID;
                            num = this.bllGoodsLog.Add(this.modelGoodsLog);
                            if (num > 0)
                            {
                                this.modelGoodsDetail.GoodsLogID = num;
                                this.modelGoodsDetail.GoodsID = goodsID;
                                this.modelGoodsDetail.GoodsInPrice = 0M;
                                this.modelGoodsDetail.GoodsOutPrice = 0M;
                                this.modelGoodsDetail.GoodsNumber = int.Parse(s);
                                this.bllGoodsDetail.Add(this.modelGoodsDetail);
                            }
                        }
                        else
                        {
                            num = 0;
                        }
                        PubFunction.SaveSysLog(userID, 3, "商品编辑", "编辑商品,商品名称:[" + this.modelGoods.Name + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
                DataRow[] rowArray = new Chain.BLL.MemCustomField().CustomGetList(" CustomType=2 ");
                Hashtable customhash = new Hashtable();
                if (rowArray.Length > 0)
                {
                    foreach (DataRow row in rowArray)
                    {
                        customhash.Add(row["CustomField"].ToString(), this.Request["Goods_Custom_" + row["CustomField"].ToString()]);
                    }
                    this.bllGoods.AddCustomField(this.modelGoods.GoodsCode, customhash);
                }
            }
            catch
            {
                num = -2;
            }
            this.Context.Response.Write(num);
        }

        public void GoodsAllot()
        {
            int num = 0;
            try
            {
                int userID = (this.Session["UID"].ToString() != "") ? int.Parse(this.Session["UID"].ToString()) : 0;
                int shopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : 0;
                string str = this.Request["goodsAccount"].ToString();
                int num4 = (this.Request["count"].ToString() != "") ? int.Parse(this.Request["count"].ToString()) : 0;
                int num5 = (this.Request["totalNumber"].ToString() != "") ? int.Parse(this.Request["totalNumber"].ToString()) : 0;
                int num6 = (this.Request["outShopID"].ToString() != "") ? int.Parse(this.Request["outShopID"].ToString()) : 0;
                int num7 = (this.Request["inShopID"].ToString() != "") ? int.Parse(this.Request["inShopID"].ToString()) : 0;
                string str2 = (this.Request["remark"] != "") ? this.Request["remark"].ToString() : "";
                DateTime time = DateTime.Parse(this.Request["time"].ToString());
                this.modelGoodsAllot.AllotAccount = str;
                this.modelGoodsAllot.AllotTotalNumber = num5;
                this.modelGoodsAllot.AllotOutShopID = num6;
                this.modelGoodsAllot.AllotInShopID = num7;
                this.modelGoodsAllot.AllotCreateTime = time;
                this.modelGoodsAllot.AllotUserID = userID;
                this.modelGoodsAllot.AllotRemark = str2;
                num = this.bllGoodsAllot.Add(this.modelGoodsAllot);
                this.modelGoodsLog.GoodsAccount = str;
                this.modelGoodsLog.Type = 6;
                this.modelGoodsLog.InShopID = num7;
                this.modelGoodsLog.OutShopID = num6;
                this.modelGoodsLog.Remark = str2;
                this.modelGoodsLog.CreateTime = time;
                this.modelGoodsLog.ShopID = shopID;
                this.modelGoodsLog.UserID = userID;
                int num8 = this.bllGoodsLog.Add(this.modelGoodsLog);
                for (int i = 0; i < num4; i++)
                {
                    int num10 = (this.Request["data[" + i + "][GoodsID]"] != "") ? int.Parse(this.Request["data[" + i + "][GoodsID]"]) : 0;
                    int num11 = (this.Request["data[" + i + "][ExpNum]"] != "") ? int.Parse(this.Request["data[" + i + "][ExpNum]"]) : 0;
                    this.modelNumber.GoodsID = num10;
                    this.modelNumber.ShopID = num6;
                    this.modelNumber.Number = -num11;
                    this.bllNumber.UpdataGoodsNumber(this.modelNumber);
                    this.modelNumber.ShopID = num7;
                    this.modelNumber.Number = num11;
                    this.bllNumber.UpdataGoodsNumber(this.modelNumber);
                    this.modelAllotDetail.AllotDetailAllotID = num;
                    this.modelAllotDetail.AllotDetailGoodsID = num10;
                    this.modelAllotDetail.AllotDetailNumber = num11;
                    this.bllAllotDetail.Add(this.modelAllotDetail);
                    this.modelGoodsDetail.GoodsLogID = num8;
                    this.modelGoodsDetail.GoodsID = num10;
                    this.modelGoodsDetail.GoodsInPrice = 0M;
                    this.modelGoodsDetail.GoodsOutPrice = 0M;
                    this.modelGoodsDetail.GoodsNumber = num11;
                    this.bllGoodsDetail.Add(this.modelGoodsDetail);
                }
                if (num > 0)
                {
                    PubFunction.SaveSysLog(userID, 4, "商品调拔", string.Concat(new object[] { "商品调拔,调拔单号:[", str, "],调拔时间:[", time, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void GoodsClassAdd()
        {
            int goodsClassID = 0;
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            try
            {
                string field = this.Request["ClassName"];
                field = PubFunction.RemoveSpace(field);
                string str2 = (this.Request["ClassRemark"] != "") ? this.Request["ClassRemark"].ToString() : "";
                str2 = PubFunction.RemoveSpace(str2);
                this.modelGdClass.ClassName = field;
                this.modelGdClass.ParentID = int.Parse(this.Request["ParentID"]);
                this.modelGdClass.ClassRemark = str2;
                if (PubFunction.curParameter.sameGoods)
                {
                    this.modelGdClass.ShopID = 0;
                }
                else
                {
                    this.modelGdClass.ShopID = int.Parse(this.Request["ShopID"]);
                }
                goodsClassID = this.bllGdClass.Add(this.modelGdClass);
                if (goodsClassID > 0)
                {
                    Chain.Model.SysShop model = new Chain.BLL.SysShop().GetModel(shopID);
                    PubFunction.SaveSysLog(userID, 1, "商品分类", "新增商品分类,分类名称:[" + this.modelGdClass.ClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                    new Chain.BLL.GoodsClassDiscount().InitGoodsLevelDiscountByGoodsClassID(goodsClassID);
                }
            }
            catch
            {
                goodsClassID = -3;
            }
            this.Context.Response.Write(goodsClassID);
        }

        public void GoodsClassDel()
        {
            int num = 0;
            try
            {
                DataTable table;
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int classID = int.Parse(this.Request["ClassID"]);
                Chain.Model.GoodsClass model = new Chain.Model.GoodsClass();
                Chain.BLL.GoodsClass class3 = new Chain.BLL.GoodsClass();
                model = class3.GetModel(classID);
                if (model.ParentID != 0)
                {
                    table = this.bllGoods.GetList("GoodsClassID=" + classID).Tables[0];
                    if (table.Rows.Count > 0)
                    {
                        num = -2;
                    }
                    else
                    {
                        num = class3.Delete(classID);
                        new Chain.BLL.GoodsClassDiscount().DelGoodsClassDiscountByGoodsClassID(classID);
                        if (num > 0)
                        {
                            DataTable table2 = this.bllGdClass.GetList("ParentID=" + classID).Tables[0];
                            if (table2.Rows.Count > 0)
                            {
                                this.bllGdClass.DeleteByParentID(classID);
                            }
                            PubFunction.SaveSysLog(userID, 1, "商品分类", "删除商品分类,分类名称:[" + model.ClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                        }
                    }
                }
                else
                {
                    DataTable table3 = class3.GetList(" ParentID=" + classID).Tables[0];
                    if (table3.Rows.Count > 0)
                    {
                        string str = "";
                        for (int i = 0; i < table3.Rows.Count; i++)
                        {
                            str = str + table3.Rows[i]["ClassID"] + ",";
                        }
                        int length = str.Length;
                        str = str.Substring(0, length - 1);
                        table = this.bllGoods.GetList(" GoodsClassID in (" + str + ")").Tables[0];
                        if (table.Rows.Count > 0)
                        {
                            num = -2;
                        }
                        else
                        {
                            num = class3.Delete(classID);
                            new Chain.BLL.GoodsClassDiscount().DelGoodsClassDiscountByGoodsClassID(classID);
                            if (num > 0)
                            {
                                this.bllGdClass.DeleteByParentID(classID);
                                PubFunction.SaveSysLog(userID, 1, "商品分类", "删除商品分类,分类名称:[" + model.ClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                            }
                        }
                    }
                    else
                    {
                        num = class3.Delete(classID);
                        new Chain.BLL.GoodsClassDiscount().DelGoodsClassDiscountByGoodsClassID(classID);
                    }
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void GoodsClassEdit()
        {
            int num = 0;
            try
            {
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int num4 = int.Parse(this.Request["ClassID"]);
                int num5 = int.Parse(this.Request["ParentID"].ToString());
                string str = this.Request["ClassName"];
                string str2 = (this.Request["ClassRemark"] != "") ? this.Request["ClassRemark"].ToString() : "";
                this.modelGdClass.ClassID = num4;
                this.modelGdClass.ClassName = str;
                this.modelGdClass.ClassRemark = str2;
                this.modelGdClass.ParentID = num5;
                if (PubFunction.curParameter.sameGoods)
                {
                    this.modelGdClass.ShopID = 0;
                }
                else
                {
                    this.modelGdClass.ShopID = int.Parse(this.Request["ShopID"]);
                }
                num = this.bllGdClass.Update(this.modelGdClass);
                if (num > 0)
                {
                    Chain.Model.SysShop model = new Chain.BLL.SysShop().GetModel(shopID);
                    PubFunction.SaveSysLog(userID, 1, "商品分类", "编辑商品分类,分类名称:[" + this.modelGdClass.ClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void GoodsDel()
        {
            int num = 0;
            try
            {
                int goodsID = int.Parse(this.Request["GoodsID"]);
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                this.modelGoods = this.bllGoods.GetModel(goodsID);
                DataTable table = this.bllDetail.GetList(" GoodsID=" + goodsID).Tables[0];
                DataTable table2 = this.bllCountDetail.GetList(" CountDetailGoodsID=" + goodsID).Tables[0];
                DataTable table3 = this.bllGoodsDetail.GetList("GoodsID=" + goodsID).Tables[0];
                if (((table.Rows.Count > 0) || (table2.Rows.Count > 0)) || (table3.Rows.Count > 0))
                {
                    num = -2;
                }
                else if (this.bllNumber.DeleteNumber(goodsID) && this.bllGoods.Delete(goodsID))
                {
                    num = 1;
                    PubFunction.SaveSysLog(userID, 2, "商品删除", "删除商品,商品名称:[" + this.modelGoods.Name + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void GoodsExpense()
        {
            string s = "0";
            string detail = "";
            try
            {
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int memID = int.Parse(this.Request["memID"].ToString());
                string str3 = this.Request["parameter[0][payType]"];
                decimal num4 = decimal.Parse(this.Request["parameter[0][DiscountMoney]"]);
                decimal num5 = (this.Request["parameter[0][CardMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CardMoney]"]) : 0M;
                decimal num6 = (this.Request["parameter[0][CashMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CashMoney]"]) : 0M;
                decimal num7 = (this.Request["parameter[0][BinkMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][BinkMoney]"]) : 0M;
                decimal num8 = (this.Request["parameter[0][CouponMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CouponMoney]"]) : 0M;
                decimal num9 = decimal.Parse(this.Request["totalMoney"]);
                decimal num10 = decimal.Parse(this.Request["staffMoney"]);
                int point = int.Parse(this.Request["point"]);
                int num12 = int.Parse(this.Request["number"]);
                string str4 = this.Request["orderCode"].ToString();
                string str5 = PubFunction.RemoveSpace(this.Request["remark"].ToString());
                int num13 = int.Parse(this.Request["count"]);
                bool flag = this.Request["print"] == "true";
                bool flag2 = this.Request["sendSMS"] == "true";
                bool flag3 = this.Request["staff"] == "true";
                DateTime time = DateTime.Parse(this.Request["expensetime"].ToString());
                string str6 = this.Request["staffName"];
                bool flag4 = bool.Parse(this.Request["parameter[0][IsCard]"]);
                bool flag5 = bool.Parse(this.Request["parameter[0][IsCash]"]);
                bool flag6 = bool.Parse(this.Request["parameter[0][IsBink]"]);
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem model = mem.GetModel(memID);
                int memLevelID = model.MemLevelID;
                if ((memID != 0) && (str3 != "EmptyBills"))
                {
                    detail = string.Concat(new object[] { "会员商品消费,会员卡号:[", model.MemCard, "],姓名:[", model.MemName, "],订单号:[", str4, "],消费金额:[", num4, "],获得积分:[", point, "],备注:", str5 });
                }
                else if ((memID != 0) && (str3 == "EmptyBills"))
                {
                    detail = "会员挂单,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "],订单号:[" + str4 + "],备注:" + str5;
                }
                else
                {
                    detail = string.Concat(new object[] { "散客商品消费,订单号:[", str4, "],消费金额:[", num4, "],备注:", str5 });
                }
                if (PubFunction.IsShopPoint(shopID, ref point) || (memID == 0))
                {
                    this.modelOrderLog.OrderAccount = str4;
                    this.modelOrderLog.OrderMemID = memID;
                    this.modelOrderLog.OrderType = 2;
                    this.modelOrderLog.OrderTotalMoney = num9;
                    this.modelOrderLog.OrderDiscountMoney = num4;
                    this.modelOrderLog.OrderIsCard = flag4;
                    this.modelOrderLog.OrderPayCard = num5;
                    this.modelOrderLog.OrderIsCash = flag5;
                    this.modelOrderLog.OrderPayCash = num6;
                    this.modelOrderLog.OrderIsBink = flag6;
                    this.modelOrderLog.OrderPayBink = num7;
                    this.modelOrderLog.OrderPayCoupon = num8;
                    this.modelOrderLog.OrderPoint = point;
                    this.modelOrderLog.OrderRemark = str5;
                    this.modelOrderLog.OrderPayType = 0;
                    this.modelOrderLog.OrderShopID = shopID;
                    this.modelOrderLog.OrderUserID = userID;
                    this.modelOrderLog.OrderCreateTime = time;
                    if (str3 == "EmptyBills")
                    {
                        this.modelOrderLog.OrderType = 3;
                    }
                    int num15 = this.bllOrderLog.Add(this.modelOrderLog);
                    this.modelGoodsLog.GoodsAccount = str4;
                    if (str3 != "EmptyBills")
                    {
                        this.modelGoodsLog.Type = 2;
                        this.modelGoodsLog.Remark = "商品销售出库";
                    }
                    else
                    {
                        this.modelGoodsLog.Type = 3;
                        this.modelGoodsLog.Remark = "商品挂单出库";
                    }
                    this.modelGoodsLog.TotalPrice = num4;
                    this.modelGoodsLog.InShopID = shopID;
                    this.modelGoodsLog.OutShopID = shopID;
                    this.modelGoodsLog.CreateTime = time;
                    this.modelGoodsLog.ShopID = shopID;
                    this.modelGoodsLog.UserID = userID;
                    int num16 = this.bllGoodsLog.Add(this.modelGoodsLog);
                    if (num15 > 0)
                    {
                        int num17 = 0;
                        for (int i = 0; i < num13; i++)
                        {
                            this.modelDetail.OrderID = num15;
                            this.modelDetail.GoodsID = int.Parse(this.Request["data[" + i + "][GoodsID]"]);
                            this.modelDetail.OrderDetailPrice = decimal.Parse(this.Request["data[" + i + "][Price]"]);
                            this.modelDetail.OrderDetailDiscountPrice = decimal.Parse(this.Request["data[" + i + "][ExpMoney]"]);
                            this.modelDetail.OrderDetailNumber = int.Parse(this.Request["data[" + i + "][ExpNum]"]);
                            this.modelDetail.OrderDetailPoint = int.Parse(this.Request["data[" + i + "][ExpPoint]"].ToString());
                            num17 = this.bllDetail.Add(this.modelDetail);
                            if (int.Parse(this.Request["data[" + i + "][GoodsType]"]) == 0)
                            {
                                this.modelNumber.GoodsID = this.modelDetail.GoodsID;
                                this.modelNumber.ShopID = shopID;
                                decimal num25 = this.modelDetail.OrderDetailNumber * -1M;
                                this.modelNumber.Number = int.Parse(num25.ToString());
                                this.bllNumber.UpdataGoodsNumber(this.modelNumber);
                                this.modelGoodsDetail.GoodsLogID = num16;
                                this.modelGoodsDetail.GoodsID = int.Parse(this.Request["data[" + i + "][GoodsID]"]);
                                this.modelGoodsDetail.GoodsInPrice = decimal.Parse(this.Request["data[" + i + "][Price]"]);
                                this.modelGoodsDetail.GoodsOutPrice = decimal.Parse((decimal.Parse(this.Request["data[" + i + "][ExpMoney]"]) / int.Parse(this.Request["data[" + i + "][ExpNum]"])).ToString("#.00"));
                                this.modelGoodsDetail.GoodsNumber = int.Parse(this.Request["data[" + i + "][ExpNum]"]) * -1;
                                this.bllGoodsDetail.Add(this.modelGoodsDetail);
                            }
                            int num20 = (this.Request["data[" + i + "][ExpStaffName]"] != "") ? int.Parse(this.Request["data[" + i + "][ExpStaffName]"]) : 0;
                            if (num20 != 0)
                            {
                                this.modelStaffMoney.StaffID = num20;
                                this.modelStaffMoney.StaffTotalMoney = Math.Abs(decimal.Parse(this.Request["data[" + i + "][ExpStaffMoney]"]));
                                this.modelStaffMoney.StaffOrderCode = str4;
                                this.modelStaffMoney.StaffMemID = memID;
                                this.modelStaffMoney.StaffGoodsID = int.Parse(this.Request["data[" + i + "][GoodsID]"]);
                                this.modelStaffMoney.StaffShopID = shopID;
                                this.modelStaffMoney.StaffCreateTime = DateTime.Now;
                                this.bllStaffMoney.Add(this.modelStaffMoney);
                            }
                            if (this.modelDetail.OrderDetailNumber < 0M)
                            {
                                DataTable table = this.bllCountDetail.GetList(-1, string.Concat(new object[] { " CountDetailMemID=", memID, " and CountDetailGoodsID=", this.modelDetail.GoodsID, " and CountDetailNumber>0" }), "CountCreateTime ASC").Tables[0];
                                int intNumber = Math.Abs(int.Parse(this.modelDetail.OrderDetailNumber.ToString()));
                                foreach (DataRow row in table.Rows)
                                {
                                    if (intNumber != 0)
                                    {
                                        int num22 = int.Parse(row["CountDetailNumber"].ToString());
                                        if (num22 > intNumber)
                                        {
                                            this.bllCountDetail.UpdateCountDetailNumber(intNumber, int.Parse(row["CountDetailID"].ToString()));
                                            intNumber = 0;
                                        }
                                        else
                                        {
                                            this.bllCountDetail.UpdateCountDetailNumber(num22, int.Parse(row["CountDetailID"].ToString()));
                                            intNumber -= num22;
                                        }
                                    }
                                }
                            }
                        }
                        if ((num17 > 0) && (memID != 0))
                        {
                            if (str3 != "EmptyBills")
                            {
                                this.modelPoint.PointMemID = memID;
                                this.modelPoint.PointNumber = point;
                                this.modelPoint.PointChangeType = 1;
                                this.modelPoint.PointRemark = "会员商品消费成功,消费总额:[" + num4 + "]";
                                this.modelPoint.PointShopID = shopID;
                                this.modelPoint.PointUserID = userID;
                                this.modelPoint.PointCreateTime = time;
                                this.modelPoint.PointOrderCode = str4;
                                if (this.bllPoint.Add(this.modelPoint) > 0)
                                {
                                    decimal dclMemMoney = model.MemMoney - num5;
                                    model.MemConsumeMoney += num4;
                                    model.MemPoint += point;
                                    model.MemConsumeLastTime = time;
                                    model.MemConsumeCount++;
                                    int num24 = mem.ExpenseUpdateMem(memID, dclMemMoney, model.MemConsumeMoney, model.MemPoint, DateTime.Now, model.MemConsumeCount);
                                    PubFunction.SetShopPoint(userID, shopID, point, "会员商品消费,扣除店铺积分", 2);
                                    MEMPointUpdate.MEMPointRate(model, this.modelOrderLog.OrderPoint, this.modelOrderLog.OrderAccount, 1);
                                    model = new Chain.BLL.Mem().GetModel(memID);
                                    string str7 = PubFunction.UpdateMemLevel(model);
                                    s = string.Concat(new object[] { "{\"Success\":\"", num15, "\",\"strUpdateMemLevel\":\"", str7, "\"}" });
                                    if (flag2)
                                    {
                                        if (Convert.ToInt32(SMSInfo.GetBalance(false)) <= 0)
                                        {
                                            s = "-2";
                                        }
                                        else if (model.MemMobile != "")
                                        {
                                            if (PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length))
                                            {
                                                SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                                                smsTemplateParameter.strCardID = model.MemCard;
                                                smsTemplateParameter.strName = model.MemName;
                                                smsTemplateParameter.dclTempMoney = num4;
                                                smsTemplateParameter.dclMoney = model.MemMoney;
                                                smsTemplateParameter.intTempPoint = point;
                                                smsTemplateParameter.intPoint = model.MemPoint;
                                                smsTemplateParameter.OldLevelID = memLevelID;
                                                model = new Chain.BLL.Mem().GetModel(memID);
                                                smsTemplateParameter.NewLevelID = model.MemLevelID;
                                                string content = SMSInfo.GetSendContent(5, smsTemplateParameter, shopID);
                                                SMSInfo.Send_GXSMS(model.MemMobile, content, "");
                                                Chain.Model.SmsLog log = new Chain.Model.SmsLog();
                                                log.SmsMemID = model.MemID;
                                                log.SmsMobile = model.MemMobile;
                                                log.SmsContent = content;
                                                log.SmsTime = DateTime.Now;
                                                log.SmsShopID = shopID;
                                                log.SmsUserID = userID;
                                                log.SmsAmount = PubFunction.GetSmsAmount(content);
                                                log.SmsAllAmount = log.SmsAmount;
                                                new Chain.BLL.SmsLog().Add(log);
                                                PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length, 2);
                                            }
                                            else
                                            {
                                                s = "-5";
                                            }
                                        }
                                    }
                                    PubFunction.SaveSysLog(userID, 4, "会员消费", detail, shopID, DateTime.Now, PubFunction.ipAdress);
                                }
                            }
                            else
                            {
                                s = "-3";
                                PubFunction.SaveSysLog(userID, 4, "会员消费", detail, shopID, DateTime.Now, PubFunction.ipAdress);
                            }
                        }
                        else if ((num17 > 0) && (memID == 0))
                        {
                            PubFunction.SaveSysLog(userID, 4, "散客消费", detail, shopID, DateTime.Now, PubFunction.ipAdress);
                            s = "{\"Success\":\"" + num15 + "\",\"strUpdateMemLevel\":\"\"}";
                        }
                    }
                }
                else
                {
                    s = "-6";
                }
            }
            catch (Exception)
            {
                s = "-1";
            }
            this.Context.Response.Write(s);
        }

        public void GoodsIn()
        {
            int num = 0;
            try
            {
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                string str = this.Request["goodsAccount"].ToString();
                int num4 = int.Parse(this.Request["count"].ToString());
                int num5 = int.Parse(this.Request["shopID"].ToString());
                string str2 = (this.Request["remark"] != "") ? this.Request["remark"].ToString() : "";
                DateTime time = DateTime.Parse(this.Request["time"].ToString());
                decimal num6 = (this.Request["totalMoney"] != "") ? decimal.Parse(this.Request["totalMoney"].ToString()) : 0M;
                this.modelGoodsLog.GoodsAccount = str;
                this.modelGoodsLog.Type = 1;
                this.modelGoodsLog.TotalPrice = num6;
                this.modelGoodsLog.InShopID = num5;
                this.modelGoodsLog.OutShopID = num5;
                this.modelGoodsLog.Remark = str2;
                this.modelGoodsLog.CreateTime = time;
                this.modelGoodsLog.ShopID = shopID;
                this.modelGoodsLog.UserID = userID;
                int num7 = this.bllGoodsLog.Add(this.modelGoodsLog);
                for (int i = 0; i < num4; i++)
                {
                    this.modelNumber.GoodsID = int.Parse(this.Request["data[" + i + "][GoodsID]"]);
                    this.modelNumber.ShopID = num5;
                    this.modelNumber.Number = int.Parse(this.Request["data[" + i + "][Number]"]);
                    this.bllNumber.UpdataGoodsNumber(this.modelNumber);
                    this.modelGoodsDetail.GoodsLogID = num7;
                    this.modelGoodsDetail.GoodsID = this.modelNumber.GoodsID;
                    this.modelGoodsDetail.GoodsInPrice = decimal.Parse(this.Request["data[" + i + "][InMoney]"]);
                    this.modelGoodsDetail.GoodsOutPrice = 0M;
                    this.modelGoodsDetail.GoodsNumber = this.modelNumber.Number;
                    num = this.bllGoodsDetail.Add(this.modelGoodsDetail);
                    if (num > 0)
                    {
                        PubFunction.SaveSysLog(userID, 4, "商品入库", string.Concat(new object[] { "商品批量入库,入库单号:[", str, "],入库时间:[", time, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void GoodsLogPrinting()
        {
            string s = "";
            string str2 = "";
            string str3 = "";
            int num = int.Parse(this.Request["id"]);
            StringBuilder builder = new StringBuilder();
            DataTable dt = this.bllGoodsLog.GetList(" ID=" + num).Tables[0];
            if (dt != null)
            {
                str2 = JsonPlus.ToJson(dt, "");
                s = "{\"strGoodsLog\":" + str2 + "}";
                DataTable table2 = this.bllGoodsDetail.getGoodsLogDetail(" GoodsLogDetail.GoodsLogID=" + num).Tables[0];
                if (table2 != null)
                {
                    str3 = JsonPlus.ToJson(table2, "");
                }
                s = "{\"strGoodsLog\":" + str2 + ",\"strGoodsLogDetail\":" + str3 + "}";
            }
            this.Context.Response.Write(s);
        }

        public void GroupdDel()
        {
            int num = 0;
            try
            {
                int groupID = int.Parse(this.Request["groupID"]);
                Chain.BLL.SysGroup group = new Chain.BLL.SysGroup();
                Chain.Model.SysGroup model = new Chain.BLL.SysGroup().GetModel(groupID);
                Chain.BLL.SysGroupAuthority authority = new Chain.BLL.SysGroupAuthority();
                DataTable table = new Chain.BLL.SysUser().GetList(" UserGroupID=" + groupID).Tables[0];
                int num3 = int.Parse(this.Session["UID"].ToString());
                int num4 = int.Parse(this.Session["UserShopID"].ToString());
                if (table.Rows.Count > 0)
                {
                    num = -2;
                }
                else
                {
                    DataTable table2 = group.GetList(string.Format(" FatherGroupID = '{0}'", groupID)).Tables[0];
                    if (table2.Rows.Count > 0)
                    {
                        num = -4;
                    }
                    else
                    {
                        group.Delete(groupID);
                        authority.DeleteList(groupID);
                        Chain.Model.SysLog log = new Chain.Model.SysLog();
                        log.LogShopID = num4;
                        log.LogUserID = num3;
                        log.LogActionID = 8;
                        log.LogCreateTime = DateTime.Now;
                        log.LogDetail = "删除角色成功,角色名称:" + model.GroupName;
                        new Chain.BLL.SysLog().Add(log);
                        num = 1;
                    }
                }
            }
            catch (Exception)
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void MemAdd()
        {
            int num = 0;
            string str = (this.Request["txtMemID"] != "") ? this.Request["txtMemID"].ToString() : "";
            try
            {
                string str2 = "";
                string memCard = (this.Request["txtMemCard"].ToString() != "") ? this.Request["txtMemCard"].ToString() : "";
                string str4 = (this.Request["txtMemName"].ToString() != "") ? this.Request["txtMemName"].ToString() : "";
                str2 = (this.Request["txtMemPassword"].ToString() != "") ? this.Request["txtMemPassword"].ToString() : "";
                int intMemSex = (this.Request["sltMemSex"].ToString() != "") ? int.Parse(this.Request["sltMemSex"].ToString()) : 0;
                string str5 = (this.Request["txtMemIdentityCard"].ToString() != "") ? this.Request["txtMemIdentityCard"].ToString() : "";
                string s = (this.Request["txtMemBirthday"].ToString() != "") ? this.Request["txtMemBirthday"].ToString() : "1900-1-1";
                string str7 = (this.Request["txtMemMobile"].ToString() != "") ? this.Request["txtMemMobile"].ToString() : "";
                int point = (this.Request["txtMemPoint"].ToString() != "") ? int.Parse(this.Request["txtMemPoint"].ToString()) : 0;
                decimal num4 = (this.Request["txtMemMoney"].ToString() != "") ? decimal.Parse(this.Request["txtMemMoney"].ToString()) : 0M;
                string str8 = (this.Request["txtMemEmail"].ToString() != "") ? this.Request["txtMemEmail"].ToString() : "";
                string str9 = (this.Request["txtMemAddress"].ToString() != "") ? this.Request["txtMemAddress"].ToString() : "";
                int num5 = (this.Request["sltMemState"].ToString() != "") ? int.Parse(this.Request["sltMemState"].ToString()) : -1;
                int levelID = (this.Request["sltMemLevelID"].ToString() != "") ? int.Parse(this.Request["sltMemLevelID"].ToString()) : 0;
                int shopID = (this.Request["sltMemShopID"].ToString() != "") ? int.Parse(this.Request["sltMemShopID"].ToString()) : 0;
                int num8 = (this.Request["txtMemRecommendID"].ToString() != "") ? int.Parse(this.Request["txtMemRecommendID"].ToString()) : 0;
                string str10 = (this.Request["txtMemCreateTime"].ToString() != "") ? this.Request["txtMemCreateTime"].ToString() : "1900-1-1";
                string str11 = (this.Request["txtMemPastTime"].ToString() != "") ? this.Request["txtMemPastTime"].ToString() : "2900-1-1";
                string str12 = (this.Request["txtMemPhoto"].ToString() != "") ? this.Request["txtMemPhoto"].ToString() : "";
                string str13 = (this.Request["txtMemRemark"].ToString() != "") ? this.Request["txtMemRemark"].ToString() : "";
                int userID = (this.Request["sltMemUserID"].ToString() != "") ? int.Parse(this.Request["sltMemUserID"].ToString()) : 0;
                string str14 = (this.Request["txtTelephone"].ToString() != "") ? this.Request["txtTelephone"].ToString() : "";
                bool flag = (this.Request["chkSMS"] != null) && (this.Request["chkSMS"] == "on");
                bool flag2 = (this.Request["chkMMS"] != null) && (this.Request["chkMMS"] == "on");
                string str15 = (this.Request["hidImgSrc"] != "") ? this.Request["hidImgSrc"].ToString() : "";
                string detail = "会员登记,会员卡号:[" + memCard + "],姓名:[" + str4 + "],会员等级:[" + PubFunction.LevelIDToName(levelID) + "]";
                string str17 = this.Request["ucSysArea$sltProvince"].ToString();
                string str18 = this.Request["ucSysArea$sltCity"].ToString();
                string str19 = this.Request["ucSysArea$sltCounty"].ToString();
                string str20 = this.Request["ucSysArea$sltVillage"].ToString();
                string memCardNumber = !string.IsNullOrEmpty(this.Request["txtCardNumber"]) ? this.Request["txtCardNumber"].ToString() : "";
                Chain.Model.Mem model = new Chain.Model.Mem();
                model.MemCard = memCard.Trim();
                model.MemName = str4.Trim();
                model.MemPassword = DESEncrypt.Encrypt(str2.Trim());
                model.MemSex = PubFunction.SetMemSex(intMemSex);
                model.MemIdentityCard = str5;
                DateTime result = new DateTime();
                DateTime.TryParse(s, out result);
                model.MemBirthday = result;
                model.MemBirthdayType = true;
                model.MemMobile = str7.Trim();
                model.MemPoint = point;
                model.MemPointAutomatic = true;
                model.MemMoney = num4;
                model.MemConsumeMoney = 0M;
                model.MemEmail = str8.Trim();
                model.MemAddress = str9;
                model.MemState = num5;
                model.MemLevelID = levelID;
                model.MemShopID = shopID;
                model.MemRecommendID = num8;
                DateTime time2 = new DateTime();
                DateTime.TryParse(str11, out time2);
                model.MemPastTime = time2;
                if (time2 > DateTime.Now)
                {
                    model.MemIsPast = false;
                }
                model.MemPhoto = str12.Trim();
                DateTime time3 = new DateTime();
                DateTime.TryParse(str10, out time3);
                model.MemCreateTime = time3;
                model.MemRemark = str13;
                model.MemUserID = userID;
                model.MemTelePhone = str14;
                model.MemQRCode = str15;
                model.MemProvince = str17;
                model.MemCity = str18;
                model.MemCounty = str19;
                model.MemVillage = str20;
                model.MemCardNumber = memCardNumber;
                Chain.BLL.Mem mem2 = new Chain.BLL.Mem();
                PubFunction.IsShopPoint(shopID, ref point);
                model.MemPoint = point;
                if (PubFunction.IsCanRegisterCard(shopID, memCard, memCardNumber))
                {
                    num = mem2.AddMemFirst(model);
                    PubFunction.SetShopPoint(userID, shopID, point, "会员登记初始化会员积分", 2);
                }
                else
                {
                    num = -7;
                }
                if (num > 0)
                {
                    this.MemRecommendPoint(model, shopID, userID);
                    DataRow[] rowArray = new Chain.BLL.MemCustomField().CustomGetList(" CustomType=1 ");
                    Hashtable customhash = new Hashtable();
                    if (rowArray.Length > 0)
                    {
                        foreach (DataRow row in rowArray)
                        {
                            customhash.Add(row["CustomField"].ToString(), this.Request["Mem_Custom_" + row["CustomField"].ToString()]);
                        }
                        mem2.AddCustomField(model.MemCard, customhash);
                    }
                    if (point != 0)
                    {
                        Chain.Model.PointLog log = new Chain.Model.PointLog();
                        log.PointMemID = num;
                        log.PointNumber = point;
                        log.PointChangeType = 5;
                        log.PointRemark = "会员初始化增加积分,积分变动:" + point.ToString();
                        log.PointShopID = shopID;
                        log.PointCreateTime = DateTime.Now;
                        log.PointUserID = userID;
                        log.PointOrderCode = PubFunction.curParameter.strMemPointChangePrefix + DateTime.Now.ToString("yyMMddHHmmssffff");
                        new Chain.BLL.PointLog().Add(log);
                    }
                    if (num4 != 0M)
                    {
                        Chain.Model.MemRecharge recharge = new Chain.Model.MemRecharge();
                        recharge.RechargeMemID = num;
                        recharge.RechargeType = 1;
                        recharge.RechargeMoney = num4;
                        recharge.RechargeRemark = "会员初始化充值,充值金额:" + num4.ToString();
                        recharge.RechargeShopID = shopID;
                        recharge.RechargeCreateTime = DateTime.Now;
                        recharge.RechargeAccount = PubFunction.curParameter.strMemRechargePrefix + DateTime.Now.ToString("yyMMddHHmmssffff");
                        recharge.RechargeUserID = userID;
                        recharge.RechargeCardBalance = num4;
                        recharge.RechargeIsApprove = true;
                        new Chain.BLL.MemRecharge().Add(recharge);
                    }
                    if (flag)
                    {
                        if (Convert.ToInt32(SMSInfo.GetBalance(false)) <= 0)
                        {
                            num = -3;
                        }
                        else if (PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length))
                        {
                            SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                            smsTemplateParameter.strCardID = model.MemCard;
                            smsTemplateParameter.strName = model.MemName;
                            smsTemplateParameter.dclMoney = num4;
                            smsTemplateParameter.dclTempMoney = num4;
                            smsTemplateParameter.intTempPoint = point;
                            smsTemplateParameter.intPoint = point;
                            smsTemplateParameter.OldLevelID = levelID;
                            smsTemplateParameter.NewLevelID = levelID;
                            string content = SMSInfo.GetSendContent(1, smsTemplateParameter, model.MemShopID);
                            SMSInfo.Send_GXSMS(model.MemMobile, content, "");
                            Chain.Model.SmsLog log3 = new Chain.Model.SmsLog();
                            log3.SmsMemID = model.MemID;
                            log3.SmsMobile = model.MemMobile;
                            log3.SmsContent = content;
                            log3.SmsTime = DateTime.Now;
                            log3.SmsShopID = model.MemShopID;
                            log3.SmsUserID = model.MemUserID;
                            log3.SmsAmount = PubFunction.GetSmsAmount(content);
                            log3.SmsAllAmount = log3.SmsAmount;
                            new Chain.BLL.SmsLog().Add(log3);
                            PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length, 2);
                        }
                        else
                        {
                            num = -5;
                        }
                    }
                    if (flag2)
                    {
                        string strMMSSeries = PubFunction.curParameter.strMMSSeries;
                        string strMMSSerialPwd = PubFunction.curParameter.strMMSSerialPwd;
                        string str25 = memCard.Trim();
                        string mobile = str7;
                        string subject = "会员" + str4 + "二维码卡号";
                        if (int.Parse(WebTest.SendMessage.GetBalance(strMMSSeries, strMMSSerialPwd)) > 0)
                        {
                            string str28 = WebTest.SendMessage.SendMMSToWG(strMMSSeries, strMMSSerialPwd, mobile, subject, str25);
                        }
                    }
                    PubFunction.SaveSysLog(userID, 1, "会员登记", detail, shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void MemCheckPwd()
        {
            int num = 0;
            int memID = (this.Request["memID"].ToString() != "") ? int.Parse(this.Request["memID"].ToString()) : 0;
            string str = this.Request["memPassword"].ToString();
            Chain.Model.Mem mem = new Chain.Model.Mem();
            Chain.BLL.Mem mem2 = new Chain.BLL.Mem();
            if (mem2.GetModel(memID).MemPassword == DESEncrypt.Encrypt(str.Trim()))
            {
                num = 1;
            }
            this.Context.Response.Write(num);
        }

        public void MemCount()
        {
            string s = "0";
            try
            {
                int memID = (this.Request["MemID"].ToString() != "") ? int.Parse(this.Request["MemID"].ToString()) : 0;
                decimal num2 = (this.Request["Money"].ToString() != "") ? decimal.Parse(this.Request["Money"].ToString()) : 0M;
                decimal num3 = (this.Request["DiscountMoney"].ToString() != "") ? decimal.Parse(this.Request["DiscountMoney"].ToString()) : 0M;
                int point = (this.Request["Point"].ToString() != "") ? int.Parse(this.Request["Point"].ToString()) : 0;
                decimal num5 = (this.Request["parameter[0][CardMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CardMoney]"]) : 0M;
                decimal num6 = (this.Request["parameter[0][CashMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CashMoney]"]) : 0M;
                decimal num7 = (this.Request["parameter[0][BinkMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][BinkMoney]"]) : 0M;
                decimal num8 = (this.Request["parameter[0][CouponMoney]"] != "0") ? decimal.Parse(this.Request["parameter[0][CouponMoney]"]) : 0M;
                string str2 = this.Request["OrderTime"].ToString();
                string str3 = this.Request["orderAccount"].ToString();
                string str4 = (this.Request["Remark"].ToString() != "") ? this.Request["remark"].ToString() : "无";
                bool flag = this.Request["IsSMS"] == "true";
                bool flag2 = bool.Parse(this.Request["parameter[0][IsCard]"]);
                bool flag3 = bool.Parse(this.Request["parameter[0][IsCash]"]);
                bool flag4 = bool.Parse(this.Request["parameter[0][IsBink]"]);
                int num9 = (this.Request["DataCount"].ToString() != "") ? int.Parse(this.Request["DataCount"].ToString()) : 0;
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int num12 = 0;
                if (PubFunction.IsShopPoint(shopID, ref point))
                {
                    Chain.Model.MemCount model = new Chain.Model.MemCount();
                    model.CountMemID = memID;
                    model.CountAccount = str3;
                    model.CountTotalMoney = num2;
                    model.CountDiscountMoney = num3;
                    model.CountPoint = point;
                    model.CountIsCard = flag2;
                    model.CountPayCard = num5;
                    model.CountIsCash = flag3;
                    model.CountPayCash = num6;
                    model.CountIsBink = flag4;
                    model.CountPayBink = num7;
                    model.CountPayCoupon = num8;
                    model.CountCreateTime = DateTime.Parse(str2);
                    model.CountPayType = num12;
                    model.CountPayCoupon = num8;
                    model.CountRemark = str4;
                    model.CountShopID = shopID;
                    model.CountUserID = userID;
                    int num13 = new Chain.BLL.MemCount().Add(model);
                    if (num13 > 0)
                    {
                        for (int i = 0; i < num9; i++)
                        {
                            Chain.Model.MemCountDetail detail = new Chain.Model.MemCountDetail();
                            detail.CountDetailCountID = num13;
                            detail.CountDetailGoodsID = int.Parse(this.Request["Data[" + i + "][GoodsID]"]);
                            detail.CountDetailMemID = memID;
                            detail.CountDetailDiscountMoney = decimal.Parse(this.Request["Data[" + i + "][ExpMoney]"]);
                            detail.CountDetailTotalNumber = int.Parse(this.Request["Data[" + i + "][ExpNum]"]);
                            detail.CountDetailNumber = int.Parse(this.Request["Data[" + i + "][ExpNum]"]);
                            detail.CountDetailPoint = int.Parse(this.Request["Data[" + i + "][ExpPoint]"]);
                            detail.CountCreateTime = DateTime.Now;
                            new Chain.BLL.MemCountDetail().Add(detail);
                        }
                        Chain.BLL.Mem mem = new Chain.BLL.Mem();
                        Chain.Model.Mem mem2 = mem.GetModel(memID);
                        int memLevelID = mem2.MemLevelID;
                        this.modelPoint.PointMemID = memID;
                        this.modelPoint.PointNumber = point;
                        this.modelPoint.PointChangeType = 3;
                        this.modelPoint.PointRemark = string.Concat(new object[] { "会员充次成功,消费总额:[", num3, "],获得积分", point });
                        this.modelPoint.PointShopID = shopID;
                        this.modelPoint.PointUserID = userID;
                        this.modelPoint.PointCreateTime = DateTime.Parse(str2);
                        this.modelPoint.PointOrderCode = str3;
                        if (this.bllPoint.Add(this.modelPoint) > 0)
                        {
                            decimal dclMemMoney = mem2.MemMoney - num5;
                            mem2.MemPoint += point;
                            int num17 = mem.MemCountUpdateMem(memID, dclMemMoney, mem2.MemPoint);
                            MEMPointUpdate.MEMPointRate(mem2, model.CountPoint, model.CountAccount, 3);
                            mem2 = new Chain.BLL.Mem().GetModel(memID);
                            string str5 = PubFunction.UpdateMemLevel(mem2);
                            PubFunction.SetShopPoint(userID, shopID, point, "会员充次扣除店铺积分", 2);
                            s = "{\"strUpdateMemLevel\":\"" + str5 + "\"}";
                            if (flag)
                            {
                                if (Convert.ToInt32(SMSInfo.GetBalance(false)) <= 0)
                                {
                                    s = "-2";
                                }
                                else if (mem2.MemMobile != "")
                                {
                                    if (PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), mem2.MemMobile.Split(new char[] { ',' }).Length))
                                    {
                                        SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                                        smsTemplateParameter.strCardID = mem2.MemCard;
                                        smsTemplateParameter.strName = mem2.MemName;
                                        smsTemplateParameter.dclTempMoney = num3;
                                        smsTemplateParameter.dclMoney = mem2.MemMoney;
                                        smsTemplateParameter.intTempPoint = point;
                                        smsTemplateParameter.intPoint = mem2.MemPoint;
                                        smsTemplateParameter.OldLevelID = memLevelID;
                                        mem2 = new Chain.BLL.Mem().GetModel(memID);
                                        smsTemplateParameter.NewLevelID = mem2.MemLevelID;
                                        string content = SMSInfo.GetSendContent(5, smsTemplateParameter, shopID);
                                        SMSInfo.Send_GXSMS(mem2.MemMobile, content, "");
                                        Chain.Model.SmsLog log = new Chain.Model.SmsLog();
                                        log.SmsMemID = mem2.MemID;
                                        log.SmsMobile = mem2.MemMobile;
                                        log.SmsContent = content;
                                        log.SmsTime = DateTime.Now;
                                        log.SmsShopID = shopID;
                                        log.SmsUserID = userID;
                                        log.SmsAmount = PubFunction.GetSmsAmount(content);
                                        log.SmsAllAmount = log.SmsAmount;
                                        new Chain.BLL.SmsLog().Add(log);
                                        PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), mem2.MemMobile.Split(new char[] { ',' }).Length, 2);
                                    }
                                    else
                                    {
                                        s = "-5";
                                    }
                                }
                            }
                            string str7 = string.Concat(new object[] { "会员充次,会员卡号:[", mem2.MemCard, "],姓名:[", mem2.MemName, "],订单号:[", str3, "],消费金额:[", num3, "],获得积分:[", point, "],备注:", str4 });
                            PubFunction.SaveSysLog(userID, 4, "会员充次", str7, shopID, DateTime.Now, PubFunction.ipAdress);
                        }
                    }
                }
                else
                {
                    s = "-6";
                }
            }
            catch
            {
                s = "-1";
            }
            this.Context.Response.Write(s);
        }

        public void MemDelete()
        {
            int num = 0;
            try
            {
                int memID = (this.Request["strMemID"].ToString() != "") ? int.Parse(this.Request["strMemID"].ToString()) : 0;
                int userID = (this.Session["UID"].ToString() != "") ? int.Parse(this.Session["UID"].ToString()) : -1;
                int shopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem model = new Chain.Model.Mem();
                model = mem.GetModel(memID);
                DataTable table = mem.GetList(" MemRecommendID=" + memID).Tables[0];
                Chain.BLL.MemRecharge recharge = new Chain.BLL.MemRecharge();
                DataTable table2 = recharge.GetList(" RechargeMemID=" + memID).Tables[0];
                Chain.BLL.OrderLog log = new Chain.BLL.OrderLog();
                DataTable table3 = log.GetList(" OrderMemID=" + memID).Tables[0];
                Chain.BLL.PointExchange exchange = new Chain.BLL.PointExchange();
                DataTable table4 = exchange.GetList(" ExchangeMemID=" + memID).Tables[0];
                Chain.BLL.PointLog log2 = new Chain.BLL.PointLog();
                DataTable table5 = log2.GetList(" PointMemID=" + memID).Tables[0];
                Chain.BLL.ScreenPopUp up = new Chain.BLL.ScreenPopUp();
                DataTable table6 = up.GetList(" CallerMemID=" + memID).Tables[0];
                Chain.BLL.SmsLog log3 = new Chain.BLL.SmsLog();
                DataTable table7 = log3.GetList(" SmsMemID=" + memID).Tables[0];
                if (table.Rows.Count > 0)
                {
                    num = 1;
                }
                else if (table2.Rows.Count > 0)
                {
                    num = 2;
                }
                else if (table3.Rows.Count > 0)
                {
                    num = 3;
                }
                else if (table4.Rows.Count > 0)
                {
                    num = 4;
                }
                else if (table5.Rows.Count > 0)
                {
                    num = 5;
                }
                else if (table6.Rows.Count > 0)
                {
                    num = 6;
                }
                else if (table7.Rows.Count > 0)
                {
                    num = 7;
                }
                else if (mem.Delete(memID))
                {
                    num = 8;
                    PubFunction.SaveSysLog(userID, 2, "会员删除", "删除会员,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void MemEdit()
        {
            int num = 0;
            string str2 = (this.Request["txtMemID"] != "") ? this.Request["txtMemID"].ToString() : "";
            try
            {
                Chain.Model.Mem model = new Chain.Model.Mem();
                int memID = (this.Request["txtMemID"].ToString() != "") ? int.Parse(this.Request["txtMemID"].ToString()) : 0;
                string memCard = (this.Request["txtMemCard"].ToString() != "") ? this.Request["txtMemCard"].ToString() : "";
                string str4 = (this.Request["txtMemName"].ToString() != "") ? this.Request["txtMemName"].ToString() : "";
                int num3 = (this.Request["sltMemSex"].ToString() != "") ? int.Parse(this.Request["sltMemSex"].ToString()) : 0;
                string str5 = (this.Request["txtMemIdentityCard"].ToString() != "") ? this.Request["txtMemIdentityCard"].ToString() : "";
                string s = (this.Request["txtMemBirthday"].ToString() != "") ? this.Request["txtMemBirthday"].ToString() : "1900-1-1";
                string str7 = (this.Request["txtMemMobile"].ToString() != "") ? this.Request["txtMemMobile"].ToString() : "";
                int num4 = (this.Request["txtMemPoint"].ToString() != "") ? int.Parse(this.Request["txtMemPoint"].ToString()) : 0;
                decimal num5 = (this.Request["txtMemMoney"].ToString() != "") ? decimal.Parse(this.Request["txtMemMoney"].ToString()) : 0M;
                string str8 = (this.Request["txtMemEmail"].ToString() != "") ? this.Request["txtMemEmail"].ToString() : "";
                string str9 = (this.Request["txtMemAddress"].ToString() != "") ? this.Request["txtMemAddress"].ToString() : "";
                int num6 = (this.Request["sltMemState"].ToString() != "") ? int.Parse(this.Request["sltMemState"].ToString()) : 0;
                int num7 = (this.Request["sltMemLevelID"].ToString() != "") ? int.Parse(this.Request["sltMemLevelID"].ToString()) : 0;
                int shopID = (this.Request["sltMemShopID"].ToString() != "") ? int.Parse(this.Request["sltMemShopID"].ToString()) : 0;
                string str10 = (this.Request["txtMemCreateTime"].ToString() != "") ? this.Request["txtMemCreateTime"].ToString() : "1900-1-1";
                int num9 = (this.Request["txtMemRecommendID"].ToString() != "") ? int.Parse(this.Request["txtMemRecommendID"].ToString()) : 0;
                string str11 = (this.Request["txtMemPastTime"].ToString() != "") ? this.Request["txtMemPastTime"].ToString() : "2900-1-1";
                string str12 = (this.Request["txtMemPhoto"].ToString() != "") ? this.Request["txtMemPhoto"].ToString() : "";
                string str13 = (this.Request["txtMemRemark"].ToString() != "") ? this.Request["txtMemRemark"].ToString() : "";
                int userID = (this.Request["sltMemUserID"].ToString() != "") ? int.Parse(this.Request["sltMemUserID"].ToString()) : 0;
                string str14 = (this.Request["txtTelephone"].ToString() != "") ? this.Request["txtTelephone"].ToString() : "";
                string str15 = this.Request["ucSysArea$sltProvince"].ToString();
                string str16 = this.Request["ucSysArea$sltCity"].ToString();
                string str17 = this.Request["ucSysArea$sltCounty"].ToString();
                string str18 = this.Request["ucSysArea$sltVillage"].ToString();
                model = new Chain.BLL.Mem().GetModel(memID);
                if (str10 != model.MemCreateTime.ToShortDateString())
                {
                    Chain.BLL.SysLog log = new Chain.BLL.SysLog();
                    DataTable table = log.GetActionList(memCard).Tables[0];
                    if (table.Rows.Count > 0)
                    {
                        num = -4;
                    }
                }
                if (num != -4)
                {
                    model.MemID = memID;
                    model.MemCard = memCard.Trim();
                    model.MemName = str4.Trim();
                    if (num3 == 0)
                    {
                        model.MemSex = true;
                    }
                    else
                    {
                        model.MemSex = false;
                    }
                    model.MemIdentityCard = str5;
                    DateTime result = new DateTime();
                    DateTime.TryParse(s, out result);
                    model.MemBirthday = result;
                    model.MemMobile = str7.Trim();
                    model.MemPoint = num4;
                    model.MemMoney = num5;
                    model.MemEmail = str8.Trim();
                    model.MemAddress = str9;
                    model.MemCreateTime = DateTime.Parse(str10);
                    model.MemState = num6;
                    model.MemLevelID = num7;
                    model.MemShopID = shopID;
                    DateTime time2 = new DateTime();
                    DateTime.TryParse(str11, out time2);
                    model.MemPastTime = time2;
                    if (time2 > DateTime.Now)
                    {
                        model.MemIsPast = false;
                    }
                    model.MemRecommendID = num9;
                    model.MemPhoto = str12.Trim();
                    model.MemRemark = str13;
                    model.MemUserID = userID;
                    model.MemTelePhone = str14;
                    model.MemProvince = str15;
                    model.MemCity = str16;
                    model.MemCounty = str17;
                    model.MemVillage = str18;
                    Chain.BLL.Mem mem2 = new Chain.BLL.Mem();
                    num = mem2.UpdateMem(model);
                    if (num > 0)
                    {
                        DataRow[] rowArray = new Chain.BLL.MemCustomField().CustomGetList(" CustomType=1 ");
                        Hashtable customhash = new Hashtable();
                        if (rowArray.Length > 0)
                        {
                            foreach (DataRow row in rowArray)
                            {
                                customhash.Add(row["CustomField"].ToString(), this.Request["Mem_Custom_" + row["CustomField"].ToString()]);
                            }
                            mem2.AddCustomField(model.MemCard, customhash);
                        }
                        PubFunction.SaveSysLog(userID, 3, "会员编辑", "编辑会员,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void MemExpenseShopList()
        {
            int num = 0;
            try
            {
                int memID = Convert.ToInt32(this.Request["MemID"]);
                string strAuthority = this.Request["List"].ToString();
                if (strAuthority != "")
                {
                    strAuthority = "," + strAuthority;
                }
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                if (mem.UpdateMemExpenseShop(strAuthority, memID) > 0)
                {
                    num = 1;
                }
            }
            catch
            {
                num = 2;
            }
            this.Context.Response.Write(num);
        }

        public void MemInfoCoupon()
        {
            string s = "";
            try
            {
                string str2 = this.Request["key"].ToString();
                int intShopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
                StringBuilder builder = new StringBuilder();
                builder.AppendFormat("(MemCard='{0}' or MemName ='{0}' or  MemMobile='{0}') ", str2);
                builder.AppendFormat(" and Mem.MemID=CouponList.CouPonMID ", new object[0]);
                int resCount = 0;
                DataTable dt = new Chain.BLL.CouponList().GetMemInfoListSP(0x3e8, 1, out resCount, new string[] { PubFunction.GetShopAuthority(intShopID, "MemShopID", builder.ToString()) }).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "CID,CouPonID,CouPon,CouPonYF,CouPonSY,CouPonMID,ConPonSendTime,ConPonUseTime,CouPonOrderAccount");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void MemInfoExchangeGift()
        {
            string s = "";
            string str2 = "";
            string str3 = this.Request["key"].ToString();
            int intShopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
            StringBuilder builder = new StringBuilder();
            Chain.BLL.PointExchange exchange = new Chain.BLL.PointExchange();
            builder.AppendFormat("(MemCard='{0}' or MemName ='{0}' or  MemMobile='{0}') ", str3);
            builder.Append(" and GiftExchange.ExchangeStatus=2 and GiftExchange.MemID=Mem.MemID and GiftExchange.ExchangeUserID = SysUser.UserID and Mem.MemShopID = SysShop.ShopID ");
            int resCount = 0;
            DataTable dt = exchange.GetListSP(50, 1, out resCount, new string[] { PubFunction.GetShopAuthority(intShopID, "MemShopID", builder.ToString()) }).Tables[0];
            if (dt != null)
            {
                str2 = JsonPlus.ToJson(dt, "ExchangeAccount,MemCard,MemName,ExchangeAllNumber,ExchangeAllPoint,ApplicationTime,ExchangeTime,ShopName,UserName,ExchangeType,ExchangeID,ExchangeStatus");
                s = "{\"MemInfoExchangeGift\":" + str2 + "}";
            }
            this.Context.Response.Write(s);
        }

        public void MemInfoExpense()
        {
            int num4;
            string s = "";
            string str2 = "";
            string str3 = this.Request["key"].ToString();
            int pageSize = int.Parse(this.Request["size"].ToString());
            int pageIndex = int.Parse(this.Request["index"].ToString());
            int intShopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
            StringBuilder builder = new StringBuilder();
            Chain.BLL.Mem mem = new Chain.BLL.Mem();
            builder.AppendFormat("(MemCard='{0}' or MemName ='{0}' or  MemMobile='{0}') ", str3);
            builder.Append(" and OrderType!=3 ");
            builder.Append("  and OrderLog.OrderShopID = SysShop.ShopID and OrderLog.OrderMemID = Mem.MemID  and OrderLog.OrderUserID = SysUser.UserID");
            DataTable dt = this.bllOrderLog.GetListSP(pageSize, pageIndex, out num4, new string[] { PubFunction.GetShopAuthority(intShopID, "OrderShopID", builder.ToString()) }).Tables[0];
            if (dt != null)
            {
                str2 = JsonPlus.ToJson(dt, "MemCard,MemName,OrderAccount,OrderTotalMoney,OrderDiscountMoney,OrderPoint,OrderCreateTime,ShopName,UserName,OrderType,OrderID");
                s = string.Concat(new object[] { "{\"MemInfoExpense\":", str2, ",\"RecordCount\":", num4, "}" });
            }
            this.Context.Response.Write(s);
        }

        public void MemInfoMobile()
        {
            string s = "";
            try
            {
                string str2 = this.Request["key"].ToString();
                int intShopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
                StringBuilder builder = new StringBuilder();
                builder.AppendFormat("(MemCard='{0}' or MemName ='{0}' or  MemMobile='{0}') ", str2);
                int resCount = 0;
                DataTable dt = new Chain.BLL.ScreenPopUp().GetScreenPopUpList(0x3e8, 1, out resCount, new string[] { PubFunction.GetShopAuthority(intShopID, "CallerShopID", builder.ToString()) }).Tables[0];
                if (dt != null)
                {
                    s = JsonPlus.ToJson(dt, "CallerID,CallerMemID,CallerIsMem,CallerState,CallerDuration,CallerRemark,CallerCreateTime,MemMobile,CallerMobile,ShopID,UserID,MemID,MemCard,MemName,UserName,ShopName");
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void MemInfoRecharge()
        {
            string s = "";
            string str2 = "";
            string str3 = this.Request["key"].ToString();
            int intShopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
            StringBuilder builder = new StringBuilder();
            Chain.BLL.MemRecharge recharge = new Chain.BLL.MemRecharge();
            builder.AppendFormat("(MemCard='{0}' or MemName ='{0}' or  MemMobile='{0}') ", str3);
            builder.Append(" and MemRecharge.RechargeShopID = SysShop.ShopID and MemRecharge.RechargeMemID = Mem.MemID and Mem.MemLevelID=MemLevel.LevelID and MemRecharge.RechargeUserID = SysUser.UserID");
            int resCount = 0;
            DataTable dt = recharge.GetListSP(50, 1, out resCount, new string[] { PubFunction.GetShopAuthority(intShopID, "RechargeShopID", builder.ToString()) }).Tables[0];
            if (dt != null)
            {
                str2 = JsonPlus.ToJson(dt, "MemCard,MemName,RechargeAccount,RechargeMoney,RechargeRemark,RechargeCreateTime,ShopName,UserName");
                s = "{\"MemInfoRecharge\":" + str2 + "}";
            }
            this.Context.Response.Write(s);
        }

        public void MemInfoRechargeCount()
        {
            string s = "";
            try
            {
                int num4;
                string str2 = "";
                string str3 = this.Request["key"].ToString();
                int pageSize = int.Parse(this.Request["size"].ToString());
                int pageIndex = int.Parse(this.Request["index"].ToString());
                int intShopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
                StringBuilder builder = new StringBuilder();
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                builder.AppendFormat("(MemCard='{0}' or MemName ='{0}' or  MemMobile='{0}') ", str3);
                builder.Append("  and MemCount.CountShopID = SysShop.ShopID and MemCount.CountMemID = Mem.MemID and Mem.MemLevelID=MemLevel.LevelID and MemCount.CountUserID = SysUser.UserID ");
                DataTable dt = new Chain.BLL.MemCount().GetListSP(pageSize, pageIndex, out num4, new string[] { PubFunction.GetShopAuthority(intShopID, "CountShopID", builder.ToString()) }).Tables[0];
                if (dt != null)
                {
                    str2 = JsonPlus.ToJson(dt, "MemCard,MemName,ShopName,CountID,CountMemID,CountAccount,CountTotalMoney,CountDiscountMoney,CountPayCard,CountPayCash,CountPayCoupon,CountPayType,CountPoint,CountRemark,CountShopID,CountCreateTime,CountUserID,UserName");
                    s = string.Concat(new object[] { "{\"MemInfoRechargeCount\":", str2, ",\"RecordCount\":", num4, "}" });
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void MemLevelAdd()
        {
            int num = 0;
            try
            {
                string str = this.Request["LevelName"].ToString();
                int num2 = int.Parse(this.Request["LevelPoint"].ToString());
                int num3 = int.Parse(this.Request["LevelDiscountPercent"].ToString());
                int num4 = int.Parse(this.Request["LevelPointPercent"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                Chain.Model.MemLevel model = new Chain.Model.MemLevel();
                model.LevelName = str;
                model.LevelPoint = num2;
                model.LevelDiscountPercent = decimal.Parse(num3.ToString()) / 100M;
                if (num4 != 0)
                {
                    model.LevelPointPercent = 1M / decimal.Parse(num4.ToString());
                }
                else
                {
                    model.LevelPointPercent = 0M;
                }
                model.LevellLock = Convert.ToBoolean(this.Request["LevellLock"]);
                num = new Chain.BLL.MemLevel().Add(model);
                if (num != 0)
                {
                    model.LevelID = num;
                    new Chain.BLL.GoodsClassDiscount().InitGoodsLevelDiscountByMemLevelID(model);
                    new Chain.BLL.SysShopMemLevel().AddShopLevelByMemAdd(model);
                }
                PubFunction.SaveSysLog(userID, 1, "会员等级", "增加会员等级,等级名称:[" + model.LevelName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
            }
            catch
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void MemLevelDelete()
        {
            int num = 0;
            try
            {
                int levelID = (this.Request["LevelID"].ToString() != "") ? int.Parse(this.Request["LevelID"].ToString()) : -1;
                int userID = (this.Session["UID"].ToString() != "") ? int.Parse(this.Session["UID"].ToString()) : -1;
                int shopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                DataTable table = mem.GetList(" MemLevelID = " + levelID).Tables[0];
                if (table.Rows.Count > 0)
                {
                    num = -1;
                }
                else
                {
                    Chain.Model.MemLevel model = new Chain.Model.MemLevel();
                    Chain.BLL.MemLevel level2 = new Chain.BLL.MemLevel();
                    model = level2.GetModel(levelID);
                    num = level2.Delete(levelID);
                    new Chain.BLL.GoodsClassDiscount().DelGoodsClassDiscountByMemLevelID(levelID);
                    new Chain.BLL.SysShopMemLevel().DeleteShopMemLevel(levelID);
                    PubFunction.SaveSysLog(userID, 2, "会员等级", "删除会员等级,等级名称:[" + model.LevelName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void MemLevelEdit()
        {
            int num = 0;
            try
            {
                int num2 = int.Parse(this.Request["LevelID"].ToString());
                string str = this.Request["LevelName"].ToString();
                int num3 = int.Parse(this.Request["LevelPoint"].ToString());
                int num4 = int.Parse(this.Request["LevelDiscountPercent"].ToString());
                int num5 = int.Parse(this.Request["LevelPointPercent"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                Chain.Model.MemLevel model = new Chain.Model.MemLevel();
                model.LevelID = num2;
                model.LevelName = str;
                model.LevelPoint = num3;
                model.LevelDiscountPercent = decimal.Parse(num4.ToString()) / 100M;
                if (num5 != 0)
                {
                    model.LevelPointPercent = 1M / decimal.Parse(num5.ToString());
                }
                else
                {
                    model.LevelPointPercent = 0M;
                }
                model.LevellLock = Convert.ToBoolean(this.Request["LevellLock"]);
                num = new Chain.BLL.MemLevel().Update(model);
                PubFunction.SaveSysLog(userID, 3, "会员等级", "编辑会员等级,等级名称:[" + model.LevelName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
            }
            catch
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void MemLock()
        {
            int num = -1;
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            int memID = (this.Request["memID"].ToString() != "") ? int.Parse(this.Request["memID"].ToString()) : 0;
            int state = (this.Request["state"].ToString() != "") ? int.Parse(this.Request["state"].ToString()) : 0;
            string str = (this.Request["remark"].ToString() != "") ? this.Request["remark"].ToString() : "无";
            try
            {
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem model = mem.GetModel(memID);
                num = mem.UpdateMemState(memID, state);
                PubFunction.SaveSysLog(userID, 3, "会员锁定", "会员状态修改,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "],备注:" + str, shopID, DateTime.Now, PubFunction.ipAdress);
            }
            catch
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void MemMessageDel()
        {
            int num = 0;
            try
            {
                int memID = int.Parse(this.Request["memID"]);
                string str = (this.Request["memName"] != "") ? this.Request["memName"] : "";
                this.modelMem = this.bllMem.GetModel(memID);
                if (this.bllMessage.MessageDel(memID) > 0)
                {
                    num = 1;
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 2, "会员留言", "卡号:[" + this.modelMem.MemCard + "]的会员留言全部删除", int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void MemOpinion()
        {
            int num = 0;
            try
            {
                string str = this.Request["ProposalContent"];
                int num2 = Convert.ToInt32(this.Request["MemID"]);
                string str2 = this.Request["MemMobile"];
                Chain.BLL.Proposal proposal = new Chain.BLL.Proposal();
                Chain.Model.Proposal model = new Chain.Model.Proposal();
                model.ProposalContent = str;
                model.MemID = new int?(num2);
                model.MemMobile = str2;
                model.ProposalTime = new DateTime?(DateTime.Now);
                num = proposal.Add(model);
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void MemPassTime()
        {
            string s = "";
            try
            {
                DataTable dt = this.bllMem.GetMemPastTime(string.Format(" and DATEDIFF(day,getdate(),MemPastTime) <= '{0}' ", this.Request["myday"].ToString()), int.Parse(this.Session["UserShopID"].ToString())).Tables[0];
                s = JsonPlus.ToJson(dt, "");
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void MemPointClear()
        {
            int num = 0;
            int memID = (this.Request["MemID"] != null) ? int.Parse(this.Request["MemID"].ToString()) : 0;
            Chain.BLL.Mem mem = new Chain.BLL.Mem();
            Chain.Model.Mem model = mem.GetModel(memID);
            if (mem.ClearMemberPoint(memID))
            {
                num = 1;
            }
            this.Context.Response.Write(num);
        }

        public void MemPointReset()
        {
            int num = 0;
            try
            {
                string str = this.Request["memID"].ToString();
                int userID = (this.Session["UID"].ToString() != "") ? int.Parse(this.Session["UID"].ToString()) : -1;
                int shopID = (this.Session["UserShopID"].ToString() != "") ? int.Parse(this.Session["UserShopID"].ToString()) : -1;
                string[] strArray = str.Remove(str.Length - 1).Split(new char[] { ',' });
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem model = new Chain.Model.Mem();
                for (int i = 0; i < strArray.Length; i++)
                {
                    model = mem.GetModel(int.Parse(strArray[i].ToString()));
                    int memPoint = model.MemPoint;
                    model.MemPoint = 0;
                    mem.UpdateMem(model);
                    num = 1;
                    PubFunction.SaveSysLog(userID, 4, "会员列表", "积分清零,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void MemRecommendPoint(Chain.Model.Mem modelMem, int ShopID, int Uid)
        {
            if ((modelMem.MemRecommendID > 0) && (PubFunction.curParameter.intRecommendPoint > 0))
            {
                int intRecommendPoint = PubFunction.curParameter.intRecommendPoint;
                if (PubFunction.IsShopPoint(ShopID, ref intRecommendPoint))
                {
                    Chain.BLL.Mem mem = new Chain.BLL.Mem();
                    Chain.Model.Mem model = mem.GetModel(modelMem.MemRecommendID);
                    Chain.Model.PointLog log = new Chain.Model.PointLog();
                    Chain.BLL.PointLog log2 = new Chain.BLL.PointLog();
                    log.PointMemID = modelMem.MemRecommendID;
                    log.PointNumber = intRecommendPoint;
                    log.PointShopID = modelMem.MemShopID;
                    log.PointUserID = modelMem.MemUserID;
                    log.PointChangeType = 0;
                    log.PointCreateTime = DateTime.Now;
                    log.PointRemark = string.Concat(new object[] { "推荐会员获得积分,推荐卡号:[", modelMem.MemCard, "] 姓名:[", modelMem.MemName, "] 获得积分:[", log.PointNumber, "]" });
                    log2.Add(log);
                    PubFunction.SetShopPoint(Uid, ShopID, intRecommendPoint, "会员添加,推荐会员获取积分,店铺扣除积分", 2);
                    if (mem.UpdatePoint(log.PointMemID, log.PointNumber) > 0)
                    {
                        PubFunction.UpdateMemLevel(mem.GetModel(log.PointMemID));
                    }
                }
            }
        }

        public void MemSendMessage()
        {
            int num = 0;
            string input = (this.Request["strMemReceiver"] != null) ? this.Request["strMemReceiver"].ToString() : "";
            string content = (this.Request["strMemContent"] != null) ? this.Request["strMemContent"].ToString() : "";
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            string[] strArray = Regex.Split(input, ";", RegexOptions.IgnoreCase);
            string mobileList = "";
            foreach (string str4 in strArray)
            {
                if (str4 != "")
                {
                    string[] strArray2 = Regex.Split(str4, ":", RegexOptions.IgnoreCase);
                    mobileList = mobileList + strArray2[1] + ",";
                }
            }
            if ((mobileList != "") && (mobileList.Substring(mobileList.Length - 1, 1) == ","))
            {
                mobileList = mobileList.Remove(mobileList.LastIndexOf(","), 1);
            }
            if (Convert.ToInt32(SMSInfo.GetBalance(true)) > 0)
            {
                if (!PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), mobileList.Split(new char[] { ',' }).Length))
                {
                    num = 5;
                }
                else
                {
                    content = content + "【" + PubFunction.curParameter.strSmsShopName + "】";
                    if (SMSInfo.Send_SMS(true, mobileList, content, ""))
                    {
                        num = 1;
                        Chain.Model.SmsLog model = new Chain.Model.SmsLog();
                        model.SmsMemID = 0;
                        model.SmsMobile = input;
                        model.SmsContent = content;
                        model.SmsTime = DateTime.Now;
                        model.SmsShopID = shopID;
                        model.SmsUserID = userID;
                        model.SmsAmount = PubFunction.GetSmsAmount(content);
                        model.SmsAllAmount = model.SmsAmount;
                        new Chain.BLL.SmsLog().Add(model);
                        PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), mobileList.Split(new char[] { ',' }).Length, 2);
                        PubFunction.SaveSysLog(userID, 4, "发送短信", "给会员发送短信", shopID, DateTime.Now, PubFunction.ipAdress);
                    }
                    else
                    {
                        num = 2;
                    }
                }
            }
            else
            {
                num = 3;
            }
            this.Context.Response.Write(num);
        }

        public void MessageDel()
        {
            int num = 0;
            try
            {
                int messageID = int.Parse(this.Request["messageID"].ToString());
                this.modelMessage = this.bllMessage.GetModel(messageID);
                this.modelMem = this.bllMem.GetModel(this.modelMessage.MessageMemID);
                if (this.bllMessage.Delete(messageID))
                {
                    num = 1;
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 2, "会员留言", "卡号:[" + this.modelMem.MemCard + "]的会员留言删除", int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void MessageReply()
        {
            int num = 0;
            try
            {
                int num2 = (this.Request["messageID"] != null) ? int.Parse(this.Request["messageID"].ToString()) : 0;
                string str = (this.Request["content"] != null) ? this.Request["content"].ToString() : "";
                this.modelMessage.MessageID = num2;
                this.modelMessage.MessageReplyContent = str;
                this.modelMessage.MessageReplyTime = DateTime.Now;
                this.modelMessage.MessageReplyUserID = int.Parse(this.Session["UID"].ToString());
                this.modelMessage.MessageIsReply = 1;
                if (this.bllMessage.Reply(this.modelMessage))
                {
                    num = 1;
                }
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void MicroGoodsAddAndEdit()
        {
            int num = 0;
            try
            {
                Chain.Model.MicroWebsiteGoods model = new Chain.Model.MicroWebsiteGoods();
                Chain.BLL.MicroWebsiteGoods goods2 = new Chain.BLL.MicroWebsiteGoods();
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int num4 = (this.Request["txtGoodsID"] != "") ? int.Parse(this.Request["txtGoodsID"].ToString()) : 0;
                model.MicroGoodsCode = this.Request["txtGoodsCode"].ToString();
                model.MicroGoodsName = this.Request["txtGoodsName"].ToString();
                model.MicroGoodsClassID = (this.Request["sltGoodsClass"].ToString() != "") ? int.Parse(this.Request["sltGoodsClass"].ToString()) : 0;
                model.MicroGoodsShopID = 1;
                model.MicroPrice = (this.Request["txtMicroPrice"] != "") ? decimal.Parse(this.Request["txtMicroPrice"].ToString()) : 0M;
                model.MicroPoint = (this.Request["txtGoodsPoint"] != "") ? int.Parse(this.Request["txtGoodsPoint"].ToString()) : -1;
                model.MicroGoodsBidPrice = (this.Request["txtGoodsBidPrice"] != "") ? decimal.Parse(this.Request["txtGoodsBidPrice"].ToString()) : 0M;
                model.MicroSalePrice = (this.Request["txtMicroSalePrice"] != "") ? decimal.Parse(this.Request["txtMicroSalePrice"].ToString()) : 0M;
                string str = PubFunction.RemoveSpace(this.Request["txtGoodsRemark"].ToString());
                model.MicroGoodsRemark = str;
                model.MicroGoodsCreateTime = DateTime.Now;
                if (num4 == 0)
                {
                    model.MicroGoodsPicture = "../Upload/MicroWebsite/MicroGoods/" + this.Request["txtUpdateGoodsName"];
                    num = goods2.Add(model);
                }
                else
                {
                    model.MicroGoodsPicture = "../Upload/MicroWebsite/MicroGoods/" + Path.GetFileName(this.Request["txtUpdateGoodsName"]);
                    model.MicroGoodsID = num4;
                    num = goods2.Update(model);
                }
                PubFunction.SaveSysLog(userID, 4, "商品管理", string.Concat(new object[] { "商家网站", (num4 == 0) ? "商品新增" : "商品编辑", ",商品名称:[", model.MicroGoodsName, "],零售金额:[", model.MicroPrice, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
            }
            catch
            {
                num = -2;
            }
            this.Response.Write(num);
        }

        public void MicroWebsiteAllowExchange()
        {
            int num = 0;
            try
            {
                int exchangeID = int.Parse(this.Request["ID"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                Chain.Model.MicroWebsiteGiftExchange model = new Chain.Model.MicroWebsiteGiftExchange();
                Chain.BLL.MicroWebsiteGiftExchange exchange2 = new Chain.BLL.MicroWebsiteGiftExchange();
                model = exchange2.GetModel(exchangeID);
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem memInfo = new Chain.Model.Mem();
                memInfo = mem.GetModel(model.MemID);
                Chain.BLL.PointLog log = new Chain.BLL.PointLog();
                Chain.Model.PointLog log2 = new Chain.Model.PointLog();
                if (memInfo.MemState != 0)
                {
                    if (memInfo.MemState == 1)
                    {
                        num = -3;
                    }
                    else if (memInfo.MemState == 2)
                    {
                        num = -4;
                    }
                }
                else if (model.ExchangeAllPoint > memInfo.MemPoint)
                {
                    num = -1;
                }
                else
                {
                    mem.UpdatePoint(model.MemID, model.ExchangeAllPoint * -1);
                    memInfo = new Chain.BLL.Mem().GetModel(model.MemID);
                    PubFunction.UpdateMemLevel(memInfo);
                    model.ExchangeStatus = 2;
                    model.ExchangeUserID = userID;
                    model.ExchangeTime = DateTime.Now;
                    if (exchange2.Update(model))
                    {
                        num = 1;
                        log2.PointMemID = memInfo.MemID;
                        log2.PointNumber = model.ExchangeAllPoint;
                        log2.PointChangeType = 4;
                        log2.PointRemark = "微网站兑换审核通过,扣减积分[" + model.ExchangeAllPoint + "]";
                        log2.PointShopID = shopID;
                        log2.PointCreateTime = DateTime.Now;
                        log2.PointUserID = userID;
                        log2.PointOrderCode = model.ExchangeAccount;
                        log.Add(log2);
                        PubFunction.SaveSysLog(userID, 4, "兑换审核", string.Concat(new object[] { "审核通过,会员卡号:[", memInfo.MemCard, "],姓名:[", memInfo.MemName, "],总积分:[", model.ExchangeAllPoint, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void MicroWebsiteGoodsAllowExchange()
        {
            int num = 0;
            try
            {
                int microOrderID = Convert.ToInt32(this.Request["MicroOrderID"]);
                bool flag = this.Request["sendSMS"] == "true";
                Chain.BLL.MicroWebsiteOrderLog log = new Chain.BLL.MicroWebsiteOrderLog();
                Chain.Model.MicroWebsiteOrderLog model = log.GetModel(microOrderID);
                int microOrderMemID = model.MicroOrderMemID;
                Chain.Model.Mem mem = new Chain.BLL.Mem().GetModel(microOrderMemID);
                if (mem.MemState != 0)
                {
                    if (this.modelMem.MemState == 1)
                    {
                        num = -3;
                    }
                    else if (this.modelMem.MemState == 2)
                    {
                        num = -4;
                    }
                }
                else
                {
                    model.MicroOrderPassCreateTime = DateTime.Now;
                    model.MicroOrderStatus = 2;
                    model.MicroOrderUserID = int.Parse(this.Session["UserShopID"].ToString());
                    log.Update(model);
                    num = 1;
                    if ((!string.IsNullOrEmpty(mem.MemMobile) && flag) && (Convert.ToInt32(SMSInfo.GetBalance(false)) > 0))
                    {
                        SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                        smsTemplateParameter.strCardID = mem.MemCard;
                        smsTemplateParameter.strName = mem.MemName;
                        smsTemplateParameter.dclTempMoney = model.MicroOrderDiscountMoney;
                        smsTemplateParameter.dclMoney = mem.MemMoney;
                        smsTemplateParameter.intTempPoint = model.MicroOrderPoint;
                        smsTemplateParameter.intPoint = mem.MemPoint;
                        smsTemplateParameter.NewLevelID = smsTemplateParameter.OldLevelID = mem.MemLevelID;
                        string content = SMSInfo.GetSendContent(5, smsTemplateParameter, int.Parse(this.Session["UserShopID"].ToString()));
                        SMSInfo.Send_GXSMS(this.modelMem.MemMobile, content, "");
                        Chain.BLL.SmsLog log3 = new Chain.BLL.SmsLog();
                        Chain.Model.SmsLog log5 = new Chain.Model.SmsLog();
                        log5.SmsMemID = mem.MemID;
                        log5.SmsMobile = mem.MemMobile;
                        log5.SmsContent = content;
                        log5.SmsShopID = int.Parse(this.Session["UserShopID"].ToString());
                        log5.SmsTime = DateTime.Now;
                        log5.SmsUserID = int.Parse(this.Session["UID"].ToString());
                        log5.SmsAmount = PubFunction.GetSmsAmount(content);
                        log5.SmsAllAmount = PubFunction.GetSmsAmount(content);
                        Chain.Model.SmsLog log4 = log5;
                        log3.Add(log4);
                    }
                }
            }
            catch (Exception)
            {
            }
            this.Response.Write(num);
        }

        public void MicroWebsiteGoodsNoExchange()
        {
            int num = 0;
            try
            {
                int microOrderID = Convert.ToInt32(this.Request["MicroOrderID"]);
                string str = this.Request["MicroOrderMark"];
                int num3 = int.Parse(this.Session["UID"].ToString());
                int intShopID = int.Parse(this.Session["UserShopID"].ToString());
                bool flag = this.Request["sendSMS"] == "true";
                Chain.BLL.MicroWebsiteOrderLog log = new Chain.BLL.MicroWebsiteOrderLog();
                Chain.Model.MicroWebsiteOrderLog model = log.GetModel(microOrderID);
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem mem2 = mem.GetModel(model.MicroOrderMemID);
                model.MicroOrderStatus = 3;
                model.MicroOrderRemark = str;
                model.MicroOrderUserID = num3;
                num = log.Update(model) ? 1 : 0;
                int point = (model.MicroOrderPoint > mem2.MemPoint) ? 0 : (mem2.MemPoint - model.MicroOrderPoint);
                mem.ExpenseUpdateMem(mem2.MemID, mem2.MemMoney + model.MicroOrderDiscountMoney, mem2.MemConsumeMoney - model.MicroOrderDiscountMoney, point, DateTime.Now, mem2.MemConsumeCount - 1);
                Chain.BLL.PointLog log3 = new Chain.BLL.PointLog();
                Chain.Model.PointLog log10 = new Chain.Model.PointLog();
                log10.PointMemID = mem2.MemID;
                log10.PointNumber = model.MicroOrderPoint;
                log10.PointChangeType = 1;
                log10.PointRemark = "会员微网站商品退回";
                log10.PointShopID = intShopID;
                log10.PointCreateTime = DateTime.Now;
                log10.PointUserID = num3;
                log10.PointGiveMemID = 0;
                log10.PointOrderCode = model.MicroOrderAccount;
                Chain.Model.PointLog log4 = log10;
                log3.Add(log4);
                DataTable table = log3.GetList(" PointChangeType=9 and PointOrderCode='" + model.MicroOrderAccount + "'").Tables[0];
                if (table != null)
                {
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        Chain.Model.PointLog log6 = new Chain.Model.PointLog();
                        log6.PointMemID = mem2.MemID;
                        log6.PointNumber = model.MicroOrderPoint * -1;
                        log6.PointChangeType = 11;
                        log6.PointRemark = "会员消费撤单推荐人积分变动";
                        log6.PointShopID = intShopID;
                        log6.PointCreateTime = DateTime.Now;
                        log6.PointUserID = num3;
                        log6.PointGiveMemID = mem2.MemID;
                        log6.PointOrderCode = model.MicroOrderAccount;
                        Chain.Model.PointLog log5 = log6;
                        log3.Add(log5);
                        log3.UpdateMemPoint(int.Parse(table.Rows[i]["PointMemID"].ToString()), int.Parse(table.Rows[i]["PointNumber"].ToString()));
                    }
                }
                if ((!string.IsNullOrEmpty(mem2.MemMobile) && flag) && (Convert.ToInt32(SMSInfo.GetBalance(false)) > 0))
                {
                    SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                    smsTemplateParameter.strCardID = mem2.MemCard;
                    smsTemplateParameter.strName = mem2.MemName;
                    smsTemplateParameter.dclTempMoney = model.MicroOrderDiscountMoney;
                    smsTemplateParameter.dclMoney = mem2.MemMoney;
                    smsTemplateParameter.intTempPoint = model.MicroOrderPoint;
                    smsTemplateParameter.intPoint = mem2.MemPoint;
                    smsTemplateParameter.OldLevelID = smsTemplateParameter.NewLevelID = mem2.MemLevelID;
                    string content = SMSInfo.GetSendContent(8, smsTemplateParameter, intShopID) + "撤单原因是:未通过审核;备注:" + str;
                    SMSInfo.Send_GXSMS(this.modelMem.MemMobile, content, "");
                    Chain.BLL.SmsLog log7 = new Chain.BLL.SmsLog();
                    Chain.Model.SmsLog log9 = new Chain.Model.SmsLog();
                    log9.SmsMemID = mem2.MemID;
                    log9.SmsMobile = mem2.MemMobile;
                    log9.SmsContent = content;
                    log9.SmsShopID = intShopID;
                    log9.SmsTime = DateTime.Now;
                    log9.SmsUserID = num3;
                    log9.SmsAmount = PubFunction.GetSmsAmount(content);
                    log9.SmsAllAmount = PubFunction.GetSmsAmount(content);
                    Chain.Model.SmsLog log8 = log9;
                    log7.Add(log8);
                }
            }
            catch (Exception)
            {
            }
            this.Response.Write(num);
        }

        public void MicroWebsiteNoExchange()
        {
            int num = 0;
            try
            {
                int exchangeID = int.Parse(this.Request["ID"].ToString());
                int num3 = int.Parse(this.Session["UID"].ToString());
                string str = this.Request["ExchangeRemark"].ToString();
                Chain.Model.MicroWebsiteGiftExchange model = new Chain.Model.MicroWebsiteGiftExchange();
                Chain.BLL.MicroWebsiteGiftExchange exchange2 = new Chain.BLL.MicroWebsiteGiftExchange();
                model = exchange2.GetModel(exchangeID);
                model.ExchangeStatus = 3;
                model.ExchangeUserID = num3;
                model.ExchangeTime = DateTime.Now;
                model.ExchangeRemark = str;
                if (exchange2.Update(model))
                {
                    num = 1;
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void NewsAdd()
        {
            int num = 0;
            try
            {
                Chain.Model.WeiXinNews model = new Chain.Model.WeiXinNews();
                model.NewsRuleID = int.Parse(this.Request["NewsRuleID"]);
                model.NewsTitle = this.Request["NewsTitle"];
                model.NewsDesc = this.Request["NewsDesc"];
                model.NewsUrlFirst = this.Request["NewsUrlFirst"];
                model.NewsUrlSecond = this.Request["NewsUrlSecond"];
                model.NewsLinkContent = this.Request["NewsLinkContent"];
                model.NewsLinkContent = model.NewsLinkContent;
                model.NewsCreateTime = DateTime.Now;
                num = new Chain.BLL.WeiXinNews().Add(model);
                model.NewsID = num;
                model.NewsUrlSecond = string.Concat(new object[] { "http://", PubFunction.curParameter.strDoMain, "/WeiXin/WeiXinNewsLink.aspx?NewsID=", num });
                num = new Chain.BLL.WeiXinNews().Update(model) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void NewsDel()
        {
            int num = 0;
            try
            {
                int newsID = int.Parse(this.Request["NewsID"]);
                Chain.Model.WeiXinNews model = new Chain.BLL.WeiXinNews().GetModel(newsID);
                if (model != null)
                {
                    num = 1;
                    string fileName = Path.GetFileName(model.NewsUrlFirst);
                    string path = this.Context.Server.MapPath("~/Upload/WeiXin/Images/" + fileName);
                    if (System.IO.File.Exists(path))
                    {
                        System.IO.File.Delete(path);
                    }
                    num = new Chain.BLL.WeiXinNews().Delete(model.NewsID) ? 1 : 0;
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void NewsEdit()
        {
            int num = 0;
            try
            {
                Chain.Model.WeiXinNews model = new Chain.Model.WeiXinNews();
                model.NewsID = int.Parse(this.Request["NewsID"]);
                model.NewsRuleID = int.Parse(this.Request["NewsRuleID"]);
                model.NewsTitle = this.Request["NewsTitle"];
                model.NewsDesc = this.Request["NewsDesc"];
                model.NewsUrlFirst = this.Request["NewsUrlFirst"];
                model.NewsUrlSecond = string.Concat(new object[] { "http://", PubFunction.curParameter.strDoMain, "/WeiXin/WeiXinNewsLink.aspx?NewsID=", model.NewsID });
                model.NewsLinkContent = this.Request["NewsLinkContent"];
                model.NewsLinkContent = model.NewsLinkContent;
                model.NewsCreateTime = DateTime.Now;
                num = new Chain.BLL.WeiXinNews().Update(model) ? 1 : 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void NewsRuleAdd()
        {
            int num = 0;
            try
            {
                Chain.Model.WeiXinRule model = new Chain.Model.WeiXinRule();
                model.RuleNUmber = this.Request["RuleNUmber"];
                model.RuleNewsType = "news";
                model.RuleUserID = int.Parse(this.Session["UID"].ToString());
                model.RuleCreateTime = DateTime.Now;
                model.RuleDesc = this.Request["RuleDesc"];
                if (new Chain.BLL.WeiXinRule().GetList("RuleNUmber='" + model.RuleNUmber + "' ").Tables[0].Rows.Count > 0)
                {
                    num = -1;
                }
                else
                {
                    num = new Chain.BLL.WeiXinRule().Add(model);
                    if (num > 0)
                    {
                        Chain.Model.WeiXinNews news = new Chain.Model.WeiXinNews();
                        news.NewsRuleID = num;
                        news.NewsTitle = this.Request["NewsTitle"];
                        news.NewsDesc = this.Request["NewsDesc"];
                        news.NewsUrlFirst = this.Request["NewsUrlFirst"];
                        news.NewsUrlSecond = this.Request["NewsUrlSecond"];
                        news.NewsLinkContent = this.Request["NewsLinkContent"];
                        news.NewsCreateTime = DateTime.Now;
                        num = new Chain.BLL.WeiXinNews().Add(news);
                        news.NewsID = num;
                        news.NewsUrlSecond = string.Concat(new object[] { "http://", PubFunction.curParameter.strDoMain, "/WeiXin/WeiXinNewsLink.aspx?NewsID=", num });
                        num = new Chain.BLL.WeiXinNews().Update(news) ? 1 : 0;
                    }
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void NewsRuleDel()
        {
            int num = 0;
            try
            {
                int ruleID = int.Parse(this.Request["RuleID"]);
                Chain.BLL.WeiXinMenu menu = new Chain.BLL.WeiXinMenu();
                if (menu.GetUseCountByRuleID(ruleID) > 0)
                {
                    num = -1;
                }
                else
                {
                    List modelList = new Chain.BLL.WeiXinNews().GetModelList("NewsRuleID=" + ruleID);
                    if (modelList != null)
                    {
                        num = 1;
                        foreach (Chain.Model.WeiXinNews news in modelList)
                        {
                            string fileName = Path.GetFileName(news.NewsUrlFirst);
                            string path = this.Context.Server.MapPath("~/Upload/WeiXin/Images/" + fileName);
                            if (System.IO.File.Exists(path))
                            {
                                System.IO.File.Delete(path);
                            }
                            num = new Chain.BLL.WeiXinNews().Delete(news.NewsID) ? 1 : 0;
                        }
                        num = new Chain.BLL.WeiXinRule().Delete(ruleID) ? 1 : 0;
                    }
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void NewsRuleEdit()
        {
            int num = 0;
            try
            {
                Chain.BLL.WeiXinRule rule = new Chain.BLL.WeiXinRule();
                Chain.Model.WeiXinRule model = new Chain.Model.WeiXinRule();
                model.RuleID = int.Parse(this.Request["RuleID"]);
                model.RuleNUmber = this.Request["RuleNUmber"];
                model.RuleNewsType = "news";
                model.RuleUserID = int.Parse(this.Session["UID"].ToString());
                model.RuleCreateTime = DateTime.Now;
                model.RuleDesc = this.Request["RuleDesc"];
                Chain.Model.WeiXinRule rule3 = rule.GetModel(model.RuleID);
                string strWhere = string.Concat(new object[] { "RuleID != ", model.RuleID, " and RuleNUmber='", model.RuleNUmber, "' " });
                if (rule.GetList(strWhere).Tables[0].Rows.Count > 0)
                {
                    num = -1;
                }
                else
                {
                    num = rule.Update(model) ? 1 : 0;
                    if (rule3.RuleNUmber != model.RuleNUmber)
                    {
                        new Chain.BLL.WeiXinMenu().UpdateMenuKey(rule3.RuleNUmber, model.RuleNUmber);
                    }
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void NoExchange()
        {
            int num = 0;
            try
            {
                int exchangeID = int.Parse(this.Request["ID"].ToString());
                int num3 = int.Parse(this.Session["UID"].ToString());
                string str = this.Request["ExchangeRemark"].ToString();
                Chain.Model.GiftExchange model = new Chain.Model.GiftExchange();
                Chain.BLL.GiftExchange exchange2 = new Chain.BLL.GiftExchange();
                model = exchange2.GetModel(exchangeID);
                model.ExchangeStatus = 3;
                model.ExchangeUserID = num3;
                model.ExchangeTime = DateTime.Now;
                model.ExchangeRemark = str;
                if (exchange2.Update(model))
                {
                    num = 1;
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void NoticeAdd()
        {
            int num = 0;
            try
            {
                Chain.Model.SysNotice model = new Chain.Model.SysNotice();
                model.SysNoticeCode = this.Request["NoticeCode"];
                model.SysNoticeTime = DateTime.Parse(DateTime.Now.ToShortDateString());
                model.SysNotieceName = this.Request["RelaseName"];
                model.SysNoticeTitle = this.Request["NoticeTitle"];
                model.SysNoticeDetail = this.Request["NoticeDetail"];
                num = new Chain.BLL.SysNotice().Add(model);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 1, "公告新增", "系统公告新增,发布人:[" + model.SysNotieceName + "],公告标题:[" + model.SysNoticeTitle + "]", int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void NoticeDel()
        {
            int num = 0;
            try
            {
                int sysNoticeID = int.Parse(this.Request["NoticeID"].ToString());
                Chain.BLL.SysNotice notice = new Chain.BLL.SysNotice();
                Chain.Model.SysNotice model = notice.GetModel(sysNoticeID);
                if (notice.Delete(sysNoticeID))
                {
                    num = 1;
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 2, "公告删除", "删除系统公告,公告更改人:" + model.SysNotieceName, int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void NoticeEdit()
        {
            int num = 0;
            try
            {
                Chain.Model.SysNotice model = new Chain.Model.SysNotice();
                model.SysNoticeID = int.Parse(this.Request["NoticeID"]);
                model.SysNoticeCode = this.Request["NoticeCode"];
                model.SysNoticeTime = DateTime.Parse(DateTime.Now.ToShortDateString());
                model.SysNotieceName = this.Request["RelaseName"];
                model.SysNoticeTitle = this.Request["NoticeTitle"];
                model.SysNoticeDetail = this.Request["NoticeDetail"];
                num = new Chain.BLL.SysNotice().Update(model);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 3, "公告编辑", "系统公告编辑,发布人:[" + model.SysNotieceName + "],公告标题:[" + model.SysNoticeTitle + "]", int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void PointChange()
        {
            string s = "0";
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            int memID = int.Parse(this.Request["memID"]);
            int num4 = (this.Request["pointNumber"] != null) ? int.Parse(this.Request["pointNumber"]) : 0;
            string str2 = this.Request["pointOrderCode"].ToString();
            bool flag = this.Request["sendSMS"] == "true";
            try
            {
                Chain.Model.PointLog model = new Chain.Model.PointLog();
                Chain.BLL.PointLog log2 = new Chain.BLL.PointLog();
                Chain.Model.Mem memInfo = new Chain.BLL.Mem().GetModel(memID);
                int memLevelID = memInfo.MemLevelID;
                if (memInfo.MemState != 0)
                {
                    s = "-1";
                }
                else
                {
                    string str3 = (this.Request["remark"] != "") ? this.Request["remark"].ToString() : "无";
                    string str4 = this.Request["type"];
                    bool flag2 = true;
                    if (str4 != "1")
                    {
                        int point = num4;
                        flag2 = PubFunction.IsShopPoint(shopID, ref point);
                        if (point == 0)
                        {
                            flag2 = false;
                        }
                    }
                    if (flag2)
                    {
                        model.PointMemID = memID;
                        model.PointNumber = num4;
                        model.PointShopID = shopID;
                        model.PointUserID = userID;
                        model.PointChangeType = 6;
                        model.PointCreateTime = DateTime.Now;
                        model.PointOrderCode = str2;
                        if (str4 == "1")
                        {
                            model.PointNumber *= -1;
                            model.PointRemark = string.Concat(new object[] { "手动进行减去积分,积分变动:[", model.PointNumber, "],备注:", str3 });
                            log2.Add(model);
                        }
                        else
                        {
                            model.PointRemark = string.Concat(new object[] { "手动进行增加积分,积分变动:[", model.PointNumber, "],备注:", str3 });
                            log2.Add(model);
                        }
                        int num7 = new Chain.BLL.Mem().UpdatePoint(memID, model.PointNumber);
                        int num8 = num4;
                        if (str4 != "1")
                        {
                            num8 = num4 * -1;
                        }
                        if (num7 > 0)
                        {
                            memInfo = new Chain.BLL.Mem().GetModel(memID);
                            if (str4 != "1")
                            {
                                PubFunction.AddShopPoint(userID, memInfo.MemShopID, num8, model.PointRemark);
                            }
                            string str5 = PubFunction.UpdateMemLevel(memInfo);
                            s = string.Concat(new object[] { "{\"Success\":\"", num7, "\",\"strUpdateMemLevel\":\"", str5, "\"}" });
                            if (flag)
                            {
                                if (Convert.ToInt32(SMSInfo.GetBalance(false)) <= 0)
                                {
                                    s = "-3";
                                }
                                else if (PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), memInfo.MemMobile.Split(new char[] { ',' }).Length))
                                {
                                    SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                                    smsTemplateParameter.strCardID = memInfo.MemCard;
                                    smsTemplateParameter.strName = memInfo.MemName;
                                    smsTemplateParameter.intTempPoint = num4;
                                    smsTemplateParameter.intPoint = memInfo.MemPoint;
                                    smsTemplateParameter.dclTempMoney = 0M;
                                    smsTemplateParameter.dclMoney = memInfo.MemMoney;
                                    smsTemplateParameter.OldLevelID = memLevelID;
                                    memInfo = new Chain.BLL.Mem().GetModel(memID);
                                    smsTemplateParameter.NewLevelID = memInfo.MemLevelID;
                                    string content = SMSInfo.GetSendContent(7, smsTemplateParameter, shopID);
                                    SMSInfo.Send_GXSMS(memInfo.MemMobile, content, "");
                                    Chain.Model.SmsLog log3 = new Chain.Model.SmsLog();
                                    log3.SmsMemID = memInfo.MemID;
                                    log3.SmsMobile = memInfo.MemMobile;
                                    log3.SmsContent = content;
                                    log3.SmsTime = DateTime.Now;
                                    log3.SmsShopID = shopID;
                                    log3.SmsUserID = userID;
                                    log3.SmsAmount = PubFunction.GetSmsAmount(content);
                                    log3.SmsAllAmount = log3.SmsAmount;
                                    new Chain.BLL.SmsLog().Add(log3);
                                    PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), memInfo.MemMobile.Split(new char[] { ',' }).Length, 2);
                                }
                                else
                                {
                                    s = "-5";
                                }
                            }
                            PubFunction.SaveSysLog(userID, 3, "积分变动", string.Concat(new object[] { "会员积分变动,会员卡号:[", memInfo.MemCard, "],会员姓名:[", memInfo.MemName, "],变动积分:[", model.PointNumber, "],备注:", str3 }), shopID, DateTime.Now, PubFunction.ipAdress);
                        }
                    }
                    else
                    {
                        s = "-6";
                    }
                }
            }
            catch
            {
                s = "-2";
            }
            this.Context.Response.Write(s);
        }

        public void PointRateEdit()
        {
            int num = 0;
            try
            {
                int num2 = (this.Request["PointRateID"].ToString() != "") ? int.Parse(this.Request["PointRateID"].ToString()) : 0;
                int num3 = (this.Request["PointRateLevel"].ToString() != "") ? int.Parse(this.Request["PointRateLevel"].ToString()) : 0;
                bool flag = (this.Request["PointRateType"] != null) && (this.Request["PointRateType"] == "true");
                int num4 = (this.Request["MemLevel1"].ToString() != "") ? int.Parse(this.Request["MemLevel1"].ToString()) : 0;
                int num5 = (this.Request["MemLevel2"].ToString() != "") ? int.Parse(this.Request["MemLevel2"].ToString()) : 0;
                int num6 = (this.Request["MemLevel3"].ToString() != "") ? int.Parse(this.Request["MemLevel3"].ToString()) : 0;
                int num7 = (this.Request["MemLevel4"].ToString() != "") ? int.Parse(this.Request["MemLevel4"].ToString()) : 0;
                int num8 = (this.Request["MemLevel5"].ToString() != "") ? int.Parse(this.Request["MemLevel5"].ToString()) : 0;
                int num9 = (this.Request["MemLevel6"].ToString() != "") ? int.Parse(this.Request["MemLevel6"].ToString()) : 0;
                int num10 = (this.Request["MemLevel7"].ToString() != "") ? int.Parse(this.Request["MemLevel7"].ToString()) : 0;
                int num11 = (this.Request["MemLevel8"].ToString() != "") ? int.Parse(this.Request["MemLevel8"].ToString()) : 0;
                int num12 = (this.Request["MemLevel9"].ToString() != "") ? int.Parse(this.Request["MemLevel9"].ToString()) : 0;
                int num13 = (this.Request["MemLevel10"].ToString() != "") ? int.Parse(this.Request["MemLevel10"].ToString()) : 0;
                int num14 = (this.Request["MemLevel11"].ToString() != "") ? int.Parse(this.Request["MemLevel11"].ToString()) : 0;
                int num15 = (this.Request["MemLevel12"].ToString() != "") ? int.Parse(this.Request["MemLevel12"].ToString()) : 0;
                int num16 = (this.Request["MemLevel13"].ToString() != "") ? int.Parse(this.Request["MemLevel13"].ToString()) : 0;
                int num17 = (this.Request["MemLevel14"].ToString() != "") ? int.Parse(this.Request["MemLevel14"].ToString()) : 0;
                int num18 = (this.Request["MemLevel15"].ToString() != "") ? int.Parse(this.Request["MemLevel15"].ToString()) : 0;
                Chain.Model.PointRate rate2 = new Chain.Model.PointRate();
                rate2.PointRateID = num2;
                rate2.PointRateLevel = num3;
                rate2.PointRateType = flag;
                rate2.MemLevel1 = num4;
                rate2.MemLevel2 = num5;
                rate2.MemLevel3 = num6;
                rate2.MemLevel4 = num7;
                rate2.MemLevel5 = num8;
                rate2.MemLevel6 = num9;
                rate2.MemLevel7 = num10;
                rate2.MemLevel8 = num11;
                rate2.MemLevel9 = num12;
                rate2.MemLevel10 = num13;
                rate2.MemLevel11 = num14;
                rate2.MemLevel12 = num15;
                rate2.MemLevel13 = num16;
                rate2.MemLevel14 = num17;
                rate2.MemLevel15 = num18;
                Chain.Model.PointRate model = rate2;
                num = new Chain.BLL.PointRate().Update(model);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 3, "积分提成", "积分提成编辑", int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void ProcessRequest(HttpContext context)
        {
            context.Response.Buffer = true;
            context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1.0);
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.AddHeader("cache-control", "");
            context.Response.CacheControl = "no-cache";
            context.Response.ContentType = "text/plain";
            this.Request = context.Request;
            this.Response = context.Response;
            this.Session = context.Session;
            this.Server = context.Server;
            this.Context = context;
            string name = this.Request["Method"].ToString();
            base.GetType().GetMethod(name).Invoke(this, null);
        }

        public void RechargeMoney()
        {
            int num = -1;
            int userID = int.Parse(this.Session["UID"].ToString());
            int intShopID = int.Parse(this.Session["UserShopID"].ToString());
            int memID = (this.Request["memID"].ToString() != "") ? int.Parse(this.Request["memID"].ToString()) : 0;
            string str = this.Request["rechargeAccount"].ToString();
            decimal num5 = (this.Request["money"].ToString() != "") ? decimal.Parse(this.Request["money"]) : 0M;
            decimal num6 = (this.Request["giveMoney"].ToString() != "") ? decimal.Parse(this.Request["giveMoney"]) : 0M;
            string str2 = (this.Request["remark"].ToString() != "") ? this.Request["remark"].ToString() : "无";
            DateTime createTime = DateTime.Parse(this.Request["createTime"]);
            bool flag = this.Request["sendSMS"] == "true";
            bool flag2 = this.Request["isbank"] == "true";
            Chain.BLL.Mem mem = new Chain.BLL.Mem();
            Chain.Model.Mem model = mem.GetModel(memID);
            string detail = string.Concat(new object[] { "会员账户充值,充值金额:[", num5.ToString(), "],赠送:[", num6, "],备注:", str2 });
            try
            {
                decimal money = 0M;
                money = num5 + num6;
                Chain.Model.MemRecharge recharge = new Chain.Model.MemRecharge();
                recharge.RechargeMemID = model.MemID;
                recharge.RechargeAccount = str;
                recharge.RechargeMoney = num5 + num6;
                recharge.RechargeShopID = intShopID;
                recharge.RechargeUserID = userID;
                recharge.RechargeCreateTime = createTime;
                recharge.RechargeRemark = str2;
                recharge.RechargeIsApprove = true;
                if (flag2)
                {
                    recharge.RechargeType = 3;
                }
                else
                {
                    recharge.RechargeType = 2;
                }
                recharge.RechargeGive = num6;
                recharge.RechargeCardBalance = model.MemMoney + money;
                num = new Chain.BLL.MemRecharge().Add(recharge);
                mem.UpdateMoney(memID, money);
                if (flag)
                {
                    if (Convert.ToInt32(SMSInfo.GetBalance(false)) <= 0)
                    {
                        num = -2;
                    }
                    else
                    {
                        if (PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length))
                        {
                            SmsTemplateParameter smsTemplateParameter = new SmsTemplateParameter();
                            smsTemplateParameter.strCardID = model.MemCard;
                            smsTemplateParameter.strName = model.MemName;
                            smsTemplateParameter.dclTempMoney = num5 + num6;
                            smsTemplateParameter.dclMoney = (model.MemMoney + num5) + num6;
                            smsTemplateParameter.intTempPoint = 0;
                            smsTemplateParameter.intPoint = model.MemPoint;
                            smsTemplateParameter.OldLevelID = model.MemLevelID;
                            smsTemplateParameter.NewLevelID = model.MemLevelID;
                            string content = SMSInfo.GetSendContent(2, smsTemplateParameter, intShopID);
                            SMSInfo.Send_GXSMS(model.MemMobile, content, "");
                            Chain.Model.SmsLog log = new Chain.Model.SmsLog();
                            log.SmsMemID = model.MemID;
                            log.SmsMobile = model.MemMobile;
                            log.SmsContent = content;
                            log.SmsTime = DateTime.Now;
                            log.SmsShopID = intShopID;
                            log.SmsUserID = userID;
                            log.SmsAmount = PubFunction.GetSmsAmount(content);
                            log.SmsAllAmount = log.SmsAmount;
                            new Chain.BLL.SmsLog().Add(log);
                            PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), model.MemMobile.Split(new char[] { ',' }).Length, 2);
                        }
                        else
                        {
                            num = -5;
                        }
                        PubFunction.SaveSysLog(userID, 4, "会员管理-会员充值", "会员充值,会员卡号:[" + model.MemCard + "],姓名:[" + model.MemName + "]", intShopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
                PubFunction.SaveSysLog(userID, 3, "会员充值", detail, intShopID, createTime, PubFunction.ipAdress);
            }
            catch
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void RechargeRevoke()
        {
            int num = 0;
            try
            {
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int rechargeID = (this.Request["rechargeID"] != "") ? int.Parse(this.Request["rechargeID"].ToString()) : 0;
                int memID = (this.Request["memID"] != "") ? int.Parse(this.Request["memID"].ToString()) : 0;
                this.modelMem = this.bllMem.GetModel(memID);
                if (rechargeID != 0)
                {
                    Chain.Model.MemRecharge model = new Chain.BLL.MemRecharge().GetModel(rechargeID);
                    DateTime time = Convert.ToDateTime(model.RechargeCreateTime);
                    DataTable table = new Chain.BLL.OrderLog().GetList(1, "OrderMemID=" + memID + " and OrderPayCard>0", " OrderCreateTime DESC").Tables[0];
                    if (table.Rows.Count > 0)
                    {
                        DateTime time2 = Convert.ToDateTime(table.Rows[0]["OrderCreateTime"].ToString());
                        if (DateTime.Compare(time, time2) < 0)
                        {
                            num = -2;
                        }
                    }
                    if (num != -2)
                    {
                        DataTable table2 = new Chain.BLL.MemCount().GetList(1, "CountMemID=" + memID + " and CountPayCard>0", " CountCreateTime DESC").Tables[0];
                        if (table2.Rows.Count > 0)
                        {
                            DateTime time3 = Convert.ToDateTime(table2.Rows[0]["CountCreateTime"].ToString());
                            if (DateTime.Compare(time, time3) < 0)
                            {
                                num = -3;
                            }
                        }
                        if (((num != -3) && (this.bllMem.DrawMoney(memID, model.RechargeMoney) > 0)) && new Chain.BLL.MemRecharge().Delete(rechargeID))
                        {
                            PubFunction.SaveSysLog(userID, 2, "会员充值", "会员充值撤单,充值单号:[" + model.RechargeAccount + "],充值会员:[" + this.modelMem.MemName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                            num = 1;
                        }
                    }
                }
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void RequestCoupon()
        {
            int num = 0;
            try
            {
                int iD = Convert.ToInt32(this.Request["ID"]);
                int num3 = Convert.ToInt32(this.Request["MemID"]);
                Chain.BLL.Coupon coupon = new Chain.BLL.Coupon();
                Chain.Model.Coupon model = coupon.GetModel(iD);
                if (model.CouponYF >= model.CouponPredictNu)
                {
                    num = -1;
                }
                else
                {
                    Chain.BLL.CouponList list = new Chain.BLL.CouponList();
                    string strWhere = string.Format("CouPonID={0} and CouPonYF='False'", iD);
                    DataRow row = list.GetList(1, strWhere, " CID ").Tables[0].Rows[0];
                    string str2 = string.Format("update CouponList set CouPonYF='True',CouPonMID={0},ConPonSendTime='{1}' where CID={2}", num3, DateTime.Now.ToString(), row["CID"]);
                    ArrayList sqlArray = new ArrayList();
                    sqlArray.Add(str2);
                    if (list.DataUpdateTran(sqlArray))
                    {
                        model.CouponYF++;
                        num = coupon.Update(model) ? 1 : 0;
                    }
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void ReturnGoods()
        {
            string s = "0";
            string str2 = "";
            try
            {
                int orderID = int.Parse(this.Request["orderID"].ToString());
                this.modelOrderLog = this.bllOrderLog.GetModel(orderID);
                this.modelMem = this.bllMem.GetModel(this.modelOrderLog.OrderMemID);
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                decimal num4 = (this.Request["Money"] != "") ? decimal.Parse(this.Request["Money"]) : 0M;
                decimal num5 = (this.Request["discountMoney"] != "") ? decimal.Parse(this.Request["discountMoney"]) : 0M;
                decimal num6 = (this.Request["staffMoney"] != "") ? decimal.Parse(this.Request["staffMoney"]) : 0M;
                int num7 = (this.Request["point"] != "") ? int.Parse(this.Request["point"]) : 0;
                int num8 = (this.Request["number"] != "") ? int.Parse(this.Request["number"]) : 0;
                int num9 = int.Parse(this.Request["count"]);
                DataTable table = new DataTable();
                Chain.Model.OrderLog model = new Chain.Model.OrderLog();
                if (this.modelMem.MemID != 0)
                {
                    if (num8 == 0)
                    {
                        s = string.Concat(new object[] { "{\"Success\":\"", -4, "\",\"strUpdateMemLevel\":\"", str2, "\"}" });
                    }
                    else if (this.modelMem.MemPoint < num7)
                    {
                        s = string.Concat(new object[] { "{\"Success\":\"", -3, "\",\"strUpdateMemLevel\":\"", str2, "\"}" });
                    }
                    else
                    {
                        int num13;
                        int num10 = 0;
                        table = this.bllDetail.GetList(" OrderID=" + orderID).Tables[0];
                        int num11 = 0;
                        Chain.Model.OrderLog log2 = this.bllOrderLog.GetModel(orderID);
                        if (this.modelOrderLog.OrderDiscountMoney > num5)
                        {
                            model.OrderAccount = "TH" + DateTime.Now.ToString("yyMMddHHmmssffff");
                            model.OrderType = 6;
                            model.OrderMemID = this.modelMem.MemID;
                            model.OrderTotalMoney = num4 * -1M;
                            model.OrderDiscountMoney = num5 * -1M;
                            model.OrderIsCard = this.modelOrderLog.OrderIsCard;
                            model.OrderPayCard = (this.modelOrderLog.OrderPayCard - log2.OrderPayCard) * -1M;
                            model.OrderIsCash = this.modelOrderLog.OrderIsCash;
                            model.OrderPayCash = (this.modelOrderLog.OrderPayCash - log2.OrderPayCash) * -1M;
                            model.OrderIsBink = this.modelOrderLog.OrderIsBink;
                            model.OrderPayBink = (this.modelOrderLog.OrderPayBink - log2.OrderPayBink) * -1M;
                            model.OrderPayCoupon = this.modelOrderLog.OrderPayCoupon * -1M;
                            model.OrderPoint = num7 * -1;
                            model.OrderRemark = "会员消费退货";
                            model.OrderPayType = 0;
                            model.OrderShopID = shopID;
                            model.OrderCreateTime = DateTime.Now;
                            model.OrderUserID = userID;
                            model.OldAccount = this.modelOrderLog.OrderAccount;
                            num10 = this.bllOrderLog.Add(model);
                        }
                        else if (this.modelOrderLog.OrderDiscountMoney == num5)
                        {
                            model.OrderAccount = "CD" + DateTime.Now.ToString("yyMMddHHmmssffff");
                            model.OrderType = 4;
                            model.OrderMemID = this.modelMem.MemID;
                            model.OrderTotalMoney = this.modelOrderLog.OrderTotalMoney * -1M;
                            model.OrderDiscountMoney = this.modelOrderLog.OrderDiscountMoney * -1M;
                            model.OrderIsCard = this.modelOrderLog.OrderIsCard;
                            model.OrderPayCard = this.modelOrderLog.OrderPayCard * -1M;
                            model.OrderIsCash = this.modelOrderLog.OrderIsCash;
                            model.OrderPayCash = this.modelOrderLog.OrderPayCash * -1M;
                            model.OrderIsBink = this.modelOrderLog.OrderIsBink;
                            model.OrderPayBink = this.modelOrderLog.OrderPayBink * -1M;
                            model.OrderPayCoupon = this.modelOrderLog.OrderPayCoupon * -1M;
                            model.OrderPoint = this.modelOrderLog.OrderPoint * -1;
                            model.OrderRemark = "会员消费撤单";
                            model.OrderPayType = 0;
                            model.OrderShopID = shopID;
                            model.OrderCreateTime = DateTime.Now;
                            model.OrderUserID = userID;
                            model.OldAccount = this.modelOrderLog.OrderAccount;
                            num10 = this.bllOrderLog.Add(model);
                            num11 = 1;
                        }
                        this.modelGoodsLog.GoodsAccount = this.modelOrderLog.OrderAccount;
                        this.modelGoodsLog.Type = 7;
                        this.modelGoodsLog.TotalPrice = num5;
                        this.modelGoodsLog.InShopID = shopID;
                        this.modelGoodsLog.OutShopID = shopID;
                        this.modelGoodsLog.Remark = "商品退货入库";
                        this.modelGoodsLog.CreateTime = DateTime.Now;
                        this.modelGoodsLog.ShopID = shopID;
                        this.modelGoodsLog.UserID = userID;
                        int num12 = this.bllGoodsLog.Add(this.modelGoodsLog);
                        for (num13 = 0; num13 < num9; num13++)
                        {
                            int goodsID = int.Parse(this.Request["data[" + num13 + "][GoodsID]"]);
                            int num15 = int.Parse(this.Request["data[" + num13 + "][OrderDetailID]"]);
                            decimal num16 = decimal.Parse(this.Request["data[" + num13 + "][Price]"]);
                            decimal num17 = decimal.Parse(this.Request["data[" + num13 + "][ReturnDiscountMoney]"]);
                            decimal num18 = decimal.Parse(this.Request["data[" + num13 + "][ReturnStaffMoney]"]);
                            int num19 = int.Parse(this.Request["data[" + num13 + "][ReturnNumber]"]);
                            int num20 = int.Parse(this.Request["data[" + num13 + "][ReturnPoint]"]);
                            int num21 = int.Parse(this.Request["data[" + num13 + "][GoodsType]"]);
                            int num22 = (this.Request["data[" + num13 + "][staffID]"] != "") ? int.Parse(this.Request["data[" + num13 + "][staffID]"]) : 0;
                            Chain.Model.OrderDetail detail = new Chain.Model.OrderDetail();
                            table = this.bllDetail.GetList(" OrderID=" + orderID).Tables[0];
                            int num23 = 0;
                            if (num19 > 0)
                            {
                                for (int i = 0; i < table.Rows.Count; i++)
                                {
                                    this.modelGoods = this.bllGoods.GetModel(goodsID);
                                    if (int.Parse(table.Rows[i]["OrderDetailID"].ToString()) == num15)
                                    {
                                        if (int.Parse(table.Rows[i]["OrderDetailNumber"].ToString()) > 0)
                                        {
                                            detail.OrderID = num10;
                                            detail.GoodsID = goodsID;
                                            detail.OrderDetailPrice = num16;
                                            detail.OrderDetailPoint = num20 * -1;
                                            detail.OrderDetailNumber = num19 * -1;
                                            detail.OrderDetailDiscountPrice = num17 * -1M;
                                            num23 = this.bllDetail.Add(detail);
                                            if (num21 == 0)
                                            {
                                                this.modelNumber.GoodsID = goodsID;
                                                this.modelNumber.ShopID = this.modelOrderLog.OrderShopID;
                                                this.modelNumber.Number = num19;
                                                this.bllNumber.UpdataGoodsNumber(this.modelNumber);
                                                this.modelGoodsDetail.GoodsLogID = num12;
                                                this.modelGoodsDetail.GoodsID = this.modelNumber.GoodsID;
                                                this.modelGoodsDetail.GoodsInPrice = num17;
                                                this.modelGoodsDetail.GoodsOutPrice = 0M;
                                                this.modelGoodsDetail.GoodsNumber = this.modelNumber.Number;
                                                this.bllGoodsDetail.Add(this.modelGoodsDetail);
                                                PubFunction.SaveSysLog(userID, 4, "会员消费退货", string.Concat(new object[] { "会员商品退货,商品名称[", this.modelGoods.Name, "],数量[", num19, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                                            }
                                        }
                                        else if (int.Parse(table.Rows[i]["OrderDetailNumber"].ToString()) < 0)
                                        {
                                            int intNumber = num19;
                                            DataTable table2 = this.bllCountDetail.GetList(-1, string.Concat(new object[] { " CountDetailGoodsID=", goodsID, " and CountDetailMemID=", this.modelOrderLog.OrderMemID }), "CountCreateTime").Tables[0];
                                            for (int j = 0; j < table2.Rows.Count; j++)
                                            {
                                                if (intNumber != 0)
                                                {
                                                    if ((int.Parse(table2.Rows[j]["CountDetailNumber"].ToString()) + intNumber) <= int.Parse(table2.Rows[j]["CountDetailTotalNumber"].ToString()))
                                                    {
                                                        intNumber *= -1;
                                                        this.bllCountDetail.UpdateCountDetailNumber(intNumber, int.Parse(table2.Rows[j]["CountDetailID"].ToString()));
                                                        intNumber = 0;
                                                    }
                                                    else
                                                    {
                                                        int num27 = int.Parse(table2.Rows[j]["CountDetailTotalNumber"].ToString()) - int.Parse(table2.Rows[j]["CountDetailNumber"].ToString());
                                                        num27 *= -1;
                                                        this.bllCountDetail.UpdateCountDetailNumber(num27, int.Parse(table2.Rows[j]["CountDetailID"].ToString()));
                                                        intNumber += num8;
                                                    }
                                                }
                                            }
                                            detail.OrderID = num10;
                                            detail.GoodsID = goodsID;
                                            detail.OrderDetailPrice = num16;
                                            detail.OrderDetailPoint = num20 * -1;
                                            detail.OrderDetailNumber = num19;
                                            detail.OrderDetailDiscountPrice = num17 * -1M;
                                            num23 = this.bllDetail.Add(detail);
                                            PubFunction.SaveSysLog(userID, 4, "会员消费退货", string.Concat(new object[] { "会员计次退次数,计次名称[", this.modelGoods.Name, "],次数[", intNumber, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                                        }
                                    }
                                }
                                DataTable table3 = this.bllStaffMoney.GetList(string.Concat(new object[] { " StaffOrderCode='", this.modelOrderLog.OrderAccount, "' and StaffGoodsID=", goodsID })).Tables[0];
                                if (table3.Rows.Count > 0)
                                {
                                    if (decimal.Parse(table3.Rows[0]["StaffTotalMoney"].ToString()) != num18)
                                    {
                                        this.bllStaffMoney.UpdateStaffMoney(this.modelOrderLog.OrderAccount, goodsID, decimal.Parse(table3.Rows[0]["StaffTotalMoney"].ToString()) - num18);
                                    }
                                    else
                                    {
                                        this.bllStaffMoney.Delete(int.Parse(table3.Rows[0]["StaffMoneyID"].ToString()));
                                    }
                                }
                            }
                        }
                        decimal dclMemMoney = this.modelMem.MemMoney + num5;
                        this.modelMem.MemConsumeMoney -= num5;
                        this.modelMem.MemPoint -= num7;
                        this.modelMem.MemConsumeLastTime = DateTime.Now;
                        if (num11 == 1)
                        {
                            this.modelMem.MemConsumeCount--;
                        }
                        int num29 = this.bllMem.ExpenseUpdateMem(this.modelOrderLog.OrderMemID, dclMemMoney, this.modelMem.MemConsumeMoney, this.modelMem.MemPoint, DateTime.Now, this.modelMem.MemConsumeCount);
                        DataTable table4 = this.bllPoint.GetList(" PointChangeType=9 and PointOrderCode='" + this.modelOrderLog.OrderAccount + "'").Tables[0];
                        DataTable table5 = this.bllPoint.GetList(string.Concat(new object[] { " PointOrderCode='", this.modelOrderLog.OrderAccount, "' and PointMemID=", this.modelMem.MemID })).Tables[0];
                        if (num7 == int.Parse(table5.Rows[0]["PointNumber"].ToString()))
                        {
                            this.modelPoint.PointMemID = this.modelMem.MemID;
                            this.modelPoint.PointNumber = num7 * -1;
                            this.modelPoint.PointChangeType = 1;
                            this.modelPoint.PointRemark = "会员消费退货积分变动";
                            this.modelPoint.PointShopID = shopID;
                            this.modelPoint.PointCreateTime = DateTime.Now;
                            this.modelPoint.PointUserID = userID;
                            this.modelPoint.PointOrderCode = model.OrderAccount;
                            this.bllPoint.Add(this.modelPoint);
                            if (table4 != null)
                            {
                                for (num13 = 0; num13 < table4.Rows.Count; num13++)
                                {
                                    this.modelPoint.PointMemID = int.Parse(table4.Rows[num13]["PointMemID"].ToString());
                                    this.modelPoint.PointNumber = int.Parse(table4.Rows[num13]["PointNumber"].ToString()) * -1;
                                    this.modelPoint.PointChangeType = 11;
                                    this.modelPoint.PointRemark = "会员消费退货推荐人积分变动";
                                    this.modelPoint.PointShopID = shopID;
                                    this.modelPoint.PointCreateTime = DateTime.Now;
                                    this.modelPoint.PointUserID = userID;
                                    this.modelPoint.PointOrderCode = model.OrderAccount;
                                    this.modelPoint.PointGiveMemID = this.modelMem.MemID;
                                    this.bllPoint.Add(this.modelPoint);
                                    this.bllPoint.UpdateMemPoint(int.Parse(table4.Rows[num13]["PointMemID"].ToString()), int.Parse(table4.Rows[num13]["PointNumber"].ToString()));
                                }
                            }
                        }
                        else
                        {
                            int num30 = int.Parse(table5.Rows[0]["PointNumber"].ToString()) - num7;
                            this.modelPoint.PointMemID = this.modelMem.MemID;
                            this.modelPoint.PointNumber = num7 * -1;
                            this.modelPoint.PointChangeType = 1;
                            this.modelPoint.PointRemark = "会员消费退货积分变动";
                            this.modelPoint.PointShopID = shopID;
                            this.modelPoint.PointCreateTime = DateTime.Now;
                            this.modelPoint.PointUserID = userID;
                            this.modelPoint.PointOrderCode = model.OrderAccount;
                            this.bllPoint.Add(this.modelPoint);
                            MEMPointUpdate.MEMPointRate(this.modelMem, num7 * -1, this.modelOrderLog.OrderAccount, -1);
                        }
                        this.modelMem = new Chain.BLL.Mem().GetModel(this.modelOrderLog.OrderMemID);
                        str2 = PubFunction.UpdateMemLevel(this.modelMem);
                        if (this.modelOrderLog.OrderDiscountMoney == num5)
                        {
                            this.bllOrderLog.UpdateType(orderID, 5);
                        }
                        PubFunction.SaveSysLog(userID, 4, "会员消费", "会员商品退货,会员卡号:[" + this.modelMem.MemCard + "],姓名:[" + this.modelMem.MemName + "],订单号:[" + this.modelOrderLog.OrderAccount + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                        s = string.Concat(new object[] { "{\"Success\":\"", num29, "\",\"strUpdateMemLevel\":\"", str2, "\"}" });
                    }
                }
                else
                {
                    s = string.Concat(new object[] { "{\"Success\":\"", -5, "\",\"strUpdateMemLevel\":\"", str2, "\"}" });
                }
            }
            catch
            {
                s = string.Concat(new object[] { "{\"Success\":\"", -1, "\",\"strUpdateMemLevel\":\"", str2, "\"}" });
            }
            this.Context.Response.Write(s);
        }

        public void Revoke()
        {
            string s = "0";
            try
            {
                Chain.Model.OrderLog log;
                int num5;
                int num6;
                DataTable table;
                int num7;
                DataTable table4;
                int orderID = int.Parse(this.Request["orderID"].ToString());
                int num2 = int.Parse(this.Request["memID"].ToString());
                this.modelOrderLog = this.bllOrderLog.GetModel(orderID);
                this.modelMem = this.bllMem.GetModel(this.modelOrderLog.OrderMemID);
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                string str2 = "";
                if (this.modelMem.MemID != 0)
                {
                    if (this.modelMem.MemPoint < this.modelOrderLog.OrderPoint)
                    {
                        s = string.Concat(new object[] { "{\"Success\":\"", -3, "\",\"strUpdateMemLevel\":\"", str2, "\"}" });
                    }
                    else
                    {
                        log = new Chain.Model.OrderLog();
                        log.OrderAccount = "CD" + DateTime.Now.ToString("yyMMddHHmmssffff");
                        log.OrderType = 4;
                        log.OrderMemID = this.modelMem.MemID;
                        log.OrderTotalMoney = this.modelOrderLog.OrderTotalMoney * -1M;
                        log.OrderDiscountMoney = this.modelOrderLog.OrderDiscountMoney * -1M;
                        log.OrderIsCard = this.modelOrderLog.OrderIsCard;
                        log.OrderPayCard = this.modelOrderLog.OrderPayCard * -1M;
                        log.OrderIsCash = this.modelOrderLog.OrderIsCash;
                        log.OrderPayCash = this.modelOrderLog.OrderPayCash * -1M;
                        log.OrderIsBink = this.modelOrderLog.OrderIsBink;
                        log.OrderPayBink = this.modelOrderLog.OrderPayBink * -1M;
                        log.OrderPayCoupon = this.modelOrderLog.OrderPayCoupon * -1M;
                        log.OrderPoint = this.modelOrderLog.OrderPoint * -1;
                        log.OrderRemark = "会员消费撤单";
                        log.OrderPayType = 0;
                        log.OrderShopID = shopID;
                        log.OrderCreateTime = DateTime.Now;
                        log.OrderUserID = userID;
                        log.OldAccount = this.modelOrderLog.OrderAccount;
                        num5 = this.bllOrderLog.Add(log);
                        if (num5 > 0)
                        {
                            if (this.modelOrderLog.OrderType == 2)
                            {
                                this.modelGoodsLog.GoodsAccount = this.modelOrderLog.OrderAccount;
                                this.modelGoodsLog.Type = 5;
                                this.modelGoodsLog.TotalPrice = this.modelOrderLog.OrderDiscountMoney;
                                this.modelGoodsLog.InShopID = shopID;
                                this.modelGoodsLog.OutShopID = shopID;
                                this.modelGoodsLog.Remark = "商品撤单入库";
                                this.modelGoodsLog.CreateTime = DateTime.Now;
                                this.modelGoodsLog.ShopID = shopID;
                                this.modelGoodsLog.UserID = userID;
                                num6 = this.bllGoodsLog.Add(this.modelGoodsLog);
                                table = this.bllDetail.GetList(" OrderID=" + orderID).Tables[0];
                                for (num7 = 0; num7 < table.Rows.Count; num7++)
                                {
                                    this.modelGoods = this.bllGoods.GetModel(int.Parse(table.Rows[num7]["GoodsID"].ToString()));
                                    this.modelDetail.OrderID = num5;
                                    this.modelDetail.GoodsID = int.Parse(table.Rows[num7]["GoodsID"].ToString());
                                    this.modelDetail.OrderDetailPrice = decimal.Parse(table.Rows[num7]["OrderDetailPrice"].ToString());
                                    this.modelDetail.OrderDetailPoint = -1 * int.Parse(table.Rows[num7]["OrderDetailPoint"].ToString());
                                    this.modelDetail.OrderDetailDiscountPrice = -1M * decimal.Parse(table.Rows[num7]["OrderDetailDiscountPrice"].ToString());
                                    this.modelDetail.OrderDetailNumber = -1 * int.Parse(table.Rows[num7]["OrderDetailNumber"].ToString());
                                    if (this.bllDetail.Add(this.modelDetail) > 0)
                                    {
                                        if (float.Parse(table.Rows[num7]["OrderDetailNumber"].ToString()) < 0f)
                                        {
                                            int intNumber = Math.Abs(int.Parse(table.Rows[num7]["OrderDetailNumber"].ToString()));
                                            DataTable table2 = this.bllCountDetail.GetList(-1, string.Concat(new object[] { " CountDetailGoodsID=", this.modelGoods.GoodsID, " and CountDetailMemID=", this.modelOrderLog.OrderMemID }), "CountCreateTime").Tables[0];
                                            for (int i = 0; i < table2.Rows.Count; i++)
                                            {
                                                if (intNumber != 0)
                                                {
                                                    if ((int.Parse(table2.Rows[i]["CountDetailNumber"].ToString()) + intNumber) <= int.Parse(table2.Rows[i]["CountDetailTotalNumber"].ToString()))
                                                    {
                                                        intNumber *= -1;
                                                        this.bllCountDetail.UpdateCountDetailNumber(intNumber, int.Parse(table2.Rows[i]["CountDetailID"].ToString()));
                                                        intNumber = 0;
                                                    }
                                                    else
                                                    {
                                                        int num10 = int.Parse(table2.Rows[i]["CountDetailTotalNumber"].ToString()) - int.Parse(table2.Rows[i]["CountDetailNumber"].ToString());
                                                        num10 *= -1;
                                                        this.bllCountDetail.UpdateCountDetailNumber(num10, int.Parse(table2.Rows[i]["CountDetailID"].ToString()));
                                                        intNumber += num10;
                                                    }
                                                    PubFunction.SaveSysLog(userID, 4, "会员消费撤单", string.Concat(new object[] { "会员计次撤单,计次名称[", this.modelGoods.Name, "],次数[", intNumber, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                                                }
                                            }
                                        }
                                        else if (this.modelGoods.GoodsType == 0)
                                        {
                                            this.modelNumber.GoodsID = int.Parse(table.Rows[num7]["GoodsID"].ToString());
                                            this.modelNumber.ShopID = this.modelOrderLog.OrderShopID;
                                            this.modelNumber.Number = int.Parse(table.Rows[num7]["OrderDetailNumber"].ToString());
                                            this.bllNumber.UpdataGoodsNumber(this.modelNumber);
                                            this.modelGoodsDetail.GoodsLogID = num6;
                                            this.modelGoodsDetail.GoodsID = this.modelNumber.GoodsID;
                                            this.modelGoodsDetail.GoodsInPrice = 0M;
                                            this.modelGoodsDetail.GoodsOutPrice = 0M;
                                            this.modelGoodsDetail.GoodsNumber = this.modelNumber.Number;
                                            this.bllGoodsDetail.Add(this.modelGoodsDetail);
                                            PubFunction.SaveSysLog(userID, 4, "会员消费撤单", string.Concat(new object[] { "会员商品撤单,商品名称[", this.modelGoods.Name, "],数量[", this.modelNumber.Number, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                                        }
                                    }
                                }
                            }
                            decimal dclMemMoney = this.modelMem.MemMoney + this.modelOrderLog.OrderDiscountMoney;
                            this.modelMem.MemConsumeMoney -= this.modelOrderLog.OrderDiscountMoney;
                            this.modelMem.MemPoint -= this.modelOrderLog.OrderPoint;
                            this.modelMem.MemConsumeLastTime = DateTime.Now;
                            this.modelMem.MemConsumeCount--;
                            int num12 = this.bllMem.ExpenseUpdateMem(this.modelOrderLog.OrderMemID, dclMemMoney, this.modelMem.MemConsumeMoney, this.modelMem.MemPoint, DateTime.Now, this.modelMem.MemConsumeCount);
                            DataTable table3 = this.bllPoint.GetList(" PointChangeType=9 and PointOrderCode='" + this.modelOrderLog.OrderAccount + "'").Tables[0];
                            PubFunction.AddShopPoint(userID, this.modelMem.MemShopID, this.modelOrderLog.OrderPoint, "消费撤单,积分返回");
                            if (table3 != null)
                            {
                                for (num7 = 0; num7 < table3.Rows.Count; num7++)
                                {
                                    this.bllPoint.UpdateMemPoint(int.Parse(table3.Rows[num7]["PointMemID"].ToString()), int.Parse(table3.Rows[num7]["PointNumber"].ToString()));
                                }
                            }
                            if (num12 > 0)
                            {
                                this.bllPoint.DeleteLog(this.modelOrderLog.OrderAccount);
                            }
                            table4 = this.bllStaffMoney.GetList(" StaffOrderCode='" + this.modelOrderLog.OrderAccount + "'").Tables[0];
                            if (table4.Rows.Count > 0)
                            {
                                this.bllStaffMoney.DeleteStaff(this.modelOrderLog.OrderAccount);
                            }
                            this.modelMem = new Chain.BLL.Mem().GetModel(this.modelOrderLog.OrderMemID);
                            str2 = PubFunction.UpdateMemLevel(this.modelMem);
                            PubFunction.SaveSysLog(userID, 4, "会员消费", "会员整单撤销,会员卡号:[" + this.modelMem.MemCard + "],姓名:[" + this.modelMem.MemName + "],订单号:[" + this.modelOrderLog.OrderAccount + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                            s = string.Concat(new object[] { "{\"Success\":\"", num12, "\",\"strUpdateMemLevel\":\"", str2, "\"}" });
                        }
                        else
                        {
                            s = "{\"Success\":\"" + -1 + "\",\"strUpdateMemLevel\":\"\"}";
                        }
                    }
                }
                else
                {
                    log = new Chain.Model.OrderLog();
                    log.OrderAccount = "CD" + DateTime.Now.ToString("yyMMddHHmmssffff");
                    log.OrderType = 4;
                    log.OrderMemID = this.modelMem.MemID;
                    log.OrderTotalMoney = this.modelOrderLog.OrderTotalMoney * -1M;
                    log.OrderDiscountMoney = this.modelOrderLog.OrderDiscountMoney * -1M;
                    log.OrderIsCard = this.modelOrderLog.OrderIsCard;
                    log.OrderPayCard = this.modelOrderLog.OrderPayCard * -1M;
                    log.OrderIsCash = this.modelOrderLog.OrderIsCash;
                    log.OrderPayCash = this.modelOrderLog.OrderPayCash * -1M;
                    log.OrderIsBink = this.modelOrderLog.OrderIsBink;
                    log.OrderPayBink = this.modelOrderLog.OrderPayBink * -1M;
                    log.OrderPayCoupon = this.modelOrderLog.OrderPayCoupon * -1M;
                    log.OrderPoint = this.modelOrderLog.OrderPoint * -1;
                    log.OrderRemark = "散客消费撤单";
                    log.OrderPayType = 0;
                    log.OrderShopID = shopID;
                    log.OrderCreateTime = DateTime.Now;
                    log.OrderUserID = userID;
                    log.OldAccount = this.modelOrderLog.OrderAccount;
                    num5 = this.bllOrderLog.Add(log);
                    if ((num5 > 0) && (this.modelOrderLog.OrderType == 2))
                    {
                        this.modelGoodsLog.GoodsAccount = this.modelOrderLog.OrderAccount;
                        this.modelGoodsLog.Type = 5;
                        this.modelGoodsLog.TotalPrice = this.modelOrderLog.OrderDiscountMoney;
                        this.modelGoodsLog.InShopID = shopID;
                        this.modelGoodsLog.OutShopID = shopID;
                        this.modelGoodsLog.Remark = "商品撤单入库";
                        this.modelGoodsLog.CreateTime = DateTime.Now;
                        this.modelGoodsLog.ShopID = shopID;
                        this.modelGoodsLog.UserID = userID;
                        num6 = this.bllGoodsLog.Add(this.modelGoodsLog);
                        table = this.bllDetail.GetList(" OrderID=" + orderID).Tables[0];
                        for (num7 = 0; num7 < table.Rows.Count; num7++)
                        {
                            this.modelGoods = this.bllGoods.GetModel(int.Parse(table.Rows[num7]["GoodsID"].ToString()));
                            if (this.modelGoods.GoodsType == 0)
                            {
                                this.modelDetail.OrderID = num5;
                                this.modelDetail.GoodsID = int.Parse(table.Rows[num7]["GoodsID"].ToString());
                                this.modelDetail.OrderDetailPrice = decimal.Parse(table.Rows[num7]["OrderDetailPrice"].ToString());
                                this.modelDetail.OrderDetailPoint = int.Parse(table.Rows[num7]["OrderDetailPoint"].ToString());
                                this.modelDetail.OrderDetailDiscountPrice = decimal.Parse(table.Rows[num7]["OrderDetailDiscountPrice"].ToString());
                                this.modelDetail.OrderDetailNumber = int.Parse(table.Rows[num7]["OrderDetailNumber"].ToString());
                                if (this.bllDetail.Add(this.modelDetail) > 0)
                                {
                                    this.modelNumber.GoodsID = int.Parse(table.Rows[num7]["GoodsID"].ToString());
                                    this.modelNumber.ShopID = this.modelOrderLog.OrderShopID;
                                    this.modelNumber.Number = int.Parse(table.Rows[num7]["OrderDetailNumber"].ToString());
                                    this.bllNumber.UpdataGoodsNumber(this.modelNumber);
                                    this.modelGoodsDetail.GoodsLogID = num6;
                                    this.modelGoodsDetail.GoodsID = this.modelNumber.GoodsID;
                                    this.modelGoodsDetail.GoodsInPrice = 0M;
                                    this.modelGoodsDetail.GoodsOutPrice = 0M;
                                    this.modelGoodsDetail.GoodsNumber = this.modelNumber.Number;
                                    this.bllGoodsDetail.Add(this.modelGoodsDetail);
                                    PubFunction.SaveSysLog(userID, 4, "散客消费撤单", string.Concat(new object[] { "散客商品撤单,商品名称[", this.modelGoods.Name, "],数量[", this.modelNumber.Number, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                                }
                                else
                                {
                                    s = "{\"Success\":\"" + -1 + "\",\"strUpdateMemLevel\":\"\"}";
                                }
                            }
                        }
                    }
                    table4 = this.bllStaffMoney.GetList(" StaffOrderCode='" + this.modelOrderLog.OrderAccount + "'").Tables[0];
                    if (table4.Rows.Count > 0)
                    {
                        this.bllStaffMoney.DeleteStaff(this.modelOrderLog.OrderAccount);
                    }
                    this.modelOrderLog.OrderType = 5;
                    this.bllOrderLog.Update(this.modelOrderLog);
                    PubFunction.SaveSysLog(userID, 4, "散客消费", "散客整单撤销,订单号:[" + this.modelOrderLog.OrderAccount + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                    s = string.Concat(new object[] { "{\"Success\":\"", 1, "\",\"strUpdateMemLevel\":\"", str2, "\"}" });
                }
            }
            catch (Exception)
            {
                s = "{\"Success\":\"" + -1 + "\",\"strUpdateMemLevel\":\"\"}";
            }
            this.Context.Response.Write(s);
        }

        public void SecondPrinting()
        {
            string s = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            int num = int.Parse(this.Request["orderID"]);
            int num2 = int.Parse(this.Request["orderType"]);
            int num3 = int.Parse(this.Request["memID"]);
            StringBuilder builder = new StringBuilder();
            DataTable dt = this.bllOrderLog.GetList(" OrderID=" + num).Tables[0];
            if (dt != null)
            {
                str2 = JsonPlus.ToJson(dt, "");
                DataTable table2 = this.bllMem.GetList(" MemID=" + num3).Tables[0];
                if (table2 != null)
                {
                    str4 = JsonPlus.ToJson(table2, "MemID,MemCard,MemName,MemPoint,MemMoney");
                    s = string.Concat(new object[] { "{\"orderType\":", num2, ",\"expense\":", str2, ",\"mem\":", str4, "}" });
                    if (num2 == 2)
                    {
                        DataTable table3 = this.bllDetail.GetOrderDetail(" OrderDetail.OrderID=" + num).Tables[0];
                        if (table3 != null)
                        {
                            str3 = JsonPlus.ToJson(table3, "");
                        }
                        s = string.Concat(new object[] { "{\"orderType\":", num2, ",\"expense\":", str2, ",\"mem\":", str4, ",\"expenseDetail\":", str3, "}" });
                    }
                }
            }
            this.Context.Response.Write(s);
        }

        public void SendCoupon()
        {
            int num = 0;
            try
            {
                string input = this.Request["MemID"].ToString();
                int top = (this.Request["Number"].ToString() != "") ? int.Parse(this.Request["Number"].ToString()) : 0;
                int iD = (this.Request["CouponID"].ToString() != "") ? int.Parse(this.Request["CouponID"].ToString()) : 0;
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                Chain.Model.SysShop model = new Chain.BLL.SysShop().GetModel(shopID);
                Chain.BLL.Coupon coupon = new Chain.BLL.Coupon();
                Chain.Model.Coupon coupon2 = new Chain.Model.Coupon();
                coupon2 = coupon.GetModel(iD);
                if (Convert.ToInt32(SMSInfo.GetBalance(false)) < top)
                {
                    num = -1;
                }
                else if (PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), input.Split(new char[] { ',' }).Length))
                {
                    if (coupon2.CouponPredictNu < top)
                    {
                        num = -2;
                    }
                    else
                    {
                        StringBuilder builder = new StringBuilder(coupon2.CouponContent);
                        builder.Replace("{店铺}", model.ShopName);
                        builder.Replace("{优惠劵}", coupon2.CouponTitle);
                        string newValue = "";
                        if (coupon2.CouponEnd.HasValue)
                        {
                            newValue = DateTime.Parse(coupon2.CouponEnd.ToString()).ToShortDateString();
                        }
                        else
                        {
                            newValue = "永久";
                        }
                        builder.Replace("{有效期}", newValue);
                        string str3 = Math.Round(coupon2.CouponMinMoney, 2).ToString();
                        builder.Replace("{最低消费}", str3);
                        builder.Replace("{店面电话}", model.ShopTelephone);
                        Chain.BLL.CouponList list = new Chain.BLL.CouponList();
                        DataTable dt = list.GetList(top, " CouPonID=" + iD + " and CouPonYF='False' ", " CID ").Tables[0];
                        List list2 = list.DataTableToList(dt);
                        list2.Sort(delegate(Chain.Model.CouponList p1, Chain.Model.CouponList p2)
                        {
                            return Comparer.Default.Compare(p1.CID, p2.CID);
                        });
                        ArrayList sqlArray = new ArrayList();
                        string[] strArray = Regex.Split(input, ",", RegexOptions.IgnoreCase);
                        for (int i = 0; i < top; i++)
                        {
                            if (strArray[i] != "")
                            {
                                StringBuilder builder2 = new StringBuilder(builder.ToString());
                                builder2.Replace("{劵号}", list2[i].CouPon);
                                if (SMSInfo.Send_GXSMS(new Chain.BLL.Mem().GetModel(int.Parse(strArray[i])).MemMobile, builder2.ToString(), ""))
                                {
                                    string str4 = ("update CouponList set CouPonYF='True',CouPonMID=" + strArray[i] + ",ConPonSendTime='" + DateTime.Now.ToString()) + "' where Coupon='" + list2[i].CouPon + "';";
                                    sqlArray.Add(str4);
                                }
                            }
                        }
                        if (list.DataUpdateTran(sqlArray))
                        {
                            coupon2.CouponYF += top;
                            coupon.Update(coupon2);
                            num = 1;
                            PubFunction.SaveSysLog(userID, 4, "优惠券", string.Concat(new object[] { "批量发放优惠券,发送", top, "人,优惠去名称[", coupon2.CouponTitle, "]" }), shopID, DateTime.Now, PubFunction.ipAdress);
                        }
                    }
                    PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), input.Split(new char[] { ',' }).Length, 2);
                }
                else
                {
                    num = -5;
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void SendMessage()
        {
            int num = 0;
            string mobileList = (this.Request["strReceiver"] != null) ? this.Request["strReceiver"].ToString() : "";
            string content = (this.Request["strContent"] != null) ? this.Request["strContent"].ToString() : "";
            int userID = int.Parse(this.Session["UID"].ToString());
            int shopID = int.Parse(this.Session["UserShopID"].ToString());
            if (mobileList.Substring(mobileList.Length - 1, 1) == ",")
            {
                mobileList = mobileList.Remove(mobileList.LastIndexOf(","), 1);
            }
            if (Convert.ToInt32(SMSInfo.GetBalance(true)) > 0)
            {
                if (!PubFunction.IsCanSendSms(Convert.ToInt32(this.Session["UserShopID"]), mobileList.Split(new char[] { ',' }).Length))
                {
                    num = 5;
                }
                else
                {
                    content = content + "【" + PubFunction.curParameter.strSmsShopName + "】";
                    if (SMSInfo.Send_SMS(true, mobileList, content, ""))
                    {
                        num = 1;
                        Chain.Model.SmsLog model = new Chain.Model.SmsLog();
                        model.SmsMemID = 0;
                        model.SmsMobile = mobileList;
                        model.SmsContent = content;
                        model.SmsTime = DateTime.Now;
                        model.SmsShopID = shopID;
                        model.SmsUserID = userID;
                        model.SmsAmount = PubFunction.GetSmsAmount(content);
                        model.SmsAllAmount = model.SmsAmount;
                        new Chain.BLL.SmsLog().Add(model);
                        PubFunction.SetShopSms(userID, Convert.ToInt32(this.Session["UserShopID"]), mobileList.Split(new char[] { ',' }).Length, 2);
                        PubFunction.SaveSysLog(userID, 4, "自定义短信", "自定义发送短信", shopID, DateTime.Now, PubFunction.ipAdress);
                    }
                    else
                    {
                        num = 2;
                    }
                }
            }
            else
            {
                num = 3;
            }
            this.Context.Response.Write(num);
        }

        public void SetShopMemLecel()
        {
            int num = -1;
            try
            {
                int shopMemLevelID = int.Parse(this.Request["ShopMemLevelID"]);
                decimal num3 = decimal.Parse(this.Request["ClassDiscountPercent"]) / 100M;
                decimal num4 = decimal.Parse(this.Request["ClassPointPercent"]);
                Chain.BLL.SysShopMemLevel level = new Chain.BLL.SysShopMemLevel();
                Chain.Model.SysShopMemLevel model = level.GetModel(shopMemLevelID);
                model.ClassDiscountPercent = num3;
                model.ClassPointPercent = num4;
                level.Update(model);
                num = 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void SetShopPonit()
        {
            int num = 0;
            try
            {
                int shopID = Convert.ToInt32(this.Request["shopID"]);
                int type = Convert.ToInt32(this.Request["type"]);
                int point = Convert.ToInt32(this.Request["count"]);
                Chain.BLL.SysShop shop = new Chain.BLL.SysShop();
                Chain.Model.SysShop model = new Chain.Model.SysShop();
                model = shop.GetModel(shopID);
                if ((model.PointCount < point) && (type == 1))
                {
                    num = 1;
                }
                else if ((type != 0) || PubFunction.IsShopPoint(model.FatherShopID, ref point))
                {
                    string str = "";
                    if (type == 0)
                    {
                        model.PointCount += point;
                        str = "新增";
                    }
                    else
                    {
                        model.PointCount -= point;
                        str = "扣除";
                    }
                    shop.Update(model);
                    Chain.BLL.SysShopPointLog log = new Chain.BLL.SysShopPointLog();
                    Chain.Model.SysShopPointLog log2 = new Chain.Model.SysShopPointLog();
                    log2.Count = (type == 0) ? point : (-1 * point);
                    log2.CreateTime = DateTime.Now;
                    log2.OutShopID = shopID;
                    log2.ShopID = int.Parse(this.Session["UserShopID"].ToString());
                    log2.ShopPointAccount = "JF" + DateTime.Now.ToString("yyMMddHHmmssffff");
                    log2.ShopPointType = type;
                    log2.UserID = int.Parse(this.Session["UID"].ToString());
                    log2.Remark = "总店" + str + "积分";
                    log.Add(log2);
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 1, "店铺积分变动", "店铺:[" + model.ShopName + "]" + str + point.ToString() + "积分", int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                    num = 2;
                    if (type != 0)
                    {
                        point = -1 * point;
                    }
                    type = (type == 0) ? 1 : 0;
                    PubFunction.SetShopPoint(int.Parse(this.Session["UID"].ToString()), model.FatherShopID, point, "子店铺积分" + str, type);
                }
                else
                {
                    num = -5;
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(num);
        }

        public void SetShopSettlement()
        {
            int num = 0;
            try
            {
                int iD = Convert.ToInt32(this.Request["ID"]);
                Chain.Model.SysShopSettlement model = new Chain.Model.SysShopSettlement();
                Chain.BLL.SysShopSettlement settlement2 = new Chain.BLL.SysShopSettlement();
                model = settlement2.GetModel(iD);
                model.IsFinish = true;
                model.UserID = Convert.ToInt32(this.Session["UID"]);
                model.Remark = this.Request["Remark"].ToString();
                model.FinishTime = DateTime.Now;
                settlement2.Update(model);
                num = 2;
            }
            catch
            {
            }
            this.Context.Response.Write(num);
        }

        public void SetShopSms()
        {
            int num = 0;
            try
            {
                int shopID = Convert.ToInt32(this.Request["shopID"]);
                int type = Convert.ToInt32(this.Request["type"]);
                int memMobileCount = Convert.ToInt32(this.Request["count"]);
                Chain.BLL.SysShop shop = new Chain.BLL.SysShop();
                Chain.Model.SysShop model = new Chain.Model.SysShop();
                model = shop.GetModel(shopID);
                if ((model.SmsCount < memMobileCount) && (type == 1))
                {
                    num = 1;
                }
                else if (PubFunction.IsCanSendSms(model.FatherShopID, memMobileCount) || (type != 0))
                {
                    string str = "";
                    if (type == 0)
                    {
                        model.SmsCount += memMobileCount;
                        str = "新增";
                    }
                    else
                    {
                        model.SmsCount -= memMobileCount;
                        str = "扣除";
                    }
                    shop.Update(model);
                    Chain.BLL.SysShopCmsLog log = new Chain.BLL.SysShopCmsLog();
                    Chain.Model.SysShopCmsLog log2 = new Chain.Model.SysShopCmsLog();
                    log2.Count = (type == 0) ? memMobileCount : (-1 * memMobileCount);
                    log2.CreateTime = DateTime.Now;
                    log2.OutShopID = shopID;
                    log2.ShopID = int.Parse(this.Session["UserShopID"].ToString());
                    log2.ShopCmsAccount = "DX" + DateTime.Now.ToString("yyMMddHHmmssffff");
                    log2.ShopCmsType = type;
                    log2.UserID = int.Parse(this.Session["UID"].ToString());
                    log2.Remark = "总店" + str + "短信";
                    log.Add(log2);
                    PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 1, "店铺短信变动", "店铺:[" + model.ShopName + "]" + str + memMobileCount.ToString() + "短信", int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                    num = 2;
                    if (type != 0)
                    {
                        memMobileCount = -1 * memMobileCount;
                    }
                    type = (type == 0) ? 1 : 0;
                    PubFunction.SetShopSms(int.Parse(this.Session["UID"].ToString()), model.FatherShopID, memMobileCount, type);
                }
                else
                {
                    num = -5;
                }
            }
            catch (Exception)
            {
            }
            this.Context.Response.Write(num);
        }

        public void ShopAdd()
        {
            int shopid = 0;
            try
            {
                string str = this.Request["shopName"].ToString();
                string str2 = this.Request["shopContactMan"].ToString();
                string str3 = this.Request["shopTelephone"].ToString();
                string str4 = this.Request["shopAddress"].ToString();
                string str5 = this.Request["shopRemark"].ToString();
                string str6 = this.Request["shopTitle"].ToString();
                string str7 = this.Request["shopFoot"].ToString();
                string str8 = this.Request["shopSmsName"].ToString();
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                Chain.Model.SysShop model = new Chain.Model.SysShop();
                model.ShopName = str;
                model.ShopContactMan = str2;
                model.ShopTelephone = str3;
                model.ShopAddress = str4;
                model.ShopRemark = str5;
                model.ShopCreateTime = DateTime.Now;
                model.ShopPrintTitle = str6;
                model.ShopPrintFoot = str7;
                model.ShopSmsName = str8;
                model.SettlementInterval = Convert.ToInt32(this.Request["SettlementInterval"]);
                model.ShopProportion = Convert.ToDecimal(this.Request["ShopProportion"]);
                model.IsAllianceProgram = this.Request["IsAllianceProgram"].ToString() == "1";
                model.FatherShopID = Convert.ToInt32(this.Request["FatherShopID"]);
                model.UnitList = this.Request["UnitList"].ToString();
                model.SmsType = Convert.ToInt32(this.Request["SmsType"]);
                model.PointType = Convert.ToInt32(this.Request["PointType"]);
                model.StockCount = Convert.ToInt32(this.Request["StockCount"]);
                Chain.Model.SysShop shop2 = new Chain.BLL.SysShop().GetModel(model.FatherShopID);
                if ((shop2.PointType < model.PointType) || (shop2.SmsType < model.SmsType))
                {
                    shopid = -5;
                }
                else
                {
                    if (this.Request["isChoose"] == "0")
                    {
                        model.ShopState = true;
                    }
                    else
                    {
                        model.ShopState = false;
                    }
                    Chain.BLL.SysShop shop3 = new Chain.BLL.SysShop();
                    shopid = shop3.Add(model);
                    if (shopid > 0)
                    {
                        new Chain.BLL.SysShopMemLevel().AddShopLevelByShopAdd(shopid);
                        Chain.BLL.SysParameter parameter = new Chain.BLL.SysParameter();
                        Chain.Model.SysParameter parameter2 = new Chain.Model.SysParameter();
                        parameter2 = parameter.GetModel(1);
                        parameter2.ShopID = shopid;
                        parameter.Add(parameter2);
                        string str9 = shopid.ToString();
                        Chain.BLL.SysShopAuthority authority = new Chain.BLL.SysShopAuthority();
                        Chain.Model.SysShopAuthority authority2 = new Chain.Model.SysShopAuthority();
                        authority2.ShopAuthorityShopID = new int?(shopid);
                        authority2.ShopAuthorityData = str9;
                        if (authority.Add(authority2) > 0)
                        {
                            DataTable table = authority.GetList(" ShopAuthorityShopID=1 ").Tables[0];
                            str9 = "";
                            DataTable table2 = shop3.GetList("ShopID>0").Tables[0];
                            for (int i = 0; i < table2.Rows.Count; i++)
                            {
                                str9 = str9 + table2.Rows[i]["ShopID"].ToString() + ",";
                            }
                            str9 = str9.Remove(str9.Length - 1);
                            if (table.Rows.Count > 0)
                            {
                                authority2.ShopAuthorityID = int.Parse(table.Rows[0]["ShopAuthorityID"].ToString());
                                authority2.ShopAuthorityShopID = 1;
                                authority2.ShopAuthorityData = str9;
                                authority.Update(authority2);
                            }
                            else
                            {
                                authority2.ShopAuthorityShopID = 1;
                                authority2.ShopAuthorityData = str9;
                                int num6 = authority.Add(authority2);
                                if (num6 > 0)
                                {
                                    authority2.ShopAuthorityID = num6;
                                    authority2.ShopAuthorityShopID = 1;
                                    authority2.ShopAuthorityData = str9;
                                    authority.Update(authority2);
                                }
                            }
                        }
                        if (PubFunction.curParameter.sameGoods)
                        {
                            this.bllNumber.InitShopData();
                        }
                        PubFunction.SaveSysLog(userID, 1, "店铺新增", "新增店铺,店铺名称:[" + model.ShopName + "],店铺联系人:[" + model.ShopContactMan + "],联系方式:[" + model.ShopTelephone + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
            }
            catch
            {
                shopid = -3;
            }
            this.Context.Response.Write(shopid);
        }

        public void ShopAuthority()
        {
            int num = 0;
            try
            {
                string str = this.Request["ShopID"].ToString();
                string str2 = this.Request["List"].ToString();
                Chain.BLL.SysShopAuthority authority = new Chain.BLL.SysShopAuthority();
                Chain.Model.SysShopAuthority model = authority.GetModelList(" ShopAuthorityShopID = " + str)[0];
                str2 = str + "," + str2;
                model.ShopAuthorityData = str2.Remove(str2.Length - 1, 1);
                if (authority.Update(model))
                {
                    num = 1;
                }
            }
            catch
            {
                num = 2;
            }
            this.Context.Response.Write(num);
        }

        public void ShopBuyCard()
        {
            int num = 0;
            try
            {
                if (PubFunction.IsCanBuyCard(this.Request["StartCardNumber"].ToString(), this.Request["EndCardNumber"].ToString()))
                {
                    Chain.BLL.SysShopBuyCard card = new Chain.BLL.SysShopBuyCard();
                    Chain.Model.SysShopBuyCard model = new Chain.Model.SysShopBuyCard();
                    model.BuyCardMoney = Convert.ToDecimal(this.Request["BuyCardMoney"]);
                    model.BuyCardShopid = Convert.ToInt32(this.Request["ShopID"]);
                    model.BuyCardTime = DateTime.Now;
                    model.EndCardNumber = this.Request["EndCardNumber"].ToString();
                    model.Remark = this.Request["Remark"].ToString();
                    model.StartCardNumber = this.Request["StartCardNumber"].ToString();
                    model.UserID = Convert.ToInt32(this.Session["UID"]);
                    num = card.Add(model);
                }
                else
                {
                    num = -1;
                }
            }
            catch
            {
            }
            this.Context.Response.Write(num);
        }

        public void ShopEdit()
        {
            int num = 0;
            try
            {
                int shopID = int.Parse(this.Request["shopID"].ToString());
                string str = this.Request["shopName"].ToString();
                string str2 = this.Request["shopContactMan"].ToString();
                string str3 = this.Request["shopTelephone"].ToString();
                string str4 = this.Request["shopAddress"].ToString();
                string str5 = this.Request["shopRemark"].ToString();
                string str6 = this.Request["shopTitle"].ToString();
                string str7 = this.Request["shopFoot"].ToString();
                string str8 = this.Request["shopSmsName"].ToString();
                int num3 = int.Parse(this.Session["UserShopID"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                Chain.Model.SysShop model = new Chain.BLL.SysShop().GetModel(shopID);
                model.ShopName = str;
                model.ShopContactMan = str2;
                model.ShopTelephone = str3;
                model.ShopAddress = str4;
                model.ShopRemark = str5;
                model.ShopPrintTitle = str6;
                model.ShopPrintFoot = str7;
                model.ShopSmsName = str8;
                model.SettlementInterval = Convert.ToInt32(this.Request["SettlementInterval"]);
                model.ShopProportion = Convert.ToDecimal(this.Request["ShopProportion"]);
                model.UnitList = this.Request["UnitList"].ToString();
                model.SmsType = Convert.ToInt32(this.Request["SmsType"]);
                model.PointType = Convert.ToInt32(this.Request["PointType"]);
                model.StockCount = Convert.ToInt32(this.Request["StockCount"]);
                Chain.Model.SysShop shop2 = new Chain.BLL.SysShop().GetModel(Convert.ToInt32(this.Request["FatherShopID"]));
                if (((shopID > 1) && (shop2.PointType < model.PointType)) || ((shopID > 1) && (shop2.SmsType < model.SmsType)))
                {
                    num = -5;
                }
                else
                {
                    if (this.Request["isChoose"] == "0")
                    {
                        if (num3 != model.ShopID)
                        {
                            model.ShopState = true;
                            new Chain.BLL.SysUser().UpdateUserLock(model.ShopID, 1);
                        }
                        else
                        {
                            num = -2;
                        }
                    }
                    else
                    {
                        model.ShopState = false;
                        new Chain.BLL.SysUser().UpdateUserLock(model.ShopID, 0);
                    }
                    if (num >= 0)
                    {
                        num = new Chain.BLL.SysShop().Update(model);
                    }
                    if (num > 0)
                    {
                        PubFunction.SaveSysLog(userID, 3, "店铺编辑", "店铺修改,店铺名称:[" + model.ShopName + "],店铺联系人:[" + model.ShopContactMan + "],联系方式:[" + model.ShopTelephone + "]", num3, DateTime.Now, PubFunction.ipAdress);
                    }
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void SmsTemplateAdd()
        {
            int num = 0;
            try
            {
                string str = this.Request["templateName"].ToString();
                string str2 = this.Request["templateContent"].ToString();
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                Chain.Model.SmsTemplate model = new Chain.Model.SmsTemplate();
                model.TemplateName = str;
                model.TemplateContent = str2;
                num = new Chain.BLL.SmsTemplate().Add(model);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(userID, 1, "模板新增", "新增短信模板,模板名称:[" + model.TemplateName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void SmsTemplateDelete()
        {
            int num = 0;
            try
            {
                int templateID = (this.Request["TemplateID"].ToString() != "") ? int.Parse(this.Request["TemplateID"].ToString()) : 0;
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                Chain.BLL.SmsTemplate template = new Chain.BLL.SmsTemplate();
                Chain.Model.SmsTemplate model = new Chain.Model.SmsTemplate();
                model = template.GetModel(templateID);
                if (template.Delete(templateID))
                {
                    PubFunction.SaveSysLog(userID, 2, "模板删除", "删除短信模板,模板名称:[" + model.TemplateName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                    num = 1;
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void SmsTemplateEdit()
        {
            int num = 0;
            try
            {
                int num2 = int.Parse(this.Request["templateID"].ToString());
                string str = this.Request["templateName"].ToString();
                string str2 = this.Request["templateContent"].ToString();
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                Chain.Model.SmsTemplate model = new Chain.Model.SmsTemplate();
                model.TemplateID = num2;
                model.TemplateName = str;
                model.TemplateContent = str2;
                num = new Chain.BLL.SmsTemplate().Update(model);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(userID, 3, "模板编辑", "修改短信模板,模板名称:[" + model.TemplateName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void StaffAdd()
        {
            int num = 0;
            try
            {
                Chain.Model.Staff model = new Chain.Model.Staff();
                int num2 = (this.Request["StaffClass"].ToString() != "") ? int.Parse(this.Request["StaffClass"].ToString()) : 0;
                bool flag = this.Request["StaffSex"].ToString() == "0";
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                model.StaffNumber = this.Request["StaffNumber"].ToString();
                model.StaffName = this.Request["StaffName"].ToString();
                model.StaffSex = flag;
                model.StaffClassID = num2;
                model.StaffMobile = this.Request["StaffMobile"].ToString();
                model.StaffAddress = this.Request["StaffAddress"].ToString();
                model.StaffRemark = this.Request["StaffRemark"].ToString();
                num = new Chain.BLL.Staff().Add(model);
                PubFunction.SaveSysLog(userID, 1, "员工新增", "新增员工,员工姓名:[" + model.StaffName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void StaffClassAdd()
        {
            int num = 0;
            try
            {
                Chain.Model.StaffClass model = new Chain.Model.StaffClass();
                int num2 = (this.Request["ClassShopID"].ToString() != "") ? int.Parse(this.Request["ClassShopID"].ToString()) : 0;
                bool flag = this.Request["ClassType"].ToString() == "0";
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                model.ClassName = this.Request["ClassName"].ToString();
                model.ClassType = flag;
                model.ClassPercent = (this.Request["ClassPercent"].ToString() != "") ? decimal.Parse(this.Request["ClassPercent"].ToString()) : 0M;
                model.ClassShopID = num2;
                model.ClassRemark = this.Request["ClassRemark"].ToString();
                num = new Chain.BLL.StaffClass().Add(model);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(userID, 1, "部门新增", "新增部门,部门名称:[" + model.ClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -2;
            }
            this.Context.Response.Write(num);
        }

        public void StaffClassDelete()
        {
            int num = 0;
            try
            {
                int classID = (this.Request["ClassID"].ToString() != "") ? int.Parse(this.Request["ClassID"].ToString()) : 0;
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                Chain.BLL.StaffClass class2 = new Chain.BLL.StaffClass();
                Chain.Model.StaffClass model = class2.GetModel(classID);
                num = class2.Delete(classID);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(userID, 2, "部门删除", "删除部门,部门名称:[" + model.ClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void StaffClassEdit()
        {
            int num = 0;
            try
            {
                Chain.Model.StaffClass model = new Chain.Model.StaffClass();
                int num2 = (this.Request["ClassID"].ToString() != "") ? int.Parse(this.Request["ClassID"].ToString()) : 0;
                int num3 = (this.Request["ClassShopID"].ToString() != "") ? int.Parse(this.Request["ClassShopID"].ToString()) : 0;
                bool flag = this.Request["ClassType"].ToString() == "0";
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                model.ClassID = num2;
                model.ClassName = this.Request["ClassName"].ToString();
                model.ClassType = flag;
                model.ClassPercent = (this.Request["ClassPercent"].ToString() != "") ? decimal.Parse(this.Request["ClassPercent"].ToString()) : 0M;
                model.ClassShopID = num3;
                model.ClassRemark = this.Request["ClassRemark"].ToString();
                num = new Chain.BLL.StaffClass().Update(model);
                if (num > 0)
                {
                    PubFunction.SaveSysLog(userID, 3, "部门编辑", "编辑部门,部门名称:[" + model.ClassName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -2;
            }
            this.Context.Response.Write(num);
        }

        public void StaffDelete()
        {
            int num = 0;
            try
            {
                int staffID = (this.Request["StaffID"].ToString() != "") ? int.Parse(this.Request["StaffID"].ToString()) : 0;
                Chain.BLL.Staff staff = new Chain.BLL.Staff();
                Chain.Model.Staff model = staff.GetModel(staffID);
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                if (staff.Delete(staffID))
                {
                    num = 1;
                    PubFunction.SaveSysLog(userID, 2, "员工删除", "删除员工,员工姓名:[" + model.StaffName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -1;
            }
            this.Context.Response.Write(num);
        }

        public void StaffEdit()
        {
            int num = 0;
            try
            {
                Chain.Model.Staff model = new Chain.Model.Staff();
                int num2 = (this.Request["StaffID"].ToString() != "") ? int.Parse(this.Request["StaffID"].ToString()) : 0;
                int num3 = (this.Request["StaffClass"].ToString() != "") ? int.Parse(this.Request["StaffClass"].ToString()) : 0;
                bool flag = this.Request["StaffSex"].ToString() == "0";
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                model.StaffID = num2;
                model.StaffNumber = this.Request["StaffNumber"].ToString();
                model.StaffName = this.Request["StaffName"].ToString();
                model.StaffSex = flag;
                model.StaffClassID = num3;
                model.StaffMobile = this.Request["StaffMobile"].ToString();
                model.StaffAddress = this.Request["StaffAddress"].ToString();
                model.StaffRemark = this.Request["StaffRemark"].ToString();
                num = new Chain.BLL.Staff().Update(model);
                PubFunction.SaveSysLog(userID, 3, "员工编辑", "编辑员工,员工姓名:[" + model.StaffName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void TextRuleAdd()
        {
            int num = 0;
            try
            {
                Chain.Model.WeiXinRule model = new Chain.Model.WeiXinRule();
                model.RuleNUmber = this.Request["RuleNUmber"];
                model.RuleNewsType = "text";
                model.RuleDesc = this.Request["RuleDesc"];
                model.RuleContent = this.Request["RuleContent"];
                model.RuleUserID = int.Parse(this.Session["UID"].ToString());
                model.RuleCreateTime = DateTime.Now;
                if (new Chain.BLL.WeiXinRule().GetList("RuleNUmber='" + model.RuleNUmber + "' ").Tables[0].Rows.Count > 0)
                {
                    num = -1;
                }
                else
                {
                    num = new Chain.BLL.WeiXinRule().Add(model);
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void TextRuleDel()
        {
            int num = 0;
            try
            {
                int ruleID = int.Parse(this.Request["RuleID"]);
                Chain.BLL.WeiXinMenu menu = new Chain.BLL.WeiXinMenu();
                if (menu.GetUseCountByRuleID(ruleID) > 0)
                {
                    num = -1;
                }
                else
                {
                    num = new Chain.BLL.WeiXinRule().Delete(ruleID) ? 1 : 0;
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void TextRuleEdit()
        {
            int num = 0;
            try
            {
                Chain.Model.WeiXinRule model = new Chain.Model.WeiXinRule();
                Chain.BLL.WeiXinRule rule2 = new Chain.BLL.WeiXinRule();
                model.RuleID = int.Parse(this.Request["RuleID"]);
                model.RuleNUmber = this.Request["RuleNUmber"];
                model.RuleNewsType = "text";
                model.RuleDesc = this.Request["RuleDesc"];
                model.RuleContent = this.Request["RuleContent"];
                model.RuleUserID = int.Parse(this.Session["UID"].ToString());
                model.RuleCreateTime = DateTime.Now;
                string strWhere = string.Concat(new object[] { "RuleID != ", model.RuleID, " and RuleNUmber='", model.RuleNUmber, "' " });
                if (rule2.GetList(strWhere).Tables[0].Rows.Count > 0)
                {
                    num = -1;
                }
                else
                {
                    Chain.Model.WeiXinRule rule3 = rule2.GetModel(model.RuleID);
                    num = rule2.Update(model) ? 1 : 0;
                    if (rule3.RuleNUmber != model.RuleNUmber)
                    {
                        new Chain.BLL.WeiXinMenu().UpdateMenuKey(rule3.RuleNUmber, model.RuleNUmber);
                    }
                }
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void TimeExpenseEnd()
        {
            string str = "0";
            string str2 = "";
            string s = "";
            bool flag = bool.Parse(this.Request["isMem"].ToString());
            try
            {
                string str4 = this.Request["Token"].ToString();
                DataTable table = this.bllOrderTime.GetList(" OrderState=0 and OrderToken='" + str4 + "'").Tables[0];
                if (table.Rows.Count > 0)
                {
                    this.modelOrderTime = this.bllOrderTime.GetModel(int.Parse(table.Rows[0]["OrderTimeID"].ToString()));
                    this.modelMem = this.bllMem.GetModel(this.modelOrderTime.OrderMemID);
                    this.modelOrderTime.OrderState = true;
                    this.modelOrderTime.OrderOutTime = DateTime.Now;
                    this.modelOrderTime.OrderEndUserID = int.Parse(this.Session["UID"].ToString());
                    if (this.bllOrderTime.Update(this.modelOrderTime))
                    {
                        str = "1";
                        string str5 = this.modelOrderTime.OrderOutTime.Subtract(this.modelOrderTime.OrderMarchTime).ToString().Substring(0, 8);
                        str2 = "计时消费结束,计时结束时间:" + DateTime.Now.ToString() + ",消费时间:" + str5;
                    }
                }
            }
            catch (Exception)
            {
                str = "-1";
            }
            s = string.Concat(new object[] { "{\"flag\":\"", str, "\",\"strReturn\":\"", str2, "\",\"OrderCode\":\"", this.modelOrderTime.OrderTimeCode, "\",\"memCard\":\"", this.modelMem.MemCard, "\",\"isMem\":\"", flag, "\"}" });
            this.Context.Response.Write(s);
        }

        public void TimeExpenseStart()
        {
            string str = "0";
            string str2 = "系统异常,未保存数据,请再次点击保存!";
            string s = "";
            try
            {
                string memCard = this.Request["Token"].ToString();
                bool flag = bool.Parse(this.Request["isMem"].ToString());
                DataTable table = this.bllOrderTime.GetList(" OrderState=0 and OrderToken='" + memCard + "'").Tables[0];
                if (table.Rows.Count > 0)
                {
                    str = "-2";
                    str2 = "有尚未结束的计时消费记录,请先结束当前的计时消费项目再进行新的计时消费!";
                }
                else if (flag)
                {
                    this.modelMem = this.bllMem.GetModelByMemCard(memCard);
                    if (this.modelMem != null)
                    {
                        this.modelOrderTime.OrderMemID = this.modelMem.MemID;
                        str2 = "计时消费开始,会员卡号:" + this.modelMem.MemCard + ",会员姓名:" + this.modelMem.MemName + ",计时消费开始时间:" + DateTime.Now.ToString();
                        this.modelOrderTime.OrderTimeCode = PubFunction.curParameter.strTimeExpensePrefix + DateTime.Now.ToString("yyMMddHHmmssffff");
                        this.modelOrderTime.OrderToken = memCard;
                        this.modelOrderTime.OrderMarchTime = DateTime.Now;
                        this.modelOrderTime.OrderState = false;
                        this.modelOrderTime.OrderOutTime = DateTime.Now;
                        this.modelOrderTime.OrderShopID = int.Parse(this.Session["UserShopID"].ToString());
                        this.modelOrderTime.OrderStartUserID = int.Parse(this.Session["UID"].ToString());
                        this.modelOrderTime.OrderCreateTime = DateTime.Now;
                        str = this.bllOrderTime.Add(this.modelOrderTime).ToString();
                    }
                    else
                    {
                        str = "-3";
                        str2 = "没有此会员卡号,请重新输入!";
                    }
                }
                else
                {
                    this.modelOrderTime.OrderMemID = 0;
                    str2 = "计时消费开始,散客令牌:" + memCard + ",计时开始时间:" + DateTime.Now.ToString();
                    this.modelOrderTime.OrderTimeCode = PubFunction.curParameter.strTimeExpensePrefix + DateTime.Now.ToString("yyMMddHHmmssffff");
                    this.modelOrderTime.OrderToken = memCard;
                    this.modelOrderTime.OrderMarchTime = DateTime.Now;
                    this.modelOrderTime.OrderState = false;
                    this.modelOrderTime.OrderOutTime = DateTime.Now;
                    this.modelOrderTime.OrderShopID = int.Parse(this.Session["UserShopID"].ToString());
                    this.modelOrderTime.OrderStartUserID = int.Parse(this.Session["UID"].ToString());
                    this.modelOrderTime.OrderCreateTime = DateTime.Now;
                    str = this.bllOrderTime.Add(this.modelOrderTime).ToString();
                }
            }
            catch (Exception)
            {
                str = "-1";
                str2 = "系统错误 请与系统管理员联系!";
            }
            s = "{\"flag\":\"" + str + "\",\"strReturn\":\"" + str2 + "\"}";
            this.Context.Response.Write(s);
        }

        public void UpdataMenuFirst()
        {
            int num = 0;
            try
            {
                int menuID = Convert.ToInt32(this.Request["MenuID"]);
                string str = this.Request["MenuName"];
                Chain.BLL.WeiXinMenu menu = new Chain.BLL.WeiXinMenu();
                Chain.Model.WeiXinMenu model = menu.GetModel(menuID);
                model.MenuName = str;
                num = menu.Update(model) ? 1 : 0;
            }
            catch (Exception)
            {
            }
            this.Response.Write(num);
        }

        public void UpdateCouponList()
        {
            int num = 0;
            try
            {
                string couPon = this.Request["Coupon"].ToString();
                string str2 = this.Request["OrderAccount"].ToString();
                Chain.BLL.CouponList list = new Chain.BLL.CouponList();
                Chain.Model.CouponList model = list.GetModel(couPon);
                model.CouPonSY = true;
                model.ConPonUseTime = DateTime.Now;
                model.CouPonOrderAccount = str2;
                if (list.Update(model))
                {
                    num = 1;
                    Chain.BLL.Coupon coupon = new Chain.BLL.Coupon();
                    Chain.Model.Coupon coupon2 = coupon.GetModel(model.CouPonID);
                    coupon2.CouponSY++;
                    coupon.Update(coupon2);
                }
            }
            catch
            {
                num = 0;
            }
            this.Context.Response.Write(num);
        }

        public void UpdateGoodsClassDiscount()
        {
            int num = -1;
            try
            {
                int classDiscountID = int.Parse(this.Request["ClassDiscountID"]);
                decimal num3 = decimal.Parse(this.Request["ClassDiscountPercent"]) / 100M;
                decimal num4 = 1M / decimal.Parse(this.Request["ClassPointPercent"]);
                Chain.BLL.GoodsClassDiscount discount = new Chain.BLL.GoodsClassDiscount();
                Chain.Model.GoodsClassDiscount model = discount.GetModel(classDiscountID);
                model.ClassDiscountPercent = num3;
                model.ClassPointPercent = num4;
                discount.Update(model);
                num = 0;
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void UpdateMemInfo()
        {
            int num = 0;
            try
            {
                int memID = Convert.ToInt32(this.Request["MemID"]);
                string str = this.Request["MemName"];
                bool flag = this.Request["MemSex"] == "1";
                DateTime time = Convert.ToDateTime((this.Request["MemBirthday"] == "") ? "1900-01-01" : this.Request["MemBirthday"]);
                string str2 = this.Request["MemMobile"];
                string str3 = this.Request["MemEmail"];
                string str4 = this.Request["MemAddress"];
                Chain.BLL.Mem mem = new Chain.BLL.Mem();
                Chain.Model.Mem model = mem.GetModel(memID);
                model.MemName = str;
                model.MemSex = flag;
                model.MemBirthday = time;
                model.MemMobile = str2;
                model.MemEmail = str3;
                model.MemAddress = str4;
                num = mem.UpdateMem(model);
            }
            catch
            {
            }
            this.Response.Write(num);
        }

        public void UpdateMenuBySystem()
        {
            int num = 0;
            try
            {
                int menuID = Convert.ToInt32(this.Request["MenuID"]);
                int num3 = Convert.ToInt32(this.Request["parentMenuID"]);
                Chain.BLL.WeiXinMenu menu = new Chain.BLL.WeiXinMenu();
                Chain.Model.WeiXinMenu model = menu.GetModel(menuID);
                model.parentMenuID = num3;
                num = menu.Update(model) ? 1 : 0;
            }
            catch (Exception)
            {
            }
            this.Response.Write(num);
        }

        public void UpdateSeeion()
        {
            string s = "";
            try
            {
                string str2 = (!string.IsNullOrEmpty(this.Request["UseriD"]) && (this.Request["UseriD"].ToString() != "")) ? this.Request["UseriD"].ToString() : "";
                if (str2 != "")
                {
                    Chain.Model.SysUser model = new Chain.BLL.SysUser().GetModel(int.Parse(str2));
                    this.Session["User"] = model;
                    this.Session["UID"] = model.UserID;
                    this.Session["UserAccount"] = model.UserAccount;
                    this.Session["UserName"] = model.UserName;
                    this.Session["UserGroupID"] = model.UserGroupID;
                    this.Session["UserShopID"] = model.UserShopID;
                    this.Session["UserAuthority"] = PubFunction.GetUserAuthority(model.UserGroupID);
                    Chain.BLL.SysParameter parameter = new Chain.BLL.SysParameter();
                    DataTable table = parameter.GetList(string.Format(" ShopID = '{0}'", model.UserShopID)).Tables[0];
                    this.Session["CurrentParameter"] = PubFunction.LoadSysParameter(Convert.ToInt32(table.Rows[0]["ParameterID"]));
                    s = string.Concat(new object[] { "{\"UID\":\"", this.Session["UID"], "\",\"UserName\":\"", this.Session["UserName"], "\"}" });
                }
            }
            catch
            {
            }
            this.Context.Response.Write(s);
        }

        public void UserAdd()
        {
            int num = 0;
            try
            {
                Chain.Model.SysUser model = new Chain.Model.SysUser();
                Chain.Model.SysLog log = new Chain.Model.SysLog();
                Chain.BLL.SysUser user2 = new Chain.BLL.SysUser();
                model.UserName = this.Request["userName"].ToString();
                model.UserAccount = this.Request["userAccount"].ToString();
                model.UserTelephone = this.Request["userTel"].ToString();
                model.UserNumber = this.Request["userNumber"].ToString();
                model.UserPassword = DESEncrypt.Encrypt(this.Request["userPassword"].ToString());
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                if (this.Request["isChoose"] == "0")
                {
                    model.UserLock = true;
                }
                else
                {
                    model.UserLock = false;
                }
                model.UserShopID = int.Parse(this.Request["userShopID"]);
                model.UserGroupID = int.Parse(this.Request["authority"]);
                model.UserRemark = this.Request["userRemark"];
                model.UserCreateTime = DateTime.Now;
                num = user2.Add(model);
                if (num > 0)
                {
                    Chain.Model.SysShop shop = new Chain.BLL.SysShop().GetModel(model.UserShopID);
                    Chain.Model.SysGroup group = new Chain.BLL.SysGroup().GetModel(model.UserGroupID);
                    PubFunction.SaveSysLog(userID, 1, "用户新增", "新增用户,用户名称:[" + model.UserName + "],用户所属店铺:[" + shop.ShopName + "],所属权限组:[" + group.GroupName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void UserDel()
        {
            int num = 0;
            try
            {
                int userID = int.Parse(this.Request["UserID"].ToString());
                Chain.BLL.SysUser user = new Chain.BLL.SysUser();
                Chain.Model.SysUser model = user.GetModel(userID);
                Chain.BLL.SysUser user3 = new Chain.BLL.SysUser();
                DataTable table = user3.GetList(string.Format(" UserID = '{0}' or HandoverUserID = '{1}'", userID)).Tables[0];
                if (table.Rows.Count <= 0)
                {
                    if (user.Delete(userID))
                    {
                        num = 1;
                        PubFunction.SaveSysLog(int.Parse(this.Session["UID"].ToString()), 2, "用户删除", "删除用户,字段名称:" + model.UserName, int.Parse(this.Session["UserShopID"].ToString()), DateTime.Now, PubFunction.ipAdress);
                    }
                }
                else
                {
                    num = -4;
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void UserEdit()
        {
            int num = 0;
            try
            {
                string text = this.Request["userPassword"].ToString();
                Chain.Model.SysUser model = new Chain.Model.SysUser();
                Chain.Model.SysLog log = new Chain.Model.SysLog();
                model.UserID = int.Parse(this.Request["userID"].ToString());
                model.UserName = this.Request["userName"].ToString();
                model.UserAccount = this.Request["userAccount"].ToString();
                model.UserPassword = DESEncrypt.Encrypt(text);
                model.UserTelephone = this.Request["userTel"].ToString();
                model.UserNumber = this.Request["userNumber"].ToString();
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                if (this.Request["isChoose"] == "0")
                {
                    if (userID != model.UserID)
                    {
                        model.UserLock = true;
                    }
                    else
                    {
                        num = -2;
                    }
                }
                else
                {
                    model.UserLock = false;
                }
                model.UserShopID = int.Parse(this.Request["userShopID"]);
                model.UserGroupID = int.Parse(this.Request["authority"]);
                model.UserRemark = this.Request["userRemark"];
                model.UserCreateTime = DateTime.Now;
                if (num >= 0)
                {
                    num = new Chain.BLL.SysUser().Update(model);
                }
                if (num > 0)
                {
                    num = 1;
                    Chain.Model.SysShop shop = new Chain.BLL.SysShop().GetModel(model.UserShopID);
                    Chain.Model.SysGroup group = new Chain.BLL.SysGroup().GetModel(model.UserGroupID);
                    PubFunction.SaveSysLog(userID, 3, "用户编辑", "用户编辑,用户名称:[" + model.UserName + "],用户所属店铺:[" + shop.ShopName + "],所属权限组:[" + group.GroupName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch (Exception)
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public void UserPwdEdit()
        {
            int num = 0;
            try
            {
                int userID = int.Parse(this.Session["UID"].ToString());
                int shopID = int.Parse(this.Session["UserShopID"].ToString());
                string text = this.Request["oldPwd"];
                string str2 = this.Request["newPwd"];
                string str3 = this.Request["newRePwd"];
                Chain.BLL.SysUser user = new Chain.BLL.SysUser();
                Chain.Model.SysUser model = user.GetModel(userID);
                text = DESEncrypt.Encrypt(text);
                str2 = DESEncrypt.Encrypt(str2);
                num = user.UpdateUserPwd(userID, text, str2);
                if (num == 1)
                {
                    PubFunction.SaveSysLog(userID, 3, "用户密码编辑", "编辑用户密码,用户名称:[" + model.UserName + "]", shopID, DateTime.Now, PubFunction.ipAdress);
                }
            }
            catch
            {
                num = -3;
            }
            this.Context.Response.Write(num);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

我伪装了一个 用户  public static Chain.Model.SysUser CheckUserLogin(string UserAccount, string Pwd)

用这个用户登录。在后台修改密码。

商家联盟会员管理系统 后台密码忘了的解决方法_第1张图片


商家联盟会员管理系统 后台密码忘了的解决方法_第2张图片商家联盟会员管理系统 后台密码忘了的解决方法_第3张图片

你可能感兴趣的:(日志)