@@ -223,8 +235,13 @@ from RB_Sell_Achievements_Details r where {where} order by r.Id asc";
}
stringsql=$@" select r.UserId,r.Depart_Id,r.School_Id,sum(r.StudentCount) as StudentCount,sum(r.CurrentPeriodMoney + r.DeductionMoney) as CurrentPeriodMoney,sum(r.PeopleNumMoney) as PeopleNumMoney
from RB_Sell_Achievements_Details r where {where} group by r.UserId,r.Depart_Id,r.School_Id";
stringsql=$@" select r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept,p.RuleId,sum(r.StudentCount) as StudentCount,sum(r.CurrentPeriodMoney + r.DeductionMoney) as CurrentPeriodMoney,sum(r.PeopleNumMoney) as PeopleNumMoney
from RB_Sell_Achievements_Details r
left join(
select e.OrderId,e.EmpId,max(e.RuleId) as RuleId from rb_sell_achievements_emp e group by e.OrderId,e.EmpId
) p on r.OrderId = p.OrderId and r.UserId = p.EmpId
where {where} group by r.UserId,r.Depart_Id,r.School_Id,r.IsCommonDept";
stringsql=$@"SELECT e.*,(o.Income - o.Refund - o.TextbookFee) as OrderMoney,o.Refund FROM rb_sell_achievements_emp e
stringsql=$@"SELECT e.*,(o.Income - o.Refund - o.TextbookFee - IFNULL(r.CommissionMoeny,0)) as OrderMoney,o.Refund FROM rb_sell_achievements_emp e
LEFT JOIN rb_order o on e.OrderId =o.OrderId
WHERE e.Group_Id={group_Id} and o.CreateTime >='2024-08-01' and e.GiveOutState =1 and (e.Type=2 or (e.Type=1 and e.IsDept=1)) and o.PreferPrice >0 and e.OrderSaleMoney <> (o.Income - o.Refund - o.TextbookFee) and e.OrderId>0 and e.Remark not like '%退款回扣%'
left join rb_order_returncomission r on o.OrderId =r.OrderId and r.CommissionType =1
WHERE e.Group_Id={group_Id} and o.CreateTime >='2024-09-01' and e.GiveOutState =1 and (e.Type=2 or (e.Type=1 and e.IsDept=1)) and o.PreferPrice >0 and e.OrderSaleMoney <> (o.Income - o.Refund - o.TextbookFee - IFNULL(r.CommissionMoeny,0)) and e.OrderId>0 and e.Remark not like '%退款回扣%'