Esempio n. 1
0
        /// <summary>
        /// 特殊规则,混装规则里正好能装下的优先
        /// </summary>
        /// <param name="re"></param>
        /// <param name="ptid"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        private static int CompareMixRuleMinMaxQuantity(RuleEntity re, string ptid, int totalCount)
        {
            if (!re.MixRuleDic.ContainsKey(ptid))
            {
                return(-10);
            }
            var ret = 0;

            foreach (var pmre in re.MixRuleDic[ptid])
            {
                var ruleItems = pmre.GetRuleItemList(ptid);
                foreach (var ruleItem in ruleItems)
                {
                    if (ruleItem.MaxQuantity == totalCount && ruleItem.MinQuantity == totalCount)
                    {
                        return(10);
                    }
                    if (ret < 9 && ruleItem.MaxQuantity == totalCount)
                    {
                        ret = 9;
                    }
                    if (ret < 8 && ruleItem.MaxQuantity > totalCount)
                    {
                        ret = 8;
                    }
                }
            }
            return(ret);
        }
Esempio n. 2
0
 public ProductMixedRuleEntity(MixRule mixRule, RuleEntity rule)
 {
     this.Rule            = rule;
     this.MRId            = mixRule.MRId;
     this.LimitedQuantity = mixRule.LimitedQuantity;
     this.LimitedWeight   = (int)mixRule.LimitedWeight;
     this.TaxThreshold    = (decimal)mixRule.TaxThreshold;
     //this.TaxRate = (int)mixRule.TaxRate;
     this.LimitedMaxPrice  = (decimal)mixRule.LimitedMaxPrice;
     this.RuleItems        = mixRule.RuleItems;
     this.ruleItemLevelDic = this.RuleItems.ToDictionary(r => Tuple.Create(r.PTId, r.LevelName ?? string.Empty));
     this.ruleItemDic      = this.RuleItems.GroupBy(r => r.PTId).ToDictionary(g => g.Key, g => g.ToList());
 }