Exemplo n.º 1
0
        /// <summary>
        /// 结束议价
        /// </summary>
        /// <param name="Id"></OverBargainparam>
        public void OverBargain(long Id)
        {
            MargainBill model = context.MargainBill.FindById <MargainBill>(Id);

            model.BillStatus = EnumBillStatus.BargainOver;
            context.SaveChanges();
        }
Exemplo n.º 2
0
        //议价 详细页面
        public ActionResult BargainDetail(long id)
        {
            string      isreview     = "false";
            MargainBill _MargainBill = ServiceHelper.Create <IMargainBillService>().GetBillById(id, base.CurrentUser.Id);

            _MargainBill.MemberName = ServiceHelper.Create <IMemberService>().GetMember(_MargainBill.MemberId).RealName == null ? "" : ServiceHelper.Create <IMemberService>().GetMember(_MargainBill.MemberId).RealName;
            _MargainBill.ShopName   = ServiceHelper.Create <IShopService>().GetShop(_MargainBill.ShopId).ShopName == null ? "" : ServiceHelper.Create <IShopService>().GetShop(_MargainBill.ShopId).ShopName;
            foreach (var item in _MargainBill._MargainBillDetail)
            {
                item.BidderName = ServiceHelper.Create <IMemberService>().GetMember(item.Bidder) == null?ServiceHelper.Create <IShopService>().GetShopName(item.Bidder) : ServiceHelper.Create <IMemberService>().GetMember(item.Bidder).RealName;
            }
            if (_MargainBill.BillStatus == EnumBillStatus.Bargaining)
            {
                isreview = "true";
            }
            ViewBag.CurrentUser = base.CurrentUser.Id;
            ViewBag.isreview    = isreview;
            if (!string.IsNullOrEmpty(_MargainBill.DeliverAddress) && !"null".Equals(_MargainBill.DeliverAddress))
            {
                ShippingAddressInfo addressinfo = ServiceHelper.Create <IShippingAddressService>().GetUserShippingAddress(long.Parse(_MargainBill.DeliverAddress));
                if (addressinfo != null)
                {
                    _MargainBill.DeliverAddress = addressinfo.RegionFullName + ">" + addressinfo.Address;
                }
            }
            else
            {
                _MargainBill.DeliverAddress = "" + ">" + "";
            }
            return(View(_MargainBill));
        }
Exemplo n.º 3
0
        public void UpdateBillStatu(long Id, EnumBillStatus status)
        {
            MargainBill model = context.MargainBill.FindById <MargainBill>(Id);

            model.BillStatus = status;
            context.SaveChanges();
        }
Exemplo n.º 4
0
        public JsonResult SubmitOrderFun(string json)
        {
            //1:CNY 2:USD
            string CoinType = ConfigurationManager.AppSettings["CoinType"] == null ? "2" : ConfigurationManager.AppSettings["CoinType"];

            try
            {
                MarginBillModel margin = Newtonsoft.Json.JsonConvert.DeserializeObject <MarginBillModel>(json);
                // MargainBill model = Newtonsoft.Json.JsonConvert.DeserializeObject<MargainBill>(json);
                MargainBill model = null;
                ShipmentEx  ship  = null;
                if (margin != null)
                {
                    model = Newtonsoft.Json.JsonConvert.DeserializeObject <MargainBill>(margin.Bill);
                    ship  = Newtonsoft.Json.JsonConvert.DeserializeObject <ShipmentEx>(margin.Ship);
                }

                if (model != null)
                {
                    //if (model.DeliverDate.Date < DateTime.Now.Date)
                    //{
                    //    return Json(new { success = false, state = 1, msg = "发货时间在今天之前!" });
                    //}
                    model.BillStatus  = EnumBillStatus.SubmitBargain;
                    model.CreateDate  = DateTime.Now;
                    model.IsDelete    = 0;
                    model.MemberId    = CurrentUser.Id;
                    model.TotalAmount = 0;
                    foreach (var item in model._MargainBillDetail)
                    {
                        item.CreateDate    = DateTime.Now;
                        item.IsDelete      = 0;
                        model.TotalAmount += item.PurchasePrice;
                        item.Bidder        = base.CurrentUser.Id;
                    }

                    model.CoinType = long.Parse(CoinType);

                    ServiceHelper.Create <IMargainBillService>().SubmitOrder(model, ship);

                    long userid = ServiceHelper.Create <IManagerService>().GetMemberIdByShopId(model.ShopId) == null ? 0 :
                                  ServiceHelper.Create <IManagerService>().GetMemberIdByShopId(model.ShopId).Id;

                    string messagecontent = "用户" + base.CurrentUser.UserName + "向你提交了订单,单号:" + model.BillNo + "。请查看。";
                    ServiceHelper.Create <ISiteMessagesService>().SendSiteMessages(userid, (int)MessageSetting.MessageModuleStatus.OrderCreated, messagecontent, base.CurrentUser.UserName);

                    return(Json(new { success = true, msg = "success!" }));
                }
                else
                {
                    return(Json(new { success = false, state = 0, msg = "提交失败!" }));
                }
            }
            catch (Exception)
            {
                return(Json(new { success = false, state = 1, msg = "提交失败!" }));
            }
        }
