Пример #1
0
        //public ActionResult OrderSupportShippingList()
        //{
        //    return View();
        //}
        ///// <summary>
        ///// 编辑订单时候显示的承运商列表
        ///// </summary>
        ///// <param name="searchModel"></param>
        ///// <returns></returns>
        //public ActionResult ListOrderSupportShipping(SearchModel searchModel)
        //{
        //    //需要对应全局的订单Guid
        //    Guid orderGid = oNewOrder.Gid;
        //    IQueryable<OrderShipping> oOrderShipping = dbEntity.OrderShippings.Include("Order").Include("Shipper").Where(p => p.Deleted == false && p.OrderID == orderGid).AsQueryable();
        //    GridColumnModelList<OrderShipping> columns = new GridColumnModelList<OrderShipping>();
        //    columns.Add(p => p.Gid).SetAsPrimaryKey();
        //    columns.Add(p => p.Shipper.FullName.GetResource(CurrentSession.Culture)).SetName("ShipperName");
        //    columns.Add(p => p.ShipWeight);
        //    columns.Add(p => p.ShippingCheckName).SetName("ShipStatus");
        //    columns.Add(p => p.Candidate);
        //    columns.Add(p => p.Remark);
        //    GridData gridData = oOrderShipping.ToGridData(searchModel, columns);
        //    return Json(gridData, JsonRequestBehavior.AllowGet);
        //}
        /// <summary>
        /// 添加订单时列出支持的承运商
        /// </summary>
        /// <returns></returns>
        public ActionResult ShippingListShow()
        {
            OrderBLL oOrderBLL = new OrderBLL(this.dbEntity);//新建oOrderBLL对象
            List<ShippingInformation> oShippingList = new List<ShippingInformation>();
            List<SelectListItem> shippinglist = new List<SelectListItem>();
            if (oNewOrder.WhID != null && oNewOrder.aLocation != null && listNewOrderItem.Count>=1)
            {
                //-----------edit by 2011/10/24 需求:手动编辑订单是可以选择所有组织支持的承运商
                //获取支持的承运商列表
                //oShippingList = oOrderBLL.GetSupportShippings(listNewOrderItem, (Guid)oNewOrder.WhID, (Guid)oNewOrder.aLocation);
                //获取组织支持的所有承运商
                oShippingList = dbEntity.ShippingInformations.Where(s => s.aParent == oNewOrder.OrgID && s.Deleted == false).ToList();
                //------------------------------------------------------------------------------

                listNewOrderShipping.Clear();//每次都清除之前的承运商列表,以保证该列表永远是最新的-----BUG修改09.25
                if (oShippingList.Count > 0)
                {
                    for (int i = 0; i < oShippingList.Count; i++)
                    {
                        OrderShipping oNewOrderShipping = new OrderShipping
                        {
                            ShipID = oShippingList.ElementAt(i).Gid,
                            Order = oNewOrder
                        };
                        listNewOrderShipping.Add(oNewOrderShipping);
                        shippinglist.Add(new SelectListItem { Text = oShippingList.ElementAt(i).FullName.GetResource(CurrentSession.Culture), Value = oShippingList.ElementAt(i).Gid.ToString() });
                    }
                    oNewShipper = oShippingList.ElementAt(0);//默认选中权重最大的,即通过排序查找出的列表的第一个
                    foreach (var reg in oOrderBLL.GetFullRegions((Guid)oNewOrder.aLocation))
                    {
                        if (oNewShipper.Areas != null)//支持区域不为空
                        {
                            foreach (var area in oNewShipper.Areas)
                            {
                                if (area.RegionID == reg.Gid)
                                {
                                    oNewOrder.ResidenceFee = area.Residential == null? 0:area.Residential.GetResource((Guid)oNewOrder.aCurrency);//收取的到门费
                                    oNewOrder.LiftGateFee = area.LiftGate == null? 0:area.LiftGate.GetResource((Guid)oNewOrder.aCurrency);//收取的上楼费
                                    oNewOrder.InstallFee = area.Installation == null? 0:area.Installation.GetResource((Guid)oNewOrder.aCurrency);//收取的安装费
                                }
                            }
                        }
                    }
                }
                else//未找到符合的承运商
                {
                    oNewShipper = new ShippingInformation();
                }
            }
            ViewBag.shippinglist = shippinglist;

            return View();
        }
