Example #1
0
        /// <summary>
        /// 收银台查询购物卡
        /// </summary>
        public void MoneyCardCheack()
        {
            string    moneycardcode = RequestTool.RequestSafeString("moneycardcode");
            string    moneycardpwd  = RequestTool.RequestSafeString("moneycardpwd");
            Lebi_Card card          = B_Lebi_Card.GetModel("Code=lbsql{'" + moneycardcode + "'} and Type_id_CardStatus in (201,203)");

            if (card == null)
            {
                Response.Write("{\"msg\":\"" + Tag("输入错误") + "\"}");
                return;
            }
            if (card.Time_End < System.DateTime.Now)
            {
                Response.Write("{\"msg\":\"" + Tag("已过期") + "\"}");
                return;
            }
            if (card.Password != moneycardpwd)
            {
                Response.Write("{\"msg\":\"" + Tag("输入错误") + "\"}");
                return;
            }
            Lebi_CardOrder cardorder = B_Lebi_CardOrder.GetModel(card.CardOrder_id);

            if (cardorder == null)
            {
                cardorder = new Lebi_CardOrder();
            }
            Response.Write("{\"msg\":\"OK\",\"id\":\"" + card.id + "\",\"name\":\"" + Lang(cardorder.Name) + "\",\"code\":\"" + card.Code + "\",\"timeend\":\"" + card.Time_End.ToString("yyyy-MM-dd") + "\",\"money\":\"" + FormatMoney(card.Money) + "\",\"money_used\":\"" + FormatMoney(card.Money_Used) + "\",\"money_last\":\"" + FormatMoney((card.Money_Last)) + "\",\"money_lastvalue\":\"" + card.Money_Last + "\"}");
        }
Example #2
0
 /// <summary>
 /// 检查购物车是否满足代金券使用条件
 /// </summary>
 /// <param name="basket"></param>
 /// <param name="card"></param>
 /// <returns></returns>
 public static bool CheckCard(Basket basket, Lebi_Card card)
 {
     if (card.Time_Begin > System.DateTime.Now)
     {
         return(false);
     }
     if (card.Time_End <= System.DateTime.Now)
     {
         card.Type_id_CardStatus = 204;
         B_Lebi_Card.Update(card);
         return(false);
     }
     if ((basket.Money_Product - basket.Money_Cut) < card.Money_Buy)
     {
         return(false);
     }
     if (card.Pro_Type_ids == "")
     {
         return(true);
     }
     foreach (Lebi_User_Product p in basket.Products)
     {
         Lebi_Product  pro  = B_Lebi_Product.GetModel(p.Product_id);
         Lebi_Pro_Type type = EX_Product.TopProductType(pro);
         if (("," + card.Pro_Type_ids + ",").Contains("," + type.id + ","))
         {
             return(true);
         }
     }
     return(false);
 }
Example #3
0
        /// <summary>
        /// 卡备注
        /// </summary>
        /// <param name="card"></param>
        /// <returns></returns>
        public string CardRemark(Lebi_Card card)
        {
            string str = "";

            if (card.Money_Buy > 0)
            {
                str += Tag("最低消费") + ":" + FormatMoney(card.Money_Buy) + ";";
            }
            if (card.Pro_Type_ids != "")
            {
                string tstr             = "";
                List <Lebi_Pro_Type> ts = B_Lebi_Pro_Type.GetList("id in (" + card.Pro_Type_ids + ")", "");
                foreach (Lebi_Pro_Type t in ts)
                {
                    if (tstr == "")
                    {
                        tstr = Lang(t.Name);
                    }
                    else
                    {
                        tstr += "," + Lang(t.Name);
                    }
                }
                str += Tag("限制商品") + ":" + tstr + ";";
            }
            return(str);
        }
Example #4
0
        /// <summary>
        /// 生成优惠券
        /// </summary>
        public void Card_Create()
        {
            if (!EX_Admin.Power("cardtype_add", "添加优惠券"))
            {
                AjaxNoPower();
                return;
            }
            int            CardType = RequestTool.RequestInt("CardType", 0);
            Lebi_CardOrder ct       = B_Lebi_CardOrder.GetModel(CardType);

            if (ct == null)
            {
                Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}");
                return;
            }
            int end = ct.NO_Now + 20;

            end       = end > ct.NO_End ? ct.NO_End : end;
            ct.NO_Now = ct.NO_Now < ct.NO_Start ? ct.NO_Start : ct.NO_Now;
            Lebi_Card model  = new Lebi_Card();
            int       leng   = ct.Length;
            string    no     = "";
            string    finish = "";

            for (int i = ct.NO_Now + 1; i < end + 1; i++)
            {
                no = i.ToString().PadLeft(leng, '0');
                model.CardOrder_id       = ct.id;
                model.Code               = ct.IndexCode + no;
                model.IsCanOtherUse      = ct.IsCanOtherUse;
                model.IsPayOnce          = model.IsPayOnce;
                model.Money              = ct.Money;
                model.Money_Last         = ct.Money;
                model.Money_Used         = 0;
                model.Password           = GetRnd(6, true, false, false, false, "");
                model.Pro_Type_ids       = ct.Pro_Type_ids;
                model.Time_Begin         = ct.Time_Begin;
                model.Time_End           = ct.Time_End;
                model.Type_id_CardStatus = 200;
                model.Money_Buy          = ct.Money_Buy;
                model.Type_id_CardType   = ct.Type_id_CardType;
                model.number             = i;
                model.IndexCode          = ct.IndexCode;
                B_Lebi_Card.Add(model);
            }
            if (end == ct.NO_End)
            {
                finish = "OK";
            }
            ct.NO_Now = end;
            B_Lebi_CardOrder.Update(ct);
            Response.Write("{\"msg\":\"OK\",\"code\":\"" + model.Code + "\",\"status\":\"" + finish + "\"}");
        }
