public static decimal AmountFromPoints(int proId, int points)
        {
            IPointOrderRuleRepository proRuleRepo = ServiceLocator.Current.Resolve <IPointOrderRuleRepository>();
            var     pro   = proRuleRepo.Get(r => r.StorePromotionId == proId && r.Status != (int)DataStatus.Deleted);
            decimal ratio = 0m;

            foreach (var rule in pro.ToList())
            {
                // hit rule be:
                // 1. rangfrom is null but rangto >points
                // 2. rangfrom is not null, and rangfrom <=points, and rangto is not null, rangto>points
                // 3. rangefrom is not null, and rangefrom <=points, and rangto is null
                if (!rule.RangeFrom.HasValue && rule.RangeTo.HasValue && rule.RangeTo > points)
                {
                    ratio = rule.Ratio.Value;
                    break;
                }
                if (rule.RangeFrom.HasValue && rule.RangeFrom <= points &&
                    (!rule.RangeTo.HasValue || (rule.RangeTo.HasValue && rule.RangeTo > points)))
                {
                    ratio = rule.Ratio.Value;
                    break;
                }
            }
            if (ratio <= 0)
            {
                throw new ApplicationException("规则设置有误!");
            }
            return(points / 100 * ratio);
        }
 public StorePromotionController(IStorePromotionRepository storepromotionRepo,
     IPointOrderRuleRepository ruleRepo,
     IStorePromotionScopeRepository scopeRepo)
 {
     _storepromotionRepo = storepromotionRepo;
     _scopeRepo = scopeRepo;
     _ruleRepo = ruleRepo;
 }
 public StorePromotionController(IStorePromotionRepository storepromotionRepo,
                                 IPointOrderRuleRepository ruleRepo,
                                 IStorePromotionScopeRepository scopeRepo)
 {
     _storepromotionRepo = storepromotionRepo;
     _scopeRepo          = scopeRepo;
     _ruleRepo           = ruleRepo;
 }