Esempio n. 1
0
        public int Save(Model.TD_Shop_Order order, Model.TD_Shop_Order_Consignee consignee, IList <Model.TD_Shop_OrderGoods> ordderGoodsList)
        {
            string tranID = MySqlHelperUtil.BeginTran();

            try
            {
                string orderID = GetOrderID();
                order.OrderID         = orderID;
                order.PayNo           = orderID;
                order.IsMemberDeleted = "0";
                order.IsPay           = "0";
                order.OrderTime       = DateTime.Now;
                int result = dal.Add(order, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                foreach (var orderGoods in ordderGoodsList)
                {
                    orderGoods.OrderID      = orderID;
                    orderGoods.OrderTime    = order.OrderTime;
                    orderGoods.OrderGoodsID = Guid.NewGuid().ToString();
                    result = orderGoodsBLL.Add(orderGoods, tranID);
                    if (result == 0)
                    {
                        MySqlHelperUtil.RollbackTran(tranID);
                        return(0);
                    }
                    result = goodsBLL.Frozen(orderGoods.GoodsID, orderGoods.Amount.Value, tranID);
                    if (result == 0)
                    {
                        MySqlHelperUtil.RollbackTran(tranID);
                        return(0);
                    }
                }
                MySqlHelperUtil.CommitTran(tranID);
                return(1);
            }
            catch (Exception ex)
            {
                MySqlHelperUtil.RollbackTran(tranID);
                return(0);
            }
        }
Esempio n. 2
0
        public JsonResult SaveOrder(Models.m_YueBing model)
        {
            int orgID = int.Parse(DESEncrypt.Decrypt(ViewBag.EnOrgID));
            var goods = sellBLL.GetModel(model.goodsID);

            if (null == goods)
            {
                throw new Exception("该商品已达上限");
            }
            //if (goods.Balance.Value < model.Amount)
            //{
            //    return GetErrorResult("数量不足");
            //}
            ShiMiao.Model.TD_Shop_Order_Consignee consignee = new Model.TD_Shop_Order_Consignee();
            consignee.Address = model.useraddress;
            consignee.Name    = model.username;
            consignee.Phone   = model.userphone;

            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;
            //月饼常规价格 + 快递费
            decimal ExtraPrice = 0;

            switch (model.ExtraPrice)
            {
            case 0:    //自提
                ExtraPrice = 0;
                break;

            case 1:    //省内
                ExtraPrice = 6;
                break;

            case 2:    //省外
                ExtraPrice = 8;
                break;

            default:    //其他
                ExtraPrice = 8;
                break;
            }
            order.ExtraPrice = ExtraPrice * model.Amount;
            order.OriPrice   = goods.Price * model.Amount + order.ExtraPrice;
            decimal realPrice = goods.Price.Value;

            if (model.Amount >= 5)
            {//优惠价格 + 快递费
                order.RealPrice = 88 * model.Amount + ExtraPrice * model.Amount;
                realPrice       = 88;
            }
            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 = realPrice;//goods.Price;
            orderGoodsList.Add(orderGoods);
            int result = orderBLL.Save(order, consignee, 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/YueBing/Index?oid=" + ViewBag.EnOrgID);
                }
                return(GetSucceedResult(new
                {
                    url = url
                }, ""));
            }
            else
            {
                return(GetErrorResult("保存失败,请稍候再试"));
            }
        }
Esempio n. 3
0
        public JsonResult SaveOrder2(Models.m_Shop_Order model)
        {
            if (model.Amount <= 0)
            {
                throw new Exception("数量有误");
            }
            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("数量不足"));
            }
            Model.TD_Shop_Order_Consignee consignee = new Model.TD_Shop_Order_Consignee()
            {
                Address = model.useraddress,
                Phone   = model.userphone,
                Name    = model.username
            };

            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.Mobile    = model.userphone;
            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, consignee, 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("保存失败,请稍候再试"));
            }
        }
Esempio n. 4
0
        public int Save(Model.TD_Shop_Order order, Model.TD_Shop_Order_Consignee consignee, IList <Model.TD_Shop_OrderGoods> ordderGoodsList)
        {
            string tranID    = MySqlHelperUtil.BeginTran();
            bool   isNotFind = true;

            try
            {
                string orderID = GetOrderID();
                order.OrderID         = orderID;
                order.PayNo           = orderID;
                order.IsMemberDeleted = "0";
                order.IsPay           = "0";
                order.OrderTime       = DateTime.Now;
                int result = dal.Add(order, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                consignee.OrderID = orderID;
                result            = dl_consignee.Add(consignee, tranID);
                if (result == 0)
                {
                    MySqlHelperUtil.RollbackTran(tranID);
                    return(0);
                }
                foreach (var orderGoods in ordderGoodsList)
                {
                    isNotFind               = true;
                    orderGoods.OrderID      = orderID;
                    orderGoods.OrderTime    = order.OrderTime;
                    orderGoods.OrderGoodsID = Guid.NewGuid().ToString();
                    result = orderGoodsBLL.Add(orderGoods, tranID);
                    if (result == 0)
                    {
                        MySqlHelperUtil.RollbackTran(tranID);
                        return(0);
                    }
                    var ShopGoodsModel = goodsBLL.GetModel(orderGoods.GoodsID);
                    if (null != ShopGoodsModel)
                    {
                        //商城商品处理冻结
                        result = goodsBLL.Frozen(orderGoods.GoodsID, orderGoods.Amount.Value, tranID);
                        if (result == 0)
                        {
                            MySqlHelperUtil.RollbackTran(tranID);
                            return(0);
                        }
                        isNotFind = false;
                    }
                    else
                    {
                        var SellGoodsModel = sellgoods.GetModel(orderGoods.GoodsID);
                        if (null != SellGoodsModel)
                        {
                            if (!bl_Config.noFrozen.Contains(orderGoods.GoodsID))
                            {//义卖商品处理冻结
                                result = sellgoods.Frozen(orderGoods.GoodsID, orderGoods.Amount.Value, tranID);
                                if (result == 0)
                                {
                                    MySqlHelperUtil.RollbackTran(tranID);
                                    return(0);
                                }
                            }
                            isNotFind = false;
                        }
                    }
                    if (isNotFind)
                    {
                        throw new Exception("认领失败了,请重新认领!");
                    }
                }
                MySqlHelperUtil.CommitTran(tranID);
                return(1);
            }
            catch (Exception ex)
            {
                MySqlHelperUtil.RollbackTran(tranID);
                return(0);
            }
        }
Esempio n. 5
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("保存失败,请稍候再试"));
            }
        }