zhangchuanxing hace 4 meses
padre
commit
ef264d3f59

+ 1 - 1
controllers/yanxuan_special.go

@@ -176,7 +176,7 @@ func (this *YanxuanSpecialController) Detail() {
 	if item.MyCollectNum > 0 {
 		item.IsCollect = 1
 	}
-
+	item.Pv += item.HzPv // 添加弘则PV
 	var resp models.CygxYanxuanSpecialResp
 
 	resp.HasPermission = 1

+ 20 - 2
models/cygx_yanxuan_special.go

@@ -55,8 +55,9 @@ type CygxYanxuanSpecialItem struct {
 	ContentHasImg   int  //正文是否包含图片 1包含 0不包含
 	ContentHasStyle bool //正文是否包含格式
 	Docs            []Doc
-	Pv              string `description:"Pv"`
-	Uv              string `description:"Uv"`
+	Pv              int `description:"Pv"`
+	Uv              int `description:"Uv"`
+	HzPv            int `description:"HzPv"`
 }
 
 type CygxYanxuanSpecialResp struct {
@@ -104,6 +105,7 @@ type CygxYanxuanSpecialCenterResp struct {
 	Source           string   `description:"来源"`
 	Pv               int      `description:"Pv"`
 	Uv               int      `description:"Uv"`
+	HzPv             int      `description:"HzPv"`
 	PublishDate      string   // 提审过审或驳回时间      string `description:"核心观点"`
 	BodyHighlight    []string `description:"搜索高亮展示结果"`
 	LikeCount        int      `description:"点赞数量"`
@@ -311,6 +313,14 @@ func UpdateYanxuanSpecialPv(id int) (err error) {
 	return
 }
 
+// UpdateYanxuanSpecialHzPv 修改研选专栏的阅读弘则Pv
+func UpdateYanxuanSpecialHzPv(id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special SET hz_pv=hz_pv+1 WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
 // UpdateYanxuanSpecialUv 修改研选专栏的阅读Uv
 func UpdateYanxuanSpecialUv(id int) (err error) {
 	o := orm.NewOrm()
@@ -319,6 +329,14 @@ func UpdateYanxuanSpecialUv(id int) (err error) {
 	return
 }
 
+// UpdateYanxuanSpecialHzUv 修改研选专栏的阅读弘则Uv
+func UpdateYanxuanSpecialHzUv(id int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_yanxuan_special SET hz_uv=hz_uv+1 WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
 func UpdateYanxuanSpecialPvNUm(pv, id int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_yanxuan_special SET pv = ? WHERE id = ? `

+ 31 - 5
services/cygx_yanxuan_special_company.go

@@ -157,6 +157,22 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 					return
 				}
 			}
+		} else {
+			//专栏Pv数量进行加一
+			e = models.UpdateYanxuanSpecialHzPv(specialId)
+			if e != nil {
+				err = errors.New("UpdateYanxuanSpecialHzPv, Err: " + e.Error())
+				return
+			}
+
+			//如果没有阅读过,那么就给专栏文章的UV、作者的UV进行加一
+			if totalRecord == 0 {
+				e = models.UpdateYanxuanSpecialHzUv(specialId)
+				if e != nil {
+					err = errors.New("UpdateYanxuanSpecialHzUv, Err: " + e.Error())
+					return
+				}
+			}
 		}
 	}
 
@@ -197,16 +213,26 @@ func GetYanxuanSpecialRecordByYanxuanSpecialId(articleIds []int) (mapResp map[in
 	}
 	var condition string
 	var pars []interface{}
-	condition = ` AND yanxuan_special_id IN (` + utils.GetOrmInReplace(lenIds) + `) `
+	//condition = ` AND yanxuan_special_id IN (` + utils.GetOrmInReplace(lenIds) + `) `
+	//pars = append(pars, articleIds)
+	//listPv, e := models.GetCygxYanxuanSpecialRecordListPv(condition, pars)
+	//if e != nil {
+	//	err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
+	//	return
+	//}
+
+	condition += ` AND id  IN (` + utils.GetOrmInReplace(lenIds) + `) `
 	pars = append(pars, articleIds)
-	listPv, e := models.GetCygxYanxuanSpecialRecordListPv(condition, pars)
-	if e != nil {
-		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
+	listPv, e := models.GetYanxuanSpecialListBycondition(condition, pars, 0, lenIds)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetYanxuanSpecialListBycondition, Err: " + e.Error())
 		return
 	}
+
 	mapResp = make(map[int]int, 0)
 	for _, v := range listPv {
-		mapResp[v.YanxuanSpecialId] = v.Pv
+		mapResp[v.Id] = v.Pv + v.HzPv
 	}
+
 	return
 }