Browse Source

修复ETA试用平台原内容

hsun 1 year ago
parent
commit
b299245a8f

+ 5 - 8
controllers/business_conf.go

@@ -16,6 +16,10 @@ type BusinessConfController struct {
 	BaseAuthController
 }
 
+type BusinessConfOpenController struct {
+	BaseCommonController
+}
+
 // Save
 // @Title 保存配置
 // @Description 保存配置
@@ -201,7 +205,7 @@ func (this *BusinessConfController) Fetch() {
 // @Description 商家编码加密
 // @Success 200 Ret=200 获取成功
 // @router /code_encrypt [get]
-func (this *BusinessConfController) CodeEncrypt() {
+func (this *BusinessConfOpenController) CodeEncrypt() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		if br.ErrMsg == "" {
@@ -210,13 +214,6 @@ func (this *BusinessConfController) CodeEncrypt() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.SysUser
-	if sysUser == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,SysUser Is Empty"
-		br.Ret = 408
-		return
-	}
 
 	res := ""
 	if utils.BusinessCode != "" {

+ 31 - 0
controllers/data_manage/chart_info.go

@@ -8,6 +8,7 @@ import (
 	"eta/eta_api/models/system"
 	"eta/eta_api/services"
 	"eta/eta_api/services/data"
+	etaTrialService "eta/eta_api/services/eta_trial"
 	"eta/eta_api/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
@@ -241,6 +242,21 @@ func (this *ChartInfoController) ChartInfoAdd() {
 		go data_manage.AddChartInfoLog(chartLog)
 	}
 
+	// 试用平台更新用户累计新增图表数
+	adminItem, e := system.GetSysAdminById(sysUser.AdminId)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error()
+		return
+	}
+	if utils.BusinessCode == utils.BusinessCodeSandbox && adminItem.DepartmentName == "ETA试用客户" {
+		go func() {
+			var r etaTrialService.EtaTrialUserReq
+			r.Mobile = adminItem.Mobile
+			_, _ = etaTrialService.UpdateUserChartNum(r)
+		}()
+	}
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "保存成功"
@@ -2577,6 +2593,21 @@ func (this *ChartInfoController) CopyChartInfo() {
 		go data_manage.AddChartInfoLog(chartLog)
 	}
 
+	// 试用平台更新用户累计新增图表数
+	adminItem, e := system.GetSysAdminById(sysUser.AdminId)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error()
+		return
+	}
+	if utils.BusinessCode == utils.BusinessCodeSandbox && adminItem.DepartmentName == "ETA试用客户" {
+		go func() {
+			var r etaTrialService.EtaTrialUserReq
+			r.Mobile = adminItem.Mobile
+			_, _ = etaTrialService.UpdateUserChartNum(r)
+		}()
+	}
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "保存成功"

+ 16 - 0
controllers/data_manage/edb_info.go

@@ -10,6 +10,7 @@ import (
 	"eta/eta_api/services/alarm_msg"
 	"eta/eta_api/services/data"
 	"eta/eta_api/services/elastic"
+	etaTrialService "eta/eta_api/services/eta_trial"
 	"eta/eta_api/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
@@ -1863,6 +1864,21 @@ func (this *EdbInfoController) EdbInfoAdd() {
 		return
 	}
 
+	// 试用平台更新用户累计新增指标数
+	adminItem, e := system.GetSysAdminById(sysUser.AdminId)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error()
+		return
+	}
+	if utils.BusinessCode == utils.BusinessCodeSandbox && adminItem.DepartmentName == "ETA试用客户" {
+		go func() {
+			var r etaTrialService.EtaTrialUserReq
+			r.Mobile = adminItem.Mobile
+			_, _ = etaTrialService.UpdateUserIndexNum(r)
+		}()
+	}
+
 	//新增操作日志
 	{
 		edbLog := new(data_manage.EdbInfoLog)

+ 31 - 0
controllers/data_manage/future_good/future_good_chart_info.go

@@ -11,6 +11,7 @@ import (
 	"eta/eta_api/services"
 	"eta/eta_api/services/data"
 	future_goodServ "eta/eta_api/services/data/future_good"
+	etaTrialService "eta/eta_api/services/eta_trial"
 	"eta/eta_api/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
@@ -561,6 +562,21 @@ func (this *FutureGoodChartInfoController) ChartInfoAdd() {
 		go data_manage.AddChartInfoLog(chartLog)
 	}
 
+	// 试用平台更新用户累计新增图表数
+	adminItem, e := system.GetSysAdminById(sysUser.AdminId)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error()
+		return
+	}
+	if utils.BusinessCode == utils.BusinessCodeSandbox && adminItem.DepartmentName == "ETA试用客户" {
+		go func() {
+			var r etaTrialService.EtaTrialUserReq
+			r.Mobile = adminItem.Mobile
+			_, _ = etaTrialService.UpdateUserChartNum(r)
+		}()
+	}
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "保存成功"
@@ -2423,6 +2439,21 @@ func (this *FutureGoodChartInfoController) CopyChartInfo() {
 		go data_manage.AddChartInfoLog(chartLog)
 	}
 
+	// 试用平台更新用户累计新增图表数
+	adminItem, e := system.GetSysAdminById(sysUser.AdminId)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error()
+		return
+	}
+	if utils.BusinessCode == utils.BusinessCodeSandbox && adminItem.DepartmentName == "ETA试用客户" {
+		go func() {
+			var r etaTrialService.EtaTrialUserReq
+			r.Mobile = adminItem.Mobile
+			_, _ = etaTrialService.UpdateUserChartNum(r)
+		}()
+	}
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "保存成功"

+ 202 - 0
controllers/eta_trial/questionnaire.go

@@ -0,0 +1,202 @@
+package eta_trial
+
+import (
+	"encoding/json"
+	"eta/eta_api/models"
+	"eta/eta_api/models/eta_trial"
+	etaTrialService "eta/eta_api/services/eta_trial"
+	"eta/eta_api/utils"
+	"time"
+)
+
+// QuestionnairePopUp
+// @Title 获取问卷调查弹窗信息
+// @Description 获取问卷调查弹窗信息
+// @Success 200 {object} response.TryOutCompanyListResp
+// @router /questionnaire/popup [get]
+func (this *EtaTrialController) QuestionnairePopUp() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	// 仅试用平台用
+	if utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		return
+	}
+
+	var resp eta_trial.QuestionnairePopupResp
+
+	var userReq etaTrialService.GetEtaTrialUserReq
+	userReq.Mobile = sysUser.Mobile
+	item, e := etaTrialService.GetEtaTrialUser(userReq)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取ETA试用客户失败, GetEtaTrialUser Err:" + e.Error()
+		return
+	}
+	if item.EtaTrialId <= 0 {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		return
+	}
+
+	fillItem, e := eta_trial.GetQuestionnaireFillRecordCountByMobile(sysUser.Mobile)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败失败,GetQuestionnaireFillRecordCountByMobile Err:" + e.Error()
+		return
+	}
+	if fillItem == nil {
+		//没填过
+		if item.ModifyTime.AddDate(0, 0, 6).Before(time.Now()) {
+			//弹窗
+			resp.IsPopup = 1
+		}
+	} else {
+		//填过,判断是否超过了14天
+		if fillItem.IsFill == 2 && fillItem.CreateTime.AddDate(0, 0, 13).Before(time.Now()) {
+			//弹窗
+			resp.IsPopup = 1
+		} else if fillItem.IsFill == 1 {
+			//显示图标但不弹窗
+			resp.IsShow = 1
+		}
+	}
+	// TODO:测试
+	resp.IsPopup = 1
+	resp.IsShow = 1
+
+	questionnaireList, e := etaTrialService.GetEtaTrialQuestionnaireList()
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取问卷调查列表失败, GetEtaTrialQuestionnaireList Err: " + e.Error()
+		return
+	}
+	resp.Question = questionnaireList
+
+	br.Data = resp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}
+
+// QuestionnaireCommit
+// @Title 提交问卷
+// @Description 提交问卷
+// @Success 200 {object} response.TryOutCompanyListResp
+// @router /questionnaire/commit [post]
+func (this *EtaTrialController) QuestionnaireCommit() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req eta_trial.EtaTrialQuestionnaireReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	var userReq etaTrialService.GetEtaTrialUserReq
+	userReq.Mobile = sysUser.Mobile
+	admin, e := etaTrialService.GetEtaTrialUser(userReq)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "获取ETA试用客户失败, GetEtaTrialUser Err:" + e.Error()
+		return
+	}
+	if admin.EtaTrialId <= 0 {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
+
+	if req.IsFill == 0 {
+		// 稍后再填
+		fillItem := &eta_trial.QuestionnaireFillRecord{
+			Mobile:     admin.Mobile,
+			IsFill:     1,
+			CreateTime: time.Now(),
+			ModifyTime: time.Now(),
+		}
+		err := eta_trial.AddQuestionnaireFillRecord(fillItem)
+		if err != nil {
+			br.Msg = "新增填写记录失败"
+			br.ErrMsg = "新增填写记录失败, Err:" + err.Error()
+			return
+		}
+	} else {
+		// 已填写
+		list := make([]eta_trial.EtaTrialQuestionnaireRecord, 0)
+		for _, q := range req.List {
+			v := eta_trial.EtaTrialQuestionnaireRecord{
+				UserName:        admin.UserName,
+				CompanyName:     admin.CompanyName,
+				Position:        admin.Position,
+				Options:         q.Options,
+				Mobile:          admin.Mobile,
+				Type:            q.Type,
+				QuestionnaireId: q.QuestionnaireId,
+				CreateTime:      time.Now(),
+			}
+			list = append(list, v)
+		}
+
+		var commitReq etaTrialService.EtaTrialQuestionnaireCommitReq
+		commitReq.List = list
+		commitRes, e := etaTrialService.EtaTrialQuestionnaireCommit(commitReq)
+		if e != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "新增问卷记录失败, EtaTrialQuestionnaireCommit Err: " + e.Error()
+			return
+		}
+		if !commitRes {
+			br.Msg = "操作失败"
+			br.ErrMsg = "新增问卷记录失败" + e.Error()
+			return
+		}
+
+		fillItem := &eta_trial.QuestionnaireFillRecord{
+			Mobile:     admin.Mobile,
+			IsFill:     2,
+			CreateTime: time.Now(),
+			ModifyTime: time.Now(),
+		}
+		err := eta_trial.AddQuestionnaireFillRecord(fillItem)
+		if err != nil {
+			br.Msg = "新增填写记录失败"
+			br.ErrMsg = "新增填写记录失败, Err:" + err.Error()
+			return
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "提交成功"
+}

+ 140 - 0
controllers/eta_trial/user.go

@@ -0,0 +1,140 @@
+package eta_trial
+
+import (
+	"encoding/json"
+	"eta/eta_api/controllers"
+	"eta/eta_api/models"
+	"eta/eta_api/models/eta_trial"
+	etaTrialService "eta/eta_api/services/eta_trial"
+	"eta/eta_api/utils"
+)
+
+// EtaTrialController ETA试用
+type EtaTrialController struct {
+	controllers.BaseAuthController
+}
+
+// UpdateActiveTime
+// @Title 累计活跃时长
+// @Description 累计活跃时长
+// @Param   ActiveTime	query	int		true	"活跃时长"
+// @Param   Part		query	string	true	"活跃板块"
+// @Success 200 {object} models.ETATrialAddReq
+// @router /user/active [post]
+func (this *EtaTrialController) UpdateActiveTime() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	// 仅试用平台用
+	if utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
+
+	var req eta_trial.UpdateUserActiveTimeReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.Part == "" {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
+
+	params := etaTrialService.UpdateEtaTrialUserActiveTimeReq{
+		UserName:   sysUser.RealName,
+		Mobile:     sysUser.Mobile,
+		ActiveTime: req.ActiveTime,
+		Part:       req.Part,
+	}
+	res, e := etaTrialService.UpdateEtaTrialUserActiveTime(params)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "更新ETA试用用户活跃时长失败, Err: " + e.Error()
+		return
+	}
+	if !res {
+		br.Msg = "操作失败"
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "新增成功"
+}
+
+// UpdateLoginDuration
+// @Title 更新用户登录时长
+// @Description 更新用户登录时长
+// @Param   ActiveTime	query	int		true	"活跃时长"
+// @Success 200 {object} models.ETATrialAddReq
+// @router /user/login_duration [post]
+func (this *EtaTrialController) UpdateLoginDuration() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	// 仅试用平台用
+	if utils.BusinessCode != utils.BusinessCodeSandbox {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "操作成功"
+		return
+	}
+	var req eta_trial.UpdateUserLoginDurationReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	params := etaTrialService.UpdateEtaTrialUserLoginDurationReq{
+		UserName:   sysUser.RealName,
+		Mobile:     sysUser.Mobile,
+		ActiveTime: req.ActiveTime,
+	}
+	res, e := etaTrialService.UpdateEtaTrialUserLoginDuration(params)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "更新ETA试用用户登录时长失败, Err: " + e.Error()
+		return
+	}
+	if !res {
+		br.Msg = "操作失败"
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "新增成功"
+}

