Example #1
0
 /// <summary>
 /// 取消订单加入历史订单
 /// </summary>
 /// <param name="order"></param>
 /// <returns></returns>
 public bool UpdateOrderHistory(OrderInformation order)
 {
     OrderHistory oNewOrderHistory = new OrderHistory
     {
         OrderID = order.Gid,
         DocVersion = order.DocVersion,
         Htype = 0,//?
         Reason = "退货",
         RefRefund = null,//?
         RefStockIn = null,//?
         WhID = order.WhID,
         LinkCode = order.LinkCode,
         Ostatus = order.Ostatus,
         Locking = order.Locking,
         PayStatus = order.PayStatus,
         Hanged = order.Hanged,
         HangReason = order.HangReason,
         ReleaseTime = order.ReleaseTime,
         TransType = order.TransType,
         PayID = order.PayID,
         PayNote = order.PayNote,
         Pieces = order.Pieces,
         Currency = order.aCurrency,
         SaleAmount = order.SaleAmount,
         ExecuteAmount = order.ExecuteAmount,
         ShippingFee = order.ShippingFee,
         TaxFee = order.TaxFee,
         Insurance = order.Insurance,
         PaymentFee = order.PaymentFee,
         PackingFee = order.PackingFee,
         ResidenceFee = order.ResidenceFee,
         LiftGateFee = order.LiftGateFee,
         InstallFee = order.InstallFee,
         OtherFee = order.OtherFee,
         TotalFee = order.TotalFee,
         UsePoint = order.UsePoint,
         PointPay = order.PointPay,
         CouponPay = order.CouponPay,
         BounsPay = order.BounsPay,
         MoneyPaid = order.MoneyPaid,
         TotalPaid = order.TotalPaid,
         OrderAmount = order.OrderAmount,
         Differ = order.Differ,
         MergeFrom = order.MergeFrom,
         SplitFrom = order.SplitFrom,
         GetPoint = order.GetPoint,
         ConfirmTime = order.ConfirmTime,
         PaidTime = order.PaidTime,
         ArrangeTime = order.ArrangeTime,
         NoticeTime = order.NoticeTime,
         ClosedTime = order.ClosedTime,
         Consignee = order.Consignee,
         Location = order.aLocation,
         FullAddress = order.FullAddress,
         PostCode = order.PostCode,
         Telephone = order.Telephone,
         Mobile = order.Mobile,
         Email = order.Email,
         ErrorAddress = order.ErrorAddress,
         BestDelivery = order.BestDelivery,
         BuildingSign = order.BuildingSign,
         PostComment = order.PostComment,
         LeaveWord = order.LeaveWord,
         IpAddress = order.IpAddress,
         AdvID = order.AdvID,
         Remark = order.Remark
     };
     dbEntity.OrderHistories.Add(oNewOrderHistory);
     dbEntity.SaveChanges();
     List<OrderItem> OrderItemList = dbEntity.OrderItems.Where(p => p.OrderID == oNewOrder.Gid && p.Deleted == false).ToList();
     foreach(OrderItem item in OrderItemList){
         item.Deleted = true;
         OrderHisItem oNewOrderHisItem = new OrderHisItem
         {
             OrderHisID = oNewOrderHistory.Gid,
             OnSkuID = item.OnSkuID,
             SkuID = item.SkuID,
             Name = item.Name,
             Quantity = item.Quantity,
             MarketPrice = item.MarketPrice,
             SalePrice = item.SalePrice,
             ExecutePrice = item.ExecutePrice,
             SkuPoint = item.SkuPoint,
             Remark = item.Remark
         };
         dbEntity.OrderHisItems.Add(oNewOrderHisItem);
         dbEntity.SaveChanges();
     }
     return true;
 }
