SP_RESULT StartAsync(Func <SP_RESULT> func) { SP_RESULT result = null; var perOrder = (APIRquestModel)OrderInfo.Clone(); var task = new Task(() => { if (IsEnd) { Thread.Sleep(10); } try { result = DoAsyncGetSpCmd(perOrder, func); } catch (Exception e) { WriteLog(e.ToString()); } finally { lock (this) { if (IsEnd) { IsAsync = false; FlushLog(); } } } }); task.Start(); if (IsEnd) { WriteLog("非用户请求数据"); return(null); } if (task.Wait(TimeToAsyc)) {//正常输出结果 return(result); } lock (this) { if (task.IsCompleted) { return(result); } this.EndTime = DateTime.Now; this.IsEnd = true; IsAsync = true; #if TDEBUG WriteLog("async start step=" + Step); #endif AddSOneFlag(); } return(new SP_RESULT()); }
public void Calculate(ref OrderInfo orderInfo) { Dictionary <string, OrderInfo> subOrderInfoList = new Dictionary <string, OrderInfo>(); #region 【 将加够商品合并至主商品 】 foreach (var plusPriceItem in orderInfo.PlusPriceItemList) { if (plusPriceItem.IsSelect) { orderInfo.OrderItemGroupList.Add(PlusPriceConvertToProduct(plusPriceItem, orderInfo.Customer.SysNo)); } } #endregion #region 【 先处理主商品 】 List <OrderProductItem> masterItemList = new List <OrderProductItem>(); if (orderInfo.OrderItemGroupList != null) { foreach (var itemGroup in orderInfo.OrderItemGroupList) { if (itemGroup.ProductItemList != null) { itemGroup.ProductItemList.ForEach(masterItem => { //将主商品拆分到最细粒度,即一个商品一个OrderProductItem for (int i = 0; i < masterItem.UnitQuantity * itemGroup.Quantity; i++) { OrderProductItem cloneItem = (OrderProductItem)masterItem.Clone(); cloneItem.UnitQuantity = 1; //设置商品上的套餐号和套餐类型,很别扭,先这样吧,下个项目再修改 at 【2014-08-08 13:25:43】 cloneItem["PackageNo"] = itemGroup.PackageNo; cloneItem["PackageType"] = itemGroup.PackageType; masterItemList.Add(cloneItem); } }); } } } //先初步按照 供应商+仓库+存储运输方式 拆分 Dictionary <string, List <OrderProductItem> > dicMasterItemPreSplitResult = GetMainItemSplitResult(masterItemList); Dictionary <string, List <OrderProductItem> > dicSubOrderMasterItemResult = new Dictionary <string, List <OrderProductItem> >(); //取得每单最大限制金额 Dictionary <string, decimal> maxPerOrderAmountConfig = GetMaxPerOrderAmountConfig(); foreach (var kvs in dicMasterItemPreSplitResult) { kvs.Value.Sort((item1, item2) => { return((item1.TotalSalePrice).CompareTo(item2.TotalSalePrice)); }); //单个订单金额拆分规则 string warehouseCountryCode = string.IsNullOrEmpty(kvs.Value[0].WarehouseCountryCode) ? string.Empty : kvs.Value[0].WarehouseCountryCode; decimal maxPerOrderAmount = decimal.MaxValue; if (maxPerOrderAmountConfig.ContainsKey(warehouseCountryCode.ToUpper().Trim())) { maxPerOrderAmount = maxPerOrderAmountConfig[warehouseCountryCode.ToUpper().Trim()]; } decimal shoppingItemPriceSum = 0; string thisKey = string.Empty; List <OrderProductItem> thisGroupMasterItemList = new List <OrderProductItem>(); //根据每单最大购买金额进行一次拆单 foreach (OrderProductItem masterItem in kvs.Value) { decimal currentItemAmtSum = masterItem.TotalSalePrice; //判断当前订单金额是否大于出库地区每单最大金额 if (shoppingItemPriceSum + currentItemAmtSum > maxPerOrderAmount) { //如果大于出库地区每单最大金额,并且主商品分组为空的话,那么当前单商品金额就已经超出 //最大购买金额,单商品自成一单 if (thisGroupMasterItemList.Count <= 0) { shoppingItemPriceSum = masterItem.TotalSalePrice; thisGroupMasterItemList.Add(masterItem); //根据订单金额重新计算一次key值 thisKey = GetSubOrderKey(kvs.Key, shoppingItemPriceSum, dicSubOrderMasterItemResult); dicSubOrderMasterItemResult[thisKey] = thisGroupMasterItemList; shoppingItemPriceSum = currentItemAmtSum; thisGroupMasterItemList = new List <OrderProductItem>(); } else { //主商品分组合并组成一个子单,清空之前的主商品分组,并且将当前主商品加入到分组中 //根据订单金额重新计算一次key值 thisKey = GetSubOrderKey(kvs.Key, shoppingItemPriceSum, dicSubOrderMasterItemResult); dicSubOrderMasterItemResult[thisKey] = thisGroupMasterItemList; shoppingItemPriceSum = currentItemAmtSum; thisGroupMasterItemList = new List <OrderProductItem>() { masterItem }; } } else { //金额没有超过最大购买金额,将当前主商品加入到分组中 shoppingItemPriceSum += masterItem.TotalSalePrice; thisGroupMasterItemList.Add(masterItem); } } //处理剩下的主商品分组,这些主商品组成一个子单 if (thisGroupMasterItemList.Count > 0) { thisKey = GetSubOrderKey(kvs.Key, shoppingItemPriceSum, dicSubOrderMasterItemResult); dicSubOrderMasterItemResult[thisKey] = thisGroupMasterItemList; } } foreach (var kvs in dicSubOrderMasterItemResult) { OrderInfo subOrderInfo = (OrderInfo)orderInfo.Clone(); //设置订单的默认出库仓 subOrderInfo["WarehouseNumber"] = kvs.Value.FirstOrDefault().WarehouseNumber; subOrderInfo["WarehouseName"] = kvs.Value.FirstOrDefault().WarehouseName; subOrderInfo["WarehouseCountryCode"] = kvs.Value.FirstOrDefault().WarehouseCountryCode; subOrderInfo["MerchantSysNo"] = kvs.Value.FirstOrDefault().MerchantSysNo; subOrderInfo["StoreType"] = kvs.Value.FirstOrDefault()["ProductStoreType"]; subOrderInfo.OrderItemGroupList = new List <OrderItemGroup>(); subOrderInfo.GiftItemList = new List <OrderGiftItem>(); subOrderInfo.AttachmentItemList = new List <OrderAttachment>(); OrderItemGroup itemGroup = new OrderItemGroup(); //商品在拆单后,购买行为上的分组失去意义,设置组上的购买数量为1,商品的上UnitQuantity及时真实的商品购买数量 itemGroup.Quantity = 1; itemGroup.ProductItemList = new List <OrderProductItem>(); kvs.Value.ForEach(masterItem => { //itemGroup.ProductItemList.Add(masterItem); //由于前面将主商品拆分到最细,这里需要将主商品合并 if (!itemGroup.ProductItemList.Exists(x => { if (x.ProductSysNo == masterItem.ProductSysNo) { x.UnitQuantity += masterItem.UnitQuantity; return(true); } return(false); })) { itemGroup.ProductItemList.Add(masterItem); } }); subOrderInfo.OrderItemGroupList.Add(itemGroup); subOrderInfoList.Add(kvs.Key, subOrderInfo); } #endregion #region 【 处理赠品和附件 】 List <OrderItem> giftAndAccessoryList = new List <OrderItem>(); if (orderInfo.GiftItemList != null) { orderInfo.GiftItemList.ForEach(gift => { if (!giftAndAccessoryList.Exists(g => { OrderGiftItem giftItem = (OrderGiftItem)g; //赠品合并增加一个赠品活动编号维度,客户端考虑对相同商品编号的赠品合并 if (giftItem.ProductSysNo == gift.ProductSysNo && giftItem.ActivityNo == gift.ActivityNo) { g.UnitQuantity += gift.UnitQuantity * gift.ParentCount; return(true); } return(false); })) { OrderGiftItem cloneGift = (OrderGiftItem)gift.Clone(); cloneGift.UnitQuantity = gift.UnitQuantity * gift.ParentCount; //合并后赠品的组数量失去意义,设置赠品的组购买数量为1 cloneGift.ParentCount = 1; giftAndAccessoryList.Add(cloneGift); } }); } if (orderInfo.AttachmentItemList != null) { orderInfo.AttachmentItemList.ForEach(attachment => { if (!giftAndAccessoryList.Exists(a => { if (a.ProductSysNo == attachment.ProductSysNo) { a.UnitQuantity += attachment.UnitQuantity * attachment.ParentCount; return(true); } return(false); })) { OrderAttachment cloneAttachment = (OrderAttachment)attachment.Clone(); cloneAttachment.UnitQuantity = attachment.UnitQuantity * attachment.ParentCount; //合并后附件的组数量失去意义,设置附件的组购买数量为1 cloneAttachment.ParentCount = 1; giftAndAccessoryList.Add(cloneAttachment); } }); } Dictionary <string, List <OrderItem> > dicGiftAndAccessorySplitResult = GetItemSplitResult(giftAndAccessoryList); //赠品和附件不会影响订单金额,将按照商家+仓库+存储运输方式拆好的单和前面主商品拆好的单进行合并 foreach (var kvs in dicGiftAndAccessorySplitResult) { OrderInfo theSubOrderInfo = null; //赠品(附件)在新的子单中 bool giftOrAccessoryInNewSubOrder = false; foreach (string thisKey in subOrderInfoList.Keys) { //thisKey:vendorSysno|warehouseNumber|storeType|amt-1....n string prefixKey = thisKey.Substring(0, thisKey.LastIndexOf('|')); prefixKey = prefixKey.Substring(0, prefixKey.LastIndexOf('|')); //kvs.Key: vendorSysno|warehouseNumber|storeType string newKey = kvs.Key.Substring(0, kvs.Key.LastIndexOf('|')); if (newKey.ToUpper().Trim() == prefixKey.ToUpper().Trim()) { theSubOrderInfo = subOrderInfoList[thisKey]; break; } } if (theSubOrderInfo == null) { giftOrAccessoryInNewSubOrder = true; theSubOrderInfo = (OrderInfo)orderInfo.Clone(); //设置订单的默认出库仓 theSubOrderInfo["WarehouseNumber"] = kvs.Value.FirstOrDefault().WarehouseNumber; theSubOrderInfo["WarehouseName"] = kvs.Value.FirstOrDefault().WarehouseName; theSubOrderInfo["WarehouseCountryCode"] = kvs.Value.FirstOrDefault().WarehouseCountryCode; theSubOrderInfo["MerchantSysNo"] = kvs.Value.FirstOrDefault().MerchantSysNo; theSubOrderInfo["StoreType"] = kvs.Value.FirstOrDefault()["ProductStoreType"]; theSubOrderInfo.OrderItemGroupList = new List <OrderItemGroup>(); theSubOrderInfo.GiftItemList = new List <OrderGiftItem>(); theSubOrderInfo.AttachmentItemList = new List <OrderAttachment>(); subOrderInfoList.Add(kvs.Key, theSubOrderInfo); } foreach (var orderItem in kvs.Value) { if (orderItem is OrderGiftItem) { OrderGiftItem giftItem = orderItem as OrderGiftItem; //Modified by PoseidonTong at [2014-08-11 12:33:01] //赠品在和主商品同仓的前提下,优先和关联的主商品拆在同一个订单 if (!giftOrAccessoryInNewSubOrder && giftItem.ParentProductSysNo > 0) { var giftMasterProductSubOrderInfos = subOrderInfoList.Select(_ => _.Value) .Where(x => x.OrderItemGroupList != null && x.OrderItemGroupList.Exists(y => y.ProductItemList != null && y.ProductItemList.Exists(p => p.ProductSysNo == giftItem.ParentProductSysNo) )); if (giftMasterProductSubOrderInfos.Count() > 0) { //取满足条件的第一个子单,考虑同一个主商品由于金额 //限制拆分成了多个子单的情况,这里将赠品放到第一个主单中 giftMasterProductSubOrderInfos.First().GiftItemList.Add(giftItem); continue; } } theSubOrderInfo.GiftItemList.Add(giftItem); } else if (orderItem is OrderAttachment) { OrderAttachment attrItem = orderItem as OrderAttachment; //Modified by PoseidonTong at [2014-08-11 12:33:01] //附件在和主商品同仓的前提下,优先和关联的主商品拆在同一个订单 if (!giftOrAccessoryInNewSubOrder && attrItem.ParentProductSysNo > 0) { var attMasterProductSubOrderInfos = subOrderInfoList.Select(_ => _.Value) .Where(x => x.OrderItemGroupList != null && x.OrderItemGroupList.Exists(y => y.ProductItemList != null && y.ProductItemList.Exists(p => p.ProductSysNo == attrItem.ParentProductSysNo) )); if (attMasterProductSubOrderInfos.Count() > 0) { //取满足条件的第一个子单,考虑同一个主商品由于金额 //限制拆分成了多个子单的情况,这里将附件放到第一个主单中 attMasterProductSubOrderInfos.First().AttachmentItemList.Add(attrItem); continue; } } theSubOrderInfo.AttachmentItemList.Add(attrItem); } } } #endregion #region 【 设置子单类型和商家模式 】 foreach (var kvs in subOrderInfoList) { OrderInfo subOrderInfo = kvs.Value; #region 设置商家模式 ECommerce.Entity.Product.VendorInfo vendorInfo = PipelineDA.GetVendorInfo((int)subOrderInfo["MerchantSysNo"]); subOrderInfo["ShippingType"] = vendorInfo.ShippingType; subOrderInfo["StockType"] = vendorInfo.StockType; subOrderInfo["InvoiceType"] = vendorInfo.InvoiceType; subOrderInfo["SellerType"] = vendorInfo.SellerType; subOrderInfo["VendorName"] = vendorInfo.VendorName; #endregion #region 设置子单类型 subOrderInfo.SOType = (int)SOType.Normal; ////团购商品不能和普通商品混合下单,所以只要订单中有团购商品,那么订单一定就是团购订单 //if (subOrderInfo.OrderItemGroupList != null) //{ // if (subOrderInfo.OrderItemGroupList.Exists(itemGroup => // { // if (itemGroup.ProductItemList != null) // { // return itemGroup.ProductItemList.Exists(product => // { // if (product.SpecialActivityType == 1 || product.SpecialActivityType == 3) // { // //记录下团购编号 // subOrderInfo["ReferenceSysNo"] = product.SpecialActivitySysNo; // return true; // } // return false; // }); // } // return false; // })) // { // subOrderInfo.SOType = (int)SOType.GroupBuy; // } // else // { // subOrderInfo.SOType = (int)SOType.Normal; // } //} //else //{ // subOrderInfo.SOType = (int)SOType.Normal; //} #endregion } #endregion orderInfo.SubOrderList = subOrderInfoList; }
private void InnerCalculate(KeyValuePair <string, OrderInfo> preSubOrderKVS, List <FreeShippingItemConfig> rules) { bool isMatchFreeShippingCharge = false; ECommerce.Entity.Area contactAddressInfo = null; OrderInfo preSubOrderInfo = preSubOrderKVS.Value; OrderInfo clonedPreSubOrderInfo = (OrderInfo)preSubOrderInfo.Clone(); //原运费 decimal ShippingPrice = preSubOrderInfo.ShippingAmount; //有效的免运费规则 string matchedRule = null; foreach (var rule in rules) { // 1. 检查是否满足金额条件限制 isMatchFreeShippingCharge = OrderAmtMatchedContext.GetContext(rule).IsMatched(preSubOrderInfo, rule); #region 2. 检查是否满足支付类型条件限制(旧逻辑现在不用) /* * if (isMatchFreeShippingCharge && !string.IsNullOrWhiteSpace(rule.PayTypeSettingValue)) * { * isMatchFreeShippingCharge = false; * * string[] setValues = rule.PayTypeSettingValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); * for (int i = 0; i < setValues.Length; i++) * { * if (setValues[i].Trim() == preSubOrderInfo.PayTypeID) * { * isMatchFreeShippingCharge = true; * break; * } * } * }*/ #endregion // 3. 检查是否满足配送区域条件限制 if (isMatchFreeShippingCharge && !string.IsNullOrWhiteSpace(rule.ShipAreaSettingValue)) { isMatchFreeShippingCharge = false; contactAddressInfo = ECommerce.DataAccess.Common.CommonDA.GetAreaBySysNo(preSubOrderInfo.Contact.AddressAreaID); if (contactAddressInfo != null && contactAddressInfo.ProvinceSysNo != null) { string[] setValues = rule.ShipAreaSettingValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < setValues.Length; i++) { if (setValues[i].Trim() == contactAddressInfo.ProvinceSysNo.ToString()) { isMatchFreeShippingCharge = true; break; } } } } //商品免运费数量 int ProductFreeNumber = 0; #region 排除免运费的商品 if (isMatchFreeShippingCharge && rule.ProductSettingValue != null && rule.ProductSettingValue.Count > 0) { isMatchFreeShippingCharge = false; if (clonedPreSubOrderInfo.OrderItemGroupList != null) { foreach (var itemGroup in clonedPreSubOrderInfo.OrderItemGroupList) { if (itemGroup.ProductItemList != null) { for (int i = itemGroup.ProductItemList.Count - 1; i >= 0; i--) { if (rule.ProductSettingValue.Exists(productSysNo => itemGroup.ProductItemList[i].ProductSysNo == productSysNo)) { isMatchFreeShippingCharge = true; itemGroup.ProductItemList.RemoveAt(i); ProductFreeNumber++; } } } } } if (clonedPreSubOrderInfo.GiftItemList != null) { for (int i = clonedPreSubOrderInfo.GiftItemList.Count - 1; i >= 0; i--) { if (rule.ProductSettingValue.Exists(productSysNo => clonedPreSubOrderInfo.GiftItemList[i].ProductSysNo == productSysNo)) { clonedPreSubOrderInfo.GiftItemList.RemoveAt(i); ProductFreeNumber++; } } } if (clonedPreSubOrderInfo.AttachmentItemList != null) { for (int i = clonedPreSubOrderInfo.AttachmentItemList.Count - 1; i >= 0; i--) { if (rule.ProductSettingValue.Exists(productSysNo => clonedPreSubOrderInfo.AttachmentItemList[i].ProductSysNo == productSysNo)) { clonedPreSubOrderInfo.AttachmentItemList.RemoveAt(i); ProductFreeNumber++; } } } } #endregion if (ProductFreeNumber > 0) { matchedRule += rule.ToXmlString() + ";"; } /* * //对同时满足门槛金额限制、支付类型限制、配送区域限制的子单重新计算运费(旧逻辑现在不用) * if (isMatchFreeShippingCharge) * { * CalcShippingAmount(preSubOrderKVS, rule); * //break; //旧逻辑 * } */ } //排除免运费商品后,子单中还剩下部分商品,计算这部分商品的运费作为本单运费 //fixbug: 在没有收货地址的情况下,如果订单满足免运费条件,此时ShippingFeeQueryInfo对象的AreaId=0,计算运费的sp进入某个特定分支后会报错 if (clonedPreSubOrderInfo.TotalItemCount > 0 && preSubOrderInfo.Contact.AddressAreaID > 0) //if (ProductFreeNumber <= 0 && preSubOrderInfo.Contact.AddressAreaID > 0 && clonedPreSubOrderInfo.TotalItemCount > 0) { List <ShippingFeeQueryInfo> qryList = new List <ShippingFeeQueryInfo>(); ShippingFeeQueryInfo qry = new ShippingFeeQueryInfo(); qry.TransID = preSubOrderKVS.Key; qry.SoAmount = clonedPreSubOrderInfo.TotalProductAmount; qry.SoTotalWeight = clonedPreSubOrderInfo.TotalWeight; qry.SOSingleMaxWeight = clonedPreSubOrderInfo.MaxWeight; qry.AreaId = preSubOrderInfo.Contact.AddressAreaID; qry.CustomerSysNo = preSubOrderInfo.Customer.SysNo; qry.IsUseDiscount = 0; qry.SubShipTypeList = preSubOrderInfo.ShipTypeID.ToString(); qry.SellType = Convert.ToInt32(preSubOrderInfo["SellerType"]); qry.MerchantSysNo = Convert.ToInt32(preSubOrderKVS.Key.Split('|')[0]); qry.ShipTypeId = 0; qryList.Add(qry); List <ShippingInfo> shipFeeList = PipelineDA.GetAllShippingFee(qryList); ShippingInfo curShippingInfo = shipFeeList.Find(x => x.TransID == preSubOrderKVS.Key && x.ShippingTypeID.ToString() == preSubOrderInfo.ShipTypeID); if (curShippingInfo != null) { preSubOrderInfo.ShippingAmount = curShippingInfo.ShippingPrice; //+curShippingInfo.ShippingPackageFee; } } else { //排除免运费商品后,子单中商品数量为0,免本单运费 preSubOrderInfo.ShippingAmount = 0m; } if (!string.IsNullOrWhiteSpace(matchedRule)) { preSubOrderInfo["FreeShippingChargeLog"] = string.Format("符合免运费规则:{0}\r\n,原运费为:{1:F2}元,减免后运费为:{2:F2}元", matchedRule.ToXmlString(), ShippingPrice, preSubOrderInfo.ShippingAmount); } }
private void CalcShippingAmount(KeyValuePair <string, OrderInfo> preSubOrderKVS, FreeShippingItemConfig matchedRule) { OrderInfo preSubOrderInfo = preSubOrderKVS.Value; OrderInfo clonedPreSubOrderInfo = (OrderInfo)preSubOrderInfo.Clone(); //主商品免运费数量 int ProductFreeNumber = 0; //全网模式,免本单运费 if (matchedRule.IsGlobal) { preSubOrderInfo.ShippingAmount = 0m; } else { //非全网模式,排除免运费的商品,计算剩下商品的运费 if (matchedRule.ProductSettingValue != null && matchedRule.ProductSettingValue.Count > 0) { #region 排除免运费的商品 if (clonedPreSubOrderInfo.OrderItemGroupList != null) { foreach (var itemGroup in clonedPreSubOrderInfo.OrderItemGroupList) { if (itemGroup.ProductItemList != null) { for (int i = itemGroup.ProductItemList.Count - 1; i >= 0; i--) { if (matchedRule.ProductSettingValue.Exists(productSysNo => itemGroup.ProductItemList[i].ProductSysNo == productSysNo)) { itemGroup.ProductItemList.RemoveAt(i); ProductFreeNumber++; } } } } } if (clonedPreSubOrderInfo.GiftItemList != null) { for (int i = clonedPreSubOrderInfo.GiftItemList.Count - 1; i >= 0; i--) { if (matchedRule.ProductSettingValue.Exists(productSysNo => clonedPreSubOrderInfo.GiftItemList[i].ProductSysNo == productSysNo)) { clonedPreSubOrderInfo.GiftItemList.RemoveAt(i); } } } if (clonedPreSubOrderInfo.AttachmentItemList != null) { for (int i = clonedPreSubOrderInfo.AttachmentItemList.Count - 1; i >= 0; i--) { if (matchedRule.ProductSettingValue.Exists(productSysNo => clonedPreSubOrderInfo.AttachmentItemList[i].ProductSysNo == productSysNo)) { clonedPreSubOrderInfo.AttachmentItemList.RemoveAt(i); } } } #endregion //排除免运费商品后,子单中还剩下部分商品,计算这部分商品的运费作为本单运费 //fixbug: 在没有收货地址的情况下,如果订单满足免运费条件,此时ShippingFeeQueryInfo对象的AreaId=0,计算运费的sp进入某个特定分支后会报错 if (clonedPreSubOrderInfo.TotalItemCount > 0 && preSubOrderInfo.Contact.AddressAreaID > 0) //if (ProductFreeNumber <= 0 && preSubOrderInfo.Contact.AddressAreaID > 0 && clonedPreSubOrderInfo.TotalItemCount > 0) { List <ShippingFeeQueryInfo> qryList = new List <ShippingFeeQueryInfo>(); ShippingFeeQueryInfo qry = new ShippingFeeQueryInfo(); qry.TransID = preSubOrderKVS.Key; qry.SoAmount = clonedPreSubOrderInfo.TotalProductAmount; qry.SoTotalWeight = clonedPreSubOrderInfo.TotalWeight; qry.SOSingleMaxWeight = clonedPreSubOrderInfo.MaxWeight; qry.AreaId = preSubOrderInfo.Contact.AddressAreaID; qry.CustomerSysNo = preSubOrderInfo.Customer.SysNo; qry.IsUseDiscount = 0; qry.SubShipTypeList = preSubOrderInfo.ShipTypeID.ToString(); qry.SellType = Convert.ToInt32(preSubOrderInfo["SellerType"]); qry.MerchantSysNo = Convert.ToInt32(preSubOrderKVS.Key.Split('|')[0]); qry.ShipTypeId = 0; qryList.Add(qry); List <ShippingInfo> shipFeeList = PipelineDA.GetAllShippingFee(qryList); ShippingInfo curShippingInfo = shipFeeList.Find(x => x.TransID == preSubOrderKVS.Key && x.ShippingTypeID.ToString() == preSubOrderInfo.ShipTypeID); if (curShippingInfo != null) { preSubOrderInfo.ShippingAmount = curShippingInfo.ShippingPrice; //+curShippingInfo.ShippingPackageFee; } } else { //排除免运费商品后,子单中商品数量为0,免本单运费 preSubOrderInfo.ShippingAmount = 0m; } } } preSubOrderInfo["FreeShippingChargeLog"] = string.Format("符合免运费规则:{0}\r\n,原运费为:{1:F2}元,减免后运费为:{2:F2}元", matchedRule.ToXmlString(), clonedPreSubOrderInfo.ShippingAmount, preSubOrderInfo.ShippingAmount); }