Example #5
0
        /// <summary>
        /// 发放卡券
        /// </summary>
        public void CardGet()
        {
            int    id         = RequestTool.RequestInt("id", 0);
            string verifycode = RequestTool.RequestString("verifycode");

            if (CurrentCheckCode != verifycode)
            {
                Response.Write("{\"msg\":\"" + Tag("验证码错误") + "\"}");
                return;
            }
            //Lebi_CardOrder order = B_Lebi_CardOrder.GetModel("Type_id_CardType=312 and id = " + id + "");
            //if (order == null)
            //{
            //    Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}");
            //    return;
            //}
            //int count = B_Lebi_Card.Counts("Type_id_CardType=312 and CardOrder_id=" + id + " and Type_id_CardStatus=200 and User_id=0");
            //if (count == 0)
            //{
            //    Response.Write("{\"msg\":\"" + Tag("卡券数量不足") + "\"}");
            //    return;
            //}
            int getcount = B_Lebi_Card.Counts("Type_id_CardType=312 and CardOrder_id=" + id + " and User_id=" + CurrentUser.id + "");

            if (getcount > 0)
            {
                Response.Write("{\"msg\":\"" + Tag("不可以重复领取") + "\"}");
                return;
            }
            Lebi_Card c = B_Lebi_Card.GetModel("Type_id_CardType=312 and CardOrder_id=" + id + " and Type_id_CardStatus=200 and User_id=0");

            if (c == null)
            {
                Response.Write("{\"msg\":\"" + Tag("卡券数量不足") + "\"}");
                return;
            }
            c.User_id            = CurrentUser.id;
            c.Type_id_CardStatus = 201;//已发放
            c.User_UserName      = CurrentUser.UserName;
            B_Lebi_Card.Update(c);
            Response.Write("{\"msg\":\"OK\"}");
        }
Example #6
0
        /// <summary>
        /// 代金券限制信息
        /// </summary>
        /// <param name="card"></param>
        /// <returns></returns>
        public string cardinfo(Lebi_Card card)
        {
            string str = "";

            if (card.Money_Buy > 0)
            {
                str  = Tag("最低消费") + ":";
                str += FormatMoney(card.Money_Buy);
            }
            if (card.Pro_Type_ids != "")
            {
                str += "&nbsp;&nbsp;" + Tag("限品类") + ":";
                List <Lebi_Pro_Type> ts = B_Lebi_Pro_Type.GetList("id in (" + card.Pro_Type_ids + ")", "");
                foreach (Lebi_Pro_Type t in ts)
                {
                    str += Lang(t.Name);
                }
            }
            return(str);
        }
Example #7
0
        /// <summary>
        /// 发放卡券
        /// </summary>
        public void SendCard()
        {
            if (!EX_Admin.Power("user_card_add", "发放卡券"))
            {
                AjaxNoPower();
                return;
            }

            string         User_Name_To = RequestTool.RequestString("User_Name_To");
            string         User_ids     = RequestTool.RequestString("User_ids");
            int            orderid      = RequestTool.RequestInt("orderid", 0);
            Lebi_CardOrder co           = B_Lebi_CardOrder.GetModel(orderid);

            if (co == null)
            {
                Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}");
                return;
            }
            SearchUser su    = new SearchUser(CurrentAdmin, CurrentLanguage.Code);
            int        count = B_Lebi_Card.Counts("CardOrder_id=" + orderid + " and Type_id_CardStatus=200 and User_id=0");

            string where = "";
            if (User_Name_To != "")
            {
                where = "UserName = lbsql{'" + User_Name_To + "'}";
            }
            else if (User_ids != "")
            {
                where = "id in (lbsql{" + User_ids + "})";
            }
            else
            {
                where = "1=1 " + su.SQL;
            }
            if (count < B_Lebi_User.Counts(where))
            {
                Response.Write("{\"msg\":\"" + Tag("卡券数量不足") + "\"}");
                return;
            }
            List <Lebi_User> users = B_Lebi_User.GetList(where, "");

            if (users.Count == 0)
            {
                Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}");
                return;
            }
            foreach (Lebi_User user in users)
            {
                Lebi_Card c = B_Lebi_Card.GetModel("CardOrder_id=" + orderid + " and Type_id_CardStatus=200 and User_id=0");
                if (c == null)
                {
                    Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}");
                    return;
                }
                c.User_id            = user.id;
                c.Type_id_CardStatus = 201;//已发放
                c.User_UserName      = user.UserName;
                B_Lebi_Card.Update(c);
            }
            Log.Add("发送" + EX_Type.TypeName(co.Type_id_CardType) + "", "card", "", CurrentAdmin, su.Description + User_Name_To + User_ids);
            Response.Write("{\"msg\":\"OK\"}");
        }
Example #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Card model)
 {
     D_Lebi_Card.Instance.Update(model);
 }
Example #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Card model)
 {
     return(D_Lebi_Card.Instance.Add(model));
 }
Example #10
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Card SafeBindForm(Lebi_Card model)
 {
     return(D_Lebi_Card.Instance.SafeBindForm(model));
 }