Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
5f0e1e07
Commit
5f0e1e07
authored
Oct 11, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
我的学习
parent
09c67689
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
309 additions
and
25 deletions
+309
-25
RB_Goods_WK_CourseStudy_Extend.cs
Mall.Model/Extend/Product/RB_Goods_WK_CourseStudy_Extend.cs
+8
-0
RB_Goods_WK_StudyTime_Extend.cs
Mall.Model/Extend/Product/RB_Goods_WK_StudyTime_Extend.cs
+20
-0
EducationModule.cs
Mall.Module.Education/EducationModule.cs
+165
-24
RB_Goods_WK_CourseStudyRepository.cs
Mall.Repository/Product/RB_Goods_WK_CourseStudyRepository.cs
+14
-1
RB_Goods_WK_StudyTimeRepository.cs
Mall.Repository/Product/RB_Goods_WK_StudyTimeRepository.cs
+52
-0
AppletEducationController.cs
...WebApi/Controllers/Education/AppletEducationController.cs
+50
-0
No files found.
Mall.Model/Extend/Product/RB_Goods_WK_CourseStudy_Extend.cs
View file @
5f0e1e07
...
...
@@ -17,5 +17,13 @@ namespace Mall.Model.Extend.Product
/// 商品ids
/// </summary>
public
string
GoodsIds
{
get
;
set
;
}
/// <summary>
/// 总章节
/// </summary>
public
int
TNum
{
get
;
set
;
}
/// <summary>
/// 已阅读章节
/// </summary>
public
int
WNum
{
get
;
set
;
}
}
}
Mall.Model/Extend/Product/RB_Goods_WK_StudyTime_Extend.cs
View file @
5f0e1e07
...
...
@@ -17,5 +17,25 @@ namespace Mall.Model.Extend.Product
/// 商品ids
/// </summary>
public
string
GoodsIds
{
get
;
set
;
}
/// <summary>
/// 商品名称
/// </summary>
public
string
GoodsName
{
get
;
set
;
}
/// <summary>
/// 图片
/// </summary>
public
string
CarouselImage
{
get
;
set
;
}
/// <summary>
/// 课程评分
/// </summary>
public
int
CourseScore
{
get
;
set
;
}
/// <summary>
/// 课程标签
/// </summary>
public
string
CourseLable
{
get
;
set
;
}
/// <summary>
/// 学习进度
/// </summary>
public
int
WatchNum
{
get
;
set
;
}
}
}
Mall.Module.Education/EducationModule.cs
View file @
5f0e1e07
...
...
@@ -1226,12 +1226,13 @@ namespace Mall.Module.Education
Time
=
0
});
}
StartTime
=
Convert
.
ToDateTime
(
StartTime
).
AddDays
(
1
).
ToString
(
"yyyy-MM-dd"
);
}
}
MyStudyTimeList
=
list
.
OrderBy
(
x
=>
x
.
CreateDate
).
Select
(
x
=>
new
{
Date
=
x
.
CreateDate
.
Value
.
ToString
(
"yyyy-MM-dd"
),
TimeFormat
=
GetTimeConvert
(
x
.
Time
)
TimeFormat
=
GetTimeConvert
(
x
.
Time
,
true
)
});
}
//今日学习时间
...
...
@@ -1244,8 +1245,8 @@ namespace Mall.Module.Education
return
new
{
MyStudyTimeList
,
ToDayTime
=
GetTimeConvert
(
ToDayTime
),
TotalTime
=
GetTimeConvert
(
TotalTime
),
ToDayTime
=
GetTimeConvert
(
ToDayTime
,
false
),
TotalTime
=
GetTimeConvert
(
TotalTime
,
false
),
StydyDay
};
}
...
...
@@ -1255,45 +1256,73 @@ namespace Mall.Module.Education
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public
object
GetTimeConvert
(
int
time
)
{
public
object
GetTimeConvert
(
int
time
,
bool
IsDay
)
{
decimal
minute
=
Convert
.
ToDecimal
(
time
)
/
60
;
if
(
minute
>=
1
)
{
decimal
hour
=
minute
/
60
;
if
(
hour
>=
1
)
if
(
IsDay
)
{
decimal
day
=
hour
/
24
;
if
(
day
>=
1
)
return
new
{
return
new
Time
=
Math
.
Truncate
(
minute
*
10
)
/
10
,
Unit
=
"分钟"
};
}
else
{
decimal
hour
=
minute
/
60
;
if
(
hour
>=
1
)
{
decimal
day
=
hour
/
24
;
if
(
day
>=
1
)
{
Time
=
Math
.
Truncate
(
day
*
10
)
/
10
,
Unit
=
"天"
};
return
new
{
Time
=
Math
.
Truncate
(
day
*
10
)
/
10
,
Unit
=
"天"
};
}
else
{
return
new
{
Time
=
Math
.
Truncate
(
hour
*
10
)
/
10
,
Unit
=
"小时"
};
}
}
else
{
else
{
return
new
{
Time
=
Math
.
Truncate
(
hour
*
10
)
/
10
,
Unit
=
"
小时
"
Time
=
Math
.
Truncate
(
minute
*
10
)
/
10
,
Unit
=
"
分钟
"
};
}
}
}
else
{
//return new
//{
// Time = Convert.ToDecimal(time),
// Unit = "秒"
//};
if
(
time
>
0
)
{
return
new
{
Time
=
1
,
Unit
=
"分钟"
};
}
else
{
return
new
{
Time
=
Math
.
Truncate
(
minute
*
10
)
/
1
0
,
Time
=
0
,
Unit
=
"分钟"
};
}
}
else
{
return
new
{
Time
=
Convert
.
ToDecimal
(
time
),
Unit
=
"秒"
};
}
}
/// <summary>
...
...
@@ -1331,7 +1360,8 @@ namespace Mall.Module.Education
CreateDate
=
DateTime
.
Now
,
Id
=
0
,
Time
=
time
,
UpdateDate
=
DateTime
.
Now
UpdateDate
=
DateTime
.
Now
,
UserId
=
userId
})
>
0
;
}
}
...
...
@@ -1378,6 +1408,117 @@ namespace Mall.Module.Education
})
>
0
;
}
}
/// <summary>
/// 获取最近学习课程列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="userId"></param>
/// <returns></returns>
public
object
GetMyRecentStudyPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
int
userId
)
{
var
list
=
goods_WK_StudyTimeRepository
.
GetMyRecentStudyPageList
(
pageIndex
,
pageSize
,
out
count
,
userId
);
if
(
list
.
Any
())
{
foreach
(
var
item
in
list
)
{
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
string
>
CarouselList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
item
.
CarouselImage
=
CarouselList
[
0
];
}
}
}
return
list
.
Select
(
x
=>
new
{
x
.
GoodsId
,
x
.
GoodsName
,
x
.
CarouselImage
});
}
/// <summary>
/// 获取学习明细列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="userId"></param>
/// <returns></returns>
public
object
GetMyStudyDetailPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
int
userId
)
{
var
list
=
goods_WK_StudyTimeRepository
.
GetMyStudyDetailPageList
(
pageIndex
,
pageSize
,
out
count
,
userId
);
if
(
list
.
Any
())
{
foreach
(
var
item
in
list
)
{
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
string
>
CarouselList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
item
.
CarouselImage
=
CarouselList
[
0
];
}
}
}
return
list
.
Select
(
x
=>
new
{
x
.
GoodsId
,
x
.
GoodsName
,
x
.
CarouselImage
,
CreateDate
=
x
.
CreateDate
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm"
),
Day
=
x
.
CreateDate
.
Value
.
ToString
(
"yyyy-MM-dd"
),
Hour
=
x
.
CreateDate
.
Value
.
ToString
(
"HH:mm"
),
x
.
CourseScore
,
CourseLableList
=
x
.
CourseLable
!=
null
&&
x
.
CourseLable
!=
"[]"
?
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
x
.
CourseLable
)
:
new
List
<
string
>()
});
}
/// <summary>
/// 获取我的报名记录
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="userId"></param>
/// <returns></returns>
public
object
GetMyOrderStudyRecordPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
int
userId
)
{
var
list
=
goods_WK_StudyTimeRepository
.
GetMyOrderStudyRecordPageList
(
pageIndex
,
pageSize
,
out
count
,
userId
);
if
(
list
.
Any
())
{
//查询观看记录
string
goodsIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
GoodsId
).
Distinct
());
var
wlist
=
goods_WK_CourseStudyRepository
.
GetCourseWatchList
(
userId
,
goodsIds
);
foreach
(
var
item
in
list
)
{
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
string
>
CarouselList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
item
.
CarouselImage
=
CarouselList
[
0
];
}
item
.
WatchNum
=
0
;
//已看完
var
wmodel
=
wlist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
).
FirstOrDefault
();
if
(
wmodel
!=
null
)
{
if
(
wmodel
.
WNum
==
0
)
{
item
.
WatchNum
=
-
1
;
//未看
}
else
{
item
.
WatchNum
=
wmodel
.
TNum
-
wmodel
.
WNum
;
}
}
}
}
return
list
.
Select
(
x
=>
new
{
x
.
GoodsId
,
x
.
GoodsName
,
x
.
CarouselImage
,
SurplusNum
=
x
.
WatchNum
});
}
#
endregion
#
region
教师管理
...
...
Mall.Repository/Product/RB_Goods_WK_CourseStudyRepository.cs
View file @
5f0e1e07
...
...
@@ -43,6 +43,19 @@ WHERE {where} ORDER BY gc.Id desc ";
return
Get
<
RB_Goods_WK_CourseStudy_Extend
>(
sql
).
ToList
();
}
/// <summary>
/// 课程观看
/// </summary>
/// <param name="userId"></param>
/// <param name="goodsIds"></param>
/// <returns></returns>
public
List
<
RB_Goods_WK_CourseStudy_Extend
>
GetCourseWatchList
(
int
userId
,
string
goodsIds
)
{
string
sql
=
$@"SELECT c.GoodsId,COUNT(0) AS TNum,SUM(CASE WHEN cs.Id IS NULL THEN 0 ELSE 1 END) AS WNum FROM rb_goods_wk_course c
LEFT JOIN rb_goods_wk_coursestudy cs on c.Id = cs.CourseId AND cs.UserId =
{
userId
}
WHERE c.GoodsId in(
{
goodsIds
}
)
GROUP BY c.GoodsId"
;
return
Get
<
RB_Goods_WK_CourseStudy_Extend
>(
sql
).
ToList
();
}
}
}
Mall.Repository/Product/RB_Goods_WK_StudyTimeRepository.cs
View file @
5f0e1e07
...
...
@@ -157,5 +157,57 @@ GROUP BY DATE_FORMAT(CreateDate,'%Y-%m-%d') ORDER BY DATE_FORMAT(CreateDate,'%Y-
string
sql
=
$@"SELECT *FROM rb_goods_wk_studytime WHERE UserId =
{
userId
}
limit 1"
;
return
Get
<
RB_Goods_WK_StudyTime_Extend
>(
sql
).
FirstOrDefault
();
}
/// <summary>
/// 最近学习列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="userId"></param>
/// <returns></returns>
public
List
<
RB_Goods_WK_StudyTime_Extend
>
GetMyRecentStudyPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
int
userId
)
{
string
sql
=
$@"
SELECT wk.GoodsId,g.`Name` as GoodsName,g.CarouselImage FROM rb_goods_wk_studytime wk
INNER JOIN rb_goods g on wk.GoodsId = g.Id
WHERE wk.UserId =
{
userId
}
AND g.GoodsClassify = 2 GROUP BY wk.GoodsId ORDER BY wk.CreateDate DESC"
;
return
GetPage
<
RB_Goods_WK_StudyTime_Extend
>(
pageIndex
,
pageSize
,
out
count
,
sql
).
ToList
();
}
/// <summary>
/// 获取我的学习详情
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="userId"></param>
/// <returns></returns>
public
List
<
RB_Goods_WK_StudyTime_Extend
>
GetMyStudyDetailPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
int
userId
)
{
string
sql
=
$@"
SELECT wk.GoodsId,wk.CreateDate,g.`Name` as GoodsName,g.CarouselImage,g.CourseScore,g.CourseLable FROM rb_goods_wk_studytime wk
INNER JOIN rb_goods g on wk.GoodsId = g.Id
WHERE wk.UserId =
{
userId
}
AND g.GoodsClassify = 2 ORDER BY wk.CreateDate DESC"
;
return
GetPage
<
RB_Goods_WK_StudyTime_Extend
>(
pageIndex
,
pageSize
,
out
count
,
sql
).
ToList
();
}
/// <summary>
/// 我的报名记录
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="userId"></param>
/// <returns></returns>
public
List
<
RB_Goods_WK_StudyTime_Extend
>
GetMyOrderStudyRecordPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
int
userId
)
{
string
sql
=
$@"SELECT od.GoodsId,g.`Name` as GoodsName,g.CarouselImage FROM rb_goods_orderdetail od
INNER JOIN rb_goods_order o on od.OrderId = o.OrderId
INNER JOIN rb_goods g on od.GoodsId = g.Id
WHERE o.OrderStatus = 5 AND o.OrderClassify = 2 AND o.UserId =
{
userId
}
ORDER BY o.PaymentTime DESC"
;
return
GetPage
<
RB_Goods_WK_StudyTime_Extend
>(
pageIndex
,
pageSize
,
out
count
,
sql
).
ToList
();
}
}
}
Mall.WebApi/Controllers/Education/AppletEducationController.cs
View file @
5f0e1e07
...
...
@@ -490,6 +490,56 @@ namespace Mall.WebApi.Controllers.Education
return
ApiResult
.
Failed
();
}
}
/// <summary>
/// 获取最新学习列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetMyRecentStudyPageList
()
{
var
parms
=
RequestParm
;
var
userInfo
=
AppletUserInfo
;
ResultPageModel
pagelist
=
JsonConvert
.
DeserializeObject
<
ResultPageModel
>(
parms
.
msg
.
ToString
());
var
list
=
educationModule
.
GetMyRecentStudyPageList
(
pagelist
.
pageIndex
,
pagelist
.
pageSize
,
out
long
count
,
userInfo
.
UserId
);
pagelist
.
count
=
Convert
.
ToInt32
(
count
);
pagelist
.
pageData
=
list
;
return
ApiResult
.
Success
(
""
,
pagelist
);
}
/// <summary>
/// 获取学习明细列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetMyStudyDetailPageList
()
{
var
parms
=
RequestParm
;
var
userInfo
=
AppletUserInfo
;
ResultPageModel
pagelist
=
JsonConvert
.
DeserializeObject
<
ResultPageModel
>(
parms
.
msg
.
ToString
());
var
list
=
educationModule
.
GetMyStudyDetailPageList
(
pagelist
.
pageIndex
,
pagelist
.
pageSize
,
out
long
count
,
userInfo
.
UserId
);
pagelist
.
count
=
Convert
.
ToInt32
(
count
);
pagelist
.
pageData
=
list
;
return
ApiResult
.
Success
(
""
,
pagelist
);
}
/// <summary>
/// 获取我的报名记录
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetMyOrderStudyRecordPageList
()
{
var
parms
=
RequestParm
;
var
userInfo
=
AppletUserInfo
;
ResultPageModel
pagelist
=
JsonConvert
.
DeserializeObject
<
ResultPageModel
>(
parms
.
msg
.
ToString
());
var
list
=
educationModule
.
GetMyOrderStudyRecordPageList
(
pagelist
.
pageIndex
,
pagelist
.
pageSize
,
out
long
count
,
userInfo
.
UserId
);
pagelist
.
count
=
Convert
.
ToInt32
(
count
);
pagelist
.
pageData
=
list
;
return
ApiResult
.
Success
(
""
,
pagelist
);
}
#
endregion
#
region
资讯留言
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment