Exemple #1
0
        //计算物流费用
        private decimal GetFreight(int freightTemplateId, List <OrderItemInfo> orderItemList, int cityId)
        {
            IFreightTemplateService freightTemplateService = ServiceHelper.Create <IFreightTemplateService>();
            decimal freight2 = 0;

            foreach (var orderItem in orderItemList)
            {
                FreightTemplateInfo freightTemplate = freightTemplateService.GetFreightTemplate(freightTemplateId);
                if (freightTemplate == null || freightTemplate.IsFree != FreightTemplateInfo.FreightTemplateType.SelfDefine)
                {
                    continue;
                }
                FreightAreaContentInfo freightAreaContentInfo = (
                    from item in freightTemplate.ChemCloud_FreightAreaContent
                    where item.AreaContent.Split(new char[] { ',' }).Contains <string>(cityId.ToString())
                    select item).FirstOrDefault() ?? freightTemplate.ChemCloud_FreightAreaContent.Where((FreightAreaContentInfo item) =>
                {
                    byte?isDefault = item.IsDefault;
                    if (isDefault.GetValueOrDefault() != 1)
                    {
                        return(false);
                    }
                    return(isDefault.HasValue);
                }).FirstOrDefault();
                if (freightTemplate.ValuationMethod == FreightTemplateInfo.ValuationMethodType.Weight)
                {
                    int     value  = freightAreaContentInfo.FirstUnit.Value;
                    decimal value1 = (decimal)freightAreaContentInfo.FirstUnitMonry.Value;
                    int     value2 = freightAreaContentInfo.AccumulationUnit.Value;
                    float?  accumulationUnitMoney = freightAreaContentInfo.AccumulationUnitMoney;
                    freight2 = freight2 + GetFreight2(orderItem.Quantity, value, value1, value2, (decimal)accumulationUnitMoney.Value);
                }
                else if (freightTemplate.ValuationMethod != FreightTemplateInfo.ValuationMethodType.Bulk)
                {
                    int     num4     = Convert.ToInt32(orderItem.Quantity);
                    decimal num5     = num4;
                    int     value3   = freightAreaContentInfo.FirstUnit.Value;
                    decimal value4   = (decimal)freightAreaContentInfo.FirstUnitMonry.Value;
                    int     value5   = freightAreaContentInfo.AccumulationUnit.Value;
                    float?  nullable = freightAreaContentInfo.AccumulationUnitMoney;
                    freight2 = freight2 + GetFreight2(num5, value3, value4, value5, (decimal)nullable.Value);
                }
                else
                {
                    decimal num6   = Convert.ToInt32(orderItem.Quantity);
                    int     value6 = freightAreaContentInfo.FirstUnit.Value;
                    decimal value7 = (decimal)freightAreaContentInfo.FirstUnitMonry.Value;
                    int     num7   = freightAreaContentInfo.AccumulationUnit.Value;
                    float?  accumulationUnitMoney1 = freightAreaContentInfo.AccumulationUnitMoney;
                    freight2 = freight2 + GetFreight2(num6, value6, value7, num7, (decimal)accumulationUnitMoney1.Value);
                }
            }

            return(freight2);
        }
 public PortfolioBuyController(IShopService iShopService, IVShopService iVShopService, IProductService iProductService,
                               ICashDepositsService iCashDepositsService, IFreightTemplateService iFreightTemplateService, IRegionService iRegionService
                               )
 {
     _iShopService            = iShopService;
     _iVShopService           = iVShopService;
     _iProductService         = iProductService;
     _iCashDepositsService    = iCashDepositsService;
     _iFreightTemplateService = iFreightTemplateService;
     _iRegionService          = iRegionService;
 }