|
@ -667,95 +667,95 @@ namespace BBWYB.Server.Business |
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 采购商累计信息
|
|
|
//#region 采购商累计信息
|
|
|
{ |
|
|
//{
|
|
|
#region 采购SKU数
|
|
|
// #region 采购SKU数
|
|
|
var purchaserPurchasedList = fsql.Select<OrderPurchaseRelationInfo, Order, OrderPurchaseInfo>() |
|
|
// var purchaserPurchasedList = fsql.Select<OrderPurchaseRelationInfo, Order, OrderPurchaseInfo>()
|
|
|
.InnerJoin((opri, o, opi) => opri.OrderId == o.Id) |
|
|
// .InnerJoin((opri, o, opi) => opri.OrderId == o.Id)
|
|
|
.InnerJoin((opri, o, opi) => opi.OrderId == opri.OrderId && opi.IsEnabled == true) |
|
|
// .InnerJoin((opri, o, opi) => opi.OrderId == opri.OrderId && opi.IsEnabled == true)
|
|
|
.Where((opri, o, opi) => !noOrderStateList.Contains(o.OrderState) && o.ShopId != 11 && !string.IsNullOrEmpty(opi.PurchaserId)) |
|
|
// .Where((opri, o, opi) => !noOrderStateList.Contains(o.OrderState) && o.ShopId != 11 && !string.IsNullOrEmpty(opi.PurchaserId))
|
|
|
.GroupBy((opri, o, opi) => new { o.ShopId, opi.PurchaserId, opri.BelongSkuId }) |
|
|
// .GroupBy((opri, o, opi) => new { o.ShopId, opi.PurchaserId, opri.BelongSkuId })
|
|
|
.ToList(g => new |
|
|
// .ToList(g => new
|
|
|
{ |
|
|
// {
|
|
|
g.Key.ShopId, |
|
|
// g.Key.ShopId,
|
|
|
g.Key.PurchaserId, |
|
|
// g.Key.PurchaserId,
|
|
|
g.Key.BelongSkuId |
|
|
// g.Key.BelongSkuId
|
|
|
}); |
|
|
// });
|
|
|
|
|
|
|
|
|
var purchaserPurchasedGroups = purchaserPurchasedList.GroupBy(x => x.PurchaserId); |
|
|
// var purchaserPurchasedGroups = purchaserPurchasedList.GroupBy(x => x.PurchaserId);
|
|
|
foreach (var g in purchaserPurchasedGroups) |
|
|
// foreach (var g in purchaserPurchasedGroups)
|
|
|
{ |
|
|
// {
|
|
|
updatePurchaserList.Add(new Purchaser() |
|
|
// updatePurchaserList.Add(new Purchaser()
|
|
|
{ |
|
|
// {
|
|
|
Id = g.Key, |
|
|
// Id = g.Key,
|
|
|
PurchasedSkuCount = g.Count(), |
|
|
// PurchasedSkuCount = g.Count(),
|
|
|
PurchasedCount = 0 |
|
|
// PurchasedCount = 0
|
|
|
}); |
|
|
// });
|
|
|
insertSkuHistoryPurchaserRelationList.AddRange(g.Select(x => new SkuHistoryPurchaserRelation() |
|
|
// insertSkuHistoryPurchaserRelationList.AddRange(g.Select(x => new SkuHistoryPurchaserRelation()
|
|
|
{ |
|
|
// {
|
|
|
CreateTime = DateTime.Now, |
|
|
// CreateTime = DateTime.Now,
|
|
|
Id = idGenerator.NewLong(), |
|
|
// Id = idGenerator.NewLong(),
|
|
|
PurchaserId = x.PurchaserId, |
|
|
// PurchaserId = x.PurchaserId,
|
|
|
ShopId = x.ShopId, |
|
|
// ShopId = x.ShopId,
|
|
|
SkuId = x.BelongSkuId |
|
|
// SkuId = x.BelongSkuId
|
|
|
})); |
|
|
// }));
|
|
|
} |
|
|
// }
|
|
|
#endregion
|
|
|
// #endregion
|
|
|
|
|
|
|
|
|
#region 采购次数
|
|
|
// #region 采购次数
|
|
|
/* |
|
|
// /*
|
|
|
select opi.PurchaserId,count(DISTINCT(opi.OrderId)) from orderpurchaserelationinfo opri |
|
|
// select opi.PurchaserId,count(DISTINCT(opi.OrderId)) from orderpurchaserelationinfo opri
|
|
|
inner join `order` o on opri.OrderId=o.Id |
|
|
// inner join `order` o on opri.OrderId=o.Id
|
|
|
inner join orderpurchaseinfo opi on opi.OrderId=opri.OrderId and opi.IsEnabled=1 |
|
|
// inner join orderpurchaseinfo opi on opi.OrderId=opri.OrderId and opi.IsEnabled=1
|
|
|
where o.OrderState not in (0,6) and o.ShopId !=11 and opi.PurchaserId is not null |
|
|
// where o.OrderState not in (0,6) and o.ShopId !=11 and opi.PurchaserId is not null
|
|
|
group by opi.PurchaserId; |
|
|
// group by opi.PurchaserId;
|
|
|
*/ |
|
|
// */
|
|
|
var purchaserPurchasedCountList = fsql.Select<OrderPurchaseRelationInfo, Order, OrderPurchaseInfo>() |
|
|
// var purchaserPurchasedCountList = fsql.Select<OrderPurchaseRelationInfo, Order, OrderPurchaseInfo>()
|
|
|
.InnerJoin((opri, o, opi) => opri.OrderId == o.Id) |
|
|
// .InnerJoin((opri, o, opi) => opri.OrderId == o.Id)
|
|
|
.InnerJoin((opri, o, opi) => opi.OrderId == opri.OrderId && opi.IsEnabled == true) |
|
|
// .InnerJoin((opri, o, opi) => opi.OrderId == opri.OrderId && opi.IsEnabled == true)
|
|
|
.Where((opri, o, opi) => !noOrderStateList.Contains(o.OrderState) && o.ShopId != 11 && !string.IsNullOrEmpty(opi.PurchaserId)) |
|
|
// .Where((opri, o, opi) => !noOrderStateList.Contains(o.OrderState) && o.ShopId != 11 && !string.IsNullOrEmpty(opi.PurchaserId))
|
|
|
.GroupBy((opri, o, opi) => opi.PurchaserId) |
|
|
// .GroupBy((opri, o, opi) => opi.PurchaserId)
|
|
|
.ToList(g => new |
|
|
// .ToList(g => new
|
|
|
{ |
|
|
// {
|
|
|
PurchaserId = g.Key, |
|
|
// PurchaserId = g.Key,
|
|
|
//Count = g.Count(g.Value.Item3.OrderId.Distinct())
|
|
|
// //Count = g.Count(g.Value.Item3.OrderId.Distinct())
|
|
|
Count = SqlExt.DistinctCount(g.Value.Item3.OrderId) |
|
|
// Count = SqlExt.DistinctCount(g.Value.Item3.OrderId)
|
|
|
}); |
|
|
// });
|
|
|
|
|
|
|
|
|
foreach (var pcount in purchaserPurchasedCountList) |
|
|
// foreach (var pcount in purchaserPurchasedCountList)
|
|
|
{ |
|
|
// {
|
|
|
var p = updatePurchaserList.FirstOrDefault(x => x.Id == pcount.PurchaserId); |
|
|
// var p = updatePurchaserList.FirstOrDefault(x => x.Id == pcount.PurchaserId);
|
|
|
if (p == null) |
|
|
// if (p == null)
|
|
|
{ |
|
|
// {
|
|
|
p = new Purchaser() { Id = pcount.PurchaserId, PurchasedSkuCount = 0 }; |
|
|
// p = new Purchaser() { Id = pcount.PurchaserId, PurchasedSkuCount = 0 };
|
|
|
updatePurchaserList.Add(p); |
|
|
// updatePurchaserList.Add(p);
|
|
|
} |
|
|
// }
|
|
|
p.PurchasedCount = Convert.ToInt32(pcount.Count); |
|
|
// p.PurchasedCount = Convert.ToInt32(pcount.Count);
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
//var purchaserPurchasedCountDataTable = fsql.Ado.ExecuteDataTable(@"select opi.PurchaserId,count(DISTINCT(opi.OrderId)) from orderpurchaserelationinfo opri
|
|
|
// //var purchaserPurchasedCountDataTable = fsql.Ado.ExecuteDataTable(@"select opi.PurchaserId,count(DISTINCT(opi.OrderId)) from orderpurchaserelationinfo opri
|
|
|
// inner join `order` o on opri.OrderId = o.Id
|
|
|
// // inner join `order` o on opri.OrderId = o.Id
|
|
|
// inner join orderpurchaseinfo opi on opi.OrderId = opri.OrderId and opi.IsEnabled = 1
|
|
|
// // inner join orderpurchaseinfo opi on opi.OrderId = opri.OrderId and opi.IsEnabled = 1
|
|
|
// where o.OrderState not in (0, 6) and o.ShopId != 11 and opi.PurchaserId is not null
|
|
|
// // where o.OrderState not in (0, 6) and o.ShopId != 11 and opi.PurchaserId is not null
|
|
|
// group by opi.PurchaserId;");
|
|
|
// // group by opi.PurchaserId;");
|
|
|
|
|
|
|
|
|
//foreach (DataRow dataRow in purchaserPurchasedCountDataTable.Rows)
|
|
|
// //foreach (DataRow dataRow in purchaserPurchasedCountDataTable.Rows)
|
|
|
//{
|
|
|
// //{
|
|
|
// var purchaserId = dataRow[0].ToString();
|
|
|
// // var purchaserId = dataRow[0].ToString();
|
|
|
// var count = dataRow[1].ToInt32() ?? 0;
|
|
|
// // var count = dataRow[1].ToInt32() ?? 0;
|
|
|
|
|
|
|
|
|
// var p = updatePurchaserList.FirstOrDefault(x => x.Id == purchaserId);
|
|
|
// // var p = updatePurchaserList.FirstOrDefault(x => x.Id == purchaserId);
|
|
|
// if (p == null)
|
|
|
// // if (p == null)
|
|
|
// {
|
|
|
// // {
|
|
|
// p = new Purchaser() { Id = purchaserId, PurchasedSkuCount = 0 };
|
|
|
// // p = new Purchaser() { Id = purchaserId, PurchasedSkuCount = 0 };
|
|
|
// updatePurchaserList.Add(p);
|
|
|
// // updatePurchaserList.Add(p);
|
|
|
// }
|
|
|
// // }
|
|
|
// p.PurchasedCount = count;
|
|
|
// // p.PurchasedCount = count;
|
|
|
|
|
|
|
|
|
//}
|
|
|
// //}
|
|
|
#endregion
|
|
|
// #endregion
|
|
|
} |
|
|
//}
|
|
|
#endregion
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
fsql.Transaction(() => |
|
|
fsql.Transaction(() => |
|
|
{ |
|
|
{ |
|
@ -774,12 +774,12 @@ namespace BBWYB.Server.Business |
|
|
.Set(ps => ps.PurchasedAmount, updatePs.PurchasedAmount) |
|
|
.Set(ps => ps.PurchasedAmount, updatePs.PurchasedAmount) |
|
|
.ExecuteAffrows(); |
|
|
.ExecuteAffrows(); |
|
|
} |
|
|
} |
|
|
foreach (var updatePurchaser in updatePurchaserList) |
|
|
//foreach (var updatePurchaser in updatePurchaserList)
|
|
|
{ |
|
|
//{
|
|
|
fsql.Update<Purchaser>(updatePurchaser.Id).Set(p => p.PurchasedSkuCount, updatePurchaser.PurchasedSkuCount) |
|
|
// fsql.Update<Purchaser>(updatePurchaser.Id).Set(p => p.PurchasedSkuCount, updatePurchaser.PurchasedSkuCount)
|
|
|
.Set(p => p.PurchasedCount, updatePurchaser.PurchasedCount) |
|
|
// .Set(p => p.PurchasedCount, updatePurchaser.PurchasedCount)
|
|
|
.ExecuteAffrows(); |
|
|
// .ExecuteAffrows();
|
|
|
} |
|
|
//}
|
|
|
fsql.Insert(insertSpuSaleInfoList).ExecuteAffrows(); |
|
|
fsql.Insert(insertSpuSaleInfoList).ExecuteAffrows(); |
|
|
fsql.Insert(insertSkuSaleInfoList).ExecuteAffrows(); |
|
|
fsql.Insert(insertSkuSaleInfoList).ExecuteAffrows(); |
|
|
fsql.Insert(insertSkuHistoryPurchaserRelationList).ExecuteAffrows(); |
|
|
fsql.Insert(insertSkuHistoryPurchaserRelationList).ExecuteAffrows(); |
|
|