Exemple #1
0
        /// <summary>
        /// 下单
        /// </summary>
        /// <param name="model"></param>
        public void SubmitOrder(MargainBill margainbill)
        {
            try
            {
                //订单号
                ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO();
                long orderid = _orderBO.GenerateOrderNumber();

                //收货信息
                ShippingAddressService _ShippingAddressService = new ShippingAddressService();
                ShippingAddressInfo    addressinfo             = _ShippingAddressService.GetUserShippingAddress(long.Parse(margainbill.RegionId.ToString()));

                //供应商
                ShopService _ShopService = new ShopService();
                string      shopname     = _ShopService.GetShopName(margainbill.ShopId);

                //会员
                MemberService _MemberService = new MemberService();
                string        username       = _MemberService.GetMember(margainbill.MemberId) == null ? "" : (_MemberService.GetMember(margainbill.MemberId).UserName == null ? "" : _MemberService.GetMember(margainbill.MemberId).UserName);

                using (TransactionScope transactionScope = new TransactionScope())
                {
                    OrderInfo orderInfo = new OrderInfo();
                    orderInfo.Id        = orderid;                          //订单号
                    orderInfo.ShopId    = margainbill.ShopId;               //供应商编号ChemCloud_Shops
                    orderInfo.ShopName  = shopname;
                    orderInfo.UserId    = margainbill.MemberId;             //采购商ChemCloud_Members
                    orderInfo.UserName  = username;
                    orderInfo.OrderDate = DateTime.Now;                     //订单日期

                    orderInfo.ExpressCompanyName = margainbill.DeliverType; //物流配送方式
                    orderInfo.Freight            = margainbill.DeliverCost; //运费
                    //orderInfo.ShippingDate = margainbill.DeliverDate; //发货日期

                    orderInfo.PaymentTypeName = margainbill.PayMode;        //支付方式

                    orderInfo.ProductTotalAmount = margainbill.TotalAmount; //产品金额
                    orderInfo.CoinType           = margainbill.CoinType;    //货币种类

                    orderInfo.ShipTo         = addressinfo.ShipTo;          //收货人
                    orderInfo.TopRegionId    = addressinfo.RegionId;        //RegionId
                    orderInfo.RegionId       = addressinfo.RegionId;        //RegionId
                    orderInfo.RegionFullName = addressinfo.RegionFullName;  //省市区街道
                    orderInfo.Address        = addressinfo.Address;
                    orderInfo.CellPhone      = addressinfo.Phone;

                    orderInfo.OrderStatus        = OrderInfo.OrderOperateStatus.WaitPay;//订单
                    orderInfo.IsPrinted          = false;
                    orderInfo.RefundTotalAmount  = new decimal(0);
                    orderInfo.CommisTotalAmount  = new decimal(0);
                    orderInfo.RefundCommisAmount = new decimal(0);
                    orderInfo.Platform           = PlatformType.PC;

                    if (margainbill.InvoiceType == 0)
                    {
                        orderInfo.InvoiceType = InvoiceType.None;
                    }
                    else if (margainbill.InvoiceType == 1)
                    {
                        orderInfo.InvoiceType = InvoiceType.VATInvoice;
                    }
                    else if (margainbill.InvoiceType == 2)
                    {
                        orderInfo.InvoiceType = InvoiceType.OrdinaryInvoices;
                    }
                    orderInfo.InvoiceTitle   = margainbill.InvoiceTitle;
                    orderInfo.InvoiceContext = margainbill.InvoiceContext;

                    orderInfo.DiscountAmount   = new decimal(0);
                    orderInfo.ActiveType       = OrderInfo.ActiveTypes.None;
                    orderInfo.IntegralDiscount = new decimal(0);

                    orderInfo.IsInsurance    = margainbill.IsInsurance; //保险费
                    orderInfo.Insurancefee   = margainbill.Insurancefee;
                    orderInfo.Transactionfee = 0;                       //交易费
                    orderInfo.Counterfee     = 0;                       //手续费

                    context.OrderInfo.Add(orderInfo);
                    context.SaveChanges();

                    MargainBillDetail billdetail    = margainbill._MargainBillDetail.LastOrDefault();
                    OrderItemInfo     orderInfoitem = new OrderItemInfo();
                    orderInfoitem.OrderId        = orderid;
                    orderInfoitem.ShopId         = margainbill.ShopId;
                    orderInfoitem.ProductId      = billdetail.ProductId;
                    orderInfoitem.ProductName    = billdetail.ProductName;
                    orderInfoitem.Quantity       = billdetail.Num;
                    orderInfoitem.SalePrice      = billdetail.PurchasePrice;
                    orderInfoitem.PackingUnit    = billdetail.PackingUnit;
                    orderInfoitem.Purity         = billdetail.Purity;
                    orderInfoitem.SpecLevel      = billdetail.SpecLevel;
                    orderInfoitem.ReturnQuantity = long.Parse("1");
                    orderInfoitem.CostPrice      = 0;

                    orderInfoitem.DiscountAmount = 0;
                    orderInfoitem.RealTotalPrice = 0;
                    orderInfoitem.RefundPrice    = 0;
                    orderInfoitem.CommisRate     = 0;
                    orderInfoitem.IsLimitBuy     = false;

                    context.OrderItemInfo.Add(orderInfoitem);
                    context.SaveChanges();

                    //下单成功 更改状态
                    margainbill.BillStatus = EnumBillStatus.BargainSucceed;
                    context.SaveChanges();

                    transactionScope.Complete();
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        /// <summary>
        /// 下单
        /// </summary>
        /// <param name="model"></param>
        public bool CartSubmitOrder(List <MargainBill> listbill)
        {
            bool result = false;

            try
            {
                foreach (MargainBill margainbill in listbill)
                {
                    //订单号
                    ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO();
                    long orderid = _orderBO.GenerateOrderNumber();

                    //收货信息
                    ShippingAddressService _ShippingAddressService = new ShippingAddressService();
                    ShippingAddressInfo    addressinfo             = _ShippingAddressService.GetUserShippingAddress(long.Parse(margainbill.RegionId.ToString()));

                    //供应商
                    ShopService _ShopService = new ShopService();
                    string      shopname     = _ShopService.GetShopName(margainbill.ShopId);

                    //会员
                    MemberService _MemberService = new MemberService();
                    string        username       = _MemberService.GetMember(margainbill.MemberId) == null ? "" : (_MemberService.GetMember(margainbill.MemberId).UserName == null ? "" : _MemberService.GetMember(margainbill.MemberId).UserName);

                    using (TransactionScope transactionScope = new TransactionScope())
                    {
                        OrderInfo orderInfo = new OrderInfo();
                        orderInfo.Id        = orderid;                          //订单号
                        orderInfo.ShopId    = margainbill.ShopId;               //供应商编号ChemCloud_Shops
                        orderInfo.ShopName  = shopname;
                        orderInfo.UserId    = margainbill.MemberId;             //采购商ChemCloud_Members
                        orderInfo.UserName  = username;
                        orderInfo.OrderDate = DateTime.Now;                     //订单日期

                        orderInfo.ExpressCompanyName = margainbill.DeliverType; //物流配送方式

                        orderInfo.Freight = margainbill.DeliverCost;            //运费
                        //orderInfo.ShippingDate = margainbill.DeliverDate; //发货日期
                        //orderInfo.ShippingDate = null; //发货日期  尚未支付
                        orderInfo.PaymentTypeName = margainbill.PayMode;           //支付方式

                        orderInfo.ProductTotalAmount = margainbill.TotalAmount;    //产品金额
                        orderInfo.CoinType           = margainbill.CoinType;       //货币种类

                        orderInfo.ShipTo             = addressinfo.ShipTo;         //收货人
                        orderInfo.TopRegionId        = addressinfo.RegionId;       //RegionId
                        orderInfo.RegionId           = addressinfo.RegionId;       //RegionId
                        orderInfo.RegionFullName     = addressinfo.RegionFullName; //省市区街道
                        orderInfo.Address            = addressinfo.Address;
                        orderInfo.CellPhone          = addressinfo.Phone;
                        orderInfo.OrderStatus        = OrderInfo.OrderOperateStatus.WaitPay;//订单
                        orderInfo.IsPrinted          = false;
                        orderInfo.RefundTotalAmount  = new decimal(0);
                        orderInfo.CommisTotalAmount  = new decimal(0);
                        orderInfo.RefundCommisAmount = new decimal(0);
                        orderInfo.Platform           = PlatformType.PC;

                        /*发票信息*/
                        if (margainbill.InvoiceType == 0)
                        {
                            orderInfo.InvoiceType = InvoiceType.None;
                        }
                        else if (margainbill.InvoiceType == 1)
                        {
                            orderInfo.InvoiceType = InvoiceType.VATInvoice;
                        }
                        else if (margainbill.InvoiceType == 2)
                        {
                            orderInfo.InvoiceType = InvoiceType.OrdinaryInvoices;
                        }
                        else if (margainbill.InvoiceType == 3)
                        {
                            orderInfo.InvoiceType = InvoiceType.SpecialTicket;
                        }
                        orderInfo.InvoiceTitle   = margainbill.InvoiceTitle;   //名称
                        orderInfo.InvoiceContext = margainbill.InvoiceContext; //纳税人识别号
                        orderInfo.SellerPhone    = margainbill.SellerPhone;    //电话
                        orderInfo.SellerRemark   = margainbill.SellerRemark;   //开户行及账号
                        orderInfo.SellerAddress  = margainbill.SellerAddress;  //地址
                        /*发票信息*/

                        orderInfo.DiscountAmount   = new decimal(0);
                        orderInfo.ActiveType       = OrderInfo.ActiveTypes.None;
                        orderInfo.IntegralDiscount = new decimal(0);

                        orderInfo.IsInsurance    = margainbill.IsInsurance; //保险费
                        orderInfo.Insurancefee   = margainbill.Insurancefee;
                        orderInfo.Transactionfee = 0;                       //交易费
                        orderInfo.Counterfee     = 0;                       //手续费

                        context.OrderInfo.Add(orderInfo);
                        context.SaveChanges();
                        MargainBillService _MargainBillService = new MargainBillService();
                        OrderItemInfo      orderInfoitem       = new OrderItemInfo();
                        foreach (MargainBillDetail billdetail in margainbill._MargainBillDetail)
                        {
                            orderInfoitem.OrderId        = orderid;
                            orderInfoitem.ShopId         = margainbill.ShopId;
                            orderInfoitem.ProductId      = billdetail.ProductId;
                            orderInfoitem.ProductName    = billdetail.ProductName;
                            orderInfoitem.Quantity       = billdetail.Num;
                            orderInfoitem.SalePrice      = billdetail.PurchasePrice;
                            orderInfoitem.PackingUnit    = billdetail.PackingUnit;
                            orderInfoitem.SpecLevel      = billdetail.SpecLevel;
                            orderInfoitem.Purity         = billdetail.Purity;
                            orderInfoitem.ReturnQuantity = long.Parse("1");
                            orderInfoitem.CostPrice      = 0;
                            orderInfoitem.DiscountAmount = 0;
                            orderInfoitem.RealTotalPrice = 0;
                            orderInfoitem.RefundPrice    = 0;
                            orderInfoitem.CommisRate     = 0;
                            orderInfoitem.IsLimitBuy     = false;
                            context.OrderItemInfo.Add(orderInfoitem);
                            context.SaveChanges();
                            _MargainBillService.RemoveCartAfterOrder(orderInfo.UserId, billdetail.ProductId); //提交成功后,删除购物车内容
                        }
                        transactionScope.Complete();
                    }
                }
                result = true;
            }
            catch (Exception)
            {
                return(false);
            }

            return(result);
        }
Exemple #3
0
        //议价单转订单
        public void TransferOrder(long MargainBillId)
        {
            try
            {
                MargainBill margainbill = GetBillById(MargainBillId, 0);

                ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO();
                long orderid = _orderBO.GenerateOrderNumber();

                ShippingAddressService _ShippingAddressService = new ShippingAddressService();
                ShippingAddressInfo    addressinfo             = _ShippingAddressService.GetUserShippingAddress(long.Parse(margainbill.DeliverAddress));

                ShopService _ShopService = new ShopService();
                string      shopname     = _ShopService.GetShopName(margainbill.ShopId);

                MemberService _MemberService = new MemberService();
                string        username       = _MemberService.GetMember(margainbill.MemberId).UserName;

                using (TransactionScope transactionScope = new TransactionScope())
                {
                    OrderInfo orderInfo = new OrderInfo();
                    orderInfo.Id                 = orderid;                    //订单号
                    orderInfo.ShopId             = margainbill.ShopId;         //供应商编号ChemCloud_Shops
                    orderInfo.ShopName           = shopname;
                    orderInfo.UserId             = margainbill.MemberId;       //采购商ChemCloud_Members
                    orderInfo.UserName           = username;
                    orderInfo.OrderDate          = DateTime.Now;               //订单日期
                    orderInfo.Address            = margainbill.DeliverAddress; //收获地址 shippingaddress 编号
                    orderInfo.ExpressCompanyName = margainbill.DeliverType;
                    orderInfo.Freight            = margainbill.DeliverCost;
                    orderInfo.ShippingDate       = margainbill.DeliverDate;
                    orderInfo.PaymentTypeName    = margainbill.PayMode;
                    orderInfo.ProductTotalAmount = margainbill.TotalAmount;
                    orderInfo.CoinType           = margainbill.CoinType;
                    orderInfo.ShipTo             = addressinfo.ShipTo;//收货人
                    orderInfo.TopRegionId        = int.Parse("1");
                    orderInfo.RegionId           = addressinfo.RegionId;
                    orderInfo.RegionFullName     = addressinfo.RegionFullName;

                    orderInfo.OrderStatus        = OrderInfo.OrderOperateStatus.WaitPay;
                    orderInfo.IsPrinted          = false;
                    orderInfo.RefundTotalAmount  = new decimal(0);
                    orderInfo.CommisTotalAmount  = new decimal(0);
                    orderInfo.RefundCommisAmount = new decimal(0);
                    orderInfo.Platform           = PlatformType.PC;
                    orderInfo.InvoiceType        = InvoiceType.OrdinaryInvoices;
                    orderInfo.InvoiceTitle       = "InvoiceTitle";
                    orderInfo.InvoiceContext     = "InvoiceContext";
                    orderInfo.DiscountAmount     = new decimal(0);
                    orderInfo.ActiveType         = OrderInfo.ActiveTypes.None;
                    orderInfo.IntegralDiscount   = new decimal(0);

                    context.OrderInfo.Add(orderInfo);
                    context.SaveChanges();

                    MargainBillDetail billdetail    = margainbill._MargainBillDetail.LastOrDefault();
                    OrderItemInfo     orderInfoitem = new OrderItemInfo();
                    orderInfoitem.OrderId        = orderid;
                    orderInfoitem.ShopId         = margainbill.ShopId;
                    orderInfoitem.ProductId      = billdetail.ProductId;
                    orderInfoitem.ProductName    = billdetail.ProductName;
                    orderInfoitem.Quantity       = billdetail.Num;
                    orderInfoitem.SalePrice      = billdetail.PurchasePrice;
                    orderInfoitem.ReturnQuantity = long.Parse("1");
                    orderInfoitem.CostPrice      = 0;

                    orderInfoitem.DiscountAmount = 0;
                    orderInfoitem.RealTotalPrice = 0;
                    orderInfoitem.RefundPrice    = 0;
                    orderInfoitem.CommisRate     = 0;
                    orderInfoitem.IsLimitBuy     = false;

                    context.OrderItemInfo.Add(orderInfoitem);
                    context.SaveChanges();

                    //下单成功 更改状态
                    margainbill.BillStatus = EnumBillStatus.BargainSucceed;
                    context.SaveChanges();

                    transactionScope.Complete();
                }
            }
            catch (Exception)
            {
            }
        }