public static QiangGouModel FetchNeedExamQiangGouAndProducts(Guid aid) { try { var dt = DALQiangGou.FetchNeedExamQiangGouAndProducts(aid); if (dt == null || dt.Rows.Count == 0) { return(null); } var model = dt.ConvertTo <QiangGouModel>()?.FirstOrDefault() ?? new QiangGouModel(); //var products = dt.ConvertTo<QiangGouProductModel>(); var pids = dt.ConvertTo <QiangGouProductModel>().Select(r => r.PID).ToList(); var costPriceSql = DALQiangGou.SelectProductCostPriceByPids(pids); var products = from a in dt.ConvertTo <QiangGouProductModel>() join b in costPriceSql on a.PID equals b.PID into temp from b in temp.DefaultIfEmpty() select new QiangGouProductModel { PKID = a.PKID, ActivityID = a.ActivityID, ActivityName = a.ActivityName, PID = a.PID, HashKey = a.HashKey, Price = a.Price, TotalQuantity = a.TotalQuantity, MaxQuantity = a.MaxQuantity, SaleOutQuantity = a.SaleOutQuantity, InstallAndPay = a.InstallAndPay, IsUsePCode = a.IsUsePCode, Channel = a.Channel, IsJoinPlace = a.IsJoinPlace, FalseOriginalPrice = a.FalseOriginalPrice, DisplayName = a.DisplayName, OriginalPrice = a.OriginalPrice, ProductName = a.ProductName, Label = a.Label, CostPrice = b?.CostPrice, Position = a.Position, IsShow = a.IsShow, InstallService = a.InstallService, DecreaseDegree = a.OriginalPrice == 0 ? "0" : (Math.Round((a.OriginalPrice - a.Price) / a.OriginalPrice, 2) * 100) + "%" }; model.Products = products; return(model); } catch (Exception ex) { Logger.Log(Level.Error, $"审核查询数据失败==》{ex}-{ex.InnerException}-{ex.StackTrace}"); return(new QiangGouModel()); } }