Ejemplo n.º 1
0
 public Spliter(IList <LogisticCacheDto> ownLogistics, IList <IList <LogisticRelatedOptionCacheDto> > relateds)
 {
     this.logistics        = ownLogistics.Select(o => new Logistic(o)).ToList();
     this.logisticsRelated = relateds.Select(o => new RelatedItem()
     {
         Logistics = o.Select(oi => oi.LogisticCode).ToList()
     }).ToList();
     this.splitConfig = new SplitConfig();
     splitConfig.Initialize(this.logistics.SelectMany(o => o.RuleSequenceDic.Select(oi => oi.Value)).ToList());
 }
Ejemplo n.º 2
0
        private Tuple <SplitedOrder, List <ProductEntity> > SplitOrderWithOrganization(string orderId, List <ProductEntity> productList, int totalQuantity, List <RuleEntity> ruleList)
        {
            // 指定物流时,此处传入的RuleEntity清单仅为该物流规则
            Debug.Assert(ruleList != null);
            var ruleOptions     = SplitConfig.GetRuleEntities(ruleList, productList);
            var splitResults    = ruleOptions.Select(rules => SplitOnce(SplitPackage.SplitV1.Common.Common.CloneProductEntityList(productList), rules, SplitPrinciple.LogisticsFirst)).ToList();
            var optimal         = splitResults.OrderBy(t => t.Item2 ? 0 : 1).ThenBy(t => t.Item1.CalculateLogisticsAndTaxCost()).FirstOrDefault();
            var result          = optimal != null ? optimal.Item1 : new SplitedOrder();
            var restProductList = optimal != null ? optimal.Item3 : productList;

            result.OrderId = orderId;
            return(Tuple.Create(result, restProductList));
        }