/// <summary> /// 根据主退货订单ID获取主退货订单及其所有子订单的实例 /// </summary> /// <param name="pOrderId">芒果商城主退货订单ID</param> /// <returns>CWmsReturnOrder实体,若失败则返回null</returns> static public CWmsReturnOrder GetCWmsReturnOrder(string pOrderId) { var ret = new ThirdResult <List <object> >(string.Format("根据主退货订单{0}获取主退货订单及其所有子订单的实例, 开始", pOrderId)); string errMsg = string.Empty; CWmsReturnOrder retObj = null; MangoReturnOrder mangoOrder = null; List <MangoSubReturnOrder> tmpList = new List <MangoSubReturnOrder>(1);; // 缓存子退货订单实体列表 #region validate parameters if (string.IsNullOrEmpty(pOrderId)) { ret.Append(string.Format("根据主退货订单{0}获取主退货订单及其所有子订单的实例失败, 非法入参", pOrderId)); ret.End(); return(retObj); } #endregion try { #region Handle MangoOrder #region 获取主退货订单 MangoReturnOrder if (null == (mangoOrder = MangoFactory.GetMangoOrder(TCWmsOrderCategory.EReturnOrder, pOrderId) as MangoReturnOrder)) { ret.Append(string.Format("根据主退货订单{0}获取主退货订单及其所有子订单的实例失败, 获取主退货订单失败", pOrderId)); ret.End(); return(retObj); } #endregion #region 获取子退货订单列表 List<MangoSubReturnOrder> errMsg = MangoFactory.GetVSubReturnOrders(pOrderId, out tmpList); ret.Append(string.Format("tmplist.count={0}", tmpList.Count)); ret.Append(string.Format("errMsg={0}", errMsg)); if (!string.IsNullOrEmpty(errMsg) || null == tmpList || 0 >= tmpList.Count) { ret.Append(string.Format("1根据主退货订单{0}获取主退货订单及其所有子订单的实例失败, 获取子退货订单失败, message={1}", pOrderId, errMsg)); ret.End(); return(retObj); } #endregion #endregion // Handle MangoOrder #region 创建CWmsReturnOrder实例及其子出库订单实例列表 retObj = new CWmsReturnOrder(); (retObj.MangoOrder as MangoReturnOrder).CopyFrom(mangoOrder); foreach (var t in tmpList) { CWmsSubReturnOrder tmpSo = new CWmsSubReturnOrder(); tmpSo.CopyFrom(t, null); // TODO: 根据子退货订单Id找原子订单Id, 移到Mis的Factory里面!! var wcfSo = WCF <Product_Warehouse_ProductOutput> .Query((tmpSo.MangoOrder as MangoSubReturnOrder).ProductIOputId.Int()).Data; // 根据原子订单Id取仓库Id, 根据仓库Id取货主 tmpSo.WmsOrderDetail.Owner.CopyFrom(MangoFactory.GetOwner(wcfSo.WarehouseId.ToString())); // 设置商品Id tmpSo.Product.ItemCode = (string.IsNullOrEmpty(t.ProductGuiGeID.ToString()) || "0".Equals(t.ProductGuiGeID.ToString())) ? t.ProductId.ToString() : string.Format("{0}-{1}", t.ProductId, t.ProductGuiGeID); retObj.SubOrders.Add(t.ZiTuihuoID.ToString(), tmpSo);// new CWmsSubReturnOrder(t, null)); } #region Handle WMS order switch ((T芒果商城退货物流)(retObj.MangoOrder as MangoReturnOrder).THwuLiu) { case T芒果商城退货物流.自行返还: { (retObj.WmsOrder as Wms.Data.WmsReturnOrder).SetOrderFlag(false, true, false); break; } case T芒果商城退货物流.蓝江上门: { (retObj.WmsOrder as Wms.Data.WmsReturnOrder).SetOrderFlag(true, false, false); break; } default: { (retObj.WmsOrder as Wms.Data.WmsReturnOrder).SetOrderFlag(false, false, false); break; } } #region TuiHuoType switch ((retObj.MangoOrder as MangoReturnOrder).TuiHuoType) { case 2: (retObj.MangoOrder as MangoReturnOrder).TuiHuoType = TWmsReturnOrderType.HHRK.Int(); break; case 3: (retObj.MangoOrder as MangoReturnOrder).TuiHuoType = TWmsReturnOrderType.HHRK.Int(); break; case 6: (retObj.MangoOrder as MangoReturnOrder).TuiHuoType = TWmsReturnOrderType.HHRK.Int(); break; default: { (retObj.MangoOrder as MangoReturnOrder).TuiHuoType = TWmsReturnOrderType.HHRK.Int(); break; } } #endregion #endregion // Handle WMS order #endregion // 创建CWmsReturnOrder实例及其子出库订单实例列表 } catch (Exception ex) { if (null != ex.InnerException) { ret.Append(string.Format("InnerException: {0}", ex.InnerException.Message)); } ret.Append(string.Format("发生异常: {0}\r\n调用堆栈:{1}", ex.Message, ex.StackTrace)); } ret.Append(string.Format("根据主退货订单{0}获取主退货订单及其所有子订单的实例失败, 获取子退货订单失败, message={1}", pOrderId, errMsg)); ret.End(); return(retObj); }
/// <summary> /// 根据主出库订单ID获取主出库订单及其所有子订单的实例 /// </summary> /// <param name="pOrderId">芒果商城主出库订单ID</param> /// <returns>CWmsExWarehouseOrder</returns> static public CWmsExWarehouseOrder GetCWmsStockoutOrder(string pOrderId) { var ret = new ThirdResult <List <object> >(string.Format("根据主出库订单[{0}]获取主出库订单及其所有子订单的实例,开始", pOrderId)); try { string errMsg = string.Empty; CWmsExWarehouseOrder outObj = null; List <MangoSubExwarehouseOrder> tmpList = null; // get mango order MangoExwarehouseOrder mangoOrder = MangoFactory.GetMangoOrder(TCWmsOrderCategory.EExwarehouseOrder, pOrderId) as MangoExwarehouseOrder; // create CWmsEntryOrder if successful if (null == mangoOrder) { ret.Append(string.Format("根据主出库订单[{0}]获取主出库订单及其所有子订单的实例结束, 获取主出库订单失败", pOrderId)); ret.End(); return(outObj); } // 获取子出库订单列表 errMsg = MangoFactory.GetMangoExwarehouseSubOrderList(pOrderId, out tmpList); if (!string.IsNullOrEmpty(errMsg) || null == tmpList || 0 >= tmpList.Count) { ret.Append(string.Format("根据主出库订单[{0}]获取主出库订单及其所有子订单的实例结束, 获取主出库订单失败。errMsg: {1}", pOrderId, errMsg)); ret.End(); return(outObj); } // 创建CWmsExWarehouseOrder实例及其子出库订单实例列表 outObj = new CWmsExWarehouseOrder(); (outObj.MangoOrder as MangoExwarehouseOrder).CopyFrom(mangoOrder); foreach (var t in tmpList) { CWmsExWarehouseSubOrder subOrder = new CWmsExWarehouseSubOrder(); (subOrder.MangoOrder as MangoSubExwarehouseOrder).CopyFrom(t); subOrder.Product.MangoProduct.ProductId = t.ProductId; (subOrder.WmsOrderDetail).Owner.CopyFrom(MangoFactory.GetOwner((subOrder.MangoOrder as MangoSubExwarehouseOrder).WarehouseId.ToString())); // 获取货主 // 设置商品Id subOrder.Product.ItemCode = (string.IsNullOrEmpty(t.ProductGuiGeID.ToString()) || "0".Equals(t.ProductGuiGeID.ToString())) ? t.ProductId.ToString() : string.Format("{0}-{1}", t.ProductId, t.ProductGuiGeID); outObj.SubOrders.Add((subOrder.MangoOrder as MangoSubExwarehouseOrder).ProductOutputId.ToString(), subOrder); } ret.Append(string.Format("根据主出库订单[{0}]获取主出库订单及其所有子订单的实例结束, 返回{1}", pOrderId, outObj)); ret.End(); return(outObj); } catch (Exception ex) { if (null != ex.InnerException) { ret.Append(string.Format("InnerException: {0}", ex.InnerException.Message)); } ret.Append(string.Format("发生异常: {0}\r\n调用堆栈:{1}", ex.Message, ex.StackTrace)); ret.End(); return(null); } }