Beispiel #1
0
 //会员减积分
 public void ChangePoint()
 {
     try
     {
         var result = from i in db.MemCards where i.MC_CardID == Request.Form["mort"].Trim() select i;
         if (Request.Form["mort"].Trim().Length == 11)
         {
             result = from i in db.MemCards where i.MC_Mobile == Request.Form["mort"] select i;
         }
         MemCards m = result.First();
         m.MC_Point -= int.Parse(Request.Form["changePoint"]); //减积分
                                                               //添加记录
         ConsumeOrders co    = new ConsumeOrders();
         Users         Udt   = Session["UserInfo"] as Users;
         string        Strde = DateTime.Now.ToString("yyyyMMddHHmmss");
         co.S_ID             = Udt.S_ID;
         co.U_ID             = Udt.U_ID;
         co.CO_OrderCode     = Strde;
         co.CO_OrderType     = 3;
         co.MC_ID            = m.MC_ID;     //int.Parse(Cdt.Rows[0]["MC_ID"].ToString());
         co.MC_CardID        = m.MC_CardID; //Cdt.Rows[0]["MC_CardID"].ToString();
         co.CO_TotalMoney    = 0;           // decimal.Parse(Request.Form["nMoney"]);
         co.CO_DiscountMoney = 0;
         co.CO_GavePoint     = int.Parse(Request.Form["changePoint"]);
         co.CO_CreateTime    = DateTime.Now;
         co.CO_Remark        = Request.Form["Remark"].Trim();
         db.ConsumeOrders.InsertOnSubmit(co);
         db.SubmitChanges();
         Response.Write("ok");
     }
     catch (Exception ex)
     {
         Response.Write("错误消息:" + ex);
     }
 }
Beispiel #2
0
        //添加消费订单  快速消费
        public ActionResult InsertConsume(ConsumeOrders c)
        {
            MPMS.Models.Users user = Session["UserInfo"] as MPMS.Models.Users;
            var U_ID             = user.U_ID;
            var S_ID             = user.S_ID;
            var CO_TotalMoney    = Request.Form["CO_TotalMoney"];
            var CO_DiscountMoney = Request.Form["CO_DiscountMoney"];
            var CO_CreateTime    = Request.Form["CO_CreateTime"];
            var CO_OrderType     = 5;
            var MC_ID            = Request.Form["MC_ID"];
            var MC_CardID        = Request.Form["MC_CardID"];

            c.CO_TotalMoney    = decimal.Parse(CO_TotalMoney);
            c.CO_DiscountMoney = decimal.Parse(CO_DiscountMoney);
            c.CO_CreateTime    = DateTime.Parse(CO_CreateTime);
            c.CO_OrderType     = byte.Parse(CO_OrderType.ToString());
            c.MC_ID            = int.Parse(MC_ID);
            c.MC_CardID        = MC_CardID;
            c.U_ID             = int.Parse(U_ID.ToString());
            c.S_ID             = int.Parse(S_ID.ToString());

            db.ConsumeOrders.InsertOnSubmit(c);
            db.SubmitChanges();
            return(Content("OK"));
        }
