Beispiel #1
0
        public NewCouponActivity GetNewCouponConfigByActivityId(Guid activityId)
        {
            NewCouponActivity result = new NewCouponActivity();
            List <RecommendActivityConfig> recommendActivity = new List <RecommendActivityConfig>();
            List <CouponRulesConfig>       couponRules       = new List <CouponRulesConfig>();
            List <SE_GetPromotionActivityCouponInfoConfig> activityCouponInfo = new List <SE_GetPromotionActivityCouponInfoConfig>();

            try
            {
                dbScopeReadManager.Execute(conn =>
                {
                    result            = DALNewCoupon.SelectNewCouponConfig(conn, activityId, "", 1, 99).FirstOrDefault();
                    recommendActivity = DALNewCoupon.SelectRecommendActivityConfig(conn, activityId);
                    couponRules       = DALNewCoupon.SelectCouponRulesConfig(conn, activityId);
                    if (couponRules != null && couponRules.Any())
                    {
                        activityCouponInfo = DALNewCoupon.SelectActivityCouponInfo(conn, string.Join(",", couponRules.Select(x => x.RulesGUID)));
                    }
                });
                if (result != null)
                {
                    result.RecommendActivityForInit    = recommendActivity.Where(x => x.ActivityType.Equals(RecommendActivityType.InitActivity)).ToList();
                    result.RecommendActivityForSuccess = recommendActivity.Where(x => x.ActivityType.Equals(RecommendActivityType.SuccessActivity)).ToList();
                    if (activityCouponInfo != null && activityCouponInfo.Any())
                    {
                        result.CouponRulesConfig = (from c in couponRules
                                                    join s in activityCouponInfo
                                                    on c.RulesGUID equals s.GetRuleGUID into temp
                                                    from t in temp.DefaultIfEmpty()
                                                    select new CouponRulesConfig()
                        {
                            RulesGUID = c.RulesGUID,
                            ValidDays = t.ValidDays,
                            ValidStartDateTime = t.ValidStartDateTime,
                            ValidEndDateTime = t.ValidEndDateTime,
                            MinMoney = t.MinMoney,
                            Description = t.Description,
                            Quantity = t.Quantity,
                            SingleQuantity = t.SingleQuantity,
                            UserType = t.UserType
                        }).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(result);
        }
Beispiel #2
0
        public List <SE_GetPromotionActivityCouponInfoConfig> SelectActivityCouponInfo(string rulesIdStr)
        {
            var result = new List <SE_GetPromotionActivityCouponInfoConfig>();

            try
            {
                result = dbScopeReadManager.Execute(conn => DALNewCoupon.SelectActivityCouponInfo(conn, rulesIdStr));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(result);
        }