Exemplo n.º 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 + "\"}");
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EX_Admin.Power("cardtype_list", "优惠券列表"))
            {
                PageReturnMsg = PageNoPowerMsg();
            }

            su           = new SearchCard(CurrentAdmin, CurrentLanguage.Code);
            type         = RequestTool.RequestInt("type", 311);
            PageSize     = RequestTool.getpageSize(25);
            string where = "1=1";
            key          = RequestTool.RequestString("key");
            user_id      = RequestTool.RequestInt("user_id");
            if (key != "")
            {
                where += " and Code like lbsql{'%" + key + "%'} or User_UserName like lbsql{'%" + key + "%'}";
            }
            if (user_id > 0)
            {
                where += " and User_id=" + user_id + "";
            }
            where += su.SQL;
            models = B_Lebi_Card.GetList(where, "id desc", PageSize, page);
            int recordCount = B_Lebi_Card.Counts(where);

            PageString = Pager.GetPaginationString("?page={0}&key=" + key + "&user_id=" + user_id + "&" + su.URL, page, PageSize, recordCount);
        }
Exemplo n.º 3
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 + "\"}");
        }
Exemplo n.º 4
0
        /// <summary>
        /// 删除卡券
        /// </summary>
        public void Card_Del()
        {
            if (!EX_Admin.Power("card_del", "删除卡券"))
            {
                AjaxNoPower();
                return;
            }
            string id = RequestTool.RequestString("id");

            if (id != "")
            {
                B_Lebi_Card.Delete("id in (lbsql{" + id + "})");
            }
            Response.Write("{\"msg\":\"OK\"}");
        }
Exemplo n.º 5
0
 protected int sid = 0;//结算供应商ID
 protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode)
 {
     LoadTheme(themecode, siteid, languagecode, pcode);
     if (CurrentUser.id == 0)
     {
         //未登录
         if (SYS.IsAnonymousUser != "1")
         {
             Response.Redirect(URL("P_Login", "" + HttpUtility.UrlEncode(RequestTool.GetRequestUrlNonDomain()) + "," + GetUrlToken(RequestTool.GetRequestUrlNonDomain()) + ""));
         }
     }
     sid = RequestTool.RequestInt("sid", 0);
     if (SYS.IsSupplierCash == "1")
     {
         supplier = B_Lebi_Supplier.GetModel(sid);
     }
     if (supplier == null)
     {
         supplier = new Lebi_Supplier();
     }
     CookieTool.SetCookieString("supplier", supplier.id.ToString(), 60);
     path   = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("首页") + "\"><span>" + Tag("首页") + "</span></a><em class=\"home\">&raquo;</em><a href=\"" + URL("P_Basket", "") + "\"><span>" + Tag("购物车") + "</span></a><em>&raquo;</em><a href=\"" + URL("P_CheckOut", "") + "\"><span>" + Tag("收银台") + "</span></a>";
     basket = new Basket(sid);
     if (basket.Products.Count == 0)
     {
         Response.Redirect(URL("P_Basket", ""));
     }
     if (CurrentUser.id > 0)
     {
         string sqlwhere = "";
         if (DataBase.DBType == "sqlserver")
         {
             sqlwhere = " and datediff(d,Time_End,'" + FormatTime(System.DateTime.Now) + "')<0";
         }
         if (DataBase.DBType == "access")
         {
             sqlwhere = " and datediff('d',Time_End,'" + FormatTime(System.DateTime.Now) + "')<0";
         }
         cards      = B_Lebi_Card.GetList("User_id=" + CurrentUser.id + " and Type_id_CardType=312 and Type_id_CardStatus in (201,203) " + sqlwhere + "", "id asc");//状态为已发放或部分使用
         moneycards = B_Lebi_Card.GetList("User_id=" + CurrentUser.id + " and Type_id_CardType=311 and Type_id_CardStatus in (201,203) " + sqlwhere + "", "id asc");
     }
     ProPerty135 = B_Lebi_ProPerty.GetList("Type_id_ProPertyType=135", "Sort desc");
 }
