|
@@ -232,3 +232,77 @@ func (this *ReportSelectionController) ClickHistory() {
|
|
|
br.Success = true
|
|
|
br.Msg = "记录成功"
|
|
|
}
|
|
|
+
|
|
|
+// @Title 上传文章阅读时间
|
|
|
+// @Description 上传文章阅读时间接口
|
|
|
+// @Param request body models.AddStopTimeRep true "type json string"
|
|
|
+// @Success 200 {object} models.ArticleDetailResp
|
|
|
+// @router /addStopTime [post]
|
|
|
+func (this *ReportSelectionController) AddStopTime() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ var req models.AddReportSelectionStopTimeRep
|
|
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "参数解析异常!"
|
|
|
+ br.ErrMsg = "参数解析失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uid := user.UserId
|
|
|
+ articleId := req.ArticleId
|
|
|
+ stopTime := req.StopTime
|
|
|
+ outType := req.OutType
|
|
|
+ source := req.Source
|
|
|
+ var reportType string
|
|
|
+ if source == 1 {
|
|
|
+ reportType = "bgjx"
|
|
|
+ } else if source == 2 {
|
|
|
+ reportType = "bzyjhz"
|
|
|
+ } else if source == 3 {
|
|
|
+ reportType = "szjyhz"
|
|
|
+ }
|
|
|
+ hasPermission, err := services.GetUserhasPermission(user)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
|
|
|
+ }
|
|
|
+
|
|
|
+ if hasPermission == 1 && stopTime > 0 {
|
|
|
+ historyRecord := new(models.CygxReportHistoryRecord)
|
|
|
+ historyRecord.UserId = uid
|
|
|
+ historyRecord.ArticleId = articleId
|
|
|
+ historyRecord.CreateTime = time.Now()
|
|
|
+ historyRecord.Mobile = user.Mobile
|
|
|
+ historyRecord.Email = user.Email
|
|
|
+ historyRecord.CompanyId = user.CompanyId
|
|
|
+ historyRecord.CompanyName = user.CompanyName
|
|
|
+ historyRecord.StopTime = stopTime
|
|
|
+ historyRecord.OutType = outType
|
|
|
+ historyRecord.ReportType = reportType
|
|
|
+ sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ br.Msg = "获取信息失败"
|
|
|
+ br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ historyRecord.RealName = user.RealName
|
|
|
+ if sellerItem != nil {
|
|
|
+ historyRecord.SellerName = sellerItem.RealName
|
|
|
+ }
|
|
|
+ go models.AddCygxReportHistoryRecord(historyRecord)
|
|
|
+ }
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "操作成功"
|
|
|
+}
|