Ver Fonte

新增标签设置

hongze há 1 ano atrás
pai
commit
6dcdbf1fa1

+ 70 - 0
controllers/overseas_custom/custom.go

@@ -21,6 +21,7 @@ import (
 // @Param   CustomType	query	int		false	"1:海外客户,2:隐藏客户"
 // @Param   SortField	query	string		false	"排序字段:ViewTotal,RoadShowTotal,CreateTime"
 // @Param   SortDesc	query	int		false	"1:降序,默认,2:升序"
+// @Param   OverseasLabel	query	int		false	"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"
 // @Success 200 {object} models.EnglishCompanyPageListResp
 // @router /custom/list [get]
 func (this *OverseasCustomController) CustomList() {
@@ -46,6 +47,7 @@ func (this *OverseasCustomController) CustomList() {
 	companyStatus := this.GetString("CompanyStatus")
 	sortField := this.GetString("SortField")
 	sortDesc, _ := this.GetInt("SortDesc")
+	overseasLabel, _ := this.GetInt("OverseasLabel", 0)
 
 	var startSize int
 	if pageSize <= 0 {
@@ -88,6 +90,11 @@ func (this *OverseasCustomController) CustomList() {
 		pars = append(pars, sellerId)
 	}
 
+	if overseasLabel > 0 {
+		condition = ` AND m.overseas_label=? `
+		pars = append(pars, overseasLabel)
+	}
+
 	total, err := obj.GetCustomListCount(condition, pars, companyStatus)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -289,3 +296,66 @@ func (this *OverseasCustomController) CustomStatusSet() {
 	br.Success = true
 	br.Msg = "操作成功"
 }
+
+// @Title 客户子标签设置
+// @Description 客户子标签设置
+// @Param	request  body  overseas_custom.CustomOverseasLabelSetReq  true  "type json string"
+// @Success 200 string "操作成功"
+// @router /custom/overseas_label_set [post]
+func (this *OverseasCustomController) CustomOverseasLabelSet() {
+	br := new(models.BaseResponse).Init()
+	br.IsSendEmail = false
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	//海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req overseas_custom.CustomOverseasLabelSetReq
+	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	if req.CompanyId <= 0 {
+		br.Msg = "参数错误!"
+		return
+	}
+
+	if req.CompanyId > 1000000 {
+		enCompanyObj := new(models.EnglishCompany)
+		// 更新客户
+		nowTime := time.Now().Local()
+		enCompanyObj.CompanyId = req.CompanyId - utils.EnCompanyIdStep
+		enCompanyObj.OverseasLabel = req.OverseasLabel
+		enCompanyObj.ModifyTime = nowTime
+		updateCols := []string{"OverseasLabel", "ModifyTime"}
+		if err := enCompanyObj.Update(updateCols); err != nil {
+			br.Msg = "设置失败"
+			br.ErrMsg = "设置英文客户标签状态失败, Err:" + err.Error()
+			return
+		}
+	} else {
+		companyObj := new(company.Company)
+		companyObj.CompanyId = req.CompanyId
+		companyObj.OverseasLabel = req.OverseasLabel
+		updateCols := []string{"OverseasLabel"}
+		err := companyObj.Update(updateCols)
+		if err != nil {
+			br.Msg = "设置失败"
+			br.ErrMsg = "设置客户标签状态失败, Err:" + err.Error()
+			return
+		}
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "设置成功"
+}

+ 1 - 0
models/company/company.go

@@ -44,6 +44,7 @@ type Company struct {
 	Nation          string    `description:"所属国家"`
 	IsHide          int       `description:"是否隐藏:0:不隐藏,1:隐藏"`
 	OverseasStatus  string    `description:"海外客户状态:'正式','试用','关闭'"`
+	OverseasLabel   int       `description:"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"`
 }
 
 // 新增客户

+ 1 - 0
models/english_company.go

@@ -29,6 +29,7 @@ type EnglishCompany struct {
 	Nation         string    `description:"所属国家"`
 	IsHide         int       `description:"是否隐藏:0:不隐藏,1:隐藏"`
 	OverseasStatus string    `description:"海外客户状态:'正式','试用','关闭'"`
+	OverseasLabel  int       `description:"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"`
 }
 
 type EnglishCompanyListItem struct {

+ 13 - 5
models/overseas_custom/custom.go

@@ -46,7 +46,7 @@ func (obj *Custom) GetCustomTotal(condition string, pars []interface{}) (list []
 				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.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
@@ -56,7 +56,7 @@ func (obj *Custom) GetCustomTotal(condition string, pars []interface{}) (list []
 				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.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
@@ -102,7 +102,7 @@ func (obj *Custom) GetCustomListCount(condition string, pars []interface{}, comp
 				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.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
@@ -120,7 +120,7 @@ func (obj *Custom) GetCustomListCount(condition string, pars []interface{}, comp
 				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.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
              WHERE 1=1 `
@@ -225,7 +225,6 @@ type CustomListResp struct {
 	OverseasLabelData []*OverseasLabelTotal
 }
 
-// EnglishCompanySaveReq 英文客户-保存请求体
 type CustomHideReq struct {
 	CompanyId int `description:"客户ID"`
 }
@@ -240,6 +239,10 @@ func (obj *Custom) GetCustomByCompanyId(companyId int) (list *Custom, err error)
 		databaseName = "hongze_rddp"
 	}
 
+	if companyId > utils.EnCompanyIdStep {
+		companyId = companyId - utils.EnCompanyIdStep
+	}
+
 	sql = `SELECT * FROM (
 				SELECT a.company_id,a.company_name,a.nation,b.seller_id,b.seller_name,
 				CASE b.status 
@@ -320,3 +323,8 @@ func (obj *Custom) GetCustomOverseasLabelTotal(condition string, pars []interfac
 	_, err = o.Raw(sql, pars).QueryRows(&list)
 	return
 }
+
+type CustomOverseasLabelSetReq struct {
+	CompanyId     int `description:"客户ID"`
+	OverseasLabel int `description:"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"`
+}