Beispiel #1
0
        /// <summary>
        /// 根据主订单Id获取芒果商城的订单实体及其子订单明细的实体
        /// </summary>
        /// <param name="pOid">主订单Id</param>
        /// <returns>若成功则返回CWmsMallOrder实体;否则返回null</returns>
        static public CWmsMallOrder GetCWmsMallOrder(string pOid)
        {
            try
            {
                string        errMsg = string.Empty;
                CWmsMallOrder outObj = null;

                // get mango order, TODO: 传入了错误的TCWmsOrderCategory类型? 固定传入了出库单类型
                MangoMallOrder mangoOrder = MangoFactory.GetMangoOrder(TCWmsOrderCategory.EExwarehouseOrder, pOid) as MangoMallOrder;

                if (null == mangoOrder)
                {
                    C_WMS.Data.Utility.MyLog.Instance.Warning("在{0}中,根据单据ID[{0}]获取商城主订单实体及其子订单明细失败", System.Reflection.MethodBase.GetCurrentMethod().Name, pOid);
                    return(outObj);
                }

                // 创建CWmsExWarehouseOrder实例及其子出库订单实例列表
                outObj = new CWmsMallOrder();
                (outObj.MangoOrder as MangoMallOrder).CopyFrom(mangoOrder);

                outObj.Owner.CopyFrom(new Wms.Data.WmsOwner(Mango.MisModelPWI.CWmsMisSystemParamCache.Cache.GetDefaultOwner().Code, Mango.MisModelPWI.CWmsMisSystemParamCache.Cache.GetDefaultOwner().Name));   // 对于商城下的订单,货主一定是蓝江智家
                outObj.CancelReason = (outObj.MangoOrder as MangoMallOrder).BeiZhu;
                outObj.WmsOrder.SetWmsStockoutOrderType((TMangoOrderType)(outObj.MangoOrder as MangoMallOrder).DingDanType.Int());
                // TODO: 目前阶段不需要处理子订单
                return(outObj);
            }
            catch (Exception ex)
            {
                C_WMS.Data.Utility.MyLog.Instance.Error(ex, "在{0}中,根据单据ID[{0}]获取商城主订单实体及其子订单明细发生异常", System.Reflection.MethodBase.GetCurrentMethod().Name, pOid);
                return(null);
            }
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        /// <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);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 根据主入库订单ID获取主入库订单及其所有子订单的实例
        /// </summary>
        /// <param name="pOrderId">芒果商城主入库单ID</param>
        /// <returns>CWmsEntryOrder对象</returns>
        static public CWmsEntryOrder GetCWmsEntryOrder(string pOrderId)
        {
            try
            {
                CWmsEntryOrder            outObj  = null;
                List <MangoSubEntryOrder> tmpList = null;
                string errMsg = string.Empty;

                // get mango order
                MangoEntryOrder mangoOrder = MangoFactory.GetMangoOrder(TCWmsOrderCategory.EEntryOrder, pOrderId) as MangoEntryOrder;

                // get sub orders
                errMsg = MangoFactory.GetVMangoSubEntryOrders(pOrderId, out tmpList);

                // create CWmsEntryOrder if successful
                if (null != mangoOrder && string.IsNullOrEmpty(errMsg) && 0 < tmpList?.Count)
                {
                    outObj = new CWmsEntryOrder();
                    (outObj.MangoOrder as MangoEntryOrder).CopyFrom(mangoOrder);
                    outObj.WmsOrder.SetWmsOrderType(TWmsOrderType.CGRK);// 默认采购入库
                    foreach (var s in tmpList)
                    {
                        int tmpPlanQty       = -1;
                        CWmsSubEntryOder cso = new CWmsSubEntryOder();
                        (cso.MangoOrder as MangoSubEntryOrder).CopyFrom(s);

                        #region // 获取应收数量
                        if (0 >= s.ProductBuyId.Int())
                        {
                            // 无采购入库Id,判断为芒果网络商品入库(补),实收数量即为应收数量
                            (cso.WmsOrderDetail as Wms.Data.WmsEntryOrderDetail).planQty = CWmsUtility.Decimal2Int(s.ProductInputCount.Decimal());
                        }
                        else
                        {
                            // 有采购入库Id,取采购入库单中的应收数量
                            (cso.WmsOrderDetail as Wms.Data.WmsEntryOrderDetail).planQty =
                                (TError.RunGood.Int() == MangoFactory.GetPlanQuantityByPid(s.ProductBuyId.ToString(), out tmpPlanQty)) ? tmpPlanQty : -1;
                        }
                        #endregion

                        // 设置商品Id
                        cso.Product.ItemCode = (string.IsNullOrEmpty(s.ProductGuiGeID.ToString()) || "0".Equals(s.ProductGuiGeID.ToString())) ?
                                               s.ProductId.ToString() : string.Format("{0}-{1}", s.ProductId, s.ProductGuiGeID);

                        outObj.SubOrders.Add(s.ProductInputId.ToString(), cso);
                    }
                    // TODO: other operations
                }
                else
                {
                    C_WMS.Data.Utility.MyLog.Instance.Error("根据主入库订单ID({0})获取主入库订单及其所有子订单的实例失败, mangoOrder=(1}, 子单据数量={2}", pOrderId, mangoOrder, tmpList?.Count);
                }

                return(outObj);
            }
            catch (Exception ex)
            {
                C_WMS.Data.Utility.MyLog.Instance.Error(ex, "根据主入库订单ID({0})获取主入库订单及其所有子订单的实例异常", pOrderId);
                return(null);
            }
        }