Пример #2
0
        public void MakeTestOrder(LiveEntities dbEntity)
        {
            // 建一个测试订单(真实订单,运单号)
            OrderInformation oNewOrder = new OrderInformation
            {
                Organization = (from o in dbEntity.MemberOrganizations
                                where o.Code == "Zhuchao" && o.Otype == (byte)ModelEnum.OrganizationType.CORPORATION
                                select o).FirstOrDefault(),
                Channel = (from c in dbEntity.MemberChannels
                           where c.Code == "Taobao01" && c.Otype == (byte)ModelEnum.OrganizationType.CHANNEL
                           select c).FirstOrDefault(),
                Warehouse = (from w in dbEntity.WarehouseInformations
                             where w.Code == "ZCWH01" && w.Otype == (byte)ModelEnum.OrganizationType.WAREHOUSE
                             select w).FirstOrDefault(),
                User = (from u in dbEntity.MemberUsers
                        where u.LoginName == "test"
                        select u).FirstOrDefault(),
                LinkCode = "92781947684462",
                Ostatus = (byte)ModelEnum.OrderStatus.DELIVERIED,
                PayStatus = (byte)ModelEnum.PayStatus.PAID,
                TransType = (byte)ModelEnum.TransType.SECURED,
                Currency = (from u in dbEntity.GeneralMeasureUnits
                            where u.Code == "¥" && u.Utype == (byte)ModelEnum.MeasureUnit.CURRENCY
                            select u).FirstOrDefault(),
                Location = (from r in dbEntity.GeneralRegions
                            where r.Code == "110105"
                            select r).FirstOrDefault(),
            };
            OrderShipping oShipping = new OrderShipping
            {
                Order = oNewOrder,
                Shipper = (from s in dbEntity.ShippingInformations
                           where s.Code == "EMS" && s.Otype == (byte)ModelEnum.OrganizationType.SHIPPER
                           select s).FirstOrDefault(),
                Ostatus = (byte)ModelEnum.ShippingCheck.PASSED,
                Candidate = true
            };
            dbEntity.OrderShippings.Add(oShipping);
            dbEntity.SaveChanges();

            ExTaobaoDeliveryPending oPending = new ExTaobaoDeliveryPending
            {
                Order = oNewOrder,
                Dstatus = (byte)ModelEnum.TaobaoDeliveryStatus.WAIT_FOR_SEND,
                ShipID = oShipping.Gid,
                tid = oNewOrder.LinkCode,
                logistics = oShipping.Shipper.Code,
                out_sid = "EM812010333CS"
            };
            dbEntity.ExTaobaoDeliveryPendings.Add(oPending);
            dbEntity.SaveChanges();
        }
Пример #3
0
 /// <summary>
 /// 查看选择的订单信息
 /// </summary>
 /// <param name="orderGid"></param>
 /// <returns></returns>
 public string SetViewOrderInfo(Guid orderGid)
 {
     //查询出查看的订单信息
     OrderInformation oViewOrder = dbEntity.OrderInformations.Include("Organization").Include("Channel").Include("User").Include("Warehouse").Include("PayType").Include("Currency").Include("Location").Include("OrderItems").Include("OrderProcesses").Include("OrderAttributes").Include("OrderHistories").Where(p => p.Gid == orderGid && p.Deleted == false).FirstOrDefault();
     //设置订单页面编辑状态
     if (oViewOrder.Hanged == (byte)ModelEnum.HangStatus.HANGED)
         bChangeOrder = true;
     else
         bChangeOrder = false;
     if (oViewOrder.Equals(null))
     {
         return "failure";
     }
     oNewOrder = oViewOrder;
     listNewOrderItem.Clear();//清空缓存区商品列表
     foreach (OrderItem item in oNewOrder.OrderItems)
     {
         OrderItem obj = dbEntity.OrderItems.Include("OnSkuItem").Include("SkuItem").Where(o => o.Gid == item.Gid && o.Deleted==false).FirstOrDefault();
         if (obj != null)
             listNewOrderItem.Add(obj);
     }
     listNewOrderShipping.Clear();//清空缓存区承运商列表
     oNewShipper = new ShippingInformation();
     //-----------------------------------------------------------------edit by 2011/10/24 手工订单编辑可以选择该组织所有支持的承运商
     //foreach (OrderShipping ship in oNewOrder.OrderShippings)
     //{
     //    OrderShipping obj = dbEntity.OrderShippings.Include("Shipper").Where(o => o.Gid == ship.Gid && o.Deleted == false).FirstOrDefault();
     //    if (obj != null)
     //    {
     //        if (obj.Candidate)//将原MODEL中选中的承运商赋给oNewShipper
     //            oNewShipper = obj.Shipper;
     //        listNewOrderShipping.Add(obj);
     //    }
     //}
     List<ShippingInformation> listOrgShippers = dbEntity.ShippingInformations.Where(s => s.Deleted == false && s.aParent == oNewOrder.OrgID).ToList();//组织支持的承运商
     foreach (ShippingInformation ship in listOrgShippers)
     {
         OrderShipping oShip = new OrderShipping {  OrderID = oNewOrder.Gid,ShipID = ship.Gid};
         listNewOrderShipping.Add(oShip);
     }
     foreach (OrderShipping ship in oNewOrder.OrderShippings)
     {
         OrderShipping obj = dbEntity.OrderShippings.Include("Shipper").Where(o => o.Gid == ship.Gid && o.Deleted == false).FirstOrDefault();
         if (obj != null)
         {
             if (obj.Candidate)//将原MODEL中选中的承运商赋给oNewShipper
                 oNewShipper = obj.Shipper;
         }
     }
     //---------------------------------------------------------------------------------------------------------------------------------
     return "success";
 }
