zwxi 11 months ago
parent
commit
e150a3cb26

+ 15 - 3
controllers/yb_research_signup_statistics.go

@@ -56,16 +56,28 @@ func (this *BannerController) StatisticsItem() {
 		br.ErrMsg = "参数错误"
 		return
 	}
+	var resp models.YbResearchSignupStatisticsItemsResp
+
+
 	list, err := models.GetYbResearchSignupStatisticsItemsById(bannerId)
 	if err != nil {
 		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
+		br.ErrMsg = "GetYbResearchSignupStatisticsItemsById,Err:" + err.Error()
 		return
 	}
 
-	var resp models.YbResearchSignupStatisticsItemsResp
-	resp.List = list
+	//amountList, err := models.GetYbResearchSignupStatisticsAmount(bannerId)
+	//if err != nil {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "GetYbResearchSignupStatisticsAmount,Err:" + err.Error()
+	//	return
+	//}
+	//for _, v := range amountList {
+	//
+	//}
 
+
+	resp.List = list
 	for _, v := range list {
 		resp.Total += v.Count
 	}

+ 16 - 3
models/yb_research_signup_statistics.go

@@ -90,7 +90,7 @@ GROUP BY
 ORDER BY
 	count DESC `
 	o := orm.NewOrm()
-	_, err = o.Raw(sql,bannerId).QueryRows(&items)
+	_, err = o.Raw(sql, bannerId).QueryRows(&items)
 	return
 }
 
@@ -105,7 +105,7 @@ WHERE
 ORDER BY
 	create_time DESC `
 	o := orm.NewOrm()
-	_, err = o.Raw(sql,mobile).QueryRows(&items)
+	_, err = o.Raw(sql, mobile).QueryRows(&items)
 	return
 }
 
@@ -115,4 +115,17 @@ func UpdateYbResearchSignupStatisticsAmountById(amount float64, id int) (err err
 	sql := `UPDATE yb_research_signup_statistics SET amount=? WHERE yb_research_signup_statistics_id=?`
 	_, err = o.Raw(sql, amount, id).Exec()
 	return
-}
+}
+
+func GetYbResearchSignupStatisticsAmount(bannerId int) (items []*YbResearchSignupStatisticsListItem, err error) {
+	sql := ` SELECT
+	a.*
+FROM
+	yb_research_signup_statistics AS a
+	INNER JOIN banner AS b ON a.banner_id = b.id 
+WHERE
+	1 = 1 AND a.banner_id = ? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, bannerId).QueryRows(&items)
+	return
+}