public void SaveOrder(Sale.ShoppingCart shoppingCart, string apiCodes, DateTime saveTime) { var dataAdapter = DataAdapterFactory.DbFactory(MachinesSettings.Mode, StoreId, MachineSN, CompanyId, DeviceSn); dataAdapter.SaveOrder(shoppingCart, apiCodes, saveTime); var saleOrders = shoppingCart.GetSaleStatistics();//销售清单 //var orderEvent = new OrderCompletedEvent() //{ // CompanyId = CompanyId, // MachineSn = MachineSN, // StoreId = StoreId, // OrderAmount = saleOrders.Receivable, // OrderProductCount = saleOrders.Num, // OrderSn = shoppingCart.OrderSN, // OrderReceiveAmount = shoppingCart.WipeZeroAfter, // OrderDetails = shoppingCart.GetOrdeList().Select(o => // new OrderDetail() // { // AveragePrice = o.AveragePrice, // ActualPrice = o.MarketingPrice, // Barcode = o.MainBarcode, // PurchaseNumber = o.SaleNumber, // BuyPrice = o.Details.BuyPrice, // ProductCode = o.ProductCode, // SalesClassifyId = (int)o.Details.SaleStatus, // ScanBarcode = o.CurrentString, // SysPrice = o.Details.SystemPrice, // Title = o.Details.Title, // Total = o.Details.Total, // Category = o.Details.Category, // Size = o.Details.Size // }) //}; //DataAdapterFactory._EventAggregator.Publish<OrderCompletedEvent>(orderEvent); }
public void SaveOrder(Sale.ShoppingCart shoppingCart, string apiCodes, DateTime saveTime) { try { //SaleOrders SaleDetail SaleDetailsTotal var saleOrders = shoppingCart.GetSaleStatistics();//销售清单 SaleOrders _saleOrder = new SaleOrders() { StoreId = shoppingCart.MachineInformation.StoreId, //门店id MachineSN = shoppingCart.MachineInformation.MachineSn, //pos机号 PaySN = shoppingCart.OrderSN, //订单流水号 CustomOrderSn = shoppingCart.CustomOrderSN, //订单流水号 TotalAmount = saleOrders.Receivable, //优惠后金额 PreferentialPrice = saleOrders.Preferential, //优惠金额 ApiCode = apiCodes, //支付方式 TODO: CreateUID = shoppingCart.MachineInformation.CashierUid, //收银员工号 CreateDT = saveTime, CompanyId = CompanyId, ProductCount = saleOrders.Num, Type = 0, State = 0, MemberId = shoppingCart.MemberId, ActivityId = shoppingCart.ActivityId, Salesman = shoppingCart.SaleMan, Receive = shoppingCart.WipeZeroAfter, IsTest = IsSalesclerkTest, InInventory = 0, IsProcess = false, OrderDiscount = shoppingCart.OrderDiscount }; SaleOrdersService.CurrentRepository.Add(_saleOrder, false); var saleOrdersDetails = shoppingCart.GetOrdeList();//订单信息 foreach (var item in saleOrdersDetails) { SaleDetail _saleDetail = new SaleDetail() { PaySN = _saleOrder.PaySN, ProductCode = item.ProductCode, AveragePrice = item.AveragePrice,//均价 CompanyId = CompanyId, Total = item.Details.Total, Barcode = item.MainBarcode, //商品条码 PurchaseNumber = item.SaleNumber, //销售数量 BuyPrice = item.Details.BuyPrice, //系统进价 SysPrice = item.Details.SystemPrice, //系统售价 ActualPrice = item.MarketingPrice, //销售价 Title = item.Details.Title, ScanBarcode = item.CurrentString, SalesClassifyId = (int)item.Details.SaleStatus,//销售分类id }; SaleDetailService.CurrentRepository.Add(_saleDetail, false); } SaleOrdersService.CurrentRepository.Update(_saleOrder); var orderEvent = new OrderCompletedEvent() { MemberId = shoppingCart.MemberId, CompanyId = CompanyId, MachineSn = MachineSN, StoreId = StoreId, OrderAmount = saleOrders.Receivable, OrderProductCount = saleOrders.Num, SourceRecordId = shoppingCart.OrderSN, OrderReceiveAmount = shoppingCart.WipeZeroAfter, OperatorUid = shoppingCart.MachineInformation.CashierUid, OrderDetails = shoppingCart.GetOrdeList().Select(o => new OrderDetail() { AveragePrice = o.AveragePrice, ActualPrice = o.MarketingPrice, Barcode = o.MainBarcode, PurchaseNumber = o.SaleNumber, BuyPrice = o.Details.BuyPrice, ProductCode = o.ProductCode, SalesClassifyId = (int)o.Details.SaleStatus, ScanBarcode = o.CurrentString, SysPrice = o.Details.SystemPrice, Title = o.Details.Title, Total = o.Details.Total, Category = o.Details.Category, Size = o.Details.Size }) }; RedisManager.Publish <OrderCompletedEvent>("OrderCompleted", orderEvent); } catch (Exception ex) { throw; } }
public void SaveOrder(Sale.ShoppingCart shoppingCart, string apiCodes, DateTime saveTime) { try { //SaleOrders SaleDetail SaleDetailsTotal var saleOrders = shoppingCart.GetSaleStatistics();//销售清单 var version = new byte[8] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; SaleOrders _saleOrder = new SaleOrders() { StoreId = shoppingCart.MachineInformation.StoreId, //门店id MachineSN = shoppingCart.MachineInformation.MachineSn, //pos机号 PaySN = shoppingCart.OrderSN, //订单流水号 CustomOrderSn = shoppingCart.CustomOrderSN, //订单流水号 TotalAmount = saleOrders.Receivable, //优惠后金额 PreferentialPrice = saleOrders.Preferential, //优惠金额 ApiCode = apiCodes, //支付方式 TODO: CreateUID = shoppingCart.MachineInformation.CashierUid, //收银员工号 CreateDT = saveTime, CompanyId = CompanyId, ProductCount = saleOrders.Num, Type = 0, State = 0, MemberId = shoppingCart.MemberId, ActivityId = shoppingCart.ActivityId, Salesman = shoppingCart.SaleMan, Receive = shoppingCart.WipeZeroAfter, IsTest = IsSalesclerkTest, InInventory = 0, IsProcess = false, OrderDiscount = shoppingCart.OrderDiscount, SyncItemId = Guid.NewGuid(), SyncItemVersion = version }; SaleOrdersService.CurrentRepository.Add(_saleOrder, false); var saleOrdersDetails = shoppingCart.GetOrdeList();//订单信息 foreach (var item in saleOrdersDetails) { SaleDetail _saleDetail = new SaleDetail() { PaySN = _saleOrder.PaySN, ProductCode = item.ProductCode, AveragePrice = item.AveragePrice,//均价 CompanyId = CompanyId, Total = item.Details.Total, Barcode = item.MainBarcode, //商品条码 PurchaseNumber = item.SaleNumber, //销售数量 BuyPrice = item.Details.BuyPrice, //系统进价 SysPrice = item.Details.SystemPrice, //系统售价 ActualPrice = item.MarketingPrice, //销售价 Title = item.Details.Title, ScanBarcode = item.CurrentString, SalesClassifyId = (int)item.Details.SaleStatus,//销售分类id SyncItemId = Guid.NewGuid(), SyncItemVersion = version }; SaleDetailService.CurrentRepository.Add(_saleDetail, false); } SaleOrdersService.CurrentRepository.Update(_saleOrder); // RedisManager.Publish("SyncDatabase", "SalePackage"); StoreManager.PubEvent("SyncDatabase", "SalePackage"); } catch (Exception ex) { throw ex; } }