Browse Source

课程价格修改

weixianghui 5 năm trước cách đây
mục cha
commit
e7a5527097

+ 9 - 5
core/src/qfw/manage/course.go

@@ -496,6 +496,8 @@ func (this *CourseManage) CreateOnLineApi() {
 		price = "0"
 	}
 	price2 := fmt.Sprintf("%.2f", qutil.Float64All(price))
+	pos := strings.Index(price2, ".")
+	price3 := qutil.Int64All(price2[:pos] + price2[pos+1:])
 	videoUrl := this.GetString("videoUrl")//课程视频
 	fileUrl := this.GetString("fileUrl")//课件
 	s_publishtime := this.GetString("publishtime")//发布时间/上线时间
@@ -543,7 +545,7 @@ func (this *CourseManage) CreateOnLineApi() {
 			"s_picUrl":      picUrl,
 			"s_videoUrl":      videoUrl,
 			"s_fileUrl":      fileUrl,
-			"i_price":        price2,
+			"i_price":        price3,
 			"l_publishtime":  publishtime.Unix(),
 			//"l_createtime":    createTime,
 			"l_endtime":      l_endTime.Unix(),
@@ -741,16 +743,18 @@ func (this *CourseManage) OnLineDetail(flag, id string) error{
 		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["price"] = fmt.Sprintf("%.2f", qutil.Float64All((*rData)["i_price"])/100)
 		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))
+		if ids != "" {
+			arr := strings.Split(ids.(string), ",")
+			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}}

+ 7 - 1
core/src/web/templates/manage/course/onLineIndex.html

@@ -224,7 +224,13 @@
                             (d.getSeconds());
                     }
                 },{
-                    title: "价格", field: "i_price",
+                    title: "价格", field: "i_price", callback: function (data) {
+                        if (data.i_price == 0){
+                            return "0.00"
+                        }else {
+                            return data.i_price/100
+                        }
+                    }
                 },{
                     title: "视频时间", field: "s_courseDate",
                 },