Пример #1
0
        public static void addCJ(JArray jrcj, t_table CurrTableInfo, t_order CurrOrderInfo, string userid, TSetting cjSetting, ref DataTable ShoppTable, int cjnum)
        {
            if (jrcj == null)
            {
                return;
            }
            JObject    ja       = (JObject)jrcj[0];
            t_shopping dishinfo = new t_shopping();

            dishinfo.Orderid     = CurrOrderInfo.orderid;
            dishinfo.Userid      = userid;
            dishinfo.Ordertime   = DateTime.Now;
            dishinfo.Orderstatus = 0;
            dishinfo.Dishnum     = cjnum;// int.Parse(CurrOrderInfo.custnum.ToString());
            dishinfo.Tableid     = CurrTableInfo.tableNo;
            dishinfo.Dishid      = ja["dishid"].ToString();
            dishinfo.Avoid       = "";
            dishinfo.Dishidleft  = 1;
            dishinfo.Title       = ja["dishname"].ToString();
            dishinfo.DishType    = ja["dishtype"].ToString();
            dishinfo.DishUnitSrc = ja["unit"].ToString();
            dishinfo.Ordertype   = 0;
            dishinfo.Memberprice = 0;
            if (CurrOrderInfo.memberno == null)
            {
                CurrOrderInfo.memberno = "";
            }
            bool    ismember = CurrOrderInfo.memberno.Length > 0;
            decimal price    = 0;
            string  pricestr = "";

            pricestr = ja["price"].ToString();
            string vipprice = ja["vipprice"].ToString();

            dishinfo.Memberprice = 0;
            try
            {
                dishinfo.Memberprice = (decimal)float.Parse(vipprice);
            }
            catch { }
            dishinfo.Price2 = (decimal)float.Parse(pricestr);
            if (dishinfo.Memberprice <= 0)
            {
                dishinfo.Memberprice = dishinfo.Price2;
            }
            if (ismember)
            {
                price = dishinfo.Memberprice;
            }
            else
            {
                price = dishinfo.Price2;
            }
            dishinfo.Price = price;

            dishinfo.Amount = 0;
            dishinfo.Source = ja["source"].ToString();
            t_shopping.add(ref ShoppTable, dishinfo, false);
        }
Пример #2
0
        private static t_shopping ParseDishInfo(string memberno, JObject ja)
        {
            t_shopping dishinfo = new t_shopping();

            dishinfo.Dishid      = ja["dishid"].ToString();
            dishinfo.Avoid       = "";
            dishinfo.Dishidleft  = 1;
            dishinfo.Title       = ja["title"].ToString();
            dishinfo.DishType    = ja["dishtype"].ToString();
            dishinfo.DishUnitSrc = ja["unit"].ToString();
            dishinfo.Memberprice = 0;
            if (memberno == null)
            {
                memberno = "";
            }
            bool    ismember = memberno.Length > 0;
            decimal price    = 0;
            string  pricestr = "";

            pricestr = ja["vipprice"].ToString(); //可能还会有多单位的问题
            if (pricestr.Equals("") || pricestr.Equals(""))
            {
                pricestr = ja["price"].ToString();
            }
            dishinfo.Memberprice = strtofloat(pricestr);
            pricestr             = ja["price"].ToString();
            dishinfo.Price2      = strtofloat(pricestr);
            if (dishinfo.Memberprice <= 0)
            {
                dishinfo.Memberprice = dishinfo.Price2;
            }
            if (ismember)
            {
                price = dishinfo.Memberprice;
            }
            else
            {
                price = dishinfo.Price2;
            }
            dishinfo.Price  = price;
            dishinfo.Amount = 0;
            dishinfo.Source = ja["source"].ToString();
            dishinfo.Weigh  = int.Parse(ja["weigh"].ToString());
            if (dishinfo.Weigh == 1)
            {
                dishinfo.Title = dishinfo.Title + "(称重)";
            }
            return(dishinfo);
        }
Пример #3
0
        public static t_shopping parseonly(JObject ja, bool ispot)
        {
            t_shopping dishinfo = new t_shopping();

            dishinfo.Orderid     = "";
            dishinfo.Userid      = "";// Globals.UserInfo.UserID;
            dishinfo.Ordertime   = DateTime.Now;
            dishinfo.Orderstatus = 0;
            dishinfo.Dishnum     = float.Parse(ja["dishnum"].ToString());
            dishinfo.Tableid     = "";
            if (ispot)
            {
                dishinfo.Dishid = ja["dishid"].ToString();
            }
            else
            {
                dishinfo.Dishid = ja["contactdishid"].ToString();
            }
            dishinfo.Avoid       = "";
            dishinfo.Dishidleft  = 1;
            dishinfo.Title       = ja["contactdishname"].ToString();
            dishinfo.DishType    = ja["dishtype"].ToString();
            dishinfo.DishUnitSrc = ja["dishunitid"].ToString();
            //dishinfo.Dishunit = ja["dishunitid"].ToString();
            dishinfo.Memberprice = 0;
            decimal price    = 0;
            string  pricestr = "";

            pricestr = ja["vipprice"].ToString(); //可能还会有多单位的问题
            if (pricestr.Equals("") || pricestr.Equals(""))
            {
                pricestr = ja["price"].ToString();
            }
            dishinfo.Memberprice = strtofloat(pricestr);
            pricestr             = ja["price"].ToString();
            dishinfo.Price2      = strtofloat(pricestr);
            if (dishinfo.Memberprice <= 0)
            {
                dishinfo.Memberprice = dishinfo.Price2;
            }
            price                  = dishinfo.Price2;
            dishinfo.Price         = price;
            dishinfo.Amount        = 0;
            dishinfo.Source        = "";
            dishinfo.Groupid       = ja["groupid"].ToString();
            dishinfo.Contactdishid = ja["contactdishid"].ToString();
            return(dishinfo);
        }
