zwxi 11 ay önce
ebeveyn
işleme
a69768dad3

+ 18 - 12
controllers/yb_research_signup_statistics.go

@@ -65,23 +65,29 @@ func (this *BannerController) StatisticsItem() {
 		br.ErrMsg = "GetYbResearchSignupStatisticsItemsById,Err:" + err.Error()
 		return
 	}
-
-	//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
 	}
 
+	amountList, err := models.GetYbResearchSignupStatisticsAmount(bannerId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "GetYbResearchSignupStatisticsAmount,Err:" + err.Error()
+		return
+	}
+	for _, v := range amountList {
+		if v.Amount > 0 {
+			resp.HasPayed.Amount += v.Amount
+			resp.HasPayed.Count += 1
+		} else {
+			resp.NoPay.Count += 1
+		}
+	}
+	resp.NoPay.Percentage = resp.NoPay.Count * 100 / resp.Total
+	resp.HasPayed.Percentage = resp.HasPayed.Count * 100 / resp.Total
+
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 9 - 2
models/yb_research_signup_statistics.go

@@ -74,8 +74,15 @@ type YbResearchSignupStatisticsItem struct {
 }
 
 type YbResearchSignupStatisticsItemsResp struct {
-	List  []*YbResearchSignupStatisticsItem
-	Total int
+	List     []*YbResearchSignupStatisticsItem
+	Total    int
+	HasPayed PayItem
+	NoPay    PayItem
+}
+type PayItem struct {
+	Count      int
+	Amount     float64
+	Percentage int
 }
 
 func GetYbResearchSignupStatisticsItemsById(bannerId int) (items []*YbResearchSignupStatisticsItem, err error) {