Exemplo n.º 6
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\"}");
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EX_Admin.Power("card_edit", "修改卡券"))
            {
                WindowNoPower();
            }
            int user_id = RequestTool.RequestInt("user_id", 0);

            card_ids = RequestTool.RequestString("ids");
            su       = new SearchCard(CurrentAdmin, CurrentLanguage.Code);
            if (card_ids != "")
            {
                models = B_Lebi_Card.GetList("id in (lbsql{" + card_ids + "})", "");
                count  = models.Count;
            }
            else
            {
                count = B_Lebi_Card.Counts("1=1" + su.SQL);
            }
        }
Exemplo n.º 8
0
        protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode)
        {
            if (CurrentUser.id == 0)
            {
                Response.Redirect(URL("P_Login", "" + HttpUtility.UrlEncode(RequestTool.GetRequestUrlNonDomain()) + "," + GetUrlToken(RequestTool.GetRequestUrlNonDomain()) + ""));
            }
            LoadTheme(themecode, siteid, languagecode, pcode);
            path      = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("首页") + "\"><span>" + Tag("首页") + "</span></a><em class=\"home\">&raquo;</em><a href=\"" + URL("P_UserCenter", "") + "\"><span>" + Tag("会员中心") + "</span></a><em>&raquo;</em><a href=\"" + URL("P_UserCard", "") + "\"><span>" + Tag("我的卡券") + "</span></a>";
            cardtype  = RequestTool.RequestInt("cardtype", 312);
            pageindex = RequestTool.RequestInt("page", 1);
            where     = "User_id=" + CurrentUser.id + "";
            if (cardtype > 0)
            {
                where += " and Type_id_CardType=" + cardtype;
            }
            cards = B_Lebi_Card.GetList(where, "id desc", PageSize, pageindex);
            int recordCount = B_Lebi_Card.Counts(where);

            PageString = Shop.Bussiness.Pager.GetPaginationStringForWeb("?page={0}&cardtype=" + cardtype, pageindex, PageSize, recordCount, CurrentLanguage);
            NextPage   = "?page=" + (pageindex + 1) + "&cardtype=" + cardtype + "";
        }