Пример #4
0
        /// <summary>
        /// 保存页面修改信息,通过编辑的标志位来判断保存不同的信息
        /// </summary>
        /// <param name="oBackOrder"></param>
        /// <returns></returns>
        public ActionResult SaveEditOrderInfo(OrderInformation oBackOrder)
        {
            if (bChangeOrder == true)
            {
                if (bOrderBaseInfoEdit == true && bOrderItemInfoEdit == false && bOrderFeeInfoEdit == false)
                {
                    oNewOrder.LinkCode = oBackOrder.LinkCode;
                    oNewOrder.PayID = oBackOrder.PayID;
                    oNewOrder.aCurrency = oBackOrder.aCurrency;
                    oNewOrder.TransType = oBackOrder.TransType;
                    oNewOrder.LeaveWord = oBackOrder.LeaveWord;
                    oNewOrder.PostComment = oBackOrder.PostComment;
                    oNewOrder.PayNote = oBackOrder.PayNote;

                    oNewOrder.Consignee = oBackOrder.Consignee;
                    oNewOrder.aLocation = oBackOrder.aLocation;
                    var bestWhID = dbEntity.Database.SqlQuery<Guid>("SELECT dbo.fn_FindBestWarehouse({0}, {1}, {2})", oNewOrder.OrgID, oNewOrder.ChlID, oNewOrder.aLocation).FirstOrDefault();
                    if (bestWhID != null)
                    {
                        oNewOrder.WhID = (Guid)bestWhID;
                    }
                    oNewOrder.FullAddress = oBackOrder.FullAddress;
                    oNewOrder.PostCode = oBackOrder.PostCode;
                    oNewOrder.Telephone = oBackOrder.Telephone;
                    oNewOrder.Mobile = oBackOrder.Mobile;
                    oNewOrder.Email = oBackOrder.Email;
                    oNewOrder.BestDelivery = oBackOrder.BestDelivery;
                    oNewOrder.BuildingSign = oBackOrder.BuildingSign;
                    EditShippingListShow();//更新承运商列表信息
                    bOrderBaseInfoEdit = false;
                }
                else if (bOrderBaseInfoEdit == false && bOrderItemInfoEdit == true && bOrderFeeInfoEdit == false)
                {
                    //保存商品信息进入全局变量
                    //oNewOrder.OrderItems.Clear();
                    List<OrderItem> newList = new List<OrderItem>();
                    foreach (OrderItem item in listNewOrderItem)
                    {
                        OrderItem newObj = new OrderItem();
                        newObj.OrderID = item.OrderID;
                        newObj.OnSkuID = item.OnSkuID;
                        newObj.SkuID = item.SkuID;
                        newObj.Name = item.Name;
                        newObj.Quantity = item.Quantity;
                        newObj.TobeShip = item.TobeShip;
                        newObj.Shipped = item.Shipped;
                        newObj.BeReturn = item.BeReturn;
                        newObj.Returned = item.Returned;
                        newObj.MarketPrice = item.MarketPrice;
                        newObj.SalePrice = item.SalePrice;
                        newObj.ExecutePrice = item.ExecutePrice;
                        newObj.SkuPoint = item.SkuPoint;
                        newObj.Remark = item.Remark;
                        //oNewOrder.OrderItems.Add(item);
                        newList.Add(newObj);
                    }
                    oNewOrder.OrderItems = newList;
                    setAmount();
                    EditShippingListShow();//更新承运商列表信息
                    bOrderItemInfoEdit = false;
                }
                else if (bOrderBaseInfoEdit == false && bOrderItemInfoEdit == false && bOrderFeeInfoEdit == true)
                {
                    //保存费用信息进入全局变量
                    oNewOrder.ShippingFee = oBackOrder.ShippingFee;
                    oNewOrder.TaxFee = oBackOrder.TaxFee;
                    oNewOrder.Insurance = oBackOrder.Insurance;
                    oNewOrder.PaymentFee = oBackOrder.PaymentFee;
                    oNewOrder.PackingFee = oBackOrder.PackingFee;
                    oNewOrder.ResidenceFee = oBackOrder.ResidenceFee;
                    oNewOrder.LiftGateFee = oBackOrder.LiftGateFee;
                    oNewOrder.InstallFee = oBackOrder.InstallFee;
                    oNewOrder.OtherFee = oBackOrder.OtherFee;
                    bOrderFeeInfoEdit = false;
                }

                if(bSaveEditOrderInfo == true)
                {
                    Guid currentEditOrderGid = oNewOrder.Gid;
                    OrderInformation oCurrentEditOrder = dbEntity.OrderInformations.Where(p => p.Gid == currentEditOrderGid && p.Deleted == false).FirstOrDefault();
                    //订单基本信息保存
                    oCurrentEditOrder.DocVersion = oCurrentEditOrder.DocVersion + 1;
                    oCurrentEditOrder.LinkCode = oNewOrder.LinkCode;
                    oCurrentEditOrder.PayID = oNewOrder.PayID;
                    oCurrentEditOrder.WhID = oNewOrder.WhID;
                    oCurrentEditOrder.aCurrency = oNewOrder.aCurrency;
                    oCurrentEditOrder.TransType = oNewOrder.TransType;
                    oCurrentEditOrder.LeaveWord = oNewOrder.LeaveWord;
                    oCurrentEditOrder.PostComment = oNewOrder.PostComment;
                    oCurrentEditOrder.PayNote = oNewOrder.PayNote;

                    oCurrentEditOrder.Consignee = oNewOrder.Consignee;
                    oCurrentEditOrder.aLocation = oNewOrder.aLocation;
                    oCurrentEditOrder.FullAddress = oNewOrder.FullAddress;
                    oCurrentEditOrder.PostCode = oNewOrder.PostCode;
                    oCurrentEditOrder.Telephone = oNewOrder.Telephone;
                    oCurrentEditOrder.Mobile = oNewOrder.Mobile;
                    oCurrentEditOrder.Email = oNewOrder.Email;
                    oCurrentEditOrder.BestDelivery = oNewOrder.BestDelivery;
                    oCurrentEditOrder.BuildingSign = oNewOrder.BuildingSign;

                    //保存商品信息
                    //保存订单的产品
                    decimal Pieces = 0;//商品件数
                    List<OrderItem> hasBeforeOrderItems = dbEntity.OrderInformations.Find(oNewOrder.Gid).OrderItems.ToList();
                    foreach (OrderItem oldOrderItem in hasBeforeOrderItems)
                    {
                        oldOrderItem.Deleted = true;
                    }
                    foreach (OrderItem newOrderItem in listNewOrderItem)
                    {
                        Pieces += Math.Round(newOrderItem.Quantity,newOrderItem.SkuItem.Percision);//简单相加商品件数
                        newOrderItem.OrderID = oNewOrder.Gid;
                        OrderItem obj = hasBeforeOrderItems.Where(o => o.OrderID == newOrderItem.OrderID && o.OnSkuID == newOrderItem.OnSkuID).FirstOrDefault();
                        if (obj != null)//本身有该索引对应的记录
                        {
                            obj.Quantity = newOrderItem.Quantity;
                            obj.ExecutePrice = newOrderItem.ExecutePrice;
                            obj.TobeShip = newOrderItem.TobeShip;
                            obj.Deleted = false;
                        }
                        else
                        {
                            OrderItem newObj = new OrderItem();
                            newObj.OrderID = newOrderItem.OrderID;
                            newObj.OnSkuID = newOrderItem.OnSkuID;
                            newObj.SkuID = newOrderItem.SkuID;
                            newObj.Name = newOrderItem.Name;
                            newObj.Quantity = newOrderItem.Quantity;
                            newObj.TobeShip = newOrderItem.TobeShip;
                            newObj.Shipped = newOrderItem.Shipped;
                            newObj.BeReturn = newOrderItem.BeReturn;
                            newObj.Returned = newOrderItem.Returned;
                            newObj.MarketPrice = newOrderItem.MarketPrice;
                            newObj.SalePrice = newOrderItem.SalePrice;
                            newObj.ExecutePrice = newOrderItem.ExecutePrice;
                            newObj.SkuPoint = newOrderItem.SkuPoint;
                            newObj.Remark = newOrderItem.Remark;
                            dbEntity.OrderItems.Add(newObj);
                        }
                        oCurrentEditOrder.Pieces = Pieces;//商品件数赋值
                    }
                    //dbEntity.SaveChanges();
                    //保存承运商信息
                    List<OrderShipping> hasBeforeOrderShippings = dbEntity.OrderShippings.Where(o => o.OrderID == oNewOrder.Gid).ToList();//获取原数据库的所有该订单下对应的OrderShipping
                    foreach (OrderShipping oldOrderShip in hasBeforeOrderShippings)
                    {
                        oldOrderShip.Deleted = true;//全部变成删除
                        oldOrderShip.Candidate = false;
                    }
                    foreach (OrderShipping newOrderShip in listNewOrderShipping)
                    {
                        newOrderShip.OrderID = oNewOrder.Gid;
                        OrderShipping obj = hasBeforeOrderShippings.Where(o => o.OrderID == newOrderShip.OrderID && o.ShipID == newOrderShip.ShipID).FirstOrDefault();
                        if (obj==null)
                        {
                            if (newOrderShip.ShipID == oNewShipper.Gid)
                                newOrderShip.Candidate = true;
                            OrderShipping newObj = new OrderShipping();
                            newObj.OrderID = newOrderShip.OrderID;
                            newObj.ShipID = newOrderShip.ShipID;
                            newObj.Ostatus = newOrderShip.Ostatus;
                            newObj.ShipWeight = newOrderShip.ShipWeight;
                            newObj.Candidate = newOrderShip.Candidate;
                            newObj.Remark = newOrderShip.Remark;
                            dbEntity.OrderShippings.Add(newObj);
                        }
                        else
                        {//若OrderShipping已经有该索引的记录
                            if (obj.ShipID == oNewShipper.Gid)
                                obj.Candidate = true;
                            obj.Deleted = false;//变成可用状态
                        }
                    }
                    //dbEntity.SaveChanges();

                    //保存价格信息
                    oCurrentEditOrder.SaleAmount = oNewOrder.SaleAmount;
                    oCurrentEditOrder.ExecuteAmount = oNewOrder.ExecuteAmount;
                    oCurrentEditOrder.ShippingFee = oNewOrder.ShippingFee;
                    oCurrentEditOrder.TaxFee = oNewOrder.TaxFee;
                    oCurrentEditOrder.Insurance = oNewOrder.Insurance;
                    oCurrentEditOrder.PaymentFee = oNewOrder.PaymentFee;
                    oCurrentEditOrder.PackingFee = oNewOrder.PackingFee;
                    oCurrentEditOrder.ResidenceFee = oNewOrder.ResidenceFee;
                    oCurrentEditOrder.LiftGateFee = oNewOrder.LiftGateFee;
                    oCurrentEditOrder.InstallFee = oNewOrder.InstallFee;
                    oCurrentEditOrder.OtherFee = oNewOrder.OtherFee;

                    //保存全局的信息
                    dbEntity.SaveChanges();

                    bOrderBaseInfoEdit = false;
                    bOrderItemInfoEdit = false;
                    bOrderFeeInfoEdit = false;
                    bChangeOrder = false;
                    bSaveEditOrderInfo = false;
                }

            }

            return null;
        }
