Commit edbfc33d authored by 吴春's avatar 吴春

提交代码,分销排行

parent d9db5492
...@@ -522,52 +522,59 @@ WHERE u.TenantId={tenantId} and u.MallBaseId={mallBaseId} and u.SuperiorId ={use ...@@ -522,52 +522,59 @@ WHERE u.TenantId={tenantId} and u.MallBaseId={mallBaseId} and u.SuperiorId ={use
/// <returns></returns> /// <returns></returns>
public List<RB_Member_User_Extend> GetRankingListPage(int pageIndex, int pageSize, out long rowCount, RB_Member_User_Extend dmodel) public List<RB_Member_User_Extend> GetRankingListPage(int pageIndex, int pageSize, out long rowCount, RB_Member_User_Extend dmodel)
{ {
string where = " 1=1 "; string where = " where 1=1 ";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
where += $@" and {nameof(RB_Member_User.TenantId)}={dmodel.TenantId}"; where += $@" and a.{nameof(RB_Member_User.TenantId)}={dmodel.TenantId}";
} }
if (dmodel.MallBaseId > 0) if (dmodel.MallBaseId > 0)
{ {
where += $@" and {nameof(RB_Member_User.MallBaseId)}={dmodel.MallBaseId}"; where += $@" and a.{nameof(RB_Member_User.MallBaseId)}={dmodel.MallBaseId}";
} }
if (!string.IsNullOrEmpty(dmodel.Name)) if (!string.IsNullOrEmpty(dmodel.Name))
{ {
where += $@" and ({nameof(RB_Member_User.Name)} like '%{dmodel.Name}%' or {nameof(RB_Member_User.Id)} like '%{dmodel.Name}%')"; where += $@" and (a.{nameof(RB_Member_User.Name)} like '%{dmodel.Name}%' or a.{nameof(RB_Member_User.Id)} like '%{dmodel.Name}%')";
} }
if (!string.IsNullOrEmpty(dmodel.AliasName)) if (!string.IsNullOrEmpty(dmodel.AliasName))
{ {
where += $@" and {nameof(RB_Member_User.AliasName)} like '%{dmodel.AliasName}%'"; where += $@" and a.{nameof(RB_Member_User.AliasName)} like '%{dmodel.AliasName}%'";
} }
if (dmodel.Source > 0) if (dmodel.Source > 0)
{ {
where += $@" and {nameof(RB_Member_User.Source)} ={(int)dmodel.Source}"; where += $@" and a.{nameof(RB_Member_User.Source)} ={(int)dmodel.Source}";
} }
if (!string.IsNullOrEmpty(dmodel.Moblie)) if (!string.IsNullOrEmpty(dmodel.Moblie))
{ {
where += $@" and {nameof(RB_Member_User.Moblie)} like '%{dmodel.Moblie}%'"; where += $@" and a.{nameof(RB_Member_User.Moblie)} like '%{dmodel.Moblie}%'";
} }
if (dmodel.MemberGrade > 0) if (dmodel.MemberGrade > 0)
{ {
where += $@" and {nameof(RB_Member_User.MemberGrade)}={dmodel.MemberGrade}"; where += $@" and a.{nameof(RB_Member_User.MemberGrade)}={dmodel.MemberGrade}";
} }
if (dmodel.SuperiorId > 0) if (dmodel.SuperiorId > 0)
{ {
where += $@" and {nameof(RB_Member_User.SuperiorId)}={dmodel.SuperiorId}"; where += $@" and a.{nameof(RB_Member_User.SuperiorId)}={dmodel.SuperiorId}";
} }
if (string.IsNullOrWhiteSpace(dmodel.OrderBy)) if (string.IsNullOrWhiteSpace(dmodel.OrderBy))
{ {
dmodel.OrderBy = " Id asc"; dmodel.OrderBy = " Id asc";
} }
string sql = $@" select * from ( SELECT a.Id,a.Source,a.`Name`,a.AliasName,a.Photo, b.TotalCommission,b.Price,c.Commission,d.ChildrenNum, string sql = $@" select * from ( SELECT a.Id,a.Source,a.`Name`,a.AliasName,a.Photo, b.TotalCommission,b.Price,c.Commission,d.ChildrenNum,e.twoChildren,f.ThreeChildren,g.AllOrderNum,
0 as AllChildrenNum , (IFNULL(d.ChildrenNum,0)+IFNULL(e.twoChildren,0)+IFNULL(f.ThreeChildren,0)) as AllChildrenNum
0 as OrderNum
from rb_member_user as a from rb_member_user as a
LEFT JOIN (SELECT UserId,MAX(TotalCommission) as TotalCommission,SUM(IFNULL(TotalCommission,0)-IFNULL(CommissionWithdrawal,0)) as Price from rb_distributor_info GROUP BY UserId) as b on a.Id=b.UserId LEFT JOIN (SELECT UserId,MAX(TotalCommission) as TotalCommission,SUM(IFNULL(TotalCommission,0)-IFNULL(CommissionWithdrawal,0)) as Price from rb_distributor_info
GROUP BY UserId) as b on a.Id=b.UserId
LEFT JOIN LEFT JOIN
(SELECT goc.UserId,SUM(Commission) as Commission from rb_goods_ordercommission as goc (SELECT goc.UserId,SUM(Commission) as Commission from rb_goods_ordercommission as goc
LEFT JOIN rb_goods_order go on goc.OrderId=go.OrderId where go.OrderStatus!=7 GROUP BY goc.UserId) as c on a.Id=c.UserId LEFT JOIN rb_goods_order go on goc.OrderId=go.OrderId where go.OrderStatus!=7 GROUP BY goc.UserId) as c on a.Id=c.UserId
LEFT JOIN (SELECT SuperiorId,COUNT(SuperiorId) as ChildrenNum from rb_member_user GROUP BY SuperiorId) as d on d.SuperiorId=a.Id) as t order by {dmodel.OrderBy} "; LEFT JOIN (SELECT SuperiorId,COUNT(SuperiorId) as ChildrenNum from rb_member_user GROUP BY SuperiorId) as d on d.SuperiorId=a.Id
LEFT JOIN (SELECT COUNT(u1.Id) as twoChildren,u.SuperiorId FROM rb_member_user u
INNER JOIN rb_member_user u1 on u.Id=u1.SuperiorId GROUP BY u.SuperiorId ) as e on e.SuperiorId=a.Id
LEFT JOIN (SELECT COUNT(u2.Id) as ThreeChildren,u.SuperiorId FROM rb_member_user u
INNER JOIN rb_member_user u1 on u.Id=u1.SuperiorId
INNER JOIN rb_member_user u2 on u1.Id=u2.SuperiorId GROUP BY u.SuperiorId ) as f on f.SuperiorId=a.Id
LEFT JOIN (SELECT UserId,COUNT(OrderId) as AllOrderNum from rb_goods_ordercommission GROUP BY UserId) as g on g.UserId=a.Id {where} ) as t
order by {dmodel.OrderBy} ";
return GetPage<RB_Member_User_Extend>(pageIndex, pageSize, out rowCount, sql).ToList(); return GetPage<RB_Member_User_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
} }
......
...@@ -2076,7 +2076,7 @@ namespace Mall.WebApi.Controllers.User ...@@ -2076,7 +2076,7 @@ namespace Mall.WebApi.Controllers.User
pagelist.pageData = list.Select(x => new pagelist.pageData = list.Select(x => new
{ {
x.Id, x.Id,
x.AliasName, AliasName= x.Name,
x.Photo, x.Photo,
x.Price, x.Price,
x.Source, x.Source,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment