protected override GetSuperRetailTraderItemListRD ProcessRequest(APIRequest <GetSuperRetailTraderItemListRP> pRequest)
        {
            GetSuperRetailTraderItemListRP rp = pRequest.Parameters;
            GetSuperRetailTraderItemListRD rd = new GetSuperRetailTraderItemListRD();

            rd.SuperRetailTraderItemList = new List <SuperRetailTraderItemInfo>();

            var superRetailTraderItemMappingBll = new T_SuperRetailTraderItemMappingBLL(CurrentUserInfo);
            var superRetailTraderSkuMappingBll  = new T_SuperRetailTraderSkuMappingBLL(CurrentUserInfo);
            var superRetailTraderConfigBll      = new T_SuperRetailTraderConfigBLL(CurrentUserInfo);

            OrderBy[] orderBy = new OrderBy[] { new OrderBy()
                                                {
                                                    FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                } };
            PagedQueryResult <T_SuperRetailTraderSkuMappingEntity> superRetailTraderSkuList = new PagedQueryResult <T_SuperRetailTraderSkuMappingEntity>();

            //获取分销商Sku列表
            superRetailTraderSkuList = superRetailTraderSkuMappingBll.GetSuperRetailTraderSkuList("", rp.ItemName, rp.Status, rp.PageSize, rp.PageIndex);
            //获取分销商怕配置信息
            T_SuperRetailTraderConfigEntity superRetailTraderConfigEntity = superRetailTraderConfigBll.QueryByEntity(new T_SuperRetailTraderConfigEntity()
            {
                CustomerId = CurrentUserInfo.ClientID
            }, null).FirstOrDefault();


            decimal temp;               //分销价格
            decimal Cost           = 0; //成本价
            decimal CustomerProfit = 0; //商家分润

            if (superRetailTraderConfigEntity != null && superRetailTraderConfigEntity.Cost != 0 && superRetailTraderConfigEntity.Cost != null)
            {
                Cost = Convert.ToDecimal(superRetailTraderConfigEntity.Cost); //成本价
            }
            if (superRetailTraderConfigEntity != null && superRetailTraderConfigEntity.CustomerProfit != null && superRetailTraderConfigEntity.CustomerProfit != 0)
            {
                CustomerProfit = Convert.ToDecimal(superRetailTraderConfigEntity.CustomerProfit); //商家分润
            }
            List <SuperRetailTraderItemInfo> SkuList = superRetailTraderSkuList.Entities.Select(n => new SuperRetailTraderItemInfo()
            {
                ItemId               = n.ItemId,
                ItemName             = n.ItemName,
                SkuId                = n.SkuId,
                PropName             = superRetailTraderItemMappingBll.GetPropName(n.PropName1, n.PropName2),
                SalesPrice           = n.SalesPrice,
                DistributerStock     = Convert.ToInt32(n.DistributerStock) - Convert.ToInt32(n.SalesQty),
                DistributerCostPrice = Convert.ToDecimal(n.DistributerCostPrice),
                DistributePirce      = temp = Cost == 0 ? 0 : Math.Round(Convert.ToDecimal(n.DistributerCostPrice / Convert.ToDecimal(Cost / 100)), 2, MidpointRounding.AwayFromZero), //分销价格 成本价 / 成本占比
                CustomerProgit       = CustomerProfit == 0 ? 0 : Math.Round(temp * Convert.ToDecimal(CustomerProfit / 100), 2, MidpointRounding.AwayFromZero),                         //商家分润  分销价 * 商家分润占比
                Status               = Convert.ToInt32(n.Status)
            }).ToList();

            rd.SuperRetailTraderItemList.AddRange(SkuList);

            rd.TotalCount     = superRetailTraderSkuList.RowCount;
            rd.TotalPageCount = superRetailTraderSkuList.PageCount;


            return(rd);
        }
Beispiel #2
0
        /// <summary>
        /// 获取商品列表
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        protected override GetItemListRD ProcessRequest(DTO.Base.APIRequest <GetItemListRP> pRequest)
        {
            GetItemListRP rp = pRequest.Parameters;
            GetItemListRD rd = new GetItemListRD();

            var superRetailTraderItemMappingBll = new T_SuperRetailTraderItemMappingBLL(CurrentUserInfo);
            var superRetailTraderSkuMappingBll  = new T_SuperRetailTraderSkuMappingBLL(CurrentUserInfo);

            //获取商品列表
            PagedQueryResult <T_SuperRetailTraderItemMappingEntity> superRetailTraderItemMappingList = superRetailTraderItemMappingBll.GetItemList(rp.ItemName, rp.ItemCategoryId, rp.PageSize, rp.PageIndex);
            //获取Sku列表
            PagedQueryResult <T_SuperRetailTraderSkuMappingEntity> superRetailTraderSkuMappingList = superRetailTraderSkuMappingBll.GetSkuList(rp.ItemName, rp.ItemCategoryId, rp.PageSize, rp.PageIndex);

            List <BaseItemInfo> ItemList = superRetailTraderItemMappingList.Entities.Select(t => new BaseItemInfo()
            {
                ItemId       = t.ItemId,
                ItemName     = t.ItemName,
                DisplayIndex = (t.DisplayIndex % rp.PageSize) == 0 ? rp.PageSize : t.DisplayIndex % rp.PageSize,
                ItemCode     = t.ItemCode,
                SkuId        = "",
                PropName     = "",
                SalesPrice   = 0,
                ParentId     = "-99" //无父节点
            }).ToList();

            //根据ItemId匹配相关Sku和商品
            List <BaseItemInfo> SkuList = superRetailTraderSkuMappingList.Entities.Join(superRetailTraderItemMappingList.Entities.ToList(), n => n.ItemId, t => t.ItemId, (n, t) => new BaseItemInfo()
            {
                ItemId       = t.ItemId,
                ItemName     = t.ItemName,
                DisplayIndex = t.DisplayIndex,
                ItemCode     = t.ItemCode,
                SkuId        = n.SkuId,
                PropName     = superRetailTraderItemMappingBll.GetPropName(n.PropName1, n.PropName2),
                SalesPrice   = n.SalesPrice,
                ParentId     = t.ItemId //父节点为ItemId
            }).ToList();

            rd.ItemList = new List <BaseItemInfo>();
            rd.ItemList.AddRange(ItemList);
            rd.ItemList.AddRange(SkuList);

            rd.TotalCount     = superRetailTraderItemMappingList.RowCount;
            rd.TotalPageCount = superRetailTraderItemMappingList.PageCount;

            return(rd);
        }