Răsfoiți Sursa

记录用户浏览音频回放记录

xingzai 2 ani în urmă
părinte
comite
1371c9aac1
5 a modificat fișierele cu 104 adăugiri și 1 ștergeri
  1. 67 0
      controllers/activity.go
  2. 26 0
      models/activity_voice_history.go
  3. 1 0
      models/db.go
  4. 9 0
      routers/commentsRouter.go
  5. 1 1
      services/task.go

+ 67 - 0
controllers/activity.go

@@ -4807,3 +4807,70 @@ func (this *ActivityCoAntroller) ActivityAppointmentCancel() {
 	br.Msg = "已取消"
 	br.Data = resp
 }
+
+// @Title 记录用户浏览音频回放接口
+// @Description 记录用户浏览音频回放接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.AppointmentResp
+// @router /voiceHistory/add [post]
+func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	var req models.ActivityIdRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	var sellerName string
+	sellerName, err = models.GetCompanySellerName(user.CompanyId)
+	if err != nil {
+		br.Msg = "报名失败!"
+		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		return
+	}
+	item := new(models.CygxActivityVoiceHistory)
+	item.UserId = uid
+	item.ActivityId = activityId
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.SellerName = sellerName
+	item.RealName = user.RealName
+	err = models.AddCygxActivityVoiceHistory(item)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	return
+}

+ 26 - 0
models/activity_voice_history.go

@@ -0,0 +1,26 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityVoiceHistory struct {
+	Id          int       `orm:"column(id);pk"`
+	ActivityId  int       `description:"活动ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
+}
+
+//添加
+func AddCygxActivityVoiceHistory(item *CygxActivityVoiceHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 1 - 0
models/db.go

@@ -116,6 +116,7 @@ func init() {
 		new(CygxYidongActivityMeetingApiLog),
 		new(CygxIndustrialActivityGroupManagement),
 		new(CygxIndustrialActivityGroupSubject),
+		new(CygxActivityVoiceHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 9 - 0
routers/commentsRouter.go

@@ -232,6 +232,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "ActivityVoiceHistoryAdd",
+            Router: `/voiceHistory/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"],
         beego.ControllerComments{
             Method: "ApplyApprove",

+ 1 - 1
services/task.go

@@ -103,7 +103,7 @@ func Task() {
 	//GetAddpArticle() //同步日度点评数据
 	//SendEmailAllUserWithRAI()     //发送当前所有权益用户到沈大爷的邮箱
 	//SendEmailAllUserWithCompany() //发送这些公司下的用户到沈大爷的邮箱
-	task.StartTask()
+	//task.StartTask()
 	//StatisticalReport()//导出报表
 	fmt.Println("end")
 }