|
@@ -35,11 +35,12 @@ type CourseManage struct {
|
|
getDetail xweb.Mapper `xweb:"/manage/courseOrder/getDetail"` //请求课程订单详情
|
|
getDetail xweb.Mapper `xweb:"/manage/courseOrder/getDetail"` //请求课程订单详情
|
|
|
|
|
|
//线上课程
|
|
//线上课程
|
|
|
|
+ onLineIndex xweb.Mapper `xweb:"/manage/course/onLineIndex"` //线上课程首页
|
|
createOnLineApi xweb.Mapper `xweb:"/manage/course/OnLineRequest"` //线上课程新增、修改
|
|
createOnLineApi xweb.Mapper `xweb:"/manage/course/OnLineRequest"` //线上课程新增、修改
|
|
onLineClickTradeRate xweb.Mapper `xweb:"/manage/course/OnLineClickTradeRate"` //线上课程点击量、购买量
|
|
onLineClickTradeRate xweb.Mapper `xweb:"/manage/course/OnLineClickTradeRate"` //线上课程点击量、购买量
|
|
onLineList xweb.Mapper `xweb:"/manage/course/OnLineList"` //线上课程列表
|
|
onLineList xweb.Mapper `xweb:"/manage/course/OnLineList"` //线上课程列表
|
|
onLineChangeStatus xweb.Mapper `xweb:"/manage/course/OnLineChangeStatus"` //上线or下线
|
|
onLineChangeStatus xweb.Mapper `xweb:"/manage/course/OnLineChangeStatus"` //上线or下线
|
|
- onLineDetail xweb.Mapper `xweb:"/manage/course/OnLineDetail"` //课程详情
|
|
|
|
|
|
+ onLineDetail xweb.Mapper `xweb:"/manage/course/OnLineDetail/(\\w+)/(\\w+)"` //课程详情
|
|
}
|
|
}
|
|
|
|
|
|
type FuncResult struct {
|
|
type FuncResult struct {
|
|
@@ -264,6 +265,10 @@ func (this *CourseManage) List() {
|
|
if queryStr != "" {
|
|
if queryStr != "" {
|
|
query["s_name"] = bson.M{"$regex": queryStr}
|
|
query["s_name"] = bson.M{"$regex": queryStr}
|
|
}
|
|
}
|
|
|
|
+ //课程类型不等于3
|
|
|
|
+ query1 := map[string]int32{}
|
|
|
|
+ query1["$ne"] = 3
|
|
|
|
+ query["i_type"] = query1
|
|
rData := mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, `{"_id":1,"i_type":1,"s_address":1,"i_status":1,"s_name":1,"l_publishtime":1}`, false, (currentPage-1)*perPage, perPage)
|
|
rData := mongodb.Find("jy_course", query, `{"l_publishtime":-1}`, `{"_id":1,"i_type":1,"s_address":1,"i_status":1,"s_name":1,"l_publishtime":1}`, false, (currentPage-1)*perPage, perPage)
|
|
count := mongodb.Count("jy_course", query)
|
|
count := mongodb.Count("jy_course", query)
|
|
this.ServeJson(map[string]interface{}{
|
|
this.ServeJson(map[string]interface{}{
|
|
@@ -490,7 +495,7 @@ func (this *CourseManage) CreateOnLineApi() {
|
|
if price == "" {
|
|
if price == "" {
|
|
price = "0"
|
|
price = "0"
|
|
}
|
|
}
|
|
- price2, err1 := strconv.ParseFloat(price, 64)
|
|
|
|
|
|
+ price2 := fmt.Sprintf("%.2f", qutil.Float64All(price))
|
|
videoUrl := this.GetString("videoUrl")//课程视频
|
|
videoUrl := this.GetString("videoUrl")//课程视频
|
|
fileUrl := this.GetString("fileUrl")//课件
|
|
fileUrl := this.GetString("fileUrl")//课件
|
|
s_publishtime := this.GetString("publishtime")//发布时间/上线时间
|
|
s_publishtime := this.GetString("publishtime")//发布时间/上线时间
|
|
@@ -528,12 +533,9 @@ func (this *CourseManage) CreateOnLineApi() {
|
|
if err != nil {
|
|
if err != nil {
|
|
return &FuncResult{false, errors.New("课程内容解析异常"), nil}
|
|
return &FuncResult{false, errors.New("课程内容解析异常"), nil}
|
|
}
|
|
}
|
|
- if err1 != nil {
|
|
|
|
|
|
+ /*if err1 != nil {
|
|
return &FuncResult{false, errors.New("课程金额异常"), nil}
|
|
return &FuncResult{false, errors.New("课程金额异常"), nil}
|
|
- }
|
|
|
|
- //if !(price2 > 0 && price != "") {
|
|
|
|
- // return &FuncResult{false, errors.New("课程金额异常"), nil}
|
|
|
|
- //}
|
|
|
|
|
|
+ }*/
|
|
//数据校验
|
|
//数据校验
|
|
mData := map[string]interface{}{
|
|
mData := map[string]interface{}{
|
|
"s_name": name,
|
|
"s_name": name,
|
|
@@ -708,7 +710,7 @@ func (this *CourseManage) OnLineChangeStatus() {
|
|
if time.Unix(qutil.Int64All((*rData)["l_endtime"]), 0).Before(time.Now()) {
|
|
if time.Unix(qutil.Int64All((*rData)["l_endtime"]), 0).Before(time.Now()) {
|
|
return &FuncResult{false, errors.New("课程截止时间已到,禁止上线"), nil}
|
|
return &FuncResult{false, errors.New("课程截止时间已到,禁止上线"), nil}
|
|
}
|
|
}
|
|
- if (*rData)["i_status"] == 0 {
|
|
|
|
|
|
+ if (*rData)["i_status"] == 0 || (*rData)["i_status"] == -1{
|
|
ok := mongodb.Update("jy_course", &map[string]interface{}{
|
|
ok := mongodb.Update("jy_course", &map[string]interface{}{
|
|
"_id": qutil.StringTOBsonId(_id),
|
|
"_id": qutil.StringTOBsonId(_id),
|
|
}, &map[string]interface{}{
|
|
}, &map[string]interface{}{
|
|
@@ -728,8 +730,40 @@ func (this *CourseManage) OnLineChangeStatus() {
|
|
this.ServeJson(r.Format())
|
|
this.ServeJson(r.Format())
|
|
}
|
|
}
|
|
|
|
|
|
-func (this *CourseManage) OnLineDetail() {
|
|
|
|
- _id := this.GetString("_id") //课程id
|
|
|
|
|
|
+func (this *CourseManage) OnLineDetail(flag, id string) error{
|
|
|
|
+ if flag == "edit" {
|
|
|
|
+ //获取文章详情
|
|
|
|
+ if id == "" {
|
|
|
|
+ return errors.New("请求参数有误")
|
|
|
|
+ }
|
|
|
|
+ rData := mongodb.FindById("jy_course", id, `{"_id":1,"i_status":1,"s_content":1,"s_name":1,"s_picUrl":1,"i_price":1,"l_publishtime":1,"l_endtime":1,"s_associatedCourses":1,"i_clickRate":1,"s_videoUrl":1,"s_fileUrl":1,"s_courseDate":1,"i_tradeRate":1}`)
|
|
|
|
+ this.T["picUrl"] = (*rData)["s_picUrl"]
|
|
|
|
+ this.T["name"] = (*rData)["s_name"]
|
|
|
|
+ this.T["videoUrl"] = (*rData)["s_videoUrl"]
|
|
|
|
+ this.T["fileUrl"] = (*rData)["s_fileUrl"]
|
|
|
|
+ this.T["price"] = (*rData)["i_price"]
|
|
|
|
+ this.T["endTime"] = time.Unix(qutil.Int64All((*rData)["l_endtime"]), 0).Format(qutil.Date_Full_Layout)
|
|
|
|
+ this.T["courseDate"] = (*rData)["s_courseDate"]
|
|
|
|
+ this.T["content"] = (*rData)["s_content"]
|
|
|
|
+ this.T["status"] = (*rData)["i_status"]
|
|
|
|
+ ids := (*rData)["s_associatedCourses"]
|
|
|
|
+ arr := strings.Split(ids.(string), ",")
|
|
|
|
+ var idSlice []bson.ObjectId
|
|
|
|
+ for _, as := range arr{
|
|
|
|
+ idSlice = append(idSlice, bson.ObjectIdHex(as))
|
|
|
|
+ }
|
|
|
|
+ now := time.Now().Unix()
|
|
|
|
+ queryAbout := bson.M{"i_type": 3, "i_status": 1, "_id": bson.M{"$in":idSlice}, "l_publishtime": bson.M{"$lt":now}, "l_endtime": bson.M{"$gt":now}}
|
|
|
|
+ aboutList := mongodb.Find("jy_course", queryAbout, `{"l_publishtime":-1}`,
|
|
|
|
+ `{"_id":1,"s_name":1}`, false, 0, 0)
|
|
|
|
+ this.T["associatedCourses"] = aboutList
|
|
|
|
+ this.T["publishtime"] = time.Unix(qutil.Int64All((*rData)["l_publishtime"]), 0).Format(qutil.Date_Full_Layout)
|
|
|
|
+ this.T["id"] = id
|
|
|
|
+ }
|
|
|
|
+ this.T["doType"] = flag
|
|
|
|
+ this.Render("/manage/course/onLineContent.html")
|
|
|
|
+ return nil
|
|
|
|
+ /*_id := this.GetString("_id") //课程id
|
|
r := func() *FuncResult {
|
|
r := func() *FuncResult {
|
|
if _id == "" {
|
|
if _id == "" {
|
|
return &FuncResult{false, errors.New("信息id为空"), nil}
|
|
return &FuncResult{false, errors.New("信息id为空"), nil}
|
|
@@ -756,9 +790,6 @@ func (this *CourseManage) OnLineDetail() {
|
|
queryAbout := bson.M{"i_type": 3, "i_status": 1, "_id": bson.M{"$in":idSlice}, "l_publishtime": bson.M{"$lt":now}, "l_endtime": bson.M{"$gt":now}}
|
|
queryAbout := bson.M{"i_type": 3, "i_status": 1, "_id": bson.M{"$in":idSlice}, "l_publishtime": bson.M{"$lt":now}, "l_endtime": bson.M{"$gt":now}}
|
|
aboutList := mongodb.Find("jy_course", queryAbout, `{"l_publishtime":-1}`,
|
|
aboutList := mongodb.Find("jy_course", queryAbout, `{"l_publishtime":-1}`,
|
|
`{"_id":1,"s_name":1}`, false, 0, 0)
|
|
`{"_id":1,"s_name":1}`, false, 0, 0)
|
|
- /*for _, v := range *aboutList {
|
|
|
|
- v["_id"] = qutil.EncodeArticleId2ByCheck(qutil.BsonIdToSId(v["_id"]))
|
|
|
|
- }*/
|
|
|
|
resultMap["aboutList"] = aboutList
|
|
resultMap["aboutList"] = aboutList
|
|
}
|
|
}
|
|
return &FuncResult{true, nil, resultMap}
|
|
return &FuncResult{true, nil, resultMap}
|
|
@@ -766,5 +797,10 @@ func (this *CourseManage) OnLineDetail() {
|
|
if r.Err != nil {
|
|
if r.Err != nil {
|
|
log.Printf(" CourseContent err:%v\n", r.Err.Error())
|
|
log.Printf(" CourseContent err:%v\n", r.Err.Error())
|
|
}
|
|
}
|
|
- this.ServeJson(r.Format())
|
|
|
|
|
|
+ this.ServeJson(r.Format())*/
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//线上课程首页
|
|
|
|
+func (this *CourseManage) OnLineIndex() error {
|
|
|
|
+ return this.Render("/manage/course/onLineIndex.html")
|
|
}
|
|
}
|