Example #2
0
        /// <summary>
        /// 将订单保存入历史表,修改订单版本号
        /// </summary>
        /// <param name="oOldOrder"></param>
        /// <param name="nHangType"></param>
        /// <param name="strReason"></param>
        /// <returns></returns>
        public ActionResult SaveOldOrderVersion(byte nHangType, string strReason)
        {
            //将订单保存入历史表,改变订单的版本号
            OrderHistory oOrderHistory = new OrderHistory();
            OrderInformation oOldOrder = oNewOrder;
            oOrderHistory.OrderID = oOldOrder.Gid;
            oOrderHistory.DocVersion = oOldOrder.DocVersion;
            oOrderHistory.Htype = nHangType;
            oOrderHistory.Reason = strReason;
            //关联退款单,需要根据更改原因来设置,可以使用Guid?类型的参数传入函数
            oOrderHistory.RefRefund = null;
            //关联入库单,需要根据更改原因来设置,可以使用Guid?类型的参数传入函数
            oOrderHistory.RefStockIn = null;
            //仓库字段
            oOrderHistory.WhID = oOldOrder.WhID;

            oOrderHistory.LinkCode = oOldOrder.LinkCode;
            oOrderHistory.Ostatus = oOldOrder.Ostatus;
            oOrderHistory.Locking = oOldOrder.Locking;
            oOrderHistory.PayStatus = oOldOrder.PayStatus;
            oOrderHistory.Hanged = oOldOrder.Hanged;
            oOrderHistory.HangReason = oOldOrder.HangReason;
            oOrderHistory.ReleaseTime = oOldOrder.ReleaseTime;
            oOrderHistory.TransType = oOldOrder.TransType;
            if (!oOldOrder.PayID.Equals(null))
            {
                oOrderHistory.PayID = (Guid)oOldOrder.PayID;
            }
            oOrderHistory.PayNote = oOldOrder.PayNote;
            oOrderHistory.Pieces = oOldOrder.Pieces;
            if (!oOldOrder.aCurrency.Equals(null))
            {
                oOrderHistory.Currency = (Guid)oOldOrder.aCurrency;
            }
            oOrderHistory.SaleAmount = oOldOrder.SaleAmount;
            oOrderHistory.ExecuteAmount = oOldOrder.ExecuteAmount;
            oOrderHistory.ShippingFee = oOldOrder.ShippingFee;
            oOrderHistory.TaxFee = oOldOrder.TaxFee;
            oOrderHistory.Insurance = oOldOrder.Insurance;
            oOrderHistory.PaymentFee = oOldOrder.PaymentFee;
            oOrderHistory.PackingFee = oOldOrder.PackingFee;
            oOrderHistory.ResidenceFee = oOldOrder.ResidenceFee;
            oOrderHistory.LiftGateFee = oOldOrder.LiftGateFee;
            oOrderHistory.InstallFee = oOldOrder.InstallFee;
            oOrderHistory.OtherFee = oOldOrder.OtherFee;
            oOrderHistory.TotalFee = oOldOrder.TotalFee;
            oOrderHistory.UsePoint = oOldOrder.UsePoint;
            oOrderHistory.PointPay = oOldOrder.PointPay;
            oOrderHistory.CouponPay = oOldOrder.CouponPay;
            oOrderHistory.BounsPay = oOldOrder.BounsPay;
            oOrderHistory.MoneyPaid = oOldOrder.MoneyPaid;
            oOrderHistory.TotalPaid = oOldOrder.TotalPaid;
            oOrderHistory.OrderAmount = oOldOrder.OrderAmount;
            oOrderHistory.Differ = oOldOrder.Differ;
            oOrderHistory.MergeFrom = oOldOrder.MergeFrom;
            oOrderHistory.SplitFrom = oOldOrder.SplitFrom;
            oOrderHistory.GetPoint = oOldOrder.GetPoint;
            oOrderHistory.ConfirmTime = oOldOrder.ConfirmTime;
            oOrderHistory.PaidTime = oOldOrder.PaidTime;
            oOrderHistory.ArrangeTime = oOldOrder.ArrangeTime;
            oOrderHistory.NoticeTime = oOldOrder.NoticeTime;
            oOrderHistory.ClosedTime = oOldOrder.ClosedTime;
            oOrderHistory.Consignee = oOldOrder.Consignee;
            if (!oOldOrder.aLocation.Equals(null))
            {
                oOrderHistory.Location = (Guid)oOldOrder.aLocation;
            }
            oOrderHistory.FullAddress = oOldOrder.FullAddress;
            oOrderHistory.PostCode = oOldOrder.PostCode;
            oOrderHistory.Telephone = oOldOrder.Telephone;
            oOrderHistory.Mobile = oOldOrder.Mobile;
            oOrderHistory.Email = oOldOrder.Email;
            oOrderHistory.ErrorAddress = oOldOrder.ErrorAddress;
            oOrderHistory.BestDelivery = oOldOrder.BestDelivery;
            oOrderHistory.BuildingSign = oOldOrder.BuildingSign;
            oOrderHistory.PostComment = oOldOrder.PostComment;
            oOrderHistory.LeaveWord = oOldOrder.LeaveWord;
            oOrderHistory.IpAddress = oOldOrder.IpAddress;
            if (!oOldOrder.AdvID.Equals(null))
            {
                oOrderHistory.AdvID = (Guid)oOldOrder.AdvID;
            }
            oOrderHistory.Remark = oOldOrder.Remark;

            dbEntity.OrderHistories.Add(oOrderHistory);
            dbEntity.SaveChanges();
            //当前变更订单的guid
            Guid currentOrderGid = oOldOrder.Gid;
            //将订单对应的商品信息保存进历史表
            List<OrderItem> listOrderItemInCurrentOrder = dbEntity.OrderItems.Include("Order").Include("OnSkuItem").Include("SkuItem").Where(p => p.Gid == currentOrderGid && p.Deleted == false).ToList();
            for (int i = 0; i < listOrderItemInCurrentOrder.Count; i++)
            {
                OrderHisItem oNewHisOrderItem = new OrderHisItem();
                oNewHisOrderItem.OrderHisID = oOrderHistory.Gid;
                oNewHisOrderItem.OnSkuID = listOrderItemInCurrentOrder.ElementAt(i).OnSkuID;
                oNewHisOrderItem.SkuID = listOrderItemInCurrentOrder.ElementAt(i).SkuID;
                oNewHisOrderItem.Name = listOrderItemInCurrentOrder.ElementAt(i).Name;
                oNewHisOrderItem.Quantity = listOrderItemInCurrentOrder.ElementAt(i).Quantity;
                oNewHisOrderItem.MarketPrice = listOrderItemInCurrentOrder.ElementAt(i).MarketPrice;
                oNewHisOrderItem.SalePrice = listOrderItemInCurrentOrder.ElementAt(i).SalePrice;
                oNewHisOrderItem.ExecutePrice = listOrderItemInCurrentOrder.ElementAt(i).ExecutePrice;
                oNewHisOrderItem.SkuPoint = listOrderItemInCurrentOrder.ElementAt(i).SkuPoint;
                oNewHisOrderItem.Remark = listOrderItemInCurrentOrder.ElementAt(i).Remark;

                dbEntity.OrderHisItems.Add(oNewHisOrderItem);
                dbEntity.SaveChanges();
            }

            bChangeOrder = true;
            return null;
        }