예제 #1
0
        public JsonResult SaveOrder2(Models.m_Shop_Order model)
        {
            int orgID = int.Parse(DESEncrypt.Decrypt(ViewBag.EnOrgID));

            Model.TD_Shop_Goods goods = goodsBLL.GetModel(model.goodsID);
            if (goods.Balance.Value < model.Amount)
            {
                return(GetErrorResult("数量不足"));
            }
            var member = MemberData.GetMember();

            Model.TD_Shop_Order order = new Model.TD_Shop_Order();
            order.PayType     = Constants.PayType.WeiXin;
            order.MemberID    = member.MemberID;
            order.HeaderImage = member.HeaderImage;
            if (!string.IsNullOrEmpty(model.username) && model.username != "输入姓名")
            {
                order.NickName = model.username;
            }
            else
            {
                order.NickName = member.NickName;
            }
            order.Message   = model.message;
            order.OrderType = (int)Constants.DonationType.Shop1;
            order.OrgID     = orgID;
            order.OriPrice  = goods.Price * model.Amount;
            order.RealPrice = order.OriPrice;
            order.Status    = (int)Constants.OrderStatus.WaitPay;

            IList <Model.TD_Shop_OrderGoods> orderGoodsList = new List <Model.TD_Shop_OrderGoods>();

            Model.TD_Shop_OrderGoods orderGoods = new Model.TD_Shop_OrderGoods();
            orderGoods.GoodsID   = goods.GoodsID;
            orderGoods.Title     = goods.Title;
            orderGoods.Amount    = model.Amount;
            orderGoods.OrgID     = orgID;
            orderGoods.OriPrice  = goods.Price;
            orderGoods.RealPrice = goods.Price;
            orderGoodsList.Add(orderGoods);
            int result = orderBLL.Save(order, orderGoodsList);

            if (result > 0)
            {
                string url = string.Empty;
                if (order.PayType == Constants.PayType.WeiXin)
                {
                    url = "/WeiXinPay/PayForShop?oid=" + ViewBag.EnOrgID + "&orderid=" + order.OrderID + "&url=" + HttpUtility.UrlEncode("/Shop/Goods2/Index?oid=" + ViewBag.EnOrgID);
                }
                return(GetSucceedResult(new
                {
                    url = url
                }, ""));
            }
            else
            {
                return(GetErrorResult("保存失败,请稍候再试"));
            }
        }
예제 #2
0
        public JsonResult SaveOrder(Models.m_YueBing model)
        {
            int orgID = int.Parse(DESEncrypt.Decrypt(ViewBag.EnOrgID));

            Model.TD_Shop_Goods goods = goodsBLL.GetModel(model.goodsID);
            if (goods.Balance.Value < model.Amount)
            {
                return(GetErrorResult("数量不足"));
            }
            ShiMiao.Model.TD_Shop_Order_Consignee consignee = new Model.TD_Shop_Order_Consignee();
            consignee.Address        = model.Adress;
            consignee.Name           = model.username;
            consignee.Phone          = model.Phone;
            consignee.Identification = model.Identification;

            var member = MemberData.GetMember();

            Model.TD_Shop_Order order = new Model.TD_Shop_Order();
            order.PayType     = Constants.PayType.WeiXin;
            order.MemberID    = member.MemberID;
            order.HeaderImage = member.HeaderImage;
            order.NickName    = member.NickName;
            order.OrderType   = (int)Constants.DonationType.Shop1;
            order.OrgID       = orgID;
            //月饼常规价格 + 快递费
            order.OriPrice = goods.Price * model.Amount + model.ExtraPrice * model.Amount;
            if (model.Amount >= 5)
            {//优惠价格 + 快递费
                order.RealPrice = 88 * model.Amount + model.ExtraPrice * model.Amount;
            }
            else
            {
                order.RealPrice = order.OriPrice;
            }
            order.Status = (int)Constants.OrderStatus.WaitPay;

            IList <Model.TD_Shop_OrderGoods> orderGoodsList = new List <Model.TD_Shop_OrderGoods>();

            Model.TD_Shop_OrderGoods orderGoods = new Model.TD_Shop_OrderGoods();
            orderGoods.GoodsID   = goods.GoodsID;
            orderGoods.Title     = goods.Title;
            orderGoods.Amount    = model.Amount;
            orderGoods.OrgID     = orgID;
            orderGoods.OriPrice  = goods.Price;
            orderGoods.RealPrice = goods.Price;
            orderGoodsList.Add(orderGoods);
            int result = orderBLL.Save(order, orderGoodsList);

            if (result > 0)
            {
                string url = string.Empty;
                if (order.PayType == Constants.PayType.WeiXin)
                {
                    url = "/WeiXinPay/PayForShop?oid=" + ViewBag.EnOrgID + "&orderid=" + order.OrderID + "&url=" + HttpUtility.UrlEncode("/Shop/Goods2/Index?oid=" + ViewBag.EnOrgID);
                }
                return(GetSucceedResult(new
                {
                    url = url
                }, ""));
            }
            else
            {
                return(GetErrorResult("保存失败,请稍候再试"));
            }
        }