public void CreateSaleRefund(ShopCart cat) { SaleOrder order = new SaleOrder() { StoreId = cat.StoreId, PosId = cat.PosId, CreatedBy = cat.Editor, UpdatedBy = cat.Editor, OrderType = 2, RefundAccount = cat.RefundAccount, WorkScheduleCode = cat.WorkScheduleCode, OrderLevel = cat.OrderLevel }; order.GenerateNewCode(); foreach (ShopCartItem item in cat.Items) { order.AddOrderItem(item.Product, item.Quantity, item.RealPrice); } this._db.Orders.Add(order); this._db.SaveChanges(); //设置订单信息 cat.OrderId = order.Id; cat.OrderCode = order.Code; }