Commit 4e1e1440 authored by liudong1993's avatar liudong1993

1

parent 7e6ebed3
...@@ -90,5 +90,10 @@ namespace Mall.Model.Extend.Education ...@@ -90,5 +90,10 @@ namespace Mall.Model.Extend.Education
/// 邮箱 /// 邮箱
/// </summary> /// </summary>
public string Email { get; set; } public string Email { get; set; }
/// <summary>
/// 赠送咖啡数量
/// </summary>
public int FreeCoffeeNum { get; set; }
} }
} }
...@@ -626,7 +626,7 @@ namespace Mall.Module.Education ...@@ -626,7 +626,7 @@ namespace Mall.Module.Education
/// <returns></returns> /// <returns></returns>
public bool GetEduStuLearning(int accountId) public bool GetEduStuLearning(int accountId)
{ {
return RB_AccountRepository.GetStuLearningCourse(accountId) > 0; return RB_AccountRepository.GetStuLearningCourse(accountId, out _) > 0;
} }
/// <summary> /// <summary>
......
...@@ -101,10 +101,11 @@ namespace Mall.Module.Education ...@@ -101,10 +101,11 @@ namespace Mall.Module.Education
else if (esModel.Type == 2) else if (esModel.Type == 2)
{ {
//学生 要看是否还有正在学习的课程 有的话 可初始化免费的咖啡劵 //学生 要看是否还有正在学习的课程 有的话 可初始化免费的咖啡劵
int learningNum = accountRepository.GetStuLearningCourse(esModel.EduSellId); int learningNum = accountRepository.GetStuLearningCourse(esModel.EduSellId, out int FreeCoffeeNum);
if (learningNum > 0) if (learningNum > 0)
{ {
int FreeNum = Convert.ToInt32(dictvalueRepository.GetList(new Model.Extend.BaseSetUp.RB_Dictvalue_Extend() { MallBaseId = userInfo.MallBaseId, DictKey = "Edu_CoffeeCoupons_Free" }).FirstOrDefault()?.Content ?? "0"); int FreeNum = Convert.ToInt32(dictvalueRepository.GetList(new Model.Extend.BaseSetUp.RB_Dictvalue_Extend() { MallBaseId = userInfo.MallBaseId, DictKey = "Edu_CoffeeCoupons_Free" }).FirstOrDefault()?.Content ?? "0");
FreeNum = FreeCoffeeNum > 0 ? FreeCoffeeNum : FreeNum;
if (FreeNum > 0) if (FreeNum > 0)
{ {
cmodel = new RB_Member_CoffeeCoupons_Extend() cmodel = new RB_Member_CoffeeCoupons_Extend()
...@@ -142,10 +143,11 @@ namespace Mall.Module.Education ...@@ -142,10 +143,11 @@ namespace Mall.Module.Education
else { else {
if (esModel != null && esModel.IsInitFreeCoffee == 1 && esModel.Type == 2) { if (esModel != null && esModel.IsInitFreeCoffee == 1 && esModel.Type == 2) {
//该用户咖啡劵没更新赠送 验证一下 其是否还有正在学习的课程 有的话 恢复赠送咖啡劵 //该用户咖啡劵没更新赠送 验证一下 其是否还有正在学习的课程 有的话 恢复赠送咖啡劵
int learningNum = accountRepository.GetStuLearningCourse(esModel.EduSellId); int learningNum = accountRepository.GetStuLearningCourse(esModel.EduSellId, out int FreeCoffeeNum);
if (learningNum > 0) if (learningNum > 0)
{ {
int FreeNum = Convert.ToInt32(dictvalueRepository.GetList(new Model.Extend.BaseSetUp.RB_Dictvalue_Extend() { MallBaseId = userInfo.MallBaseId, DictKey = "Edu_CoffeeCoupons_Free" }).FirstOrDefault()?.Content ?? "0"); int FreeNum = Convert.ToInt32(dictvalueRepository.GetList(new Model.Extend.BaseSetUp.RB_Dictvalue_Extend() { MallBaseId = userInfo.MallBaseId, DictKey = "Edu_CoffeeCoupons_Free" }).FirstOrDefault()?.Content ?? "0");
FreeNum = FreeCoffeeNum > 0 ? FreeCoffeeNum : FreeNum;
if (FreeNum > 0) if (FreeNum > 0)
{ {
cmodel.FreeNum = FreeNum; cmodel.FreeNum = FreeNum;
......
...@@ -278,16 +278,19 @@ WHERE 1=1 {0} ...@@ -278,16 +278,19 @@ WHERE 1=1 {0}
/// </summary> /// </summary>
/// <param name="accountId"></param> /// <param name="accountId"></param>
/// <returns></returns> /// <returns></returns>
public int GetStuLearningCourse(int accountId) public int GetStuLearningCourse(int accountId,out int FreeCoffeeNum)
{ {
string sql = $@"SELECT COUNT(0) AS Count FROM rb_account a string sql = $@"SELECT COUNT(0) AS IsSelectLevelNor,max(c.FreeCoffeeNum) as FreeCoffeeNum FROM rb_account a
INNER JOIN rb_student s on a.AccountId = s.StuId INNER JOIN rb_student s on a.AccountId = s.StuId
INNER JOIN rb_student_orderguest sog on sog.Student_Id = s.StuId INNER JOIN rb_student_orderguest sog on sog.Student_Id = s.StuId
INNER JOIN rb_order_guest og on sog.GuestId = og.Id INNER JOIN rb_order_guest og on sog.GuestId = og.Id
INNER JOIN rb_order o on sog.OrderId = o.OrderId INNER JOIN rb_order o on sog.OrderId = o.OrderId
left join rb_course c on o.CourseId = c.CourseId
WHERE a.`Status` =0 and a.AccountType =4 and a.Id ={accountId} and og.GuestState not in(2,7) and o.OrderState =1 and o.OrderType =1 and og.TotalHours > og.CompleteHours"; WHERE a.`Status` =0 and a.AccountType =4 and a.Id ={accountId} and og.GuestState not in(2,7) and o.OrderState =1 and o.OrderType =1 and og.TotalHours > og.CompleteHours";
var robj = ExecuteScalar(sql);
return robj == null ? 0 : Convert.ToInt32(robj); var rmodel = Get<RB_Account_ViewModel>(sql).FirstOrDefault();
FreeCoffeeNum = rmodel?.FreeCoffeeNum ?? 0;
return rmodel?.IsSelectLevelNor ?? 0;
} }
/// <summary> /// <summary>
...@@ -297,12 +300,13 @@ WHERE a.`Status` =0 and a.AccountType =4 and a.Id ={accountId} and og.GuestState ...@@ -297,12 +300,13 @@ WHERE a.`Status` =0 and a.AccountType =4 and a.Id ={accountId} and og.GuestState
/// <returns></returns> /// <returns></returns>
public List<RB_Account_ViewModel> GetStuLearningCourseList(int groupId =100000) public List<RB_Account_ViewModel> GetStuLearningCourseList(int groupId =100000)
{ {
string sql = $@"SELECT a.Id,a.AccountId,IFNULL(s.StuName,'') AS AccountName,s.StuIcon as UserIcon string sql = $@"SELECT a.Id,a.AccountId,IFNULL(s.StuName,'') AS AccountName,s.StuIcon as UserIcon, max(c.FreeCoffeeNum) as FreeCoffeeNum
FROM rb_account a FROM rb_account a
INNER JOIN rb_student s on a.AccountId = s.StuId INNER JOIN rb_student s on a.AccountId = s.StuId
INNER JOIN rb_student_orderguest sog on sog.Student_Id = s.StuId INNER JOIN rb_student_orderguest sog on sog.Student_Id = s.StuId
INNER JOIN rb_order_guest og on sog.GuestId = og.Id INNER JOIN rb_order_guest og on sog.GuestId = og.Id
INNER JOIN rb_order o on sog.OrderId = o.OrderId INNER JOIN rb_order o on sog.OrderId = o.OrderId
left join rb_course c on o.CourseId = c.CourseId
WHERE a.`Status` =0 and a.Group_Id ={groupId} and a.AccountType =4 and og.GuestState not in(2,7) and o.OrderState =1 and o.OrderType =1 and og.TotalHours > og.CompleteHours WHERE a.`Status` =0 and a.Group_Id ={groupId} and a.AccountType =4 and og.GuestState not in(2,7) and o.OrderState =1 and o.OrderType =1 and og.TotalHours > og.CompleteHours
group by a.Id"; group by a.Id";
return Get<RB_Account_ViewModel>(sql).ToList(); return Get<RB_Account_ViewModel>(sql).ToList();
......
...@@ -113,6 +113,11 @@ namespace Mall.WindowsService.Module ...@@ -113,6 +113,11 @@ namespace Mall.WindowsService.Module
education_EduSellRepository.Update(keyValues, wheres); education_EduSellRepository.Update(keyValues, wheres);
fNum = 0;//毕业了 初始化免费数量 fNum = 0;//毕业了 初始化免费数量
} }
else
{
//如果课程上有赠送咖啡劵
fNum = emodel.FreeCoffeeNum > 0 ? emodel.FreeCoffeeNum : fNum;
}
//直接更新 //直接更新
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() { Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Member_CoffeeCoupons_Extend.FreeNum),fNum } { nameof(RB_Member_CoffeeCoupons_Extend.FreeNum),fNum }
......
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