Пример #5
0
        /// <summary>
        /// 编辑订单时列出支持的承运商
        /// </summary>
        /// <returns></returns>
        public void EditShippingListShow()
        {
            OrderBLL oOrderBLL = new OrderBLL(this.dbEntity);//新建oOrderBLL对象
            oNewShipper = dbEntity.ShippingInformations.Find(oNewShipper.Gid);
            List<ShippingInformation> oShippingList = new List<ShippingInformation>();
            List<SelectListItem> shippinglist = new List<SelectListItem>();
            if (oNewOrder.WhID != null && oNewOrder.aLocation != null && listNewOrderItem.Count >= 1)
            {
                //-----------edit by 2011/10/24 需求:手动编辑订单是可以选择所有组织支持的承运商
                //获取支持的承运商列表
                //oShippingList = oOrderBLL.GetSupportShippings(listNewOrderItem, (Guid)oNewOrder.WhID, (Guid)oNewOrder.aLocation);
                //获取组织支持的所有承运商
                oShippingList = dbEntity.ShippingInformations.Where(s => s.aParent == oNewOrder.OrgID && s.Deleted == false).ToList();
                //------------------------------------------------------------------------------

                listNewOrderShipping.Clear();//每次都清除之前的承运商列表,以保证该列表永远是最新的-----BUG修改09.25
                if (oShippingList.Count >= 1)//如果查出承运商
                {
                    for (int i = 0; i < oShippingList.Count; i++)
                    {
                        OrderShipping oNewOrderShipping = new OrderShipping
                        {
                            ShipID = oShippingList.ElementAt(i).Gid,
                            Order = oNewOrder
                        };
                        listNewOrderShipping.Add(oNewOrderShipping);
                    }
                    if (oNewShipper == null)//如果之前没有承运商的
                    {
                        oNewShipper = oShippingList.ElementAt(0);
                    }
                    foreach (var reg in oOrderBLL.GetFullRegions((Guid)oNewOrder.aLocation))
                    {
                        if (oNewShipper.Areas != null)//地区不为空
                        {
                            foreach (var area in oNewShipper.Areas)
                            {
                                if (area.RegionID == reg.Gid)
                                {
                                    oNewOrder.ResidenceFee = area.Residential == null ? 0 : area.Residential.GetResource((Guid)oNewOrder.aCurrency);//收取的到门费
                                    oNewOrder.LiftGateFee = area.LiftGate == null ? 0 : area.LiftGate.GetResource((Guid)oNewOrder.aCurrency);//收取的上楼费
                                    oNewOrder.InstallFee = area.Installation == null ? 0 : area.Installation.GetResource((Guid)oNewOrder.aCurrency);//收取的安装费
                                }
                            }
                        }
                    }
                }
                else//未找到符合的承运商
                {
                    oNewShipper = new ShippingInformation();
                }
            }
            else//错误:仓库ID 地区ID 不能为空 且 订单商品列表不为空
            {

            }
        }
