Browse Source

新增子标签

hongze 1 year ago
parent
commit
effd4c58eb
2 changed files with 69 additions and 7 deletions
  1. 11 2
      controllers/overseas_custom/custom.go
  2. 58 5
      models/overseas_custom/custom.go

+ 11 - 2
controllers/overseas_custom/custom.go

@@ -108,7 +108,14 @@ func (this *OverseasCustomController) CustomList() {
 		}
 	}
 
-	StatisticsDataList, err := obj.GetCustomTotal(condition, pars)
+	statisticsDataList, err := obj.GetCustomTotal(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取各状态总数失败, Err: " + err.Error()
+		return
+	}
+
+	overseasLabelDataList, err := obj.GetCustomOverseasLabelTotal(condition, pars)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取各状态总数失败, Err: " + err.Error()
@@ -120,7 +127,9 @@ func (this *OverseasCustomController) CustomList() {
 	resp := new(overseas_custom.CustomListResp)
 	resp.Paging = page
 	resp.List = list
-	resp.StatisticsData = StatisticsDataList
+	resp.StatisticsData = statisticsDataList
+	resp.OverseasLabelData = overseasLabelDataList
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 58 - 5
models/overseas_custom/custom.go

@@ -21,6 +21,7 @@ type Custom struct {
 	IsHide         int    `description:"是否隐藏:0:不隐藏,1:隐藏"`
 	OverseasStatus string `description:"海外客户状态:'正式','试用','关闭'"`
 	Source         int    `description:"来源:1,英文客户,2:客户列表"`
+	OverseasLabel  int    `description:"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"`
 }
 
 type CustomTotal struct {
@@ -158,7 +159,7 @@ func (obj *Custom) GetCustomList(condition string, pars []interface{}, companySt
 				WHEN '试用' THEN '试用'
 				ELSE '关闭' END AS company_status,
 				b.view_total,b.road_show_total,a.created_time AS create_time,b.last_view_time,a.is_hide,a.overseas_status,
-				2 AS source
+				2 AS source,b.overseas_label
 				FROM company AS a
 				INNER JOIN company_product AS b ON a.company_id=b.company_id
 				INNER JOIN overseas_custom_seller AS c ON b.seller_id=c.seller_id
@@ -177,7 +178,7 @@ func (obj *Custom) GetCustomList(condition string, pars []interface{}, companySt
 				WHEN 0 THEN '关闭'
 				ELSE '试用' END AS company_status,
 				t.view_total,0 AS road_show_total,t.create_time,'' AS last_view_time,t.is_hide,t.overseas_status,
-				1 AS source
+				1 AS source,t.overseas_label
 				FROM %s.english_company AS t
 				INNER JOIN overseas_custom_seller AS n ON t.seller_id=n.seller_id
              WHERE 1=1 `
@@ -218,9 +219,10 @@ func (obj *Custom) GetCustomList(condition string, pars []interface{}, companySt
 }
 
 type CustomListResp struct {
-	Paging         *paging.PagingItem
-	List           []*Custom
-	StatisticsData []*CustomTotal
+	Paging            *paging.PagingItem
+	List              []*Custom
+	StatisticsData    []*CustomTotal
+	OverseasLabelData []*OverseasLabelTotal
 }
 
 // EnglishCompanySaveReq 英文客户-保存请求体
@@ -267,3 +269,54 @@ func (obj *Custom) GetCustomByCompanyId(companyId int) (list *Custom, err error)
 	_, err = o.Raw(sql, companyId).QueryRows(&list)
 	return
 }
+
+type OverseasLabelTotal struct {
+	OverseasLabel int `description:"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"`
+	Total         int `description:"总数"`
+}
+
+func (obj *Custom) GetCustomOverseasLabelTotal(condition string, pars []interface{}) (list []*OverseasLabelTotal, err error) {
+	o := orm.NewOrm()
+	sql := ``
+	var databaseName string
+	if utils.RunMode == "debug" {
+		databaseName = "test_v2_hongze_rddp"
+	} else {
+		databaseName = "hongze_rddp"
+	}
+
+	sql = `SELECT overseas_label,COUNT(1) AS total FROM (
+				SELECT a.company_id,a.company_name,a.nation,b.seller_id,b.seller_name,
+				CASE b.status 
+				WHEN '正式' THEN '正式'
+				WHEN '永续' THEN '正式'
+				WHEN '试用' THEN '试用'
+				ELSE '关闭' END AS company_status,
+				b.view_total,b.road_show_total,a.created_time AS create_time,b.last_view_time,b.overseas_label
+				FROM company AS a
+				INNER JOIN company_product AS b ON a.company_id=b.company_id
+				INNER JOIN overseas_custom_seller AS c ON b.seller_id=c.seller_id
+				WHERE b.is_overseas = 0
+				UNION ALL
+				SELECT t.company_id+10000000,t.company_name,t.nation,t.seller_id,t.seller_name,
+				CASE t.enabled
+				WHEN 0 THEN '关闭'
+				ELSE '试用' END AS company_status,
+				t.view_total,0 AS road_show_total,t.create_time,'' AS last_view_time,t.overseas_label
+				FROM %s.english_company AS t
+				INNER JOIN overseas_custom_seller AS n ON t.seller_id=n.seller_id
+				)AS m
+		WHERE 1=1                       
+`
+
+	if condition != "" {
+		sql += condition
+	}
+
+	sql += ` GROUP BY m.overseas_label `
+
+	sql = fmt.Sprintf(sql, databaseName)
+
+	_, err = o.Raw(sql, pars).QueryRows(&list)
+	return
+}