Пример #4
0
        public static TCombo parsecombo(JObject ja)
        {
            TCombo combo = new TCombo();

            combo.Startnum   = int.Parse(ja["startnum"].ToString());
            combo.Endnum     = int.Parse(ja["endnum"].ToString());
            combo.Status     = ja["status"].ToString();
            combo.Columnname = ja["columnname"].ToString();
            combo.Ordernum   = float.Parse(ja["ordernum"].ToString());
            combo.Columnid   = ja["columnid"].ToString();
            combo.Id         = ja["id"].ToString();
            combo.Dishid     = ja["dishid"].ToString();
            combo.ItemDesc   = ja["itemDesc"].ToString();
            JArray jr = (JArray)ja["alldishes"];

            for (int i = 0; i <= jr.Count - 1; i++)
            {
                JObject jacombo = (JObject)jr[i];
                string  dishes  = jacombo["dishes"].ToString();
                if (dishes == null)
                {
                    dishes = "";
                }
                if (dishes.Length > 0)
                {
                    //鱼锅
                    TPotDishInfo potinfo = parseonlyPot(jacombo);
                    combo.Dishs.Add(potinfo);
                }
                else
                {
                    t_shopping dishinfo = parseonly(jacombo, false);
                    combo.Dishs.Add(dishinfo);
                }
            }
            return(combo);
        }
Пример #5
0
        public static TComboDish parse(JObject jaData)
        {
            TComboDish combodish = new TComboDish();
            JArray     jronly    = (JArray)jaData["only"];
            JArray     jrcombo   = (JArray)jaData["combo"];

            //必选
            for (int i = 0; i <= jronly.Count - 1; i++)
            {
                //如果是单品 dishes
                JObject ja     = (JObject)jronly[i];
                string  dishes = ja["dishes"].ToString();
                if (dishes == null)
                {
                    dishes = "";
                }
                if (dishes.Length > 0)
                {
                    //鱼锅
                    TPotDishInfo potinfo = parseonlyPot(ja);
                    combodish.Onlydishs.Add(potinfo);
                }
                else
                {
                    t_shopping dishinfo = parseonly(ja, false);
                    combodish.Onlydishs.Add(dishinfo);
                }
            }
            //几选几
            for (int i = 0; i <= jrcombo.Count - 1; i++)
            {
                TCombo combo = parsecombo((JObject)jrcombo[i]);
                combodish.Combodishs.Add(combo);
            }
            return(combodish);
        }
Пример #6
0
        /// <summary>
        /// 往购物车内增加一行数据
        /// </summary>
        /// <param name="dishrow"></param>
        public static void add(ref DataTable shopptable, t_shopping dishrow, bool isdish)
        {
            //如果dishid和单位相同就相加
            int i = 0;

            if (!isdish)
            {                    //如果是鱼锅不能加一起 套餐
                foreach (DataRow dr2 in shopptable.Rows)
                {
                    string dishid          = dr2["dishid"].ToString();
                    string dishunit        = dr2["dishunit"].ToString();
                    string primarydishtype = dr2["primarydishtype"].ToString();

                    if ((dishid.Equals(dishrow.Dishid)) && (dishunit.Equals(dishrow.Dishunit)) && (primarydishtype.Equals(dishrow.Primarydishtype.ToString())))
                    {
                        //如果已经有一条相同的
                        adddish(ref shopptable, i);
                        return;
                    }
                    i++;
                }
            }
            DataRow dr = shopptable.NewRow();

            dr["orderid"]         = dishrow.Orderid;
            dr["userid"]          = dishrow.Userid;
            dr["ordertime"]       = dishrow.Ordertime;
            dr["orderstatus"]     = dishrow.Orderstatus;
            dr["dishnum"]         = (decimal)Math.Round(dishrow.Dishnum, 2);
            dr["tableid"]         = dishrow.Tableid;
            dr["dishid"]          = dishrow.Dishid;
            dr["avoid"]           = dishrow.Avoid;
            dr["dishidleft"]      = dishrow.Dishidleft;
            dr["title"]           = dishrow.Title;
            dr["dishunit"]        = dishrow.Dishunit;
            dr["dishunitSrc"]     = dishrow.DishUnitSrc;
            dr["memberprice"]     = dishrow.Memberprice;
            dr["price"]           = dishrow.Price;
            dr["price2"]          = dishrow.Price2;
            dr["ordertype"]       = dishrow.Ordertype;
            dr["amount"]          = dishrow.Price * (decimal)dishrow.Dishnum;
            dr["source"]          = dishrow.Source;
            dr["weigh"]           = dishrow.Weigh;//dishstatus 如果是称重下单为1
            dr["primarydishtype"] = dishrow.Primarydishtype;
            if (dishrow.IsPot == null)
            {
                dr["ispot"] = "";
            }
            else
            {
                dr["ispot"] = dishrow.IsPot.ToString();
            }
            if (dishrow.Parentdishid == null)
            {
                dr["Parentdishid"] = "";
            }
            else
            {
                dr["Parentdishid"] = dishrow.Parentdishid;
            }

            if (dishrow.Groupid == null)
            {
                dr["groupid"] = "";
            }
            else
            {
                dr["groupid"] = dishrow.Groupid;
            }

            if (dishrow.Groupid2 == null)
            {
                dr["Groupid2"] = "";
            }
            else
            {
                dr["Groupid2"] = dishrow.Groupid2;
            }

            shopptable.Rows.Add(dr);
        }