Beispiel #3
0
        //快速消费
        public void Fastmoney()
        {
            try
            {
                ConsumeOrders co    = new ConsumeOrders();
                DataTable     Cdt   = Session["CriD"] as DataTable;
                Users         Udt   = Session["UserInfo"] as Users;
                DateTime      de    = DateTime.Now;
                string        Strde = de.ToString("yyyyMMddHHmmss");
                co.S_ID             = Udt.S_ID;
                co.U_ID             = Udt.U_ID;
                co.CO_OrderCode     = Strde;
                co.CO_OrderType     = 5;
                co.MC_ID            = int.Parse(Cdt.Rows[0]["MC_ID"].ToString());
                co.MC_CardID        = Cdt.Rows[0]["MC_CardID"].ToString();
                co.CO_TotalMoney    = decimal.Parse(Request.Form["nMoney"]);
                co.CO_DiscountMoney = decimal.Parse(Request.Form["factMoney"]);
                co.CO_GavePoint     = int.Parse(Request.Form["autoPoint"]);
                co.CO_CreateTime    = de;
                co.CO_Remark        = Request.Form["Remark"];
                db.ConsumeOrders.InsertOnSubmit(co);
                MemCards m = (from i in db.MemCards where i.MC_CardID == Cdt.Rows[0]["MC_CardID"].ToString() select i).First();

                m.MC_Point      = int.Parse(Cdt.Rows[0]["MC_Point"].ToString()) + int.Parse(Request.Form["autoPoint"]);
                m.MC_TotalMoney = (float.Parse(Cdt.Rows[0]["MC_TotalMoney"].ToString())) + (float.Parse(Request.Form["factMoney"]));
                m.MC_TotalCount = (int.Parse(Cdt.Rows[0]["MC_TotalCount"].ToString())) + 1;
                db.SubmitChanges();
                Response.Write("ok");
            }
            catch (Exception ex)
            {
                Response.Write(ex);
            }
        }
Beispiel #4
0
        //添加消费订单  兑/减积分
        public ActionResult InsertConsumeGavePoint(ConsumeOrders c)
        {
            MPMS.Models.Users user = Session["UserInfo"] as MPMS.Models.Users;
            var U_ID          = user.U_ID;
            var S_ID          = user.S_ID;
            var CO_CreateTime = Request.Form["CO_CreateTime"];
            var CO_OrderType  = 3;
            var MC_ID         = Request.Form["MC_ID"];
            var MC_CardID     = Request.Form["MC_CardID"];
            var CO_GavePoint  = Request.Form["CO_GavePoint"]; //兑减积分
            var CO_Remark     = Request.Form["CO_Remark"];    //备注

            c.CO_CreateTime = DateTime.Parse(CO_CreateTime);
            c.CO_OrderType  = byte.Parse(CO_OrderType.ToString());
            c.MC_ID         = int.Parse(MC_ID);
            c.MC_CardID     = MC_CardID;
            c.U_ID          = int.Parse(U_ID.ToString());
            c.S_ID          = int.Parse(S_ID.ToString());
            c.CO_GavePoint  = int.Parse(CO_GavePoint);
            c.CO_Remark     = CO_Remark;

            db.ConsumeOrders.InsertOnSubmit(c);
            db.SubmitChanges();
            return(Content("OK"));
        }
Beispiel #5
0
 public void PointToMoney(int id)
 {
     try
     {
         int changePoint = int.Parse(Request.Form["ExchangPoint"]);
         var m           = db.MemCards.Where(me => me.MC_ID == id).First();
         m.MC_Point -= changePoint;//改变积分
         //添加记录
         ConsumeOrders co    = new ConsumeOrders();
         Users         Udt   = Session["UserInfo"] as Users;
         string        Strde = DateTime.Now.ToString("yyyyMMddHHmmss");
         co.S_ID             = Udt.S_ID;
         co.U_ID             = Udt.U_ID;
         co.CO_OrderCode     = Strde;
         co.CO_OrderType     = 2;
         co.MC_ID            = m.MC_ID;     //int.Parse(Cdt.Rows[0]["MC_ID"].ToString());
         co.MC_CardID        = m.MC_CardID; //Cdt.Rows[0]["MC_CardID"].ToString();
         co.CO_TotalMoney    = 0;           // decimal.Parse(Request.Form["nMoney"]);
         co.CO_DiscountMoney = 0;
         co.CO_GavePoint     = changePoint;
         co.CO_CreateTime    = DateTime.Now;
         co.CO_Recash        = int.Parse(Request.Form["ExchangMoney"]);
         db.ConsumeOrders.InsertOnSubmit(co);
         db.SubmitChanges();
         Response.Write("返现成功!");
     }
     catch (Exception ex)
     {
         Response.Write("错误消息:" + ex.Message);
     }
 }
