瀏覽代碼

Merge branch 'CRM_15.7' into debug

zwxi 11 月之前
父節點
當前提交
47d59a91da
共有 3 個文件被更改,包括 248 次插入0 次删除
  1. 111 0
      controllers/yb_research_signup_statistics.go
  2. 110 0
      models/yb_research_signup_statistics.go
  3. 27 0
      routers/commentsRouter.go

+ 111 - 0
controllers/yb_research_signup_statistics.go

@@ -0,0 +1,111 @@
+package controllers
+
+import (
+	"hongze/hz_crm_api/models"
+)
+
+// @Title 调研报名统计列表
+// @Description 获取分类
+// @Success 200 {object} models.BannerListResp
+// @router /research_statistics/list [get]
+func (this *BannerController) StatisticsList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	list, err := models.GetYbResearchSignupStatisticsItems()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.YbResearchSignupStatisticsResp)
+
+	for _, v := range list {
+		if v.Enable == 1 {
+			resp.OngoingList = append(resp.OngoingList, v)
+		} else {
+			resp.OverList = append(resp.OverList, v)
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 调研报名统计列表
+// @Description 获取分类
+// @Param   BannerId   query   int  true       "图片id"
+// @Success 200 {object} models.BannerListResp
+// @router /research_statistics/item [get]
+func (this *BannerController) StatisticsItem() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	bannerId, _ := this.GetInt("BannerId")
+
+	if bannerId <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+	list, err := models.GetYbResearchSignupStatisticsItemsById(bannerId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+
+	var resp models.YbResearchSignupStatisticsItemsResp
+	resp.List = list
+
+	for _, v := range list {
+		resp.Total += v.Count
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 调研报名统计列表
+// @Description 获取分类
+// @Param   Mobile   query   int  true       "分享人手机号"
+// @Success 200 {object} models.BannerListResp
+// @router /research_statistics/detail [get]
+func (this *BannerController) StatisticsDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	mobile := this.GetString("Mobile")
+
+	if mobile == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+	list, err := models.GetYbResearchSignupStatisticsItemsByMobile(mobile)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = list
+}

+ 110 - 0
models/yb_research_signup_statistics.go

@@ -0,0 +1,110 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// YbResearchSignupStatistics 调研报名统计结构体
+type YbResearchSignupStatistics struct {
+	YbResearchSignupStatisticsId int       // 主键ID
+	UserId                       int       // 分享人ID
+	RealName                     string    // 分享人姓名
+	Mobile                       string    // 分享人手机号
+	CompanyName                  string    // 公司名称
+	BannerId                     int       // 活动ID
+	CreateTime                   time.Time // 创建时间
+	Amount                       float64   // 付款金额
+	CustomName                   string    // 报名人姓名
+	CustomMobile                 string    // 报名人手机号
+	CustomCompanyName            string    // 报名人公司名称
+}
+
+type YbResearchSignupStatisticsListItem struct {
+	YbResearchSignupStatisticsId int     // 主键ID
+	BannerId                     int     // 活动ID
+	Amount                       float64 // 付款金额
+	Count                        int     // 报名人数
+	Remark                       string  // 备注-活动名称
+	StartDate                    string  // 活动开始时间
+	EndDate                      string  // 活动结束时间
+	Enable                       int     // 1:有效,0:禁用
+}
+
+func GetYbResearchSignupStatisticsItems() (items []*YbResearchSignupStatisticsListItem, err error) {
+	sql := ` SELECT
+	a.*,
+	b.start_date,
+	b.end_date,
+	b.remark,
+	b.enable,
+	COUNT( 1 ) AS count 
+FROM
+	yb_research_signup_statistics AS a
+	INNER JOIN banner AS b ON a.banner_id = b.id 
+WHERE
+	1 = 1 
+GROUP BY
+	a.banner_id 
+ORDER BY
+	start_date DESC `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+type YbResearchSignupStatisticsResp struct {
+	OngoingList []*YbResearchSignupStatisticsListItem
+	OverList    []*YbResearchSignupStatisticsListItem
+}
+
+type YbResearchSignupStatisticsItem struct {
+	YbResearchSignupStatisticsId int     // 主键ID
+	UserId                       int     // 分享人ID
+	RealName                     string  // 分享人姓名
+	Mobile                       string  // 分享人手机号
+	CompanyName                  string  // 公司名称
+	BannerId                     int     // 活动ID
+	CreateTime                   string  // 创建时间
+	Amount                       float64 // 付款金额
+	CustomName                   string  // 报名人姓名
+	CustomMobile                 string  // 报名人手机号
+	CustomCompanyName            string  // 报名人公司名称
+	Count                        int     // 报名人数
+}
+
+type YbResearchSignupStatisticsItemsResp struct {
+	List  []*YbResearchSignupStatisticsItem
+	Total int
+}
+
+func GetYbResearchSignupStatisticsItemsById(bannerId int) (items []*YbResearchSignupStatisticsItem, err error) {
+	sql := ` SELECT
+	*,count(1) as count
+FROM
+	yb_research_signup_statistics 
+WHERE
+	1 = 1 and banner_id = ?
+GROUP BY
+	mobile 
+ORDER BY
+	count DESC `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql,bannerId).QueryRows(&items)
+	return
+}
+
+func GetYbResearchSignupStatisticsItemsByMobile(mobile string) (items []*YbResearchSignupStatisticsItem, err error) {
+	sql := ` SELECT
+	*
+FROM
+	yb_research_signup_statistics 
+WHERE
+	1 = 1 and mobile = ?
+
+ORDER BY
+	create_time DESC `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql,mobile).QueryRows(&items)
+	return
+}

+ 27 - 0
routers/commentsRouter.go

@@ -8953,6 +8953,33 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:BannerController"],
+        beego.ControllerComments{
+            Method: "StatisticsDetail",
+            Router: `/research_statistics/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:BannerController"],
+        beego.ControllerComments{
+            Method: "StatisticsItem",
+            Router: `/research_statistics/item`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:BannerController"],
+        beego.ControllerComments{
+            Method: "StatisticsList",
+            Router: `/research_statistics/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:BannerController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:BannerController"],
         beego.ControllerComments{
             Method: "BannerStatistic",