예제 #1
0
 private void buildShowPrice(CommodityListCDTO commodity, List <Deploy.CommodityStockDTO> comStocks,
                             TodayPromotion todayPromotion)
 {
     if (commodity == null)
     {
         return;
     }
     commodity.RealPrice = commodity.Price;
     commodity.OriPrice  = commodity.MarketPrice;
     if (todayPromotion != null)
     {
         commodity.RealPrice = todayPromotion.DiscountPrice > 0
                                   ? todayPromotion.DiscountPrice.Value
                                   : Math.Round(commodity.Price * todayPromotion.Intensity / 10.0m, 2);
         commodity.OriPrice = commodity.Price;
     }
     else
     {
         if (comStocks != null && comStocks.Any())
         {
             var minMarkPriceStock =
                 comStocks.Where(c => c.MarketPrice.HasValue).OrderBy(c => c.MarketPrice).FirstOrDefault();
             if (minMarkPriceStock != null)
             {
                 commodity.OriPrice = comStocks.Min(c => c.MarketPrice);
             }
         }
     }
 }
예제 #2
0
        /// <summary>
        /// 查询商品
        /// </summary>
        public ResultDTO <ListResult <PresentPromotionCommoditySearchResultDTO> > GetCommoditiesExt(PresentPromotionCommoditySearchDTO input)
        {
            if (input.AppId == Guid.Empty)
            {
                return(new ResultDTO <ListResult <PresentPromotionCommoditySearchResultDTO> > {
                    isSuccess = false, Message = "参数错误"
                });
            }

            // 今日活动商品
            var hasAddCommodityIds = TodayPromotion.ObjectSet().Select(_ => _.CommodityId).ToList();

            var query = Commodity.ObjectSet().Where(_ => !_.IsDel && _.State == 0 && _.AppId == input.AppId && !hasAddCommodityIds.Contains(_.Id));

            #region 增加商品查询条件---分类、毛利率区间,价格区间
            query = AddCommoditySelectWhere(input, query, hasAddCommodityIds);

            #endregion

            if (!string.IsNullOrWhiteSpace(input.Name))
            {
                query = query.Where(_ => _.Name.Contains(input.Name));
            }
            var count = query.Count();
            var data  = query.OrderByDescending(q => q.SubTime).Skip((input.PageIndex - 1) * input.PageSize).Take(input.PageSize).Select(_ => new PresentPromotionCommoditySearchResultDTO
            {
                Id    = _.Id,
                Code  = _.No_Code,
                Name  = _.Name,
                Pic   = _.PicturesPath,
                Price = _.Price,
                Stock = _.Stock
            }).ToList();
            var ids    = data.Select(_ => _.Id).ToList();
            var stocks = CommodityStock.ObjectSet().Where(_ => ids.Contains(_.CommodityId));
            foreach (var d in data)
            {
                d.SKU = new List <PresentPromotionCommoditySearchResultDTO.CommoditySKUModel>();
                foreach (var s in stocks.Where(_ => _.CommodityId == d.Id))
                {
                    var sku = new PresentPromotionCommoditySearchResultDTO.CommoditySKUModel();
                    sku.Id    = s.Id;
                    sku.Code  = s.No_Code;
                    sku.Price = s.Price;
                    sku.Stock = s.Stock;
                    var skuAttr = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ComAttributeDTO> >(s.ComAttribute);
                    sku.Name = string.Join(";", skuAttr.Select(_ => _.Attribute + ":" + _.SecondAttribute));
                    d.SKU.Add(sku);
                }
            }
            return(new ResultDTO <ListResult <PresentPromotionCommoditySearchResultDTO> >
            {
                isSuccess = true,
                Data = new ListResult <PresentPromotionCommoditySearchResultDTO> {
                    List = data, Count = count
                }
            });
        }
