zhangchuanxing 4 luni în urmă
părinte
comite
47bb48a73e
2 a modificat fișierele cu 57 adăugiri și 0 ștergeri
  1. 8 0
      models/cygx_yanxuan_special.go
  2. 49 0
      services/cygx_yanxuan_special.go

+ 8 - 0
models/cygx_yanxuan_special.go

@@ -395,3 +395,11 @@ func UpdateYanxuanSpecialLikeCountHistory() (err error) {
 	_, err = o.Raw(sql).Exec()
 	return
 }
+
+// UpdateYanxuanSpecialHzPv 修改研选专栏的阅读弘则Pv
+func Need_1006INIT(hz_pv, hz_uv, id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special SET hz_pv= ? , hz_uv = ?  WHERE id = ? `
+	_, err = o.Raw(sql, hz_pv, hz_uv, id).Exec()
+	return
+}

+ 49 - 0
services/cygx_yanxuan_special.go

@@ -617,3 +617,52 @@ func GetYanxuanSpecialLikeCountDifferent(cont context.Context) (err error) {
 
 	return
 }
+
+//func init() {
+//	need_1006INIT()
+//}
+
+// 获取专栏用户最新的一篇文章信息
+func need_1006INIT() (mapResp map[int]*models.CygxYanxuanSpecialCenterAuthorResp) {
+
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("获取研选专栏用户信息失败,GetBestNewYanxuanSpecialByUserId Err ", err, "userIds"), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+
+	list, e := models.GetYanxuanSpecialListBycondition(condition, pars, 0, 999)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetYanxuanSpecialListBycondition, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]*models.CygxYanxuanSpecialCenterAuthorResp, 0)
+	for _, v := range list {
+		fmt.Println(v.Id)
+		pars = make([]interface{}, 0)
+		condition = " AND  yanxuan_special_id = ?  AND company_id =  16  "
+		pars = append(pars, v.Id)
+		listYanxuanSpecialRecord, e := models.GetCygxYanxuanSpecialRecordRespListAll(condition, pars)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+		listYanxuanSpecialRecordUv, e := models.GetCygxYanxuanSpecialRecordRespListAll(condition+"  GROUP BY user_id ", pars)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+
+		e = models.Need_1006INIT(len(listYanxuanSpecialRecord), len(listYanxuanSpecialRecordUv), v.Id)
+
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+	}
+	return
+}