Browse Source

no message

xingzai 1 year ago
parent
commit
619e4be06b

+ 30 - 28
controllers/yanxuan_special.go

@@ -493,7 +493,7 @@ func (this *YanxuanSpecialController) Enable() {
 	} else {
 		status = 4
 	}
-	if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason); tmpErr != nil {
+	if tmpErr := models.EnableYanxuanSpecial(req.Id, status, req.Reason, user.RealName); tmpErr != nil {
 		br.Msg = "审批失败"
 		br.ErrMsg = "审批失败, Err:" + tmpErr.Error()
 		return
@@ -504,7 +504,7 @@ func (this *YanxuanSpecialController) Enable() {
 	go services.SendWxMsgSpecialAuthor(req.Id, req.Status)
 	go services.UpdateYanxuanSpecialResourceData(req.Id)                                  //  写入首页最新  cygx_resource_data 表
 	go services.EsAddYanxuanSpecial(req.Id)                                               //  写入es 综合搜索
-	go services.AddAddCygxYanxuanSpecialApprovalLog(user, req.Id, req.Status, req.Reason) //  写入es 综合搜索
+	go services.AddAddCygxYanxuanSpecialApprovalLog(user, req.Id, req.Status, req.Reason) //  添加审核记录日志
 	br.Msg = "审批成功"
 	br.Ret = 200
 	br.Success = true
@@ -521,8 +521,8 @@ func (this *YanxuanSpecialController) Collect() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.User
-	if sysUser == nil {
+	user := this.User
+	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		br.Ret = 408
@@ -545,20 +545,21 @@ func (this *YanxuanSpecialController) Collect() {
 		return
 	}
 	var sellerName string
-	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
 	if err != nil {
-		br.Msg = "报名失败!"
-		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		br.Msg = "查询栏目详情失败!"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
 		return
 	}
+	sellerName = sellerItemQy.RealName
 	if req.Status == 1 {
 		item := models.CygxYanxuanSpecialCollect{
-			UserId:           sysUser.UserId,
-			Mobile:           sysUser.Mobile,
-			Email:            sysUser.Email,
-			CompanyId:        sysUser.CompanyId,
-			CompanyName:      sysUser.CompanyName,
-			RealName:         sysUser.RealName,
+			UserId:           user.UserId,
+			Mobile:           user.Mobile,
+			Email:            user.Email,
+			CompanyId:        user.CompanyId,
+			CompanyName:      user.CompanyName,
+			RealName:         user.RealName,
 			SellerName:       sellerName,
 			CreateTime:       time.Now(),
 			ModifyTime:       time.Now(),
@@ -573,7 +574,7 @@ func (this *YanxuanSpecialController) Collect() {
 		}
 		br.Msg = "收藏成功"
 	} else {
-		err = models.DelCygxYanxuanSpecialCollect(sysUser.UserId, req.Id)
+		err = models.DelCygxYanxuanSpecialCollect(user.UserId, req.Id)
 		if err != nil {
 			br.Msg = "删除失败"
 			br.ErrMsg = "删除失败,Err:" + err.Error()
@@ -581,7 +582,7 @@ func (this *YanxuanSpecialController) Collect() {
 		}
 		br.Msg = "取消收藏成功"
 	}
-
+	go services.UdpateYanxuanSpecialCollect(user, req.Id, req.Status)
 	br.Ret = 200
 	br.Success = true
 }
@@ -703,8 +704,8 @@ func (this *YanxuanSpecialController) Follow() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	sysUser := this.User
-	if sysUser == nil {
+	user := this.User
+	if user == nil {
 		br.Msg = "请登录"
 		br.ErrMsg = "请登录,SysUser Is Empty"
 		br.Ret = 408
@@ -727,21 +728,22 @@ func (this *YanxuanSpecialController) Follow() {
 		return
 	}
 	var sellerName string
-	sellerName, err = models.GetCompanySellerName(sysUser.CompanyId)
+	sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
 	if err != nil {
-		br.Msg = "报名失败!"
-		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+		br.Msg = "查询栏目详情失败!"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
 		return
 	}
+	sellerName = sellerItemQy.RealName
 	if req.Status == 1 {
 		item := models.CygxYanxuanSpecialFollow{
-			UserId:           sysUser.UserId,
+			UserId:           user.UserId,
 			FollowUserId:     req.FollowUserId,
-			Mobile:           sysUser.Mobile,
-			Email:            sysUser.Email,
-			CompanyId:        sysUser.CompanyId,
-			CompanyName:      sysUser.CompanyName,
-			RealName:         sysUser.RealName,
+			Mobile:           user.Mobile,
+			Email:            user.Email,
+			CompanyId:        user.CompanyId,
+			CompanyName:      user.CompanyName,
+			RealName:         user.RealName,
 			SellerName:       sellerName,
 			CreateTime:       time.Now(),
 			ModifyTime:       time.Now(),
@@ -756,7 +758,7 @@ func (this *YanxuanSpecialController) Follow() {
 		}
 		br.Msg = "关注成功"
 	} else {
-		err = models.DelCygxYanxuanSpecialFollow(sysUser.UserId, req.FollowUserId)
+		err = models.DelCygxYanxuanSpecialFollow(user.UserId, req.FollowUserId)
 		if err != nil {
 			br.Msg = "删除失败"
 			br.ErrMsg = "删除失败,Err:" + err.Error()
@@ -764,7 +766,7 @@ func (this *YanxuanSpecialController) Follow() {
 		}
 		br.Msg = "取消关注成功"
 	}
-
+	go services.UdpateYanxuanSpecialFansNum(user, req.FollowUserId, req.Status)
 	br.Ret = 200
 	br.Success = true
 }

+ 21 - 3
models/cygx_yanxuan_special.go

@@ -155,11 +155,11 @@ type EnableCygxYanxuanSpecialReq struct {
 	Reason string //理由
 }
 
-func EnableYanxuanSpecial(id, status int, reason string) (err error) {
+func EnableYanxuanSpecial(id, status int, reason, adminName string) (err error) {
 	o := orm.NewOrm()
 	sql := ``
-	sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW(),modify_time=NOW() WHERE id = ? `
-	_, err = o.Raw(sql, status, reason, id).Exec()
+	sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,admin_name = ? , publish_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, status, reason, adminName, id).Exec()
 	return
 }
 
@@ -313,3 +313,21 @@ func UpdateYanxuanSpecialUv(id int) (err error) {
 	_, err = o.Raw(sql, id).Exec()
 	return
 }
+
+// 增加收藏数量
+func UpdateYanxuanSpecialarticleCollectNumIncrease(id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET article_collect_num = article_collect_num +1  WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}
+
+// 减少收藏数量
+func UpdateYanxuanSpecialarticleCollectNumReduce(id int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special SET article_collect_num = article_collect_num  - 1  WHERE id = ? `
+	_, err = o.Raw(sql, id).Exec()
+	return
+}

+ 36 - 0
models/cygx_yanxuan_special_user.go

@@ -184,3 +184,39 @@ func UpdateCygxYanxuanSpecialAuthorUv(userId int) (err error) {
 	_, err = o.Raw(sql, userId).Exec()
 	return
 }
+
+// 增加收藏数量
+func UpdateYanxuanSpecialAuthorArticleCollectNumIncrease(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET article_collect_num = article_collect_num +1  WHERE id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// 减少收藏数量
+func UpdateYanxuanSpecialAuthorArticleCollectNumReduce(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET article_collect_num = article_collect_num  - 1  WHERE id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// 增加粉丝数量
+func UpdateYanxuanSpecialAuthorFansNumIncrease(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET fans_num = fans_num +1  WHERE id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+// 减少粉丝数量
+func UpdateYanxuanSpecialAuthorFansNumReduce(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := ``
+	sql = `UPDATE cygx_yanxuan_special_author SET fans_num = fans_num  - 1  WHERE id = ? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}

+ 86 - 0
services/cygx_yanxuan_special.go

@@ -409,3 +409,89 @@ func AddAddCygxYanxuanSpecialApprovalLog(user *models.WxUserItem, specialId, sta
 	}
 	return
 }
+
+// 更新文章收藏数量
+func UdpateYanxuanSpecialCollect(user *models.WxUserItem, specialId, status int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("更新文章收藏数量失败,UdpateYanxuanSpecialCollect Err ", err, "userId", user.UserId), 2)
+		}
+	}()
+	detail, e := models.GetYanxuanSpecialBySpecialId(specialId)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialBySpecialId, Err: " + e.Error())
+		return
+	}
+
+	specialAuthor, e := models.GetCygxYanxuanSpecialAuthorByUserId(detail.UserId)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialAuthorByUserId, Err: " + e.Error())
+		return
+	}
+
+	if status == 1 {
+		//更新文章被收藏数量
+		e = models.UpdateYanxuanSpecialarticleCollectNumIncrease(specialId)
+		if e != nil {
+			err = errors.New("UpdateYanxuanSpecialarticleCollectNumIncrease, Err: " + e.Error())
+			return
+		}
+
+		//更新作者文章被收藏数量
+		e = models.UpdateYanxuanSpecialAuthorArticleCollectNumIncrease(specialAuthor.Id)
+		if e != nil {
+			err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNumIncrease, Err: " + e.Error())
+			return
+		}
+	} else {
+		//更新文章被收藏数量
+		e = models.UpdateYanxuanSpecialarticleCollectNumReduce(specialId)
+		if e != nil {
+			err = errors.New("UpdateYanxuanSpecialarticleCollectNumReduce, Err: " + e.Error())
+			return
+		}
+
+		//更新作者文章被收藏数量
+		e = models.UpdateYanxuanSpecialAuthorArticleCollectNumReduce(specialAuthor.Id)
+		if e != nil {
+			err = errors.New("UpdateYanxuanSpecialAuthorArticleCollectNumReduce, Err: " + e.Error())
+			return
+		}
+	}
+	return
+}
+
+// 更新作者粉丝数量
+func UdpateYanxuanSpecialFansNum(user *models.WxUserItem, specialUserIdId, status int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("更新作者粉丝数量失败,UdpateYanxuanSpecialFansNum Err ", err, "userId", user.UserId), 2)
+		}
+	}()
+	specialAuthor, e := models.GetCygxYanxuanSpecialAuthorByUserId(specialUserIdId)
+	if e != nil {
+		err = errors.New("GetCygxYanxuanSpecialAuthorByUserId, Err: " + e.Error())
+		return
+	}
+
+	if status == 1 {
+		//更新作者粉丝数量
+		e := models.UpdateYanxuanSpecialAuthorFansNumIncrease(specialAuthor.Id)
+		if e != nil {
+			err = errors.New("UpdateYanxuanSpecialAuthorFansNumIncrease, Err: " + e.Error())
+			return
+		}
+	} else {
+		//更新作者粉丝数量
+		e := models.UpdateYanxuanSpecialAuthorFansNumReduce(specialAuthor.Id)
+		if e != nil {
+			err = errors.New("UpdateYanxuanSpecialAuthorFansNumReduce, Err: " + e.Error())
+			return
+		}
+	}
+	return
+}