private void WriteLog() { string subSONoList = string.Join("," , SubSOList.Select(item => item.SysNo.ToString()).ToArray()); string logContent = ResourceHelper.Get("Res_SO_Split_Success", CurrentSO.SysNo, subSONoList); base.WriteLog(ECCentral.BizEntity.Common.BizLogType.Sale_SO_Update, logContent); }
/// <summary> /// 拆分当前订单 /// </summary> private void SplitCurrentSO() { #region 拆分订单 List <SOItemInfo> couponList = new List <SOItemInfo>(); //订单使用的优惠券 List <SOItemInfo> extendWarrentyList = new List <SOItemInfo>(); //订单的所有延保 List <int> stockSysNoList = new List <int>(); CurrentSO.Items.ForEach(item => { switch (item.ProductType.Value) { case SOProductType.Product: case SOProductType.Gift: case SOProductType.Award: case SOProductType.Accessory: case SOProductType.SelfGift: { if (!stockSysNoList.Exists(stockSysNo => { return(stockSysNo == item.StockSysNo && item.StockSysNo != null); })) { stockSysNoList.Add(item.StockSysNo.Value); } break; } case SOProductType.Coupon: couponList.Add(item); break; case SOProductType.ExtendWarranty: extendWarrentyList.Add(item); break; } }); if (stockSysNoList.Count < 2) { BizExceptionHelper.Throw("SO_Split_NotSplit"); return; } foreach (int stockSysNo in stockSysNoList) { SOInfo soInfo = CreateSubSO(); //取得子订单的商品 soInfo.Items = SerializationUtility.DeepClone <List <SOItemInfo> >(CurrentSO.Items.FindAll(item => item.StockSysNo == stockSysNo)); //修改ItemsExtenstion if (soInfo.Items != null && soInfo.Items.Count > 0) { foreach (var item in soInfo.Items) { if (item.ItemExtList != null && item.ItemExtList.Count > 0) { item.ItemExtList.ForEach(x => { x.SOSysNo = soInfo.SysNo.Value; }); } } } //添加优惠券到每个仓库 if (couponList != null && couponList.Count > 0) { soInfo.Items.AddRange(SerializationUtility.DeepClone(couponList)); } //延保跟随主商品 extendWarrentyList.ForEach(item => { if (soInfo.Items.Exists(o => o.ProductSysNo == int.Parse(item.MasterProductSysNo))) { soInfo.Items.Add(SerializationUtility.DeepClone <SOItemInfo>(item)); } }); //计算总金额 soInfo.BaseInfo.SOAmount = UtilityHelper.ToMoney(soInfo.Items.Sum <SOItemInfo>(item => { if (item.ProductType == SOProductType.Product || item.ProductType == SOProductType.ExtendWarranty) { return(item.OriginalPrice.Value * item.Quantity.Value); } return(0); })); //soInfo.ShippingInfo.DeliveryFrequency = SetDeliveryType(soInfo);//设置订单的配置频率 SetSOCCheckShippingSettlementStatus(soInfo); SubSOList.Add(soInfo); } #endregion }