Beispiel #1
0
 /// <summary>
 /// 初始化商品拆单规则,构建以商品ID为Key,拆单规则对象为Value的字典
 /// 其中专线的Value为单个对象,
 ///     混装的Value为集合,对应一类商品可以和多类不同商品混装的情况
 /// </summary>
 private void InitSplitRule()
 {
     if (this.Rule == null)
     {
         return;
     }
     if (this.Rule.MixRule != null)
     {
         foreach (var mixRule in this.Rule.MixRule)
         {
             var pmre = new ProductMixedRuleEntity(mixRule, this);
             foreach (var ruleItem in mixRule.RuleItems)
             {
                 //循环混装规则中的商品ID(PTId)
                 if (MixRuleDic.ContainsKey(ruleItem.PTId))
                 {
                     MixRuleDic[ruleItem.PTId].Add(pmre);
                 }
                 else
                 {
                     var pmreList = new List <ProductMixedRuleEntity>();
                     pmreList.Add(pmre);
                     MixRuleDic.Add(ruleItem.PTId, pmreList);
                 }
                 // 将商品规则添加到商品规则字典中
                 if (pRuleDic.ContainsKey(ruleItem.PTId.ToString()))
                 {
                     pRuleDic[ruleItem.PTId.ToString()].Add(pmre);
                 }
                 else
                 {
                     var ipmrelist = new List <IProductRuleEntity>();
                     ipmrelist.Add(pmre);
                     pRuleDic.Add(ruleItem.PTId.ToString(), ipmrelist);
                 }
             }
         }
     }
 }
Beispiel #2
0
 private static bool IsValid(ProductMixedRuleEntity pmre, List <string> ptids)
 {
     return((ptids != null && ptids.Count > 0) ? pmre.CanSupportPTId(ptids) : true);
 }