Commit 1d551281 authored by liudong1993's avatar liudong1993

Merge branch 'master' of http://gitlab.oytour.com/Kui2/mall.oytour.com into sdzq-ld

parents 4a6fc394 b0b93ade
...@@ -1102,53 +1102,52 @@ LEFT JOIN (SELECT SuperiorId,COUNT(SuperiorId) as ChildrenNum from rb_member_use ...@@ -1102,53 +1102,52 @@ LEFT JOIN (SELECT SuperiorId,COUNT(SuperiorId) as ChildrenNum from rb_member_use
{ {
if (query.TenantId > 0) if (query.TenantId > 0)
{ {
where += string.Format(" AND TenantId={0} ", query.TenantId); where += string.Format(" AND A.TenantId={0} ", query.TenantId);
} }
if (query.MallBaseId > 0) if (query.MallBaseId > 0)
{ {
where += string.Format(" AND MallBaseId={0} ", query.MallBaseId); where += string.Format(" AND A.MallBaseId={0} ", query.MallBaseId);
} }
if (!string.IsNullOrWhiteSpace(query.UserIds)) if (!string.IsNullOrWhiteSpace(query.UserIds))
{ {
where += string.Format(" AND UserId IN({0}) ", query.UserIds); where += string.Format(" AND A.UserId IN({0}) ", query.UserIds);
} }
if (query.Id > 0) if (query.Id > 0)
{ {
where += string.Format(" AND UserId IN({0}) ", query.Id); where += string.Format(" AND A.UserId IN({0}) ", query.Id);
} }
} }
if (IsGetCurrentMonth) if (IsGetCurrentMonth)
{ {
where += string.Format(" AND DATE_FORMAT(CreateDate, '%Y/%m')=DATE_FORMAT('{0}','%Y/%m') ", DateTime.Now.ToString("yyyy-MM-dd")); where += string.Format(" AND DATE_FORMAT(A.CreateDate, '%Y/%m')=DATE_FORMAT('{0}','%Y/%m') ", DateTime.Now.ToString("yyyy-MM-dd"));
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" builder.AppendFormat(@"
SELECT UserId AS Id,IsRemit,SUM(A.Commission) AS Commission SELECT UserId AS Id,IsRemit,SUM(A.Commission) AS Commission
FROM FROM
( (
SELECT UserId,SUM(Commission) AS Commission,IsRemit SELECT A.UserId,SUM(A.Commission) AS Commission,A.IsRemit
FROM rb_goods_ordercommission FROM rb_goods_ordercommission AS A LEFT JOIN rb_goods_order AS B ON A.OrderId=B.OrderId
WHERE UserId>0 {0} WHERE B.OrderStatus<>7 AND A.OrderId NOT IN(select OrderId from rb_goods_orderaftersale where ReOrderStatus<>6) {0}
GROUP BY UserId GROUP BY A.UserId
UNION ALL UNION ALL
SELECT UserId,SUM(Commission) AS Commission,RemitStatus AS IsRemit SELECT A.UserId,SUM(A.Commission) AS Commission,A.RemitStatus AS IsRemit
FROM rb_goods_orderintroduction FROM rb_goods_orderintroduction AS A LEFT JOIN rb_goods_order AS B ON A.OrderId=B.OrderId
WHERE UserId>0 {0} WHERE B.OrderStatus<>7 AND A.OrderId NOT IN(select OrderId from rb_goods_orderaftersale where ReOrderStatus<>6) {0}
GROUP BY UserId,RemitStatus GROUP BY A.UserId,A.RemitStatus
UNION ALL
SELECT UserId,SUM(Commission) AS Commission,IsRemit
FROM rb_vipbuy_commission
WHERE UserId>0 {0}
GROUP BY UserId,IsRemit
UNION ALL UNION ALL
SELECT A.UserId,SUM(A.Commission) AS Commission,IsRemit
SELECT UserId,SUM(Commission) AS Commission,IsRemit FROM rb_vipbuy_commission AS A
FROM rb_smallshops_commission WHERE 1=1 {0}
WHERE UserId>0 {0} GROUP BY A.UserId,A.IsRemit
GROUP BY UserId,IsRemit
UNION ALL
SELECT A.UserId,SUM(A.Commission) AS Commission,A.IsRemit
FROM rb_smallshops_commission AS A LEFT JOIN rb_goods_order AS B ON A.OrderId=B.OrderId
WHERE B.OrderStatus<>7 AND A.OrderId NOT IN(select OrderId from rb_goods_orderaftersale where ReOrderStatus<>6) {0}
GROUP BY A.UserId,A.IsRemit
) AS A GROUP BY UserId,IsRemit ) AS A GROUP BY UserId,IsRemit
", where); ", where);
return Get<RB_Member_User_Extend>(builder.ToString()).ToList(); return Get<RB_Member_User_Extend>(builder.ToString()).ToList();
......
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