hongze před 1 rokem
rodič
revize
d28969c706

+ 3 - 3
controllers/overseas_custom/custom.go

@@ -68,7 +68,7 @@ func (this *OverseasCustomController) CustomList() {
 	var pars []interface{}
 	if keywords != "" {
 		k := "%" + keywords + "%"
-		enCompanyIds, e := models.GetEnCompanyIdsByKeyword(k)
+		enCompanyIds, e := overseas_custom.GetEnCompanyIdsByKeyword(k)
 		if e != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "关键词获取英文客户IDs失败, Err: " + e.Error()
@@ -436,7 +436,7 @@ func (this *OverseasCustomController) CustomStatistics() {
 	var pars []interface{}
 	if keywords != "" {
 		k := "%" + keywords + "%"
-		enCompanyIds, e := models.GetEnCompanyIdsByKeyword(k)
+		enCompanyIds, e := overseas_custom.GetEnCompanyIdsByKeyword(k)
 		if e != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "关键词获取英文客户IDs失败, Err: " + e.Error()
@@ -557,7 +557,7 @@ func (this *OverseasCustomController) CustomLabelStatistics() {
 	condition += " AND m.overseas_status='试用' "
 	if keywords != "" {
 		k := "%" + keywords + "%"
-		enCompanyIds, e := models.GetEnCompanyIdsByKeyword(k)
+		enCompanyIds, e := overseas_custom.GetEnCompanyIdsByKeyword(k)
 		if e != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "关键词获取英文客户IDs失败, Err: " + e.Error()

+ 4 - 4
models/english_report_email.go

@@ -283,12 +283,12 @@ b.company_name AS company_name,a.company_name AS register_company_name FROM engl
 func GetEnCompanyIdsByKeyword(keyword string) (companyIds []int, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	sql := `SELECT DISTINCT
-				a.company_id+10000000
+				a.company_id
 			FROM
-				english_report_email AS a
-			JOIN english_company AS b ON a.company_id = b.company_id AND b.is_deleted = 0
+				english_company AS a
+			LEFT JOIN english_report_email AS b ON a.company_id = b.company_id AND b.is_deleted = 0
 			WHERE
-				a.is_deleted = 0 AND a.status = 1 AND (a.email LIKE ? OR a.mobile LIKE ? OR b.company_name LIKE ? OR b.country_code LIKE ? )`
+				a.is_deleted = 0 AND a.status = 1 AND (b.email LIKE ? OR b.mobile LIKE ? OR a.company_name LIKE ? OR a.country_code LIKE ? )`
 	_, err = o.Raw(sql, keyword, keyword, keyword, keyword).QueryRows(&companyIds)
 	return
 }

+ 17 - 5
models/overseas_custom/custom.go

@@ -266,11 +266,10 @@ func (obj *Custom) GetCustomByCompanyId(companyId int) (item *Custom, err error)
 				SELECT a.company_id,a.company_name,a.nation,b.seller_id,b.seller_name,
 				b.view_total,b.road_show_total,a.created_time AS create_time,b.last_view_time,a.is_hide,a.overseas_status,a.reset_btn,
 				CASE b.status 
-+				WHEN '正式' THEN '正式'
-+				WHEN '永续' THEN '正式'
-+				WHEN '试用' THEN '试用'
-+				ELSE '关闭' END AS company_status
-				
+				WHEN '正式' THEN '正式'
+				WHEN '永续' THEN '正式'
+				WHEN '试用' THEN '试用'
+				ELSE '关闭' END AS company_status
 				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
@@ -367,3 +366,16 @@ func (obj *Custom) UpdateCompany(updateParams, whereParam map[string]interface{}
 	_, err = qs.Update(updateParams)
 	return
 }
+
+// GetEnCompanyIdsByKeyword 关键词获取英文客户IDs
+func GetEnCompanyIdsByKeyword(keyword string) (companyIds []int, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := ` SELECT (a.company_id+10000000) AS company_id 
+ FROM english_company AS a
+ LEFT JOIN english_report_email AS b ON a.company_id=b.company_id
+ WHERE a.is_deleted=0
+AND ( a.company_name LIKE ? OR a.country_code LIKE ? OR b.email LIKE ? OR b.mobile LIKE ?)
+GROUP BY a.company_id `
+	_, err = o.Raw(sql, keyword, keyword, keyword, keyword).QueryRows(&companyIds)
+	return
+}