+ 31 - 0
controllers/sys_admin.go

@@ -8,6 +8,7 @@ import (
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services"
+	etaTrialService "eta/eta_api/services/eta_trial"
 	"eta/eta_api/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
@@ -718,6 +719,18 @@ func (this *SysAdminController) Edit() {
 	utils.Rc.Delete(utils.CACHE_KEY_ADMIN)
 	utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
 
+	// 试用客户更新对应信息
+	if utils.BusinessCode == utils.BusinessCodeSandbox && adminInfo.DepartmentName == "ETA试用客户" {
+		go func() {
+			var r etaTrialService.EtaTrialUserEditReq
+			r.RealName = req.RealName
+			r.Position = req.Position
+			r.Mobile = adminInfo.Mobile
+			r.Enabled = req.Enabled
+			_, _ = etaTrialService.EditEtaTrialUser(r)
+		}()
+	}
+
 	br.Ret = 200
 	br.Success = true
 	br.IsAddLog = true
@@ -758,6 +771,15 @@ func (this *SysAdminController) EditEnabled() {
 			br.ErrMsg = "修改系统用户数据失败,Err:" + err.Error()
 			return
 		}
+
+		// 更新试用平台客户
+		if utils.BusinessCode == utils.BusinessCodeSandbox && adminItem.DepartmentName == "ETA试用客户" {
+			go func() {
+				var r etaTrialService.EtaTrialUserReq
+				r.Mobile = adminItem.Mobile
+				_, _ = etaTrialService.DisableEtaTrialUser(r)
+			}()
+		}
 	} else {
 		admin := new(system.Admin)
 		admin.Enabled = req.Enabled
@@ -855,6 +877,15 @@ func (this *SysAdminController) Delete() {
 	utils.Rc.Delete(utils.CACHE_KEY_ADMIN)
 	utils.Rc.Delete(utils.CACHE_KEY_ADMIN_ID)
 
+	// 删除试用平台客户
+	if utils.BusinessCode == utils.BusinessCodeSandbox && adminInfo.DepartmentName == "ETA试用客户" {
+		go func() {
+			var r etaTrialService.EtaTrialUserReq
+			r.Mobile = mobile
+			_, _ = etaTrialService.RemoveEtaTrialUser(r)
+		}()
+	}
+
 	br.Ret = 200
 	br.Success = true
 	br.IsAddLog = true

+ 10 - 0
controllers/sys_user.go

@@ -5,6 +5,7 @@ import (
 	"eta/eta_api/models"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services"
+	"eta/eta_api/services/eta_trial"
 	"eta/eta_api/utils"
 	"fmt"
 	"time"
@@ -185,6 +186,15 @@ func (this *SysUserController) Login() {
 			utils.Rc.Put(noTrustLoginKey, sysSession.Id, 30*time.Minute)
 		}
 	}
+
+	// ETA试用平台-请求中间服务更新用户最后登录时间和次数
+	if utils.BusinessCode == utils.BusinessCodeSandbox {
+		go func() {
+			var r eta_trial.EtaTrialUserReq
+			r.Mobile = sysUser.Mobile
+			_, _ = eta_trial.UpdateEtaTrialUserLogin(r)
+		}()
+	}
 }
 
 type SysUserAuthController struct {

+ 7 - 0
models/base.go

@@ -37,3 +37,10 @@ type BaseRequest struct {
 func (br *BaseRequest) Init() *BaseRequest {
 	return &BaseRequest{}
 }
+
+type ResultData struct {
+	Code   int         `json:"code" description:"状态码"`
+	Msg    string      `json:"msg" description:"提示信息"`
+	Data   interface{} `json:"data" description:"返回数据"`
+	ErrMsg string      `json:"-" description:"错误信息,不用返回给前端,只是做日志记录"`
+}

+ 14 - 1
models/db.go

@@ -1,17 +1,18 @@
 package models
 
 import (
-	_ "github.com/go-sql-driver/mysql"
 	"eta/eta_api/models/company"
 	"eta/eta_api/models/data_manage"
 	future_good2 "eta/eta_api/models/data_manage/future_good"
 	"eta/eta_api/models/data_manage/supply_analysis"
+	"eta/eta_api/models/eta_trial"
 	"eta/eta_api/models/ppt_english"
 	"eta/eta_api/models/sandbox"
 	"eta/eta_api/models/semantic_analysis"
 	"eta/eta_api/models/system"
 	"eta/eta_api/models/yb"
 	"eta/eta_api/utils"
+	_ "github.com/go-sql-driver/mysql"
 	"time"
 
 	"github.com/beego/beego/v2/client/orm"
@@ -132,6 +133,11 @@ func init() {
 
 	// 商家配置
 	initBusinessConf()
+
+	// ETA试用相关表
+	if utils.BusinessCode == utils.BusinessCodeSandbox {
+		initEtaTrial()
+	}
 }
 
 // initSystem 系统表 数据表
@@ -392,3 +398,10 @@ func initBusinessConf() {
 		new(BusinessConfOperationRecord), // 商家配置操作记录表
 	)
 }
+
+// initEtaTrial 试用平台相关表
+func initEtaTrial() {
+	orm.RegisterModel(
+		new(eta_trial.QuestionnaireFillRecord), // 问卷填写记录表
+	)
+}

+ 41 - 0
models/eta_trial/questionnaire_fill_record.go

@@ -0,0 +1,41 @@
+package eta_trial
+
+import (
+	"eta/eta_api/utils"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// QuestionnaireFillRecord 问卷填写记录表
+type QuestionnaireFillRecord struct {
+	RecordId   int    `orm:"column(fill_record_id);pk" description:"记录id"`
+	Mobile     string `description:"手机"`
+	IsFill     int    `description:"0未点过 1稍后再填 2已填写"`
+	CreateTime time.Time
+	ModifyTime time.Time
+}
+
+// GetQuestionnaireFillRecordCountByMobile 手机号获取问卷填写记录
+func GetQuestionnaireFillRecordCountByMobile(mobile string) (item *QuestionnaireFillRecord, err error) {
+	if utils.BusinessCode != utils.BusinessCodeSandbox {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `SELECT * FROM questionnaire_fill_record WHERE mobile=? ORDER BY create_time DESC LIMIT 1`
+	err = o.Raw(sql, mobile).QueryRow(&item)
+	return
+}
+
+// AddQuestionnaireFillRecord 新增问卷填写记录
+func AddQuestionnaireFillRecord(item *QuestionnaireFillRecord) (err error) {
+	if utils.BusinessCode != utils.BusinessCodeSandbox {
+		return
+	}
+	o := orm.NewOrm()
+	id, err := o.Insert(item)
+	if err != nil {
+		return
+	}
+	item.RecordId = int(id)
+	return
+}

+ 80 - 0
models/eta_trial/request.go

@@ -0,0 +1,80 @@
+package eta_trial
+
+import "time"
+
+type QuestionnairePopupResp struct {
+	IsPopup  int `description:"0 弹窗 1不弹"`
+	IsShow   int `description:"0 不显示 1显示"`
+	Question EtaTrialQuestionnaireResp
+}
+
+// EtaTrialQuestionnaireResp 问卷调查列表响应体
+type EtaTrialQuestionnaireResp struct {
+	List []EtaTrialQuestionnaireRespItem
+}
+
+// EtaTrialQuestionnaireRespItem 问卷调查信息
+type EtaTrialQuestionnaireRespItem struct {
+	QuestionnaireId int      `orm:"column(questionnaire_id);pk" description:"问卷题目id"`
+	Question        string   `description:"题目"`
+	Type            int      `description:"1单选 2多选 3简答题"`
+	Sort            int      `description:"排序"`
+	Option          []string `description:"选项"`
+	IsMust          int      `description:"是否必填"`
+	CreateTime      string
+}
+
+type EtaTrialQuestionnaireReq struct {
+	IsFill int `description:"0稍后再填 1已填写"`
+	List   []EtaTrialQuestionnaireReqItem
+}
+
+type EtaTrialQuestionnaireReqItem struct {
+	QuestionnaireId int    `description:"题目id"`
+	Options         string `description:"选项"`
+	Type            int    `description:"1单选 2多选 3简答题"`
+}
+
+// EtaTrialUserItem ETA试用客户
+type EtaTrialUserItem struct {
+	EtaTrialId    int    `description:"eta试用客户id"`
+	UserName      string `description:"客户名称"`
+	CompanyName   string `description:"客户公司姓名"`
+	Position      string `description:"职位"`
+	Password      string
+	Account       string
+	Mobile        string    `description:"手机号"`
+	Enabled       int       `description:"1:有效,0:禁用"`
+	ActiveTime    int       `description:"累计活跃时长"`
+	IndexNum      int       `description:"累计添加指标"`
+	ChartNum      int       `description:"累计添加图表"`
+	LoginNum      int       `description:"累计登录次数"`
+	LastLoginTime time.Time `description:"最后一次登陆时间"`
+	SellerId      int       `description:"销售id"`
+	Seller        string    `description:"销售员名称"`
+	CreateTime    time.Time
+	ModifyTime    time.Time
+}
+
+type EtaTrialQuestionnaireRecord struct {
+	RecordId        int       `description:"记录id" json:"record_id"`
+	UserName        string    `description:"用户名" json:"user_name"`
+	CompanyName     string    `description:"公司名" json:"company_name"`
+	Position        string    `description:"职位" json:"position"`
+	Options         string    `description:"选项" json:"options"`
+	Mobile          string    `description:"手机" json:"mobile"`
+	Type            int       `description:"1单选 2多选 3简答题" json:"type"`
+	QuestionnaireId int       `description:"题目id" json:"questionnaire_id"`
+	CreateTime      time.Time `json:"create_time"`
+}
+
+// UpdateUserActiveTimeReq 更新用户活跃时间请求体
+type UpdateUserActiveTimeReq struct {
+	ActiveTime int    `description:"活跃时长, 单位秒"`
+	Part       string `description:"活跃板块"`
+}
+
+// UpdateUserLoginDurationReq 更新用户登录时长请求体
+type UpdateUserLoginDurationReq struct {
+	ActiveTime int `description:"活跃时长, 单位秒"`
+}

+ 45 - 9
routers/commentsRouter.go

@@ -3985,6 +3985,42 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"],
+        beego.ControllerComments{
+            Method: "QuestionnaireCommit",
+            Router: `/questionnaire/commit`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"],
+        beego.ControllerComments{
+            Method: "QuestionnairePopUp",
+            Router: `/questionnaire/popup`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"],
+        beego.ControllerComments{
+            Method: "UpdateActiveTime",
+            Router: `/user/active`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/eta_trial:EtaTrialController"],
+        beego.ControllerComments{
+            Method: "UpdateLoginDuration",
+            Router: `/user/login_duration`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/roadshow:CalendarController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/roadshow:CalendarController"],
         beego.ControllerComments{
             Method: "ResearcherList",
@@ -4372,15 +4408,6 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_api/controllers:BusinessConfController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:BusinessConfController"],
-        beego.ControllerComments{
-            Method: "CodeEncrypt",
-            Router: `/code_encrypt`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
     beego.GlobalControllerRouter["eta/eta_api/controllers:BusinessConfController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:BusinessConfController"],
         beego.ControllerComments{
             Method: "Fetch",
@@ -4399,6 +4426,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers:BusinessConfOpenController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:BusinessConfOpenController"],
+        beego.ControllerComments{
+            Method: "CodeEncrypt",
+            Router: `/code_encrypt`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers:ClassifyController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers:ClassifyController"],
         beego.ControllerComments{
             Method: "Add",

+ 7 - 0
routers/router.go

@@ -16,6 +16,7 @@ import (
 	"eta/eta_api/controllers/data_manage/line_feature"
 	"eta/eta_api/controllers/data_manage/supply_analysis"
 	"eta/eta_api/controllers/english_report"
+	"eta/eta_api/controllers/eta_trial"
 	"eta/eta_api/controllers/roadshow"
 	"eta/eta_api/controllers/sandbox"
 	"eta/eta_api/controllers/semantic_analysis"
@@ -257,6 +258,7 @@ func init() {
 		web.NSNamespace("/business_conf",
 			web.NSInclude(
 				&controllers.BusinessConfController{},
+				&controllers.BusinessConfOpenController{},
 			),
 		),
 		web.NSNamespace("/trade_analysis",
@@ -264,6 +266,11 @@ func init() {
 				&trade_analysis.TradeAnalysisController{},
 			),
 		),
+		web.NSNamespace("/eta_trial",
+			web.NSInclude(
+				&eta_trial.EtaTrialController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 132 - 0
services/eta_trial/questionnaire.go

@@ -0,0 +1,132 @@
+package eta_trial
+
+import (
+	"encoding/json"
+	"eta/eta_api/models"
+	"eta/eta_api/models/eta_trial"
+	"eta/eta_api/utils"
+	"fmt"
+	"io/ioutil"
+	"net/http"
+	"strings"
+)
+
+type EtaTrialQuestionnaireListResp struct {
+	Code   int                                 `json:"code" description:"状态码"`
+	Msg    string                              `json:"msg" description:"提示信息"`
+	Data   eta_trial.EtaTrialQuestionnaireResp `json:"data" description:"返回数据"`
+	ErrMsg string                              `json:"-" description:"错误信息,不用返回给前端,只是做日志记录"`
+}
+
+// GetEtaTrialQuestionnaireList CRM_ETA服务-获取问卷列表
+func GetEtaTrialQuestionnaireList() (res eta_trial.EtaTrialQuestionnaireResp, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/questionnaire/list")
+
+	body := ioutil.NopCloser(strings.NewReader(""))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(EtaTrialQuestionnaireListResp)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = result.Data
+	return
+}
+
+type EtaTrialQuestionnaireCommitReq struct {
+	List []eta_trial.EtaTrialQuestionnaireRecord
+}
+
+// EtaTrialQuestionnaireCommit CRM_ETA服务-提交问卷调查
+func EtaTrialQuestionnaireCommit(pars EtaTrialQuestionnaireCommitReq) (res bool, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/questionnaire/commit")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(models.ResultData)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = true
+	return
+}

+ 573 - 0
services/eta_trial/user.go

@@ -0,0 +1,573 @@
+package eta_trial
+
+import (
+	"encoding/json"
+	"eta/eta_api/models"
+	"eta/eta_api/models/eta_trial"
+	"eta/eta_api/utils"
+	"fmt"
+	"io/ioutil"
+	"net/http"
+	"strings"
+)
+
+// EtaTrialUserReq 更新试用客户最后登录时间和次数请求体
+type EtaTrialUserReq struct {
+	Mobile string `description:"手机号"`
+}
+
+// UpdateEtaTrialUserLogin CRM_ETA服务-更新试用客户最后登录时间和次数
+func UpdateEtaTrialUserLogin(pars EtaTrialUserReq) (res bool, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/user/update_login")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(models.ResultData)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = true
+	return
+}
+
+// GetEtaTrialUserReq 获取试用客户请求体
+type GetEtaTrialUserReq struct {
+	Mobile string `description:"手机号"`
+}
+
+type EtaTrialUserResp struct {
+	Code   int                        `json:"code" description:"状态码"`
+	Msg    string                     `json:"msg" description:"提示信息"`
+	Data   eta_trial.EtaTrialUserItem `json:"data" description:"返回数据"`
+	ErrMsg string                     `json:"-" description:"错误信息,不用返回给前端,只是做日志记录"`
+}
+
+// GetEtaTrialUser CRM_ETA服务-获取试用客户信息
+func GetEtaTrialUser(pars GetEtaTrialUserReq) (res eta_trial.EtaTrialUserItem, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/user/mobile_fetch")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	//result := new(models.ResultData)
+	result := new(EtaTrialUserResp)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	utils.FileLog.Info("%s", string(b))
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = result.Data
+	//r, ok := result.Data.(eta_trial.EtaTrialUserResp)
+	//if !ok {
+	//	err = fmt.Errorf("result data err")
+	//	return
+	//}
+	//res = r
+	return
+}
+
+// DisableEtaTrialUser CRM_ETA服务-禁用试用客户
+func DisableEtaTrialUser(pars EtaTrialUserReq) (res bool, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/user/disable")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(models.ResultData)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = true
+	return
+}
+
+// RemoveEtaTrialUser CRM_ETA服务-删除试用客户
+func RemoveEtaTrialUser(pars EtaTrialUserReq) (res bool, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/user/remove")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(models.ResultData)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = true
+	return
+}
+
+// EtaTrialUserEditReq 更新用户信息请求体
+type EtaTrialUserEditReq struct {
+	RealName string `description:"姓名"`
+	Position string `description:"职务"`
+	Mobile   string `description:"手机号"`
+	Enabled  int    `description:"禁启用"`
+}
+
+// EditEtaTrialUser CRM_ETA服务-编辑试用客户
+func EditEtaTrialUser(pars EtaTrialUserEditReq) (res bool, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/user/edit")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(models.ResultData)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = true
+	return
+}
+
+// UpdateUserIndexNum CRM_ETA服务-更新用户累计新增指标数
+func UpdateUserIndexNum(pars EtaTrialUserReq) (res bool, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/user/update_index_num")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(models.ResultData)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = true
+	return
+}
+
+// UpdateUserChartNum CRM_ETA服务-更新用户累计新增图表数
+func UpdateUserChartNum(pars EtaTrialUserReq) (res bool, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/user/update_chart_num")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(models.ResultData)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = true
+	return
+}
+
+// UpdateEtaTrialUserActiveTimeReq 更新试用客户活跃时长请求体
+type UpdateEtaTrialUserActiveTimeReq struct {
+	Mobile     string `description:"手机号"`
+	UserName   string `description:"用户姓名"`
+	ActiveTime int    `description:"活跃时长, 单位秒"`
+	Part       string `description:"活跃板块"`
+}
+
+// UpdateEtaTrialUserActiveTime CRM_ETA服务-更新试用客户活跃时长
+func UpdateEtaTrialUserActiveTime(pars UpdateEtaTrialUserActiveTimeReq) (res bool, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/user/update_active_time")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(models.ResultData)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = true
+	return
+}
+
+// UpdateEtaTrialUserLoginDurationReq 更新试用客户登录时长请求体
+type UpdateEtaTrialUserLoginDurationReq struct {
+	Mobile     string `description:"手机号"`
+	UserName   string `description:"用户姓名"`
+	ActiveTime int    `description:"活跃时长, 单位秒"`
+}
+
+// UpdateEtaTrialUserLoginDuration CRM_ETA服务-更新试用客户登录时长
+func UpdateEtaTrialUserLoginDuration(pars UpdateEtaTrialUserLoginDurationReq) (res bool, err error) {
+	url := fmt.Sprint(utils.CrmEtaServerUrl, "/api/eta_trial/user/update_login_duration")
+	params, e := json.Marshal(pars)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	body := ioutil.NopCloser(strings.NewReader(string(params)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", url, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.CrmEtaAuthorization)
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	b, e := ioutil.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(b) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(b)
+		str = strings.Trim(str, `"`)
+		b = utils.DesBase64Decrypt([]byte(str))
+	}
+
+	result := new(models.ResultData)
+	if e = json.Unmarshal(b, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b))
+		return
+	}
+	if result.Code != 200 {
+		err = fmt.Errorf("result: %s", string(b))
+		return
+	}
+	res = true
+	return
+}

+ 2 - 0
utils/constants.go

@@ -300,3 +300,5 @@ const (
 	BusinessCodeSandbox = "E2023080700" // 试用平台
 	BusinessCodeRelease = "E2023080900" // 生产环境
 )
+
+const CrmEtaAuthorization = "NIi1RbEmH0C2rksXtPGDPBBgRgTZY87Q"