예제 #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 + "\"}");
        }
예제 #2
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\"}");
        }
예제 #3
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\"}");
        }