Пример #6
0
        /// <summary>
        /// 用户确认订单
        /// </summary>
        /// <param name="formCollection"></param>
        /// <returns></returns>
        public string SaveNewOrder(FormCollection formCollection)
        {
            string strReturnInfo = "success";

            //检查收货人信息是否存在
            if (oNewOrder.aLocation == null || oNewOrder.aLocation.Equals(Guid.Empty))
            {
                strReturnInfo = "请选择收货人信息!";
                return strReturnInfo;
            }

            //检查承运商信息是否存在
            if (globalShipperGid == null || globalShipperGid.Equals(Guid.Empty))
            {
                strReturnInfo = "请选择承运商!";
                return strReturnInfo;
            }

            #region 提交订单的信息

            OrderInformation oConfirmOrder = new OrderInformation();
            //订单基本信息
            oConfirmOrder.OrgID = oNewOrder.OrgID;
            oConfirmOrder.ChlID = oNewOrder.ChlID;
            //计算出最佳仓库
            var bestWhID = dbEntity.Database.SqlQuery<Guid>("SELECT dbo.fn_FindBestWarehouse({0}, {1}, {2})", oNewOrder.OrgID, oNewOrder.ChlID, oNewOrder.aLocation).FirstOrDefault();
            oConfirmOrder.WhID = bestWhID;
            oConfirmOrder.UserID = oNewOrder.UserID;
            oConfirmOrder.DocVersion = 0;
            oConfirmOrder.aCurrency = globalCurrencyGid;
            //交易类型
            oConfirmOrder.TransType = byte.Parse(formCollection["TransType"]);
            //当前订单是货到付款,则不需要检查支付方式;否则检查用户是否选择支付方式
            if (oConfirmOrder.TransType != (byte)ModelEnum.TransType.COD)
            {
                if (oNewOrder.PayID == null)
                {
                    strReturnInfo = "请选择支付方式!";
                    return strReturnInfo;
                }
                else
                {
                    oConfirmOrder.PayID = oNewOrder.PayID;
                }
            }
            oConfirmOrder.Pieces = globalOrderItemPieces;
            //计算商品销售总价
            decimal salePriceSum = 0m;
            for (int i = 0; i < globalOrderItemList.Count; i++)
            {
                salePriceSum = salePriceSum + globalOrderItemList.ElementAt(i).Value.SalePrice * globalOrderItemList.ElementAt(i).Value.Quantity;
            }

            #region 订单价格信息

            oConfirmOrder.SaleAmount = salePriceSum;
            //设定订单执行价的总和
            oConfirmOrder.ExecuteAmount = globalProductExacuteAmount;
            oConfirmOrder.ShippingFee = oNewOrder.ShippingFee;
            oConfirmOrder.TaxFee = oNewOrder.TaxFee;
            oConfirmOrder.Insurance = oNewOrder.Insurance;
            oConfirmOrder.PaymentFee = oNewOrder.PaymentFee;
            oConfirmOrder.PackingFee = oNewOrder.PackingFee;
            oConfirmOrder.ResidenceFee = oNewOrder.ResidenceFee;
            oConfirmOrder.LiftGateFee = oNewOrder.LiftGateFee;
            oConfirmOrder.InstallFee = oNewOrder.InstallFee;
            oConfirmOrder.OtherFee = oNewOrder.OtherFee;
            oConfirmOrder.TotalFee = oNewOrder.TotalFee;
            oConfirmOrder.UsePoint = oNewOrder.UsePoint;
            oConfirmOrder.PointPay = oNewOrder.PointPay;
            oConfirmOrder.CouponPay = oNewOrder.CouponPay;
            oConfirmOrder.BounsPay = oNewOrder.BounsPay;
            oConfirmOrder.MoneyPaid = oNewOrder.MoneyPaid;
            oConfirmOrder.Discount = oNewOrder.Discount;
            oConfirmOrder.TotalPaid = oNewOrder.TotalPaid;
            oConfirmOrder.OrderAmount = oNewOrder.OrderAmount;
            oConfirmOrder.Differ = oNewOrder.Differ;

            #endregion

            #region 收货人基本信息

            oConfirmOrder.Consignee = oNewOrder.Consignee;
            oConfirmOrder.aLocation = oNewOrder.aLocation;
            oConfirmOrder.FullAddress = oNewOrder.FullAddress;
            oConfirmOrder.PostCode = oNewOrder.PostCode;
            oConfirmOrder.Telephone = oNewOrder.Telephone;
            oConfirmOrder.Mobile = oNewOrder.Mobile;
            oConfirmOrder.Email = oNewOrder.Email;
            oConfirmOrder.BestDelivery = formCollection["OrderBestDelivery"];
            oConfirmOrder.PostComment = formCollection["OrderPosComment"];

            dbEntity.OrderInformations.Add(oConfirmOrder);
            dbEntity.SaveChanges();

            #endregion

            #endregion

            #region 保存订单商品信息
            //将全局订单商品的列表保存入数据库
            for (int i = 0; i < globalOrderItemList.Count; i++)
            {
                OrderItem oNewOrderItem = new OrderItem();
                oNewOrderItem.OrderID = oConfirmOrder.Gid;
                oNewOrderItem.OnSkuID = globalOrderItemList.ElementAt(i).Value.OnSkuID;
                oNewOrderItem.SkuID = globalOrderItemList.ElementAt(i).Value.SkuID;
                oNewOrderItem.Name = globalOrderItemList.ElementAt(i).Value.Name;
                oNewOrderItem.Quantity = globalOrderItemList.ElementAt(i).Value.Quantity;
                oNewOrderItem.MarketPrice = globalOrderItemList.ElementAt(i).Value.MarketPrice;
                oNewOrderItem.SalePrice = globalOrderItemList.ElementAt(i).Value.SalePrice;
                oNewOrderItem.ExecutePrice = globalOrderItemList.ElementAt(i).Value.ExecutePrice;
                dbEntity.OrderItems.Add(oNewOrderItem);
                //删除购物车
                Guid mallCartGid = globalOrderItemList.ElementAt(i).Key;
                MallCart oCurrrentMallCart = dbEntity.MallCarts.Where(p => p.Gid == mallCartGid && p.Deleted == false).FirstOrDefault();
                if (oCurrrentMallCart != null)
                {
                    oCurrrentMallCart.Deleted = true;
                }
                dbEntity.SaveChanges();
            }

            #endregion

            #region 保存订单承运商信息
            //如果使用承运商,则保存最佳承运商信息
            if (bUseShipper == true)
            {
                OrderShipping oNewOrderShipping = new OrderShipping();
                oNewOrderShipping.OrderID = oConfirmOrder.Gid;
                oNewOrderShipping.ShipID = globalShipperGid;
                dbEntity.OrderShippings.Add(oNewOrderShipping);
                dbEntity.SaveChanges();
            }

            #endregion

            #region 订单的属性

            #endregion

            #region 发票信息
            //有订单发票信息
            if (bInvoiceOrNot == true)
            {
                FinanceInvoice oNewFinanceInvoice = new FinanceInvoice();
                Guid optionItemGid = Guid.Parse(formCollection["InvoiceItem"]);
                GeneralOptItem oInvoiceItem = dbEntity.GeneralOptItems.Include("Name").Where(p => p.Gid == optionItemGid && p.Deleted == false).FirstOrDefault();
                if (oInvoiceItem != null)
                {
                    oNewFinanceInvoice.Matter = oInvoiceItem.Name.GetResource(LiveSession.Culture);
                }
                oNewFinanceInvoice.Title = formCollection["orderInvoice"];
                oNewFinanceInvoice.Amount = oConfirmOrder.OrderAmount;
                dbEntity.FinanceInvoices.Add(oNewFinanceInvoice);
                dbEntity.SaveChanges();
            }

            #endregion

            #region 将使用的券信息写入用户记录

            for (int i = 0; i < globalCouponList.Count; i++)
            {
                Guid pointGid = globalCouponList.ElementAt(i).Key;
                MemberPoint oMemberPoint = dbEntity.MemberPoints.Include("User").Include("Promotion").Include("Coupon").Where(p=>p.Gid == pointGid && p.Deleted==false).FirstOrDefault();
                if (oMemberPoint != null)
                {
                    decimal couponBalance = globalCouponList.ElementAt(i).Value;
                    MemberUsePoint oNewMemberUsePoint = new MemberUsePoint();
                    oNewMemberUsePoint.PointID = pointGid;
                    oNewMemberUsePoint.Pstatus = (byte)ModelEnum.PointUsed.USED;
                    oNewMemberUsePoint.RefType = (byte)ModelEnum.NoteType.ORDER;
                    oNewMemberUsePoint.RefID = oConfirmOrder.Gid;
                    //将原有的金额减去余额即为消费金额
                    oNewMemberUsePoint.Amount = oMemberPoint.Balance - couponBalance;
                    dbEntity.MemberUsePoints.Add(oNewMemberUsePoint);
                    //将积分表的余额变为当前余额
                    oMemberPoint.Balance = couponBalance;
                    //将状态变为已使用
                    oMemberPoint.Pstatus = (byte)ModelEnum.PointStatus.USED;
                    //当余额为0时,是否改变状态
                    //To do 不改变券的状态
                    dbEntity.SaveChanges();
                }
            }

            #endregion

            return strReturnInfo;
        }