Beispiel #6
0
        //快速消费
        public ActionResult DoJffx(int MC_ID, string MC_CardID, float CO_Recash, int CO_GavePoint)
        {
            //修改消费的会员信息
            MemCards mc = mpms.MemCards.FirstOrDefault(x => x.MC_ID == MC_ID);

            mc.MC_Point -= CO_GavePoint;
            mpms.Entry <MemCards>(mc).State = System.Data.Entity.EntityState.Modified;


            //在转账记录表插入一条记录
            ConsumeOrders co = new ConsumeOrders
            {
                S_ID             = (Session["Users"] as Users).S_ID,
                U_ID             = (Session["Users"] as Users).U_ID,
                CO_OrderCode     = DateTime.Now.ToString("yyyyMMddHHmmss"),
                CO_OrderType     = 2,
                MC_ID            = MC_ID,
                MC_CardID        = MC_CardID,
                EG_ID            = 0,
                CO_TotalMoney    = 0,
                CO_DiscountMoney = 0,
                CO_GavePoint     = CO_GavePoint,
                CO_Recash        = CO_Recash,
                CO_Remark        = "积分返现",
                CO_CreateTime    = Convert.ToDateTime(Convert.ToDateTime(DateTime.Now).ToString("yyyy-MM-dd HH:mm:ss"))
            };

            mpms.ConsumeOrders.Add(co);
            return(Json(mpms.SaveChanges() > 1, JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
        //快速消费 根据卡号查询
        public ActionResult GetInfoByNum()
        {
            var cardNum = Request.QueryString["num"];
            var Mobile  = "";
            var CardID  = "";

            if (cardNum.Length == 11)
            {
                var num = (from i in db.MemCards     //判断手机号是否存在
                           where i.MC_Mobile == cardNum
                           select i).Count();
                if (num > 0)
                {
                    Mobile = cardNum;
                }
                else
                {
                    Mobile = "";
                    return(null);
                }
            }
            else
            {
                var num = (from i in db.MemCards    //判断卡号是否存在
                           where i.MC_CardID == cardNum
                           select i).Count();
                if (num > 0)
                {
                    CardID = cardNum;
                }
                else
                {
                    CardID = "";
                    return(null);
                }
            }
            string        strSql = string.Format(@"select a.CL_LevelName,a.CL_Percent,b.MC_Point,b.MC_ID,b.MC_CardID,b.MC_Name,b.MC_TotalMoney from CardLevels a,MemCards b
                                           where b.MC_CardID='{0}' or b.MC_Mobile='{1}'", CardID, Mobile);
            DataTable     dt     = SqlHelper.GetDataTable(strSql);
            DataRow       dr     = dt.Rows[0];
            CardLevels    cl     = dr.ToModel <CardLevels>();
            MemCards      mc     = dr.ToModel <MemCards>();
            ConsumeOrders co     = dr.ToModel <ConsumeOrders>();

            return(Json(new { CardLevels = cl, MemCards = mc, ConsumeOrders = co }, JsonRequestBehavior.AllowGet));
        }
Beispiel #8
0
        public bool PointCash(ConsumeOrders co, MemCards m)
        {
            string sql = "P_PointCash";

            SqlParameter[] para =
            {
                new SqlParameter("@S_ID",          co.S_ID),
                new SqlParameter("@U_ID",          co.U_ID),
                new SqlParameter("@CO_OrderCode",  co.CO_OrderCode),
                new SqlParameter("@CO_OrderType",  co.CO_OrderType),
                new SqlParameter("@MC_ID",         co.MC_ID),
                new SqlParameter("@MC_CardID",     co.MC_CardID),
                new SqlParameter("@CO_Recash",     co.CO_Recash),
                new SqlParameter("@CO_GavePoint",  co.CO_GavePoint),
                new SqlParameter("@CO_CreateTime", co.CO_CreateTime),
                new SqlParameter("@MC_Point",      m.MC_Point)
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
Beispiel #9
0
        public bool FastConsume(ConsumeOrders co, MemCards m)
        {
            string sql = "P_FastConsume";

            SqlParameter[] para =
            {
                new SqlParameter("@S_ID",             co.S_ID),
                new SqlParameter("@U_ID",             co.U_ID),
                new SqlParameter("@CO_OrderCode",     co.CO_OrderCode),
                new SqlParameter("@CO_OrderType",     co.CO_OrderType),
                new SqlParameter("@MC_ID",            co.MC_ID),
                new SqlParameter("@MC_CardID",        co.MC_CardID),
                new SqlParameter("@CO_TotalMoney",    co.CO_TotalMoney),
                new SqlParameter("@CO_DiscountMoney", co.CO_DiscountMoney),
                new SqlParameter("@CO_GavePoint",     co.CO_GavePoint),
                new SqlParameter("@CO_CreateTime",    co.CO_CreateTime),
                new SqlParameter("@MC_Point",         m.MC_Point),
                new SqlParameter("@MC_TotalCount",    m.MC_TotalCount)
            };
            return(DBHelper.ExecuteNonQuery(sql, true, para));
        }
Beispiel #10
0
        public JsonResult GetStatisticInfo(int id)
        {
            StringBuilder sb = new StringBuilder(string.Format("select * from ConsumeOrders, MemCards where ConsumeOrders.MC_ID = MemCards.MC_ID AND ConsumeOrders.S_ID = {0}", (Session["UserInfo"] as Users).S_ID));

            if (!string.IsNullOrEmpty(Request.Form["CO_OrderType"]))
            {
                sb.Append("AND CO_OrderType = " + Request.Form["CO_OrderType"].Trim());
            }
            else
            {
                sb.Append(id == -1 ? "" : "AND CO_OrderType = " + id + "");
            }
            if (!string.IsNullOrEmpty(Request.Form["CO_OrderCode"]))
            {
                sb.AppendFormat(" AND CO_OrderCode like '%{0}%'", Request.Form["CO_OrderCode"].Trim());
            }
            if (!string.IsNullOrEmpty(Request.Form["MC_CardID"]))
            {
                string id1 = Request.Form["MC_CardID"].Trim();
                if (id1.ToString().Trim().Length == 11)//手机号
                {
                    id1 = (from i1 in db.MemCards where i1.MC_Mobile == id1.Trim() select i1).First().MC_CardID.ToString().Trim();
                }
                sb.AppendFormat(" AND MemCards.MC_CardID like '%{0}%'", id1);
            }
            if (!string.IsNullOrEmpty(Request.Form["cID"]))
            {
                sb.AppendFormat(" AND CL_ID = {0}", Request.Form["cID"].Trim());
            }
            if (!string.IsNullOrEmpty(Request.Form["CO_DiscountMoney"]) && !string.IsNullOrEmpty(Request.Form["ysf"]))
            {
                sb.AppendFormat(" AND CO_DiscountMoney {1} '{0}'", Request.Form["CO_DiscountMoney"].Trim(), Request.Form["ysf"].Trim());
            }
            else if (!string.IsNullOrEmpty(Request.Form["CO_GavePoint"]) && !string.IsNullOrEmpty(Request.Form["ysf"]))
            {
                sb.AppendFormat(" AND CO_GavePoint {1} '{0}'", Request.Form["CO_GavePoint"].Trim(), Request.Form["ysf"].Trim());
            }
            else if (!string.IsNullOrEmpty(Request.Form["CO_Recash"]) && !string.IsNullOrEmpty(Request.Form["ysf"]))
            {
                sb.AppendFormat(" AND CO_Recash {1} '{0}'", Request.Form["CO_Recash"].Trim(), Request.Form["ysf"].Trim());
            }
            if (!string.IsNullOrEmpty(Request.Form["BTime"]) && !string.IsNullOrEmpty(Request.Form["ETime"]))
            {
                sb.AppendFormat(" AND CO_CreateTime >= '{0}' AND  CO_CreateTime <= '{1}'", Request.Form["BTime"].Trim(), Request.Form["ETime"].Trim());
            }
            else if (!string.IsNullOrEmpty(Request.Form["BTime"]))
            {
                sb.AppendFormat(" AND CO_CreateTime >= '{0}'", Request.Form["BTime"].Trim());
            }
            else if (!string.IsNullOrEmpty(Request.Form["ETime"]))
            {
                sb.AppendFormat(" AND CO_CreateTime <= '{0}'", Request.Form["ETime"].Trim());
            }
            DataTable     dt = SqlHelper.GetDataTable(sb.ToString());
            List <object> ml = new List <object>();

            foreach (DataRow dr in dt.Rows)
            {
                ConsumeOrders c = dr.ToModel <ConsumeOrders>();
                MemCards      m = dr.ToModel <MemCards>();
                ml.Add(new { m = m, c = c, CI_Name = (from i in db.CategoryItems where i.C_Category == "CO_OrderType" && i.CI_ID == c.CO_OrderType select i).First().CI_Name });
            }
            int pageSize  = int.Parse(Request.Form["rows"] == "NaN" ? "1" : Request.Form["rows"]);
            int pageIndex = int.Parse(Request.Form["page"] == "NaN" ? "1" : Request.Form["page"]);

            return(Json(new { total = ml.Count, rows = ml.Skip(--pageIndex * pageSize).Take(pageSize).ToList() }, JsonRequestBehavior.AllowGet));
        }
Beispiel #11
0
        //消费历史记录
        public ActionResult GetInfoByNumOrders()
        {
            var cardNum = Request.Form["num"];
            var Mobile  = "";
            var CardID  = "";
            //分页
            int pageSize = 2, pageIndex = 0;

            if (Request.Form["rows"] != null)  //每页显示的几条数据
            {
                pageSize = int.Parse(Request.Form["rows"]);
            }
            if (Request.Form["page"].Trim() != null)   //当前页面是第几页
            {
                pageIndex = int.Parse(Request.Form["page"]);
            }
            int skip = (pageIndex - 1) * pageSize;  //需要去除的数据,即当前页面要显示的数据

            if (cardNum == null)
            {
                return(null);
            }
            else
            {
                if (cardNum.Length == 11)
                {
                    var num = (from i in db.MemCards     //判断手机号是否存在
                               where i.MC_Mobile == cardNum
                               select i).Count();
                    if (num > 0)
                    {
                        Mobile = cardNum;
                    }
                    else
                    {
                        Mobile = "";
                        return(null);
                    }
                }
                else
                {
                    var num = (from i in db.MemCards    //判断卡号是否存在
                               where i.MC_CardID == cardNum
                               select i).Count();
                    if (num > 0)
                    {
                        CardID = cardNum;
                    }
                    else
                    {
                        CardID = "";
                        return(null);
                    }
                }
            }

            string    strSql = string.Format(@"select a.CL_LevelName,a.CL_Percent,b.MC_Point,b.MC_ID,b.MC_CardID,b.MC_Name,b.MC_TotalMoney,c.* from CardLevels a,MemCards b,ConsumeOrders c
                                           where b.MC_CardID='{0}' or b.MC_Mobile='{1}'", CardID, Mobile);
            DataTable dt     = SqlHelper.GetDataTable(strSql);

            if (dt != null && dt.Rows.Count > 0)          //表数据不为空
            {
                List <Object> list = new List <Object>(); //申明泛型集合
                foreach (DataRow dr in dt.Rows)           //遍历
                {
                    CardLevels    cl = dr.ToModel <CardLevels>();
                    MemCards      mc = dr.ToModel <MemCards>();
                    ConsumeOrders co = dr.ToModel <ConsumeOrders>();
                    list.Add(new { CardLevels = cl, MemCards = mc, ConsumeOrders = co });
                }
                var result = list.Skip(skip).Take(pageSize).ToList();
                return(Json(new { total = list.Count(), rows = result }, JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Beispiel #12
0
 public bool JianPoint(ConsumeOrders co, MemCards m)
 {
     return(_IMemCardsDAL.JianPoint(co, m));
 }
Beispiel #13
0
 public bool FastConsume(ConsumeOrders co, MemCards m)
 {
     return(_IMemCardsDAL.FastConsume(co, m));
 }
Beispiel #14
0
 public bool PointCash(ConsumeOrders co, MemCards m)
 {
     return(_IConsumeOrdersDAL.PointCash(co, m));
 }