Commit be661f15 authored by liudong1993's avatar liudong1993

1

parent cac1edbe
......@@ -5249,8 +5249,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 +5260,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 +5277,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 +5315,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
});
}
}
//培训/留学订单 直接验证 订单的应收 大于等于实收
......
......@@ -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