Пример #7
0
 public ActionResult ConfirmDelivery(string data, Guid outID)
 {
     if (!base.CheckPrivilege("EnableApprove"))//是否允许确认(扫描/发货)
         RedirectToAction("ErrorPage", "Home", new { message = "Sorry you have no privilege to visit the Page" });
     WarehouseStockOut stockOut = dbEntity.WarehouseStockOuts.Find(outID);
     if (stockOut == null || stockOut.Deleted)
     {
         return Error("记录不存在", Url.Action("StockOut"));
     }
     else if (stockOut.Ostatus != (byte)ModelEnum.StockOutStatus.NONE)
     {
         return Error("已确认,不能再次确认", Url.Action("StockOut"));
     }
     JavaScriptSerializer jss = new JavaScriptSerializer();
     IEnumerable<WarehouseOutDelivery> models = jss.Deserialize<IEnumerable<WarehouseOutDelivery>>(data);
     foreach (WarehouseOutDelivery model in models)
     {
         WarehouseOutDelivery delivery = new WarehouseOutDelivery
         {
             OutID = outID,
             Envelope = model.Envelope,
             PackWeight = model.PackWeight,
             ShipID = model.ShipID
         };
         dbEntity.WarehouseOutDeliveries.Add(delivery);
     }
     Guid shipper = models.ElementAt(0).ShipID;//最终承运商
     #region 修改出库单的最终信息
     stockOut.ShipID = models.ElementAt(0).ShipID;//设置出库单的最终承运商
     stockOut.Ostatus = (byte)ModelEnum.StockOutStatus.DELIVERIED;//设置出库单的状态
     stockOut.SendMan = CurrentSession.UserID;
     #endregion 修改出库单的最终信息
     #region 设置订单的最终承运商
     OrderShipping os = (from i in dbEntity.OrderShippings
                         where i.OrderID == stockOut.RefID
                            && i.ShipID == shipper
                            && i.Deleted == false
                         select i).FirstOrDefault();
     //如果订单对应的运输信还没有,新建
     if (os == null)
     {
         os = new OrderShipping
         {
             ShipID = shipper,
             OrderID = stockOut.RefID.Value,
             Candidate = true
         };
         dbEntity.OrderShippings.Add(os);
     }
     else
     {
         os.Candidate = true;
     }
     #endregion 设置订单的最终承运商
     #region 修改订单最终信息
     OrderInformation order = dbEntity.OrderInformations.Find(stockOut.RefID);
     order.Ostatus = (byte)ModelEnum.OrderStatus.DELIVERIED;
     //若是淘宝订单,需要另外做的修改
     if (order.Channel.ExtendType.Ctype == (byte)ModelEnum.StandardCategoryType.CHANNEL && order.Channel.Code == "Taobao")
     {
         ExTaobaoDeliveryPending TDelivery = (from t in dbEntity.ExTaobaoDeliveryPendings
                                             where t.OrderID == stockOut.RefID
                                                && !t.Deleted
                                             select t).SingleOrDefault();
         if (TDelivery != null)
         {
             TDelivery.ShipID = shipper;
             TDelivery.tid = order.LinkCode;
             TDelivery.out_sid = stockOut.Shipper.Code;
         }
         else
         {
             TDelivery = new ExTaobaoDeliveryPending
             {
                 OrderID = order.Gid,
                 ShipID = shipper,
                 tid = order.LinkCode,
                 out_sid = stockOut.Shipper.Code
             };
             dbEntity.ExTaobaoDeliveryPendings.Add(TDelivery);
         }
     }
     #endregion 修改订单最终信息
     dbEntity.SaveChanges();
     return RedirectToAction("StockOut");
 }