Commit abda47e2 authored by 黄奎's avatar 黄奎

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents e0eeb659 6120ab6f
......@@ -5166,11 +5166,14 @@ namespace Edu.Module.Course
#endregion
var stuModel = stuTimeList.Where(x => x.OrderGuestId == item.GuestId).FirstOrDefault();
item.UseClassHours = (stuModel?.CurrentDeductionHours ?? 0);
item.Unit_Price = 0;
item.Unit_Price = guestModel?.ClassUnitPrice ?? 0;
item.UseCourseFee = 0;
if (item.TotalClassHours2 > 0)
{
item.Unit_Price = Math.Round(item.TotalCourseFee2 / item.TotalClassHours2, 6, MidpointRounding.AwayFromZero);//根据合同计算(包含优惠, 需减去课件费等)
if (item.Unit_Price <= 0)
{
item.Unit_Price = Math.Round(item.TotalCourseFee2 / item.TotalClassHours2, 6, MidpointRounding.AwayFromZero);//根据合同计算(包含优惠, 需减去课件费等)
}
item.UseCourseFee = Math.Round((Convert.ToDecimal(item.UseClassHours) / item.TotalClassHours2) * item.TotalCourseFee2, 6, MidpointRounding.AwayFromZero);
//if (item.TotalDiscountMoney2 > 0)
//{
......@@ -5249,8 +5252,9 @@ namespace Edu.Module.Course
/// </summary>
/// <param name="guestId"></param>
/// <param name="money"></param>
/// <param name="isRefund">是否退费单据</param>
/// <returns></returns>
public bool UpdateStudentValidClassHours(int guestId, decimal money)
public bool UpdateStudentValidClassHours(int guestId, decimal money, int isRefund)
{
var gmodel = order_GuestRepository.GetEntity(guestId);
if (gmodel == null) { return false; }
......@@ -5259,16 +5263,16 @@ namespace Edu.Module.Course
if (omodel.OrderType == OrderTypeEnum.CourseOrder)
{
//有合同
omodel.Income = money >= 0 ? money : 0;
omodel.Income -= (omodel.CoursewareFee + omodel.TextbookFee);
if (omodel.Income < 0) { omodel.Income = 0; }
decimal HourseMoeny = money >= 0 ? money : 0;
HourseMoeny -= (omodel.CoursewareFee + omodel.TextbookFee);
if (HourseMoeny < 0) { HourseMoeny = 0; }
omodel.Unit_Price = 0;
if (gmodel.TotalHours > 0)
omodel.Unit_Price = gmodel.ClassUnitPrice;
if (omodel.Unit_Price <= 0 && gmodel.TotalHours > 0)
{
omodel.Unit_Price = Math.Round((omodel.PreferPrice - omodel.DiscountMoney - omodel.CoursewareFee - omodel.TextbookFee) / gmodel.TotalHours, 6, MidpointRounding.AwayFromZero);//根据合同计算
}
decimal validClassHours = omodel.Unit_Price > 0 ? Math.Round(omodel.Income / omodel.Unit_Price, 2, MidpointRounding.AwayFromZero) : 0;
decimal validClassHours = omodel.Unit_Price > 0 ? Math.Round(HourseMoeny / omodel.Unit_Price, 2, MidpointRounding.AwayFromZero) : 0;
Dictionary<string, object> keyValues = new Dictionary<string, object>()
{
......@@ -5276,12 +5280,21 @@ namespace Edu.Module.Course
};
//HK2021-07-19新增【有效课时大于完成课时修改学员状态为正常】
string LogContent = "";
if (gmodel.CompleteHours <= validClassHours)
if (gmodel.CompleteHours <= validClassHours && gmodel.GuestState != GuestStateEnum.Normal)
{
keyValues.Add(nameof(RB_Order_Guest.GuestState), (int)GuestStateEnum.Normal);
keyValues.Add(nameof(RB_Order_Guest.DropOutRemark), "有效课时大于完成课时,恢复学员状态!");
LogContent = gmodel.GuestName + "有效课时大于完成课时,系统恢复学员状态!";
}
if (isRefund ==1)
{
if (gmodel.GuestState != GuestStateEnum.DropOut)
{
keyValues.Add(nameof(RB_Order_Guest.GuestState), (int)GuestStateEnum.DropOut);
}
keyValues.Add(nameof(RB_Order_Guest.TotalHours), validClassHours);
LogContent += gmodel.GuestName + $"学员退费,修改学员状态为退学!总课时由【{gmodel.TotalHours}】变更为【{validClassHours}】";
}
if (!string.IsNullOrEmpty(LogContent))
{
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
......@@ -5305,7 +5318,34 @@ namespace Edu.Module.Course
OperatorEnum= OperatorEnum.Equal
}
};
order_GuestRepository.Update(keyValues, wheres);
bool gflag = order_GuestRepository.Update(keyValues, wheres);
if (isRefund == 1 && gflag) {
decimal NewPreferPrice = omodel.Income + omodel.PlatformTax - omodel.Refund + omodel.DiscountMoney;
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Order.OrderState),(int)OrderStateEnum.DropOut},
{ nameof(RB_Order.PreferPrice), NewPreferPrice},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName = nameof(RB_Order.OrderId),
FiledValue = omodel.OrderId,
OperatorEnum = OperatorEnum.Equal
}
};
orderRepository.Update(keyValues1, wheres1);
changeLogRepository.Insert(new Model.Entity.Log.RB_User_ChangeLog()
{
Id = 0,
Type = 2,
CreateBy = omodel.CreateBy,
CreateTime = DateTime.Now,
Group_Id = omodel.Group_Id,
LogContent = $"学员退费,自动更新订单应收由【{omodel.PreferPrice}】修改为【{NewPreferPrice}】",
School_Id = omodel.School_Id,
SourceId = omodel.OrderId
});
}
}
//培训/留学订单 直接验证 订单的应收 大于等于实收
......
......@@ -518,15 +518,17 @@ GROUP BY tt.TeacherId,tt.ClassId;";
public List<RB_Class_Check_ViewModel> GetStudentHoursList(int groupId, string userIds, string startMonth, string endMonth)
{
string sql = $@"SELECT q.TeacherId,q.OrderGuestId,q.CurrentDeductionHours,
case when q.ClassUnitPrice >0 then q.ClassUnitPrice else
case when q.ClassHours>0 and q.TotalSub >0 then
(q.CourseFee - q.DiscountMoney) /q.ClassHours
else 0 END AS UnitPrice
else 0 END END AS UnitPrice
FROM (
SELECT tt.TeacherId,tt.OrderGuestId,tt.CurrentDeductionHours
,IFNULL(o.PreferPrice,0) -IFNULL(o.TextbookFee,0) -IFNULL(o.CoursewareFee,0) as CourseFee
,IFNULL(o.DiscountMoney,0) as DiscountMoney
,IFNULL(o.PreferPrice,0) as TotalSub
,IFNULL(g.TotalHours,0) as ClassHours
,IFNULL(g.ClassUnitPrice,0) as ClassUnitPrice
FROM(
SELECT p.TeacherId,p.OrderGuestId,SUM(p.CurrentDeductionHours) as CurrentDeductionHours FROM rb_class_check p
WHERE p.`Status`=0 and p.Group_Id ={groupId} and p.TeacherId in ({userIds}) and p.ClassDate >= '{startMonth}' and p.ClassDate <='{endMonth} 23:59:59'
......@@ -571,7 +573,7 @@ GROUP BY tt.TeacherId,tt.OrderGuestId
string sql = $@"
SELECT p.TeacherId,t2.TeacherName,t2.BaseHourFee,t2.BaseHoursEnabled,t2.EnableTime,t2.BaseHoursAdd,if(cp.PlanType=2,'预约课',c.ClassName) as ClassName,if(cp.PlanType=2,co2.CourseName,co.CourseName) as CourseName,p.ClassId,if(cp.PlanType=2,co2.AddHoursMoney,co.AddHoursMoney) as CourseAddHoursMoney,
c.ClassType,c.ClassNo,if(cp.PlanType=2,s2.SName,s.SName) as SName,c.ClassHourMinute,if(cp.PlanType=2,cp.CourseId,c.CouseId) as CouseId,p.ClassDate,p.ClassTimeId,t.StartTime as StartDate,t.EndTime as EndDate,Max(p.CurrentDeductionHours) as CurrentDeductionHours
c.ClassType,c.ClassNo,if(cp.PlanType=2,s2.SName,s.SName) as SName,c.ClassHourMinute,if(cp.PlanType=2,cp.CourseId,c.CouseId) as CouseId,p.ClassDate,p.ClassTimeId,t.StartTime as StartDate,t.EndTime as EndDate,Max(p.IsCalcTeacFee =1 then p.CurrentDeductionHours else 0 end) as CurrentDeductionHours
FROM rb_class_check p
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
inner join rb_class_plan cp on t.ClassPlanId = cp.ClassPlanId
......@@ -616,7 +618,7 @@ ORDER BY p.ClassDate ASC
string sql = $@"
SELECT p.TeacherId,t2.TeacherName,t2.BaseHourFee,t2.BaseHoursEnabled,t2.EnableTime,if(cp.PlanType=2,'预约课',c.ClassName) as ClassName,if(cp.PlanType=2,co2.CourseName,co.CourseName) as CourseName,if(cp.PlanType=2,co2.AddHoursMoney,co.AddHoursMoney) as CourseAddHoursMoney,
p.ClassId,if(cp.PlanType=2,s2.SName,s.SName) as SName,c.ClassType,c.ClassNo,c.ClassHourMinute,if(cp.PlanType=2,cp.CourseId,c.CouseId) as CouseId,p.ClassDate,p.ClassTimeId,t.StartTime as StartDate,t.EndTime as EndDate,Max(p.CurrentDeductionHours) as CurrentDeductionHours FROM rb_class_check p
p.ClassId,if(cp.PlanType=2,s2.SName,s.SName) as SName,c.ClassType,c.ClassNo,c.ClassHourMinute,if(cp.PlanType=2,cp.CourseId,c.CouseId) as CouseId,p.ClassDate,p.ClassTimeId,t.StartTime as StartDate,t.EndTime as EndDate,Max(case when p.IsCalcTeacFee =1 then p.CurrentDeductionHours else 0 end) as CurrentDeductionHours FROM rb_class_check p
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
inner join rb_class_plan cp on t.ClassPlanId = cp.ClassPlanId
LEFT JOIN rb_teacher t2 on p.TeacherId = t2.TId
......@@ -682,9 +684,10 @@ ORDER BY p.ClassDate ASC
string sql = $@"
SELECT tt.*,
case when tt.ClassUnitPrice>0 then tt.ClassUnitPrice else
case when tt.ClassHours>0 and tt.TotalSub >0 then
(tt.CourseFee - tt.DiscountMoney) /tt.ClassHours
else 0 END AS UnitPrice
else 0 END END AS UnitPrice
FROM (
SELECT p.OrderGuestId,p.CurrentDeductionHours,t2.GuestName,p.TeacherId,t3.TeacherName,t2.OrderId,ec.ContractNo,if(cp.PlanType=2,'预约课',c.ClassName) as ClassName,c.ClassNo,if(cp.PlanType=2,co2.CourseName,co.CourseName) as CourseName,p.ClassId,if(cp.PlanType=2,cp.CourseId,c.CouseId) as CouseId
,p.ClassDate,p.ClassTimeId,t.StartTime as StartDate,t.EndTime as EndDate,o.EnterID,o.HelpEnterId
......@@ -692,6 +695,7 @@ SELECT p.OrderGuestId,p.CurrentDeductionHours,t2.GuestName,p.TeacherId,t3.Teache
,IFNULL(o.DiscountMoney,0) as DiscountMoney
,IFNULL(o.PreferPrice,0) as TotalSub
,IFNULL(t2.TotalHours,0) as ClassHours
,IFNULL(t2.ClassUnitPrice,0) as ClassUnitPrice
,o.JoinType,o.TargetJoinType,o.SourceOrderId,o.TargetOrderId
FROM rb_class_check p
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
......@@ -761,9 +765,10 @@ ORDER BY tt.ClassDate ASC
string sql = $@"
SELECT tt.*,
case when tt.ClassUnitPrice >0 then tt.ClassUnitPrice else
case when tt.ClassHours>0 and tt.TotalSub >0 then
(tt.CourseFee - tt.DiscountMoney) /tt.ClassHours
else 0 END AS UnitPrice
else 0 END END AS UnitPrice
FROM (
SELECT p.OrderGuestId,p.CurrentDeductionHours,t2.GuestName,p.TeacherId,t3.TeacherName,t2.OrderId,ec.ContractNo,if(cp.PlanType=2,'预约课',c.ClassName) as ClassName,c.ClassNo,if(cp.PlanType=2,co2.CourseName,co.CourseName) as CourseName,p.ClassId,if(cp.PlanType=2,cp.CourseId,c.CouseId) as CouseId
,p.ClassDate,p.ClassTimeId,t.StartTime as StartDate,t.EndTime as EndDate,o.EnterID,o.HelpEnterId
......@@ -771,6 +776,7 @@ SELECT p.OrderGuestId,p.CurrentDeductionHours,t2.GuestName,p.TeacherId,t3.Teache
,IFNULL(o.DiscountMoney,0) as DiscountMoney
,IFNULL(o.PreferPrice,0) as TotalSub
,IFNULL(t2.TotalHours,0) as ClassHours
,IFNULL(t2.ClassUnitPrice,0) as ClassUnitPrice
FROM rb_class_check p
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
inner join rb_class_plan cp on t.ClassPlanId = cp.ClassPlanId
......@@ -821,15 +827,17 @@ WHERE p.`Status` =0 and p.Group_Id ={groupId} and case when cp.PlanType=2 then t
{
string sql = $@"SELECT hq.ClassId, SUM(hq.CurrentDeductionHours * hq.UnitPrice) AS UnitPrice FROM (
SELECT q.ClassId,q.OrderGuestId,q.CurrentDeductionHours,
case when q.ClassUnitPrice >0 then q.ClassUnitPrice else
case when q.ClassHours>0 and q.TotalSub >0 then
(q.CourseFee - q.DiscountMoney) /q.ClassHours
else 0 END AS UnitPrice
else 0 END END AS UnitPrice
FROM (
SELECT tt.ClassId,tt.OrderGuestId,tt.CurrentDeductionHours
,IFNULL(o.PreferPrice,0) -IFNULL(o.TextbookFee,0) -IFNULL(o.CoursewareFee,0) as CourseFee
,IFNULL(o.DiscountMoney,0) as DiscountMoney
,IFNULL(o.PreferPrice,0) as TotalSub
,IFNULL(g.TotalHours,0) as ClassHours
,IFNULL(g.ClassUnitPrice,0) as ClassUnitPrice
FROM(
SELECT case when cp.PlanType=2 then t2.ClassId else p.ClassId end as ClassId,p.OrderGuestId,SUM(p.CurrentDeductionHours) as CurrentDeductionHours FROM rb_class_check p
INNER JOIN rb_class_time t on p.ClassTimeId = t.ClassTimeId
......
......@@ -1781,8 +1781,9 @@ namespace Edu.WebApi.Controllers.Finance
JObject jObj = JObject.Parse(RequestParm.Msg.ToString());
int GuestId = jObj.GetInt("GuestId", 0);
decimal Money = jObj.GetDecimal("Money");
int IsRefund = jObj.GetInt("IsRefund", 0);//是否退费单据 1是
bool flag = orderModule.UpdateStudentValidClassHours(GuestId, Money);
bool flag = orderModule.UpdateStudentValidClassHours(GuestId, Money, IsRefund);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......
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