public override IEnumerable <AbsSynchroDataInfo> GetK3Datas(Context ctx, FormOperation oper = null) { DataBaseConst.K3CloudContext = ctx; List <DynamicObject> objs = null; if (GetDynamicObjects(ctx, oper) != null && GetDynamicObjects(ctx, oper).Count() > 0) { objs = GetDynamicObjects(ctx, oper).ToList(); } Material material = null; List <Material> materials = null; if (materials == null || materials.Count == 0) { if (objs != null && objs.Count > 0) { var group = from o in objs where !string.IsNullOrWhiteSpace(SQLUtils.GetFieldValue(o, "FNumber")) group o by o["FNumber"] into g select g; if (group != null && group.Count() > 0) { materials = new List <Material>(); foreach (var lst in group) { if (lst != null && lst.Count() > 0) { foreach (var mat in lst) { if (mat != null) { material = new Material(); material.F_HS_ListID = SQLUtils.GetFieldValue(mat, "F_HS_ListID"); material.F_HS_ListName = SQLUtils.GetFieldValue(mat, "F_HS_ListName"); string isConver = SQLUtils.GetFieldValue(mat, "F_HS_NotCoverMaterialName"); if (!string.IsNullOrWhiteSpace(isConver)) { material.F_HS_NotCoverMaterialName = isConver.Equals("0") ? false : true; } material.FNumber = SQLUtils.GetFieldValue(mat, "FNumber"); material.SrcNo = material.FNumber; material.F_HS_IsPuHuo = SQLUtils.GetFieldValue(mat, "F_HS_IsPuHuo"); material.F_HS_BatteryMod = SQLUtils.GetFieldValue(mat, "F_HS_BatteryMod"); material.F_HS_IsOil = SQLUtils.GetFieldValue(mat, "F_HS_IsOil"); material.F_HS_ProductLimitState = SQLUtils.GetFieldValue(mat, "F_HS_ProductLimitState"); material.FForbidStatus = SQLUtils.GetFieldValue(mat, "FForbidStatus"); material.FSaleUnitId = SQLUtils.GetFieldValue(mat, "FSaleUnitId"); material.F_HS_PRODUCTSTATUS = SQLUtils.GetFieldValue(mat, "F_HS_PRODUCTSTATUS"); material.F_HS_BrandNumber = SQLUtils.GetFieldValue(mat, "F_HS_BrandNumber"); material.F_HS_BrandName = SQLUtils.GetFieldValue(mat, "F_HS_BrandName"); material.F_HS_SKUGroupCode = SQLUtils.GetFieldValue(mat, "F_HS_SKUGroupCode"); material.FGROSSWEIGHT = Convert.ToDecimal(SQLUtils.GetFieldValue(mat, "FGROSSWEIGHT")); material.F_HS_IsOnSale = SQLUtils.GetFieldValue(mat, "F_HS_IsOnSale").CompareTo("1") == 0 ? true : false; material.F_HS_ProductSKU = SQLUtils.GetFieldValue(mat, "F_HS_ProductSKU"); material.F_HS_Specification1 = SQLUtils.GetFieldValue(mat, "F_HS_Specification1"); material.F_HS_Specification2 = SQLUtils.GetFieldValue(mat, "F_HS_Specification2"); material.F_HS_ExtraPercentage = Convert.ToDecimal(SQLUtils.GetFieldValue(mat, "F_HS_ExtraPercentage")); material.F_HS_ExtraCommissionCountry = SQLUtils.GetFieldValue(mat, "F_HS_ExtraCommissionCountry"); material.F_HS_BasePrice = Convert.ToDecimal(SQLUtils.GetFieldValue(mat, "F_HS_BasePrice")); material.F_HS_BasePriceCountry = SQLUtils.GetFieldValue(mat, "F_HS_BasePriceCountry"); material.F_HS_FreeMailMod = SQLUtils.GetFieldValue(objs.ElementAt(0), "F_HS_FreeMailMod").Equals("1") ? true : false; material.F_HS_MinSalesNum = Convert.ToInt32(SQLUtils.GetFieldValue(mat, "F_HS_MinSalesNum")); material.F_HS_MaxSalesNum = Convert.ToInt32(SQLUtils.GetFieldValue(mat, "F_HS_MaxSalesNum")); material.F_HS_TouristPrice = Convert.ToDecimal(SQLUtils.GetFieldValue(mat, "F_HS_TouristPrice")); material.F_HS_YNZeroMgSmokeOil = SQLUtils.GetFieldValue(mat, "F_HS_YNZeroMgSmokeOil").Equals("1") ? true : false; material.F_HS_ISCanTogetherPureBT = SQLUtils.GetFieldValue(mat, "F_HS_ISCanTogetherPureBT").Equals("1") ? true : false; material.FDocumentStatus = SQLUtils.GetFieldValue(mat, "FDocumentStatus"); material.FForbidStatus = SQLUtils.GetFieldValue(mat, "FForbidStatus"); material.F_HS_YNHomePageMarkup = SQLUtils.GetFieldValue(mat, "F_HS_YNHomePageMarkup").Equals("1")?true:false; materials.Add(material); } } } } } } } if (materials != null && materials.Count > 0) { string prefix = SQLUtils.GetAUB2BDropShipOrderPrefix(ctx); if (this.Direction == SynchroDirection.ToB2B) { // 1.2 物料同步数据过滤:物料为物料.液体属性=="非液体" 且 物料.商品状态<>"停产" 或 len(物料编码)==12 且 right(物料编码,2)==客户.dropship订单前缀 return(materials.Where(m => !string.IsNullOrWhiteSpace(m.FNumber) && !string.IsNullOrWhiteSpace(m.F_HS_IsOil) && (m.F_HS_IsOil.Equals("3") && (!m.F_HS_PRODUCTSTATUS.Equals("SPTC")) || (m.FNumber.Length == 13 && m.FNumber.Substring(m.FNumber.Length - 3, 3).Equals(prefix))) )); } else { return(materials.Where(m => !string.IsNullOrWhiteSpace(m.FNumber) && !m.FNumber.Substring(m.FNumber.Length - 3, 3).Equals(prefix) )); } } return(null); }
/// <summary> /// 调价单明细 /// </summary> /// <param name="ctx"></param> /// <param name="obj"></param> /// <returns></returns> private List <K3BatchAdjustEntry> GetK3BatchAdjustEntry(Context ctx, DynamicObject obj) { DynamicObjectCollection coll = obj["SAL_BATCHADJUSTENTRY"] as DynamicObjectCollection; K3BatchAdjustEntry entry = null; List <K3BatchAdjustEntry> entrys = null; if (entrys == null || entrys.Count == 0) { if (coll != null && coll.Count > 0) { entrys = new List <K3BatchAdjustEntry>(); foreach (var item in coll) { if (item != null) { bool entryInSync = Convert.ToBoolean(SQLUtils.GetFieldValue(item, "F_HS_YNEntryInSync")); if (!entryInSync) { entry = new K3BatchAdjustEntry(); entry.FEntryId = Convert.ToInt32(SQLUtils.GetFieldValue(item, "Id")); entry.FAdjustType = SQLUtils.GetFieldValue(item, "AdjustType"); entry.FAfterPrice = SQLUtils.GetFieldValue(item, "AfterPrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "AfterPrice"); DynamicObject price = item["PriceListId"] as DynamicObject; entry.FPriceListId = SQLUtils.GetFieldValue(price, "Number"); entry.FPriceLevel = SQLUtils.GetFieldValue(price, "Name"); DynamicObject currency = price["CurrencyId"] as DynamicObject; entry.FCurrencyId = SQLUtils.GetFieldValue(currency, "Number"); DynamicObject material = item["MaterialId"] as DynamicObject; entry.FMaterialId = SQLUtils.GetFieldValue(material, "Number"); if (this.Direction == SynchroDirection.ToB2B) { Material mat = SQLUtils.GetMaterial(ctx, entry.FMaterialId); if (mat != null) { entry.F_HS_IsOil = mat.F_HS_IsOil; entry.F_HS_PRODUCTSTATUS = mat.F_HS_PRODUCTSTATUS; entry.F_HS_DropShipOrderPrefix = mat.F_HS_DropShipOrderPrefix; } } entry.FAfterEffDate = Convert.ToDateTime(SQLUtils.GetFieldValue(item, "AfterEffDate")).ToString("yyyy-MM-dd"); entry.FAfterUnEffDate = Convert.ToDateTime(SQLUtils.GetFieldValue(item, "AfterUnEffDate")).ToString("yyyy-MM-dd");; DynamicObject plst = item["PriceListId"] as DynamicObject; entry.F_HS_YNSpecialPrice = Convert.ToBoolean(SQLUtils.GetFieldValue(plst, "F_HS_YNSpecialPrice")); entry.F_HS_YNEntryInSync = entryInSync; if (!entry.F_HS_YNSpecialPrice) { //如果批量调价单调的特价价目表,则忽略调后美国包邮单价、调后澳洲包邮单价、调后美国不包邮单价、调后澳洲不包邮单价、调后欧洲单价的同步 entry.F_HS_AfterUSPrice = SQLUtils.GetFieldValue(item, "F_HS_AfterUSPrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterUSPrice"); entry.F_HS_AfterAUPrice = SQLUtils.GetFieldValue(item, "F_HS_AfterAUPrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterAUPrice"); entry.F_HS_AfterEUPrice = SQLUtils.GetFieldValue(item, "F_HS_AfterEUPrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterEUPrice"); entry.F_HS_AfterUSNoPostagePrice = SQLUtils.GetFieldValue(item, "F_HS_AfterUSNoPostagePrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterUSNoPostagePrice"); entry.F_HS_AfterAUNoPostagePrice = SQLUtils.GetFieldValue(item, "F_HS_AfterAUNoPostagePrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterAUNoPostagePrice"); entry.F_HS_AfterJPNoPostagePrice = SQLUtils.GetFieldValue(item, "F_HS_AfterJPNoPostagePrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterJPNoPostagePrice"); entry.F_HS_AfterKRNoPostagePrice = SQLUtils.GetFieldValue(item, "F_HS_AfterKRNoPostagePrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterKRNoPostagePrice"); entry.F_HS_AfterUKNoPostagePrice = SQLUtils.GetFieldValue(item, "F_HS_AfterUKNoPostagePrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterUKNoPostagePrice"); entry.F_HS_AfterDENoPostagePrice = SQLUtils.GetFieldValue(item, "F_HS_AfterDENoPostagePrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterDENoPostagePrice"); entry.F_HS_AfterFRNoPostagePrice = SQLUtils.GetFieldValue(item, "F_HS_AfterFRNoPostagePrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterFRNoPostagePrice"); entry.F_HS_AfterEUNoPostagePrice = SQLUtils.GetFieldValue(item, "F_HS_AfterEUNoPostagePrice").Equals("0") ? "" : SQLUtils.GetFieldValue(item, "F_HS_AfterEUNoPostagePrice"); double diffDate = GetDiffDate(DateTime.Now, Convert.ToDateTime(entry.FAfterUnEffDate)); if (diffDate >= 50) { entrys.Add(entry); } } else { entrys.Add(entry); } } } } } } if (entrys != null && entrys.Count > 0) { string prefix = SQLUtils.GetAUB2BDropShipOrderPrefix(ctx); if (this.Direction == SynchroDirection.ToB2B) { return(entrys.Where(m => m != null && !string.IsNullOrWhiteSpace(m.F_HS_IsOil) && ((!m.F_HS_PRODUCTSTATUS.Equals("SPTC") && m.F_HS_IsOil.Equals("3")) || (m.FMaterialId.Length == 13 && m.FMaterialId.Substring(m.FMaterialId.Length - 3, 3).Equals(prefix))) ).ToList()); } else { return(entrys.Where(m => m != null && !m.FMaterialId.Substring(m.FMaterialId.Length - 3, 3).Equals(prefix) ).ToList()); } } return(null); }