Пример #1
0
        public ActionResult PayOrdersNow(string Remark)
        {
            #region 生成订单
            string ids = Request["ids"].TrimEnd(',');
            Business.Sys_Flower        Sys_Flower        = new Business.Sys_Flower();
            Business.Sys_OrdersManaage Sys_OrdersManaage = new Business.Sys_OrdersManaage();
            string[] idarry        = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            string   FlowerNum     = Request["FlowerNums"];
            string[] FlowerNumarry = FlowerNum.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            string ConsigneAaddress = Request["DetailedAddress"];
            string ConsigneeName    = Request["ConsigneeName"];
            string ConsigneePhone   = Request["ConsigneePhone"];
            //唯一的订单
            Model.Orders Orders = new Model.Orders();
            Orders.UsersId          = int.Parse(userid);
            Orders.CreateTime       = DateTime.Now;
            Orders.OrdersState      = 1;
            Orders.OrderId          = Utility.ChangeText.OrderIdCreate();
            Orders.GoodsSum         = int.Parse(Request["goodnum"]);// 总件数
            Orders.ConsigneeName    = ConsigneeName;
            Orders.ConsigneePhone   = ConsigneePhone;
            Orders.ConsigneAaddress = ConsigneAaddress;
            //详情列表
            List <Model.OrdersDetails> OrdersDetailsList = new List <Model.OrdersDetails>();
            for (int j = 0; j < idarry.Length; j++)
            {
                //每一种花
                Model.Flower Flower = Sys_Flower.GetFlower(idarry[j]);
                Orders.SellingPrice += Flower.FlowerSalesPrice * int.Parse(FlowerNumarry[j]);
                Orders.CostPrice    += Flower.FlowerCostPrice * int.Parse(FlowerNumarry[j]);
                //每种花对应的数量
                for (int i = 0; i < int.Parse(FlowerNumarry[j]); i++)
                {
                    Model.OrdersDetails OrdersDetails = new Model.OrdersDetails();
                    OrdersDetails.OrderId          = Orders.OrderId;
                    OrdersDetails.FlowerNumber     = Flower.FlowerNumber;
                    OrdersDetails.FlowerWatchName  = Flower.FlowerWatchName;
                    OrdersDetails.FlowerWatchPhoto = Flower.FlowerWatchPhoto;
                    OrdersDetails.SellingPrice     = Flower.FlowerSalesPrice;
                    OrdersDetails.SellingNum       = 1;
                    OrdersDetails.CostPrice        = Flower.FlowerCostPrice;
                    OrdersDetailsList.Add(OrdersDetails);
                }
            }
            Model.OrdersLog OrdersLog = new Model.OrdersLog();
            OrdersLog.OrdersId    = Orders.OrderId;
            OrdersLog.OrdersState = 1;
            OrdersLog.UserName    = Utility.ChangeText.GetUserName();
            OrdersLog.Remark      = Remark;
            OrdersLog.Time        = DateTime.Now;

            #endregion
            Sys_OrdersManaage.TransactionAddOrders(Orders, OrdersDetailsList, OrdersLog);
            //return Redirect("/WxPay/Index?OrdersId=" + Orders.OrderId + "&PayTotal=" + Orders.SellingPrice);
            return(Json(new { OrdersId = Orders.OrderId, PayTotal = Orders.SellingPrice }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult CreateOrders()
        {
            string GoodsId = Request["GoodsId"];

            Business.Sys_Flower Sys_Flower = new Business.Sys_Flower();
            Model.Flower        Flower     = Sys_Flower.GetFlowerByFlowerNumber(GoodsId);
            //判断库存是否足够商品
            if (Flower.FlowerStock < Convert.ToInt32(Request["FlowerStock"]))
            {
                ViewData["success"] = "抱歉,库存不足";
                return(View());
            }
            Model.Orders Orders = new Model.Orders();
            Orders.OrderId          = Utility.ChangeText.GenerateOutTradeNo();
            Orders.OrdersState      = 1;
            Orders.SellingPrice     = Flower.FlowerSalesPrice * Convert.ToInt32(Request["FlowerStock"]);
            Orders.CostPrice        = Flower.FlowerCostPrice * Convert.ToInt32(Request["FlowerStock"]);
            Orders.ConsigneAaddress = Request["ConsigneAaddress"];
            Orders.ConsigneeName    = Request["ConsigneeName"];
            Orders.GoodsSum         = Convert.ToInt32(Request["FlowerStock"]);
            Orders.ConsigneePhone   = Request["ConsigneePhone"];
            List <Model.OrdersDetails> OrdersDetailsList = new List <Model.OrdersDetails> ();

            for (int i = 0; i < Convert.ToInt32(Request["FlowerStock"]); i++)
            {
                Model.OrdersDetails OrdersDetails = new Model.OrdersDetails();
                OrdersDetails.OrderId          = Orders.OrderId;
                OrdersDetails.SellingPrice     = Flower.FlowerSalesPrice;
                OrdersDetails.FlowerNumber     = Flower.FlowerNumber;
                OrdersDetails.CostPrice        = Flower.FlowerCostPrice;
                OrdersDetails.FlowerWatchPhoto = Flower.FlowerWatchPhoto;
                OrdersDetails.SellingNum       = 1;
                OrdersDetails.FlowerWatchName  = Flower.FlowerWatchName;
                OrdersDetailsList.Add(OrdersDetails);
            }
            Model.OrdersLog OrdersLog = new Model.OrdersLog();
            OrdersLog.OrdersId    = Orders.OrderId;
            OrdersLog.OrdersState = 1;
            OrdersLog.UserName    = Utility.ChangeText.GetUserName();
            Business.Sys_OrdersManaage Sys_OrdersManaage = new Business.Sys_OrdersManaage();
            if (!Sys_OrdersManaage.InsertOrders(Orders, OrdersDetailsList, OrdersLog))
            {
                ViewData["success"] = "下单失败,请联系管理员";
                return(View());
            }
            return(RedirectToAction("", ""));
        }