private void BindSaleFiliales() { List <FilialeInfo> dataSource = new List <FilialeInfo> { new FilialeInfo { ID = Guid.Empty, Name = "" } }; dataSource.AddRange(FilialeManager.GetB2CFilialeList()); DdlSaleFiliale.DataSource = dataSource; DdlSaleFiliale.DataBind(); DdlSaleFiliale.SelectedValue = string.Format("{0}", Guid.Empty); }
public void TestGetB2CFilialeList() { using (ShimsContext.Create()) { //模拟返回结果 ShimFilialeSao.GetAllFiliale = () => new List <FilialeInfo> { new FilialeInfo { ID = new Guid("6E677868-AE98-4932-B4DB-0000020DC859"), Type = (int)FilialeType.EntityShop, IsActive = false }, new FilialeInfo { ID = new Guid("7E677868-AE98-4932-B4DB-0000020DC859"), Type = (int)FilialeType.SaleCompany, IsActive = false }, new FilialeInfo { ID = new Guid("8E677868-AE98-4932-B4DB-0000020DC859"), Type = (int)FilialeType.EntityShop, IsActive = true } }; var result = FilialeManager.GetB2CFilialeList(); Assert.IsNotNull(result); } }
/// <summary>订单导入 /// </summary> public bool AddOrderAndInvoice(GoodsOrderInfo goodsOrder, IList <GoodsOrderDetailInfo> goodsOrderDetailList, InvoiceInfo invoiceInfo, out string errorMessage) { errorMessage = string.Empty; if (goodsOrderDetailList.Count == 0) { errorMessage = "订单明细没有数据!"; return(false); } Boolean isEdit = false; #region 验证B2C订单信息 (订单目前是走推送服务) var filialeList = FilialeManager.GetB2CFilialeList(); if (filialeList.Any(act => act.ID == goodsOrder.SaleFilialeId)) { try { var info = OrderSao.GetGoodsOrderInfo(goodsOrder.SaleFilialeId, goodsOrder.OrderId); if (info == null) { errorMessage = "获取B2C订单信息不存在"; return(false); } if (info.OrderState == (int)OrderState.Cancellation) { return(true); } } catch (Exception ex) { errorMessage = "获取B2C订单信息异常" + ex.Message; throw ex; } } #endregion var localGoodsOrderInfo = _goodsOrderDao.GetGoodsOrder(goodsOrder.OrderId); goodsOrder.HostingFilialeId = WMSSao.GetHostingFilialeIdByWarehouseIdGoodsTypes(goodsOrder.DeliverWarehouseId, goodsOrder.SaleFilialeId, goodsOrderDetailList.Select(ent => ent.GoodsType).Distinct()); IList <GoodsOrderDetailInfo> localGoodsOrderDetails = new List <GoodsOrderDetailInfo>(); if (localGoodsOrderInfo != null && localGoodsOrderInfo.OrderId != Guid.Empty) { isEdit = true; if (localGoodsOrderInfo.OrderState == (int)OrderState.Cancellation) { return(true); } localGoodsOrderDetails = _goodsOrderDetailDao.GetGoodsOrderDetailList(goodsOrder.OrderId); } using (var ts = new TransactionScope(TransactionScopeOption.Required)) { //1.订单导入,先删后插 if (isEdit) { var success = _goodsOrderDao.Delete(goodsOrder.OrderId); if (!success) { errorMessage = "删除订单失败"; return(false); } } //2.插入订单和订单明细 var insertSuccess = _goodsOrderDao.Insert(goodsOrder, out errorMessage); if (!insertSuccess) { errorMessage = string.Format("添加订单信息失败:{0}", errorMessage); return(false); } var insertDetailSuccess = _goodsOrderDetailDao.Insert(goodsOrderDetailList, goodsOrder, out errorMessage); if (!insertDetailSuccess) { errorMessage = string.Format("添加订单商品明细失败:{0}", errorMessage); return(false); } //3.记录销量 //异步销量 if (goodsOrder.OrderState == (int)OrderState.WaitOutbound || goodsOrder.OrderState == (int)OrderState.StockUp || goodsOrder.OrderState == (int)OrderState.RequirePurchase || goodsOrder.OrderState == (int)OrderState.Redeploy) { var orderJsonStr = new Framework.Core.Serialize.JsonSerializer().Serialize(goodsOrder); var orderDetailJsonStr = new Framework.Core.Serialize.JsonSerializer().Serialize(goodsOrderDetailList); var asynGoodsDaySalesStatisticsInfo = isEdit ? ASYN_GoodsDaySalesStatisticsInfo.EditGoodsDaySale(goodsOrder.OrderNo, orderJsonStr, orderDetailJsonStr, new Framework.Core.Serialize.JsonSerializer().Serialize(localGoodsOrderDetails)) : ASYN_GoodsDaySalesStatisticsInfo.AddGoodsDaySale(goodsOrder.OrderNo, orderJsonStr, orderDetailJsonStr); var asynResult = _goodsOrderDetailDao.InsertASYN_GoodsDaySalesStatisticsInfo(asynGoodsDaySalesStatisticsInfo); if (!asynResult) { errorMessage = "销量记录到异步失败!"; return(false); } } //4.发票插入 if (invoiceInfo != null && invoiceInfo.InvoiceId != Guid.Empty) { invoiceInfo.DeliverWarehouseId = goodsOrder.DeliverWarehouseId; var insertInvoiceSuccess = _invoiceDao.Insert(invoiceInfo, new Dictionary <Guid, string> { { goodsOrder.OrderId, goodsOrder.OrderNo } }); if (!insertInvoiceSuccess) { errorMessage = "插入发票失败"; return(false); } } //5.配货中,会员中心交互 MemberCenterSao.OrderAllocateGoods(goodsOrder.SalePlatformId, goodsOrder.OrderId); //提交事务 ts.Complete(); return(true); } }