Exemplo n.º 5
0
        public void SellerCloseBargain(string bargainno)
        {
            MargainBill MargainBillInfo = (
                from P in context.MargainBill
                where P.BillNo == bargainno
                select P).FirstOrDefault();

            MargainBillInfo.BillStatus = EnumBillStatus.BargainDelete;
            context.SaveChanges();
        }
Exemplo n.º 6
0
        //修改议价单
        public void UpdateBill(MargainBill model)
        {
            MargainBill _MargainBill = context.MargainBill.FindById <MargainBill>(model.Id);

            _MargainBill.TotalAmount = model.TotalAmount;

            UpdateBillDetail(model._MargainBillDetail.FirstOrDefault());

            context.SaveChanges();
        }
Exemplo n.º 7
0
 //添加议价单
 public void AddBill(MargainBill model)
 {
     context.MargainBill.Add(model);
     context.SaveChanges();
     foreach (var item in model._MargainBillDetail)
     {
         context.MargainBillDetail.Add(item);
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
        public void UpdateBargainPrice(long BargainDId, decimal freight)
        {
            MargainBillDetail bargain = context.MargainBillDetail.FindById <MargainBillDetail>(BargainDId);

            bargain.ShopPirce = freight;
            context.SaveChanges();
            MargainBill MargainBillInfo = (
                from P in context.MargainBill
                where P.BillNo == bargain.BillNo
                select P).FirstOrDefault();

            MargainBillInfo.BillStatus = EnumBillStatus.Bargaining;
            context.SaveChanges();
        }
Exemplo n.º 9
0
        public MargainBill GetBillById(long id, long userid)
        {
            MargainBill MargainBillInfo = (
                from P in context.MargainBill
                where P.Id == id
                select P).FirstOrDefault();
            List <MargainBillDetail> _MargainBillDetail = (from q in context.MargainBillDetail
                                                           where q.BillNo == MargainBillInfo.BillNo
                                                           orderby q.CreateDate ascending
                                                           select q).ToList();

            MargainBillInfo._MargainBillDetail = _MargainBillDetail;

            return(MargainBillInfo);
        }
Exemplo n.º 10
0
        public MargainBill GetBillByNo(string BillNo)
        {
            MargainBill MargainBillInfo = (
                from P in context.MargainBill
                where P.BillNo == BillNo
                select P).FirstOrDefault();

            List <MargainBillDetail> _MargainBillDetail = (from q in context.MargainBillDetail
                                                           where q.BillNo == MargainBillInfo.BillNo
                                                           select q).ToList();

            MargainBillInfo._MargainBillDetail = _MargainBillDetail;

            return(MargainBillInfo);
        }
Exemplo n.º 11
0
        public JsonResult UpdateBargaion(long Id, int Num, decimal PurchasePrice, string MessageReply)
        {
            try
            {
                MargainBill model = ServiceHelper.Create <IMargainBillService>().GetBillById(Id, base.CurrentUser.Id);
                if (model != null)
                {
                    //更新回复信息
                    MargainBillDetail item = model._MargainBillDetail.OrderByDescending(q => q.Id).FirstOrDefault();
                    item.MessageReply  = MessageReply;
                    item.PurchasePrice = PurchasePrice;
                    item.Num           = Num;
                    ServiceHelper.Create <IMargainBillService>().UpdateMargainDetailMessageReply(item);

                    //更改询盘状态
                    ServiceHelper.Create <IMargainBillService>().UpdateBillStatu(model.Id);

                    ////添加新的询盘记录
                    //MargainBillDetail modeldetail = model._MargainBillDetail.LastOrDefault();
                    //MargainBillDetail detail = new MargainBillDetail();
                    //detail.CreateDate = DateTime.Now;
                    //detail.IsDelete = 0;
                    //detail.BillNo = modeldetail.BillNo;
                    //detail.ProductId = modeldetail.ProductId;
                    //detail.ProductName = modeldetail.ProductName;
                    //detail.MarketPrice = modeldetail.MarketPrice;
                    //detail.PackingUnit = modeldetail.PackingUnit;
                    //detail.Purity = modeldetail.Purity;
                    //detail.Num = Num;
                    //detail.PurchasePrice = PurchasePrice;
                    //detail.Bidder = base.CurrentUser.Id;
                    //detail.CASNo = modeldetail.CASNo;
                    //ServiceHelper.Create<IMargainBillService>().AddMargainDetail(detail);

                    return(Json(new { success = true, msg = "修改成功!" }));
                }
                else
                {
                    return(Json(new { success = false, msg = "修改失败!" }));
                }
            }
            catch (Exception)
            {
                return(Json(new { success = false, msg = "修改失败!" }));
            }
        }
Exemplo n.º 12
0
        public JsonResult AddBargaion(string json)
        {
            string CoinType = ConfigurationManager.AppSettings["CoinType"] == null ? "1" : ConfigurationManager.AppSettings["CoinType"];

            try
            {
                MargainBill model = Newtonsoft.Json.JsonConvert.DeserializeObject <MargainBill>(json);
                if (model != null)
                {
                    model.BillStatus  = EnumBillStatus.SubmitBargain;
                    model.CreateDate  = DateTime.Now;
                    model.IsDelete    = 0;
                    model.MemberId    = CurrentUser.Id;
                    model.TotalAmount = 0;
                    model.CoinType    = long.Parse(CoinType); //设置币种
                    foreach (var item in model._MargainBillDetail)
                    {
                        item.CreateDate    = DateTime.Now;
                        item.IsDelete      = 0;
                        model.TotalAmount += item.PurchasePrice;
                        item.Bidder        = base.CurrentUser.Id;
                    }
                    model.TotalAmount += model.DeliverCost;
                    ServiceHelper.Create <IMargainBillService>().AddBill(model);

                    long userid = ServiceHelper.Create <IManagerService>().GetMemberIdByShopId(model.ShopId) == null ? 0 : ServiceHelper.Create <IManagerService>().GetMemberIdByShopId(model.ShopId).Id;


                    string messagecontent = "用户" + base.CurrentUser.UserName + "向你提交了询盘,单号:" + model.BillNo + "。请查看。";

                    ServiceHelper.Create <ISiteMessagesService>().SendSiteMessages(userid, (int)MessageSetting.MessageModuleStatus.XunPan, messagecontent, base.CurrentUser.UserName);

                    return(Json(new { success = true, msg = "添加成功!" }));
                }
                else
                {
                    return(Json(new { success = false, msg = "添加失败!" }));
                }
            }
            catch (Exception)
            {
                return(Json(new { success = false, msg = "添加失败!" }));
            }
        }
Exemplo n.º 13
0
        public JsonResult SubmitLimit(string json)
        {
            string CoinType = ConfigurationManager.AppSettings["CoinType"] == null ? "2" : ConfigurationManager.AppSettings["CoinType"];

            try
            {
                MargainBill model = Newtonsoft.Json.JsonConvert.DeserializeObject <MargainBill>(json);

                if (model != null)
                {
                    model.BillStatus  = EnumBillStatus.SubmitBargain;
                    model.CreateDate  = DateTime.Now;
                    model.IsDelete    = 0;
                    model.MemberId    = CurrentUser.Id;
                    model.TotalAmount = 0;
                    foreach (var item in model._MargainBillDetail)
                    {
                        item.CreateDate    = DateTime.Now;
                        item.IsDelete      = 0;
                        model.TotalAmount += item.PurchasePrice;
                        item.Bidder        = base.CurrentUser.Id;
                    }
                    //model.TotalAmount += model.DeliverCost;
                    model.CoinType = long.Parse(CoinType);
                    //曹凯添加方法
                    //ApplyAmountInfo Applymodel = new ApplyAmountInfo()
                    //{
                    //    ApplyUserId = base.CurrentUser.Id,
                    //    ApplyAmount = model.TotalAmount,
                    //    ApplyDate = DateTime.Now,
                    //    CoinType = int.Parse(model.CoinType.ToString()),
                    //    OrderId = long.Parse(model.BillNo)
                    //};
                    //ServiceHelper.Create<IApplyAmountService>().AddApplyAmount(Applymodel);
                }
                return(Json(new { success = true, msg = "提交成功!" }));
            }
            catch (Exception)
            {
                return(Json(new { success = false, msg = "提交失败!" }));
            }
        }
Exemplo n.º 14
0
        public JsonResult UpdateBargaion(long Id, int Num, decimal PurchasePrice, string BuyerMessage)
        {
            try
            {
                MargainBill model = ServiceHelper.Create <IMargainBillService>().GetBillById(Id, base.CurrentUser.Id);
                if (model != null)
                {
                    MargainBillDetail modeldetail = model._MargainBillDetail.OrderByDescending(q => q.Id).FirstOrDefault();
                    MargainBillDetail detail      = new MargainBillDetail();
                    detail.CreateDate    = DateTime.Now;
                    detail.IsDelete      = 0;
                    detail.BillNo        = modeldetail.BillNo;
                    detail.ProductId     = modeldetail.ProductId;
                    detail.ProductName   = modeldetail.ProductName;
                    detail.MarketPrice   = modeldetail.MarketPrice;
                    detail.PackingUnit   = modeldetail.PackingUnit;
                    detail.Purity        = modeldetail.Purity;
                    detail.Num           = Num;
                    detail.PurchasePrice = PurchasePrice;
                    detail.SpecLevel     = modeldetail.SpecLevel;
                    detail.Bidder        = base.CurrentUser.Id;
                    detail.CASNo         = modeldetail.CASNo;
                    detail.BuyerMessage  = BuyerMessage;
                    ServiceHelper.Create <IMargainBillService>().AddMargainDetail(detail);

                    ServiceHelper.Create <IMargainBillService>().UpdateBillStatu(model.Id, EnumBillStatus.SubmitBargain);//采购商再次询盘时,重置询盘状态为:已提交(未回复)

                    return(Json(new { success = true, msg = "修改成功!" }));
                }
                else
                {
                    return(Json(new { success = false, msg = "修改失败!" }));
                }
            }
            catch (Exception)
            {
                return(Json(new { success = false, msg = "修改失败!" }));
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 下单
        /// </summary>
        /// <param name="model"></param>
        public void SubmitOrderBatch(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.ShippingDate = DateTime.Now.AddDays(3); //发货日期
                    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;

                    //orderInfo.InvoiceType = InvoiceType.OrdinaryInvoices;
                    //orderInfo.InvoiceTitle = "InvoiceTitle";
                    //orderInfo.InvoiceContext = "InvoiceContext";

                    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();

                    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();
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 下单
        /// </summary>
        /// <param name="model"></param>
        public void SubmitOrder(MargainBill margainbill, ShipmentEx shipment)
        {
            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;
                    }
                    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();

                    foreach (MargainBillDetail billdetail in margainbill._MargainBillDetail)
                    {
                        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();

                    //保存物流信息
                    if (shipment != null)
                    {
                        ShipmentService ship = new ShipmentService();
                        ship.SaveShipmentEx(shipment, orderid);
                    }
                    transactionScope.Complete();
                }

                //保存物流信息
                //if (shipment != null)
                //{
                //    ShipmentService ship = new ShipmentService();
                //    ship.SaveShipment(shipment, orderid);
                //}
            }
            catch (DbEntityValidationException ex)
            {
            }
        }
Exemplo n.º 17
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)
            {
            }
        }