@@ -1096,6 +1097,7 @@ LEFT JOIN (SELECT SuperiorId,COUNT(SuperiorId) as ChildrenNum from rb_member_use
#endregion
#region其他模块
/// <summary>
/// 获取用户佣金
...
...
@@ -1696,7 +1698,123 @@ FROM RB_Member_User AS a LEFT JOIN rb_miai_baseinfo AS b ON a.Id = b.UserId) as
stringsql=$@"select a.*,b.StudentId from RB_Member_User as a LEFT JOIN rb_education_baseinfo as b on a.Id=b.UserId and b.`Status`=0 where {where} order by {orderBy} ";
stringsql=$@"SELECT u.Id,u.`Name`,i.TotalCommission AS TotalCommission,
IFNULL(tt.Num,0) + IFNULL(nt.Num,0) AS AllOrderNum,
IFNULL(tt.Income,0) + IFNULL(nt.Income,0) AS Commission
FROM rb_distributor_info i
INNER JOIN rb_member_user u on i.UserId = u.Id
LEFT JOIN(
SELECT t.UserId,COUNT(0) AS Num,SUM(t.Income) AS Income FROM(
SELECT oc.UserId,oc.OrderId,o.Income FROM rb_goods_ordercommission oc
LEFT JOIN rb_goods_order o on oc.OrderId = o.OrderId
WHERE o.OrderStatus <> 7 and o.Recycled=2 and o.`Status`=0 and o.MallBaseId ={mallbaseId} and o.CreateDate >= '{startTime}' AND o.CreateDate <= '{endTime} 23:59:59'
GROUP BY oc.UserId,oc.OrderId)t GROUP BY t.UserId
)tt on tt.UserId = u.Id
LEFT JOIN (
SELECT o.UserId,COUNT(0) AS Num,SUM(o.Income) AS Income FROM rb_goods_order o
LEFT JOIN rb_goods_ordercommission oc ON o.OrderId = oc.OrderId
WHERE o.OrderStatus <> 7 and o.Recycled=2 and o.`Status`=0 and o.MallBaseId ={mallbaseId} and o.CreateDate >= '{startTime}' AND o.CreateDate <= '{endTime} 23:59:59' AND oc.Id is NULL
stringsql=$@"SELECT tt.UserId as Id,u.`Name`,u1.`Name` as PName1,u2.`Name` as PName2,u3.`Name` as PName3,o2.OrderId as ShopId FROM(
SELECT * FROM (
SELECT UserId,COUNT(0) as Count FROM rb_goods_order o WHERE o.OrderStatus <> 1 and o.OrderStatus <> 7 and o.Recycled=2
and o.`Status`=0 and o.CreateDate >= '{startTime}' AND o.CreateDate < '{endTime} 23:59:59'
GROUP BY UserId)t
WHERE t.Count =1 and (SELECT COUNT(0) AS Count1 FROM rb_goods_order o1 WHERE o1.UserId = t.UserId and o1.OrderStatus <> 1
and o1.OrderStatus <> 7 and o1.Recycled=2 and o1.`Status`=0 and o1.MallBaseId ={mallbaseId} and o1.CreateDate < '{startTime}')=0
)tt
LEFT JOIN rb_member_user u on tt.UserId = u.Id
LEFT JOIN rb_member_user u1 on u.SuperiorId = u1.Id
LEFT JOIN rb_member_user u2 on u1.SuperiorId = u2.Id
LEFT JOIN rb_member_user u3 on u2.SuperiorId = u3.Id
LEFT JOIN rb_goods_order o2 on o2.UserId = tt.UserId
WHERE o2.TenantId = 1 and o2.OrderStatus <> 1 and o2.OrderStatus <> 7 and o2.Recycled=2 and o2.`Status`=0 and o2.MallBaseId ={mallbaseId} and o2.CreateDate <='{endTime} 23:59:59'";