Exemplo n.º 9
0
        /// <summary>
        /// 生成新订单
        /// </summary>
        public void order_save()
        {
            if (CurrentUserLevel.BuyRight != 1)
            {
                Response.Write("{\"msg\":\"" + Tag("您所在的分组不允许下单") + "\"}");
                return;
            }
            int         pay_id        = RequestTool.RequestInt("pay_id", 0);
            int         sid           = RequestTool.RequestInt("sid", 0);//结算供应商ID
            int         onlinepay_id  = RequestTool.RequestInt("onlinepay_id", 0);
            decimal     Money_UserCut = RequestTool.RequestDecimal("Money_UserCut", 0);
            int         usermoneytype = RequestTool.RequestInt("usermoneytype", 0);
            string      Pay_Password  = RequestTool.RequestSafeString("Pay_Password");
            Lebi_PickUp pick          = null;
            DateTime    pickdate      = System.DateTime.Now;

            if (usermoneytype == 3)
            {
                if (Pay_Password == "")
                {
                    Response.Write("{\"msg\":\"" + Tag("请输入支付密码") + "\"}");
                    return;
                }
                else
                {
                    if (EX_User.MD5(Pay_Password) != CurrentUser.Pay_Password)
                    {
                        Response.Write("{\"msg\":\"" + Tag("支付密码不正确") + "\"}");
                        return;
                    }
                }
                if (Money_UserCut > 0 && Money_UserCut > CurrentUser.Money)
                {
                    Response.Write("{\"msg\":\"" + Tag("余额不足") + "\"}");
                    return;
                }
            }
            Lebi_Pay pay = B_Lebi_Pay.GetModel(pay_id);

            if (pay == null)
            {
                Response.Write("{\"msg\":\"" + Tag("请设置付款方式") + "\"}");
                return;
            }
            Basket  basket             = new Basket(sid);
            int     CustomOfflineMoney = RequestTool.RequestInt("CustomOfflineMoney" + pay.id, 0);
            decimal OfflineMoney       = RequestTool.RequestDecimal("OfflineMoney" + pay.id, 0);

            if (CustomOfflineMoney == 1)
            {
                if (pay.Code != "OfflinePay" && pay.Code != "OnlinePay")
                {
                    //订单如果选择了线下支付,并且非货到付款
                    if (OfflineMoney < basket.Money_Product)
                    {
                        Response.Write("{\"msg\":\"" + Tag("打款金额不能少于订单金额") + "\"}");
                        return;
                    }
                }
            }
            if (pay.Code == "OnlinePay")
            {
                Lebi_OnlinePay onpay = B_Lebi_OnlinePay.GetModel(onlinepay_id);
                if (onpay == null)
                {
                    Response.Write("{\"msg\":\"" + Tag("请设置付款方式") + "\"}");
                    return;
                }
            }

            if (basket.Products.Count == 0)
            {
                Response.Write("{\"msg\":\"" + Tag("购物车为空") + "\"}");
                return;
            }
            foreach (Lebi_User_Product up in basket.Products)
            {
                if (up.count < 1)
                {
                    Response.Write("{\"msg\":\"" + Tag("购物车异常") + "\"}");
                    return;
                }
            }
            if (basket.Point_Buy > 0 && (basket.Point_Buy > CurrentUser.Point))
            {
                Response.Write("{\"msg\":\"" + Tag("积分不足") + "\"}");
                return;
            }
            int ProductCount = 0;

            foreach (Lebi_User_Product up in basket.Products)
            {
                Lebi_Product pro = B_Lebi_Product.GetModel(up.Product_id);
                if (pro.Type_id_ProductType != 323)
                {
                    ProductCount += up.count;
                }
                //<-{ 判断是否上架状态 by lebi.kingdge 2015-02-10
                if (pro.Type_id_ProductStatus != 101)
                {
                    Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("该商品已经下架") + "\"}");
                    return;
                }
                //}->
                if (pro.Type_id_ProductType != 324)
                {
                    int levelcount = ProductLevelCount(pro);
                    if (up.count < levelcount)
                    {
                        Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("起订量") + " " + levelcount + "\"}");
                        return;
                    }
                }
                if (pro.Type_id_ProductType != 320 && pro.Time_Expired > System.DateTime.Now)
                {
                    if (pro.Count_Limit < up.count && pro.Count_Limit > 0)
                    {
                        Response.Write("{\"msg\":\"" + Tag("购买数量大于限购数量") + "\"}");
                        return;
                    }
                }
                if (SYS.IsNullStockSale != "1")
                {
                    if (pro.Count_Stock - pro.Count_Freeze < up.count && pro.Type_id_ProductType != 324)
                    {
                        Response.Write("{\"msg\":\"" + Lang(pro.Name) + "" + Tag("库存不足") + "\"}");
                        return;
                    }
                }
            }
            //验证当前分组允许的最低订单提交金额
            if (CurrentUserLevel.OrderSubmit > 0)
            {
                if (basket.Money_Product < CurrentUserLevel.OrderSubmit)
                {
                    Response.Write("{\"msg\":\"" + Tag("单笔订单最低金额为:") + FormatMoney(CurrentUserLevel.OrderSubmit) + "\"}");
                    return;
                }
            }
            //验证当前分组允许的最低订单提交数量
            if (CurrentUserLevel.OrderSubmitCount > 0 && ProductCount > 0)
            {
                if (ProductCount < CurrentUserLevel.OrderSubmitCount)
                {
                    Response.Write("{\"msg\":\"" + Tag("单笔订单最低数量为:") + CurrentUserLevel.OrderSubmitCount + "\"}");
                    return;
                }
            }
            Lebi_User_Address shouhuo = B_Lebi_User_Address.GetModel(CurrentUser.User_Address_id);

            if (shouhuo == null)
            {
                Response.Write("{\"msg\":\"" + Tag("未设置收获地址") + "\"}");
                return;
            }
            if (CurrentUser.Transport_Price_id == "")
            {
                Response.Write("{\"msg\":\"" + Tag("运费设置错误") + "\"}");
                return;
            }

            foreach (BasketShop shop in basket.Shops)
            {
                Lebi_Transport_Price tprice = B_Lebi_Transport_Price.GetModel("id in (lbsql{" + CurrentUser.Transport_Price_id + "}) and Supplier_id=" + shop.Shop.id + "");
                if (tprice == null)
                {
                    Response.Write("{\"msg\":\"" + Tag("运费设置错误") + "\"}");
                    return;
                }
                Lebi_Transport transport = B_Lebi_Transport.GetModel(tprice.Transport_id);
                if (tprice == null)
                {
                    Response.Write("{\"msg\":\"" + Tag("运费设置错误") + "\"}");
                    return;
                }
                //检查运费设置是否正确
                if (!EX_Area.CheckAreaPrice(tprice, shouhuo.Area_id))
                {
                    Response.Write("{\"msg\":\"" + Tag("运费设置错误") + "\"}");
                    return;
                }
                if (transport.Type_id_TransportType == 332)//自提检查
                {
                    int    pickup_id = RequestTool.RequestInt("pickup_id" + shop.Shop.id);
                    string pickdate_ = RequestTool.RequestString("pickupdate_" + pickup_id);

                    try
                    {
                        pickdate = Convert.ToDateTime(pickdate_);
                    }
                    catch
                    {
                        Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}");
                        return;
                    }

                    pick = B_Lebi_PickUp.GetModel(pickup_id);
                    if (pick == null)
                    {
                        Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}");
                        return;
                    }
                    if (pick.IsCanWeekend == 0 && (pickdate.DayOfWeek == DayOfWeek.Saturday || pickdate.DayOfWeek == DayOfWeek.Sunday))
                    {
                        Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}");
                        return;
                    }
                    if (System.DateTime.Now.Date.AddDays(pick.BeginDays) > pickdate)
                    {
                        Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}");
                        return;
                    }
                    string NoServiceDays = pick.NoServiceDays.TrimStart('0').Replace(".0", ".");
                    string nowday        = pickdate.ToString("M.d");
                    if (("," + NoServiceDays + ",").Contains("," + nowday + ","))
                    {
                        Response.Write("{\"msg\":\"" + Tag("配送方式设置错误") + "\"}");
                        return;
                    }
                }
            }
            //检查代金券
            string pay312 = RequestTool.RequestSafeString("pay312");

            if (pay312 != "")
            {
                List <Lebi_Card> cs = B_Lebi_Card.GetList("User_id=" + CurrentUser.id + " and id in (lbsql{" + pay312 + "})", "id asc");
                int flag            = cs.FirstOrDefault().IsCanOtherUse;
                if (flag == 0 && cs.Count > 1)
                {
                    Response.Write("{\"msg\":\"" + Tag("代金券异常") + "\"}");
                    return;
                }
                foreach (Lebi_Card c in cs)
                {
                    if (flag != c.IsCanOtherUse)
                    {
                        Response.Write("{\"msg\":\"" + Tag("代金券异常") + "\"}");
                        return;
                    }
                    if (!Basket.CheckCard(basket, c))
                    {
                        Response.Write("{\"msg\":\"" + Tag("代金券异常") + "\"}");
                        return;
                    }
                }
            }
            //检查代金券结束
            //检查发票信息
            int           billtype_id = RequestTool.RequestInt("billtype_id", 0);
            Lebi_BillType billtype    = B_Lebi_BillType.GetModel(billtype_id);

            if (ShopCache.GetBaseConfig().BillFlag == "1")
            {
                if (billtype == null)
                {
                    Response.Write("{\"msg\":\"" + Tag("请设置发票内容") + "\"}");
                    return;
                }
            }
            CurrentUser.Pay_id       = pay.id;
            CurrentUser.OnlinePay_id = onlinepay_id;
            Lebi_Order        ordergroup;
            List <Lebi_Order> orders = Shop.Bussiness.Order.CreateOrder(CurrentUser, basket, shouhuo, billtype, CurrentCurrency, CurrentSite, CurrentLanguage, out ordergroup);

            CurrentUser.Count_Order = CurrentUser.Count_Order + orders.Count;
            B_Lebi_User.Update(CurrentUser);
            List <Lebi_Order> ordermodel = B_Lebi_Order.GetList("User_id=" + CurrentUser.id + "", "id desc");

            ordergroup = ordermodel.FirstOrDefault();
            if (OfflineMoney == 0)
            {
                OfflineMoney = ordergroup.Money_Order;
            }
            string remark = RequestTool.RequestSafeString("remark");

            ordergroup.Remark_User = remark;
            bool needupdate = false;

            if (remark != "")
            {
                Lebi_Comment model = new Lebi_Comment();
                model.Content       = remark;
                model.Keyid         = ordergroup.id;
                model.TableName     = "Order";
                model.User_id       = CurrentUser.id;
                model.User_UserName = CurrentUser.UserName;
                B_Lebi_Comment.Add(model);
                needupdate = true;
            }

            if (pick != null)
            {
                ordergroup.PickUp_Date = pickdate;
                ordergroup.PickUp_id   = pick.id;
                ordergroup.PickUp_Name = pick.Name;
                needupdate             = true;
            }
            if (needupdate)
            {
                B_Lebi_Order.Update(ordergroup);
            }

            if (pay.Code != "OfflinePay" && pay.Code != "OnlinePay")
            {
                //订单如果选择了线下支付,并且非货到付款
                //生成一笔充值单
                //OfflineMoney

                Lebi_Currency DefaultCurrency = B_Lebi_Currency.GetModel("IsDefault=1");
                if (DefaultCurrency == null)
                {
                    DefaultCurrency = B_Lebi_Currency.GetList("", "Sort desc").FirstOrDefault();
                }
                Lebi_Order order = new Lebi_Order();
                order.Code                  = "M" + Shop.Bussiness.Order.CreateOrderCode();
                order.Money_Order           = OfflineMoney;
                order.Money_Pay             = OfflineMoney;
                order.User_id               = CurrentUser.id;
                order.User_UserName         = CurrentUser.UserName;
                order.IsPaid                = 0;
                order.Currency_Code         = ordergroup.Currency_Code;
                order.Currency_ExchangeRate = ordergroup.Currency_ExchangeRate;
                order.Currency_id           = ordergroup.Currency_id;
                order.Currency_Msige        = ordergroup.Currency_Msige;
                order.Type_id_OrderType     = 214;
                order.Pay_id                = pay.id;
                order.Pay          = pay.Name;
                order.Site_id      = CurrentSite.id;
                order.Language_id  = CurrentLanguage.id;
                order.Remark_Admin = "";
                order.Order_id     = ordergroup.id;
                B_Lebi_Order.Add(order);
            }
            //if (orders.Count == 1)
            //    ordergroup = orders.FirstOrDefault();
            //Shop.Bussiness.Order.SupplierOrder(order);//根据商品供应商分单
            Response.Write("{\"msg\":\"OK\",\"id\":\"" + ordergroup.id + "\"}");
            return;
        }
Exemplo n.º 10
0
        public int count_card_no(int oid)
        {
            int count = B_Lebi_Card.Counts("CardOrder_id=" + oid + " and Type_id_CardStatus=200");

            return(count);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 卡券总数
        /// </summary>
        /// <param name="oid"></param>
        /// <returns></returns>
        public int count_card(int oid)
        {
            int count = B_Lebi_Card.Counts("CardOrder_id=" + oid + "");

            return(count);
        }
Exemplo n.º 12
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\"}");
        }