public object GetMyRelation()
{
var list = new List<object>();
int directCount = 0, totalCount = 0, otherCount = 0, reward = 0;
DbConnectionManipulator.RunMainDatabase(conn =>
{
//直接好友
var directList = conn.Query<Member>("select Id,Mobile,CreateTime from Member where PromoCode = @ID", new { ID = UserContext.GetMemberId() }).ToList();
//间接好友
int sumcount = 0;
foreach(var model in directList)
{
if (model == null) continue;
var count = conn.QueryFirstOrDefault<int>("select count(1) from Member where PromoCode = @ID", new { ID = model.Id });
sumcount += count;
list.Add(new
{
Id = model.Id,
Mobile = model.Mobile,
CreateTime = model.CreateTime,
Count = count
});
}
reward = conn.QueryFirstOrDefault<int>("select RewardIntegral from IntegralList where MemberId = @MemberId", new { MemberId = UserContext.GetMemberId() });
directCount = directList.Count;
totalCount = sumcount + directCount;
otherCount = sumcount;
});
return new
{
list,
directCount,
totalCount,
otherCount,
reward
};
}