Пример #1
0
        public PackageActivityConfig SelectPackageActivityConfig(Guid activityId)
        {
            PackageActivityConfig result = new PackageActivityConfig();

            try
            {
                dbReadScopeManager.Execute(conn =>
                {
                    result = DALPackageActivity.SelectPackageActivity(conn, activityId, "", null, null, 1, 99).FirstOrDefault();
                    if (result != null && result.ActivityId != Guid.Empty)
                    {
                        result.ShopConfig    = DALPackageActivity.SelectPackageActivityShopConfig(conn, activityId);
                        result.RoundConfig   = DALPackageActivity.SelectPackageActivitySceneConfig(conn, activityId);
                        result.ProductConfig = DALPackageActivity.SelectPackageActivityProductConfig(conn, activityId);
                        result.VehicleConfig = DALPackageActivity.SelectPackageActivityVehicleConfig(conn, activityId);
                        result.PriceConfig   = DALPackageActivity.SelectPackageActivityPriceConfig(conn, activityId);
                    }
                });
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(result);
        }
Пример #2
0
        public List <PackageActivityConfig> SelectPackageActivity(string activityID, string activityName, DateTime?startTime, DateTime?endTime, int pageIndex, int pageSize)
        {
            List <PackageActivityConfig> result    = new List <PackageActivityConfig>();
            List <OrderLists>            orderInfo = new List <OrderLists>();
            var activityId = Guid.Empty;

            try
            {
                dbReadScopeManager.Execute(conn =>
                {
                    if (!string.IsNullOrEmpty(activityID))
                    {
                        activityId = Guid.Parse(activityID);
                    }
                    result = DALPackageActivity.SelectPackageActivity(conn, activityId, activityName, startTime, endTime, pageIndex, pageSize);
                    if (result != null && result.Any())
                    {
                        result.ForEach(x => x.RoundConfig = DALPackageActivity.SelectPackageActivitySceneConfig(conn, x.ActivityId));
                    }
                });
                if (result != null && result.Any())
                {
                    foreach (var item in result)
                    {
                        if (item.RoundConfig != null && item.RoundConfig.Any())
                        {
                            var flashSaleLog = DALPackageActivity.SelectFlashSalRecordsLog(item.ActivityId);
                            if (flashSaleLog != null && flashSaleLog.Any())
                            {
                                flashSaleLog = flashSaleLog.GroupBy(x => x.OrderId).Select(g => g.FirstOrDefault()).ToList();
                                dbReadScopeManager.Execute(conn =>
                                {
                                    orderInfo = DALPackageActivity.SelectOrderInfo(conn, flashSaleLog.Select(x => x.OrderId).Distinct().ToList());
                                });
                                flashSaleLog = (from fs in flashSaleLog
                                                join or in orderInfo on fs.OrderId equals or.OrderId into temp
                                                from t in temp.DefaultIfEmpty()
                                                select new FlashSaleRecordsLog()
                                {
                                    CreateDate = fs.CreateDate,
                                    OrderStatus = t != null ? t.Status : string.Empty,
                                    OrderId = t != null ? t.OrderId : 0
                                }).Where(x => !string.Equals(x.OrderStatus, "7Canceled") && x.OrderId > 0).ToList();
                            }
                            item.RoundConfig.ForEach(_ =>
                            {
                                _.SurplusNum = _.LimitedQuantity - flashSaleLog.Where(x => x.CreateDate >= _.StartTime && x.CreateDate <= _.EndTime).Count();
                            });
                            item.AllSurplusNum = item.MaxSaleQuantity - flashSaleLog.Count();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(result);
        }