예제 #3
0
        /// <summary>
        /// 获取商品列表(平台获取平台商品、店铺获取店铺商品)
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public Jinher.AMP.BTP.Deploy.CustomDTO.ComdtyListResultCDTO GetCommodityListV2Ext(CommodityListSearchDTO search)
        {
            Jinher.AMP.BTP.Deploy.CustomDTO.ComdtyListResultCDTO comdtyListResultCDTO = new Jinher.AMP.BTP.Deploy.CustomDTO.ComdtyListResultCDTO();
            try
            {
                if (search == null || search.PageSize <= 0 || search.PageIndex <= 0)
                {
                    comdtyListResultCDTO.isSuccess   = false;
                    comdtyListResultCDTO.Code        = 1;
                    comdtyListResultCDTO.Message     = "参数不能为空";
                    comdtyListResultCDTO.realCount   = 0;
                    comdtyListResultCDTO.comdtyList  = null;
                    comdtyListResultCDTO.appInfoList = null;
                    return(comdtyListResultCDTO);
                }
                if (!search.AppId.HasValue || search.AppId == Guid.Empty)
                {
                    comdtyListResultCDTO.isSuccess   = false;
                    comdtyListResultCDTO.Code        = 1;
                    comdtyListResultCDTO.Message     = "参数不能为空";
                    comdtyListResultCDTO.realCount   = 0;
                    comdtyListResultCDTO.comdtyList  = null;
                    comdtyListResultCDTO.appInfoList = null;
                    return(comdtyListResultCDTO);
                }

                DateTime now = DateTime.Now;

                var appId = search.AppId.Value;

                IQueryable <Commodity> ocommodityList;
                //用于存储临加入真实价格后的Commodity信息
                IQueryable <TempCommodity> tempOcommodityList;
                //根据是否平台区分
                bool isPavilion = Jinher.AMP.BTP.TPS.ZPHSV.Instance.IsAppPavilion(search.AppId.Value);
                if (isPavilion)
                {
                    tempOcommodityList = (from cs in CommodityCategory.ObjectSet()
                                          join cate in Category.ObjectSet() on cs.CategoryId equals cate.Id
                                          join c in Commodity.ObjectSet() on cs.CommodityId equals c.Id
                                          join pro in
                                          (
                                              from query in TodayPromotion.ObjectSet()
                                              where
                                              (query.PromotionType != 3 &&
                                               (query.StartTime <= now || query.PresellStartTime <= now) &&
                                               query.EndTime > now)
                                              select query
                                          ) on c.Id equals pro.CommodityId
                                          into todayPros
                                          from promotion in todayPros.DefaultIfEmpty()
                                          where cs.AppId == appId && c.IsDel == false && c.State == 0 && c.CommodityType == 0 && !cate.IsDel
                                          orderby c.Salesvolume descending, c.SubTime descending
                                          select new TempCommodity
                    {
                        Com = c,
                        newPrice = (promotion.Id == null) ? c.Price : (promotion.DiscountPrice > 0 ? promotion.DiscountPrice : c.Price * promotion.Intensity / 10)
                    });
                }
                else
                {
                    tempOcommodityList = (from c in Commodity.ObjectSet()
                                          join pro in
                                          (
                                              from query in TodayPromotion.ObjectSet()
                                              where (query.PromotionType != 3 && (query.StartTime <= now || query.PresellStartTime <= now) && query.EndTime > now)
                                              select query
                                          ) on c.Id equals pro.CommodityId
                                          into todayPros
                                          from promotion in todayPros.DefaultIfEmpty()

                                          where c.AppId == appId && c.IsDel == false && c.State == 0 && c.CommodityType == 0
                                          select new TempCommodity
                    {
                        Com = c,
                        newPrice = (promotion.Id == null) ? c.Price : (promotion.DiscountPrice > 0 ? promotion.DiscountPrice : c.Price * promotion.Intensity / 10)
                    });
                }

                if (search.MinPrice.HasValue && search.MinPrice != 0)
                {
                    tempOcommodityList = tempOcommodityList.Where(c => c.newPrice >= search.MinPrice);
                }
                if (search.MaxPrice.HasValue && search.MaxPrice != 0)
                {
                    tempOcommodityList = tempOcommodityList.Where(c => c.newPrice <= search.MaxPrice);
                }

                ocommodityList = tempOcommodityList.Select(c => c.Com).Distinct();


                if (search.IsHasStock)
                {
                    ocommodityList = ocommodityList.Where(c => c.Stock > 0);
                }

                if (!ProvinceCityHelper.IsTheWholeCountry(search.areaCode))
                {
                    var province = ProvinceCityHelper.GetProvinceByAreaCode(search.areaCode);
                    var city     = ProvinceCityHelper.GetCityByAreaCode(search.areaCode);
                    if (province != null && city != null)
                    {
                        if (province.AreaCode == city.AreaCode)
                        {
                            ocommodityList = ocommodityList.Where(c => c.SaleAreas == null || c.SaleAreas == "" || c.SaleAreas == ProvinceCityHelper.CountryCode || c.SaleAreas.Contains(province.AreaCode));
                        }
                        else
                        {
                            ocommodityList = ocommodityList.Where(c => c.SaleAreas == null || c.SaleAreas == "" || c.SaleAreas == ProvinceCityHelper.CountryCode || c.SaleAreas.Contains(province.AreaCode) || c.SaleAreas.Contains(city.AreaCode));
                        }
                    }
                }
                var commoditiesQuery         = from c in ocommodityList select c;
                List <Commodity> commodities = null;
                List <Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO> commodityList = null;

                comdtyListResultCDTO.realCount = commoditiesQuery.Count();
                if (isPavilion)
                {
                    commodities = (from c in commoditiesQuery
                                   orderby c.Salesvolume descending, c.SubTime descending
                                   select c).Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList();
                }
                else
                {
                    commodities = (from c in commoditiesQuery
                                   orderby c.SortValue
                                   select c).Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList();
                }

                //commodities = commoditiesQuery.Skip((search.PageIndex - 1) * search.PageSize).Take(search.PageSize).ToList();


                if (!commodities.Any())
                {
                    return(comdtyListResultCDTO);
                }

                commodityList = commodities.Select(c => new Jinher.AMP.BTP.Deploy.CustomDTO.CommodityListCDTO
                {
                    Id               = c.Id,
                    Pic              = c.PicturesPath,
                    Price            = c.Price,
                    State            = c.State,
                    Stock            = c.Stock,
                    Name             = c.Name,
                    MarketPrice      = c.MarketPrice,
                    AppId            = c.AppId,
                    IsEnableSelfTake = c.IsEnableSelfTake,
                    ComAttribute     = c.ComAttribute,
                    ComAttrType      = (c.ComAttribute == "[]" || c.ComAttribute == null) ? 1 : 3
                }).ToList();

                var appList = commodities.Select(c => c.AppId).Distinct().ToList();

                #region 众筹
                if (CustomConfig.CrowdfundingFlag)
                {
                    var crowdFundingApps = Crowdfunding.ObjectSet().Where(c => c.StartTime < now && c.State == 0 && appList.Contains(c.AppId)).Select(c => c.AppId).ToList();
                    if (crowdFundingApps.Any())
                    {
                        for (int i = 0; i < commodityList.Count; i++)
                        {
                            if (crowdFundingApps.Any(c => c == commodityList[i].AppId))
                            {
                                commodityList[i].IsActiveCrowdfunding = true;
                            }
                        }
                    }
                }
                #endregion

                var commodityIds = commodityList.Select(c => c.Id).Distinct().ToList();
                var comStockList = CommodityStock.ObjectSet()
                                   .Where(c => commodityIds.Contains(c.CommodityId))
                                   .Select(
                    c =>
                    new Deploy.CommodityStockDTO
                {
                    Id          = c.Id,
                    CommodityId = c.CommodityId,
                    Price       = c.Price,
                    MarketPrice = c.MarketPrice
                })
                                   .ToList();
                var todayPromotions = TodayPromotion.GetCurrentPromotionsWithPresell(commodityIds);

                foreach (var commodity in commodityList)
                {
                    commodity.IsMultAttribute = Commodity.CheckComMultAttribute(commodity.ComAttribute);
                    List <Deploy.CommodityStockDTO> comStocks = comStockList.Where(c => c.CommodityId == commodity.Id).ToList();

                    var todayPromotion = todayPromotions.FirstOrDefault(c => c.CommodityId == commodity.Id && c.PromotionType != 3);

                    if (todayPromotion != null)
                    {
                        commodity.LimitBuyEach         = todayPromotion.LimitBuyEach ?? -1;
                        commodity.LimitBuyTotal        = todayPromotion.LimitBuyTotal ?? -1;
                        commodity.SurplusLimitBuyTotal = todayPromotion.SurplusLimitBuyTotal ?? 0;
                        commodity.PromotionType        = todayPromotion.PromotionType;
                        if (todayPromotion.DiscountPrice > -1)
                        {
                            commodity.DiscountPrice = Convert.ToDecimal(todayPromotion.DiscountPrice);
                            commodity.Intensity     = 10;
                        }
                        else
                        {
                            commodity.DiscountPrice = -1;
                            commodity.Intensity     = todayPromotion.Intensity;
                        }
                    }
                    else
                    {
                        commodity.DiscountPrice        = -1;
                        commodity.Intensity            = 10;
                        commodity.LimitBuyEach         = -1;
                        commodity.LimitBuyTotal        = -1;
                        commodity.SurplusLimitBuyTotal = -1;
                        commodity.PromotionType        = 9999;
                    }
                    buildShowPrice(commodity, comStocks, todayPromotion);
                }

                try
                {
                    var apps = APPSV.GetAppListByIds(appList);
                    if (apps != null && apps.Any())
                    {
                        comdtyListResultCDTO.appInfoList = new List <ComdtyAppInfoCDTO>();
                        foreach (var appInfo in apps)
                        {
                            comdtyListResultCDTO.appInfoList.Add(new ComdtyAppInfoCDTO
                            {
                                appId   = appInfo.AppId,
                                appName = appInfo.AppName,
                                icon    = appInfo.AppIcon
                            });
                        }

                        foreach (var commodityListCdto in commodityList)
                        {
                            var appInfo = apps.FirstOrDefault(c => c.AppId == commodityListCdto.AppId);
                            if (appInfo != null)
                            {
                                commodityListCdto.AppName = appInfo.AppName;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error(string.Format("AppSetSV.GetCommodityListExt,获取app名称错误。appId:{0}", appId), ex);
                }

                comdtyListResultCDTO.comdtyList = commodityList;
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("商品列表查询错误,CommoditySV.GetCommodityListV2Ext。search:{0}", JsonHelper.JsonSerializer(search)), ex);
                comdtyListResultCDTO.isSuccess   = false;
                comdtyListResultCDTO.Code        = -1;
                comdtyListResultCDTO.Message     = "Error";
                comdtyListResultCDTO.realCount   = 0;
                comdtyListResultCDTO.comdtyList  = null;
                comdtyListResultCDTO.appInfoList = null;
                return(comdtyListResultCDTO);
            }
            comdtyListResultCDTO.isSuccess = true;
            comdtyListResultCDTO.Code      = 0;
            comdtyListResultCDTO.Message   = "Success";
            return(comdtyListResultCDTO);
        }
예제 #4
0
        public bool initComs()
        {
            bool hasError = false;

            var selecid       = _condition.coms.Select(c => c.commodityId).Distinct().ToList();
            var cStockid      = _condition.coms.Where(c => c.commodityStockId != Guid.Empty).Select(c => c.commodityStockId).Distinct().ToList();
            var promotionIds  = _condition.coms.Select(c => c.promotionId != Guid.Empty).Distinct().ToList();
            var commodityList = (
                from c in Commodity.ObjectSet()
                join s in CommodityStock.ObjectSet()
                on c.Id equals s.CommodityId into os
                from ss in os.DefaultIfEmpty()
                where c.CommodityType == 0 && selecid.Contains(c.Id) && (ss == null || cStockid.Contains(ss.Id))
                select new CheckCommodityDTO
            {
                Id = c.Id,
                Price = ss != null ? ss.Price : c.Price,
                State = c.IsDel ? 3 : c.State,
                Stock = ss != null ? ss.Stock : c.Stock,
                Intensity = 10,
                DiscountPrice = -1,
                OPrice = c.Price,
                LimitBuyEach = -1,
                LimitBuyTotal = -1,
                SurplusLimitBuyTotal = 0,
                CommodityStockId = ss != null ? ss.Id : Guid.Empty,
                IsEnableSelfTake = c.IsEnableSelfTake,
                AppId = c.AppId
            }).ToList();
            var vipAppIds = (from condition in _condition.coms
                             join com in commodityList on condition.commodityId equals com.Id
                             where condition.promotionId == Guid.Empty
                             select com.AppId
                             ).Distinct().ToList();
            var vipDict = AVMSV.GetVipIntensities(vipAppIds, _condition.userId);
            List <TodayPromotionDTO> promotionDic = new List <TodayPromotionDTO>();

            //商品在每日促销表里集合
            if (promotionIds.Any())
            {
                promotionDic = TodayPromotion.ObjectSet().Where(a => selecid.Contains(a.CommodityId)).
                               Select(a => new TodayPromotionDTO
                {
                    CommodityId          = a.CommodityId,
                    Intensity            = a.Intensity,
                    DiscountPrice        = a.DiscountPrice,
                    LimitBuyTotal        = a.LimitBuyTotal ?? -1,
                    SurplusLimitBuyTotal = a.SurplusLimitBuyTotal,
                    LimitBuyEach         = a.LimitBuyEach,
                    PromotionId          = a.PromotionId,
                    PromotionType        = a.PromotionType,
                    OutsideId            = a.OutsideId,
                    GroupMinVolume       = a.GroupMinVolume,
                    ExpireSecond         = a.ExpireSecond,
                    StartTime            = a.StartTime,
                    EndTime = a.EndTime
                }).Distinct().ToList();
            }
            foreach (var createOrderCom in _condition.coms)
            {
                createOrderCom.checkResult = new CreateOrderComCheckResult();
                var com = commodityList.FirstOrDefault(c => c.Id == createOrderCom.commodityId && c.CommodityStockId == createOrderCom.commodityStockId);

                if (!checkComCanBuy(com, createOrderCom))
                {
                    hasError = true;
                    continue;
                }

                var realPrice = com.Price;
                TodayPromotionDTO promotion;
                //有活动参加活动
                if (createOrderCom.promotionId != Guid.Empty)
                {
                    promotion = promotionDic.FirstOrDefault(c => c.CommodityId == createOrderCom.commodityId && c.PromotionId == createOrderCom.promotionId);

                    if (!checkCanBuyByPromotion(promotion, createOrderCom))
                    {
                        hasError = true;
                        continue;
                    }

                    if (promotion != null)
                    {
                        realPrice = (promotion.DiscountPrice > -1) ? promotion.DiscountPrice.Value : decimal.Round((com.Price * promotion.Intensity / 10), 2, MidpointRounding.AwayFromZero);
                    }
                }
                //没有活动有vip机制,采用vip体系
                else if (vipDict.ContainsKey(com.AppId) && vipDict[com.AppId] != null && vipDict[com.AppId].IsVip)
                {
                    realPrice = (vipDict[com.AppId].DiscountPrice > -1) ? vipDict[com.AppId].DiscountPrice : decimal.Round((com.Price * vipDict[com.AppId].Intensity / 10), 2, MidpointRounding.AwayFromZero);
                }
                if (createOrderCom.realPrice != realPrice)
                {
                    createOrderCom.checkResult.FillData(true, false, 0, ComCantBuyReasonEnum.Price, "商品价格发生变化");
                    hasError = true;
                }
            }
            return(!hasError);
        }
예제 #5
0
        /// <summary>
        /// 获取当前商品结算列表
        /// </summary>
        /// <param name="id">商品结算价检索类</param>
        /// <returns>结果</returns>
        public List <Jinher.AMP.BTP.Deploy.CustomDTO.SettlingAccountVM> GetNowSettlingAccountExt(SettlingAccountSearchDTO search, out int rowCount)
        {
            List <Jinher.AMP.BTP.Deploy.CustomDTO.SettlingAccountVM> comcalist = new List <Jinher.AMP.BTP.Deploy.CustomDTO.SettlingAccountVM>();

            if (search == null || search.appId == Guid.Empty || search.pageIndex < 1 || search.pageSize < 1)
            {
                rowCount = 0;
                return(comcalist);
            }

            DateTime now = DateTime.Now;

            //appid
            var query = Commodity.ObjectSet().Where(n => n.IsDel.Equals(false) && n.AppId.Equals(search.appId) && n.State == 0 && n.CommodityType == 0);


            //commodityName
            if (!string.IsNullOrWhiteSpace(search.commodityName))
            {
                query = query.Where(n => n.Name.Contains(search.commodityName));
            }

            //commodityCategory
            if (!string.IsNullOrWhiteSpace(search.commodityCategory))
            {
                string[]    commodityCategoryID = search.commodityCategory.Split(',');
                List <Guid> idlist = new List <Guid>();
                foreach (string commodityCategoryid in commodityCategoryID)
                {
                    if (!string.IsNullOrEmpty(commodityCategoryid))
                    {
                        idlist.Add(new Guid(commodityCategoryid));
                    }
                }
                query = from n in query
                        join m in CommodityCategory.ObjectSet() on n.Id equals m.CommodityId
                        where idlist.Contains(m.CategoryId)
                        select n;
            }

            query    = query.Distinct();
            rowCount = query.Count();
            query    = query.OrderBy(n => n.SortValue).ThenByDescending(n => n.SubTime).Skip((search.pageIndex - 1) * search.pageSize).Take(search.pageSize);

            var commodityIds = query.Select(t => t.Id).ToList();

            //取出厂家结算价
            var settlingAccountQuery = (
                from s in SettlingAccount.ObjectSet()
                where commodityIds.Contains(s.CommodityId) && s.EffectiveTime < now
                select new
            {
                Id = s.Id,
                CommodityId = s.CommodityId,
                ManufacturerClearingPrice = s.ManufacturerClearingPrice,
                AppId = s.AppId,
                Effectable = s.Effectable,
                EffectiveTime = s.EffectiveTime,
                SubId = s.SubId,
                SubName = s.SubName,
                SubTime = s.SubTime,
                ModifiedOn = s.ModifiedOn,
                UserCode = s.UserCode
            })
                                       .GroupBy(t => t.CommodityId).ToDictionary(x => x.Key, y => y.OrderByDescending(c => c.EffectiveTime).First());


            //取出商品的销售价
            var compromoList = (from t in TodayPromotion.ObjectSet()
                                where commodityIds.Contains(t.CommodityId) && t.EndTime > now && t.StartTime < now
                                select new
            {
                SurplusLimitBuyTotal = t.SurplusLimitBuyTotal,
                ComdityID = t.CommodityId,
                LimitBuyEach = t.LimitBuyEach,
                PromotionId = t.PromotionId,
                ID = t.Id,
                LimitBuyTotal = t.LimitBuyTotal,
                Intensity = t.Intensity,
                DiscountPrice = t.DiscountPrice,
                PromotionType = t.PromotionType,
                ChannelId = t.ChannelId,
                OutsideId = t.OutsideId
            }).GroupBy(c => c.ComdityID).ToDictionary(x => x.Key, y => y.OrderByDescending(c => c.PromotionType).First());

            var comList = query.ToList();

            int?     intNull      = null;
            DateTime?dateTimeNull = null;
            Guid?    guidNull     = null;
            Decimal? decimalNull  = null;

            foreach (var com in comList)
            {
                var settlingAccountTmp = settlingAccountQuery.ContainsKey(com.Id) ? settlingAccountQuery[com.Id] : null;

                decimal Intensity     = 10;
                decimal?DiscountPrice = -1;
                decimal realPrice     = com.Price;
                if (compromoList.ContainsKey(com.Id))
                {
                    if (compromoList[com.Id].DiscountPrice > -1)
                    {
                        Intensity     = 10;
                        DiscountPrice = compromoList[com.Id].DiscountPrice == null?-1:compromoList[com.Id].DiscountPrice;
                    }
                    else
                    {
                        Intensity     = compromoList[com.Id].Intensity == null ? 10 : compromoList[com.Id].Intensity;
                        DiscountPrice = -1;
                    }

                    realPrice = (DiscountPrice > -1)
                                     ? DiscountPrice.Value
                                     : decimal.Round((com.Price * Intensity / 10), 2, MidpointRounding.AwayFromZero);
                }

                Jinher.AMP.BTP.Deploy.CustomDTO.SettlingAccountVM settingAccount = new Jinher.AMP.BTP.Deploy.CustomDTO.SettlingAccountVM()
                {
                    AppId                     = com.AppId,
                    CommodityCode             = com.No_Code,
                    CommodityId               = com.Id,
                    CommodityName             = com.Name,
                    Effectable                = settlingAccountTmp == null ? intNull : settlingAccountTmp.Effectable,
                    EffectiveTime             = settlingAccountTmp == null ? dateTimeNull : settlingAccountTmp.EffectiveTime,
                    Id                        = settlingAccountTmp == null ? guidNull : settlingAccountTmp.Id,
                    IsEnableSelfTake          = com.IsEnableSelfTake,
                    UserCode                  = settlingAccountTmp == null ? null : settlingAccountTmp.UserCode,
                    ManufacturerClearingPrice = settlingAccountTmp == null ? decimalNull : settlingAccountTmp.ManufacturerClearingPrice,
                    ModifiedOn                = settlingAccountTmp == null ? dateTimeNull : settlingAccountTmp.ModifiedOn,
                    PicturesPath              = com.PicturesPath,
                    SalePrice                 = realPrice,
                    SubId                     = settlingAccountTmp == null ? guidNull : settlingAccountTmp.SubId,
                    SubName                   = settlingAccountTmp == null ? null : settlingAccountTmp.SubName,
                    SubTime                   = settlingAccountTmp == null ? dateTimeNull : settlingAccountTmp.SubTime,
                };
                comcalist.Add(settingAccount);
            }

            return(comcalist);
        }
예제 #6
0
        /// <summary>
        /// 根据用户ID查询收藏商品
        /// </summary>
        /// <param name="userId">商品ID</param>
        /// <param name="appId">appId</param>
        /// <returns></returns>
        public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.CommoditySDTO> GetCollectionItemsExt(System.Guid userId, System.Guid appId)
        {
            var commodityList = (from data in Collection.ObjectSet()
                                 join data1 in Commodity.ObjectSet() on data.CommodityId equals data1.Id
                                 where data.UserId == userId && data.AppId == appId && data1.IsDel == false && data1.CommodityType == 0
                                 select new CommoditySDTO
            {
                Name = data1.Name,
                Id = data1.Id,
                Price = data1.Price,
                Pic = data1.PicturesPath,
                Stock = data1.Stock,
                State = data1.State,
                CollectNum = data1.TotalCollection,
                ReviewNum = data1.TotalReview,
                Total = data1.Salesvolume
            }).ToList();

            DateTime now = DateTime.Now;

            List <Guid> commodityIds = commodityList.Select(c => c.Id).ToList();

            //读今日折扣表
            try
            {
                //zgx-modify
                var comAttributeList = (from a in CommodityStock.ObjectSet()
                                        where commodityIds.Contains(a.CommodityId)
                                        group a by a.CommodityId into g
                                        select new
                {
                    minPrice = g.Min(a => a.Price),
                    maxPrice = g.Max(a => a.Price),
                    CommodityId = g.Key
                }).ToList();

                var promotionDic = TodayPromotion.GetCurrentPromotionsWithPresell(commodityIds);

                foreach (var commodity in commodityList)
                {
                    //zgx-modify
                    if (comAttributeList != null && comAttributeList.Count > 0)
                    {
                        var comAttribute = comAttributeList.Find(r => r.CommodityId == commodity.Id);
                        if (comAttribute != null)
                        {
                            commodity.MaxPrice = comAttribute.maxPrice;
                            commodity.MinPrice = comAttribute.minPrice;
                        }
                    }

                    bool isdi = false;
                    foreach (var com in promotionDic)
                    {
                        if (com.CommodityId == commodity.Id)
                        {
                            commodity.LimitBuyEach         = com.LimitBuyEach == null ? -1 : com.LimitBuyEach;
                            commodity.LimitBuyTotal        = com.LimitBuyTotal == null ? -1 : com.LimitBuyTotal;
                            commodity.SurplusLimitBuyTotal = com.SurplusLimitBuyTotal == null ? 0 : com.SurplusLimitBuyTotal;
                            if (com.DiscountPrice > -1)
                            {
                                commodity.DiscountPrice = Convert.ToDecimal(com.DiscountPrice);
                                commodity.Intensity     = 10;
                                isdi = true;
                                break;
                            }
                            else
                            {
                                commodity.DiscountPrice = -1;
                                commodity.Intensity     = com.Intensity;
                                isdi = true;
                                break;
                            }
                        }
                    }
                    if (!isdi)
                    {
                        commodity.DiscountPrice        = -1;
                        commodity.Intensity            = 10;
                        commodity.LimitBuyEach         = -1;
                        commodity.LimitBuyTotal        = -1;
                        commodity.SurplusLimitBuyTotal = -1;
                    }
                    //if (promotionDic.ContainsKey(commodity.Id))
                    //{
                    //    commodity.Intensity = promotionDic[commodity.Id];
                    //}
                    //else
                    //{
                    //    commodity.Intensity = 10;
                    //}
                }
            }
            catch (Exception e)
            {
                Jinher.JAP.Common.Loging.LogHelper.Error(string.Format("商品列表查询错误,userId{111},appId{111}", userId, appId), e);
            }
            return(commodityList);
        }