Exemplo n.º 1
0
        /// <summary>
        /// 填充调用与外Domain相关的字段
        /// </summary>
        /// <param name="soList"></param>
        protected void FillSOInfo(List <SOInfo> soList)
        {
            if (soList != null && soList.Count > 0)
            {
                List <SOItemInfo> soItemList        = new List <SOItemInfo>();
                List <int>        productSysNoList  = new List <int>();
                List <int>        customerSysNoList = new List <int>();
                List <SOItemInfo> exItemList        = new List <SOItemInfo>();
                soList.ForEach(soInfo =>
                {
                    //取得订单使用的礼品卡记录
                    soInfo.SOGiftCardList = ExternalDomainBroker.GetSOGiftCardBySOSysNo(soInfo.SysNo.Value);
                    if (!customerSysNoList.Exists(no => no == soInfo.BaseInfo.CustomerSysNo.Value))
                    {
                        customerSysNoList.Add(soInfo.BaseInfo.CustomerSysNo.Value);
                    }
                    soInfo.Items.ForEach(item =>
                    {
                        item.ProductID = string.Empty;
                        switch (item.ProductType.Value)
                        {
                        case SOProductType.Coupon:
                            item.ProductID = item.ProductSysNo.ToString();
                            soItemList.Add(item);
                            break;

                        case SOProductType.ExtendWarranty:
                            exItemList.Add(item);
                            break;

                        default:
                            {
                                soItemList.Add(item);
                                if (!productSysNoList.Exists(sysNo => sysNo == item.ProductSysNo))
                                {
                                    productSysNoList.Add(item.ProductSysNo.Value);
                                }
                                break;
                            }
                        }
                    });
                });
                List <CustomerBasicInfo> customerList = ExternalDomainBroker.GetCustomerBasicInfo(customerSysNoList);
                if (customerList != null)
                {
                    customerList.ForEach(c =>
                    {
                        SOInfo soInfo = soList.Find(so => so.BaseInfo.CustomerSysNo == c.CustomerSysNo);
                        if (soInfo != null)
                        {
                            soInfo.BaseInfo.CustomerID   = c.CustomerID;
                            soInfo.BaseInfo.CustomerName = c.CustomerName;
                        }
                    });
                }
                if (productSysNoList.Count > 0)
                {
                    List <ECCentral.BizEntity.IM.ProductInfo> productList = ExternalDomainBroker.GetProductInfoListByProductSysNoList(productSysNoList);
                    if (productList != null)
                    {
                        productList.ForEach(product =>
                        {
                            List <SOItemInfo> itemList = soItemList.FindAll(item => { return(item.ProductType != SOProductType.Coupon && item.ProductType != SOProductType.ExtendWarranty && item.ProductSysNo == product.SysNo); });
                            foreach (SOItemInfo item in itemList)
                            {
                                item.ProductID = product.ProductID;
                            }
                        });
                        exItemList.ForEach(ei =>
                        {
                            int mpNo      = int.TryParse(ei.MasterProductSysNo, out mpNo) ? mpNo : int.MinValue;
                            SOItemInfo mp = soItemList.Find(i => i.ProductSysNo == mpNo);
                            if (mp != null)
                            {
                                ei.ProductID = mp.ProductID + "E";
                            }
                        });
                    }
                }
            }
        }