Browse Source

no message

xingzai 1 năm trước cách đây
mục cha
commit
43c04836eb

+ 19 - 0
controllers/cygx/apply_record.go

@@ -97,11 +97,13 @@ func (this *ApplyRecordController) ListSysRole() {
 	}
 	var sellerCompanyIds []int
 	var microvideoIds []int
+	var userIds []int
 	for _, v := range list {
 		if v.Source == "roadshow" {
 			microvideoIds = append(microvideoIds, v.SourceId)
 		}
 		sellerCompanyIds = append(sellerCompanyIds, v.CompanyIdPay)
+		userIds = append(userIds, v.UserId)
 	}
 	sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
 	lenmicrovideoIds := len(microvideoIds)
@@ -124,7 +126,24 @@ func (this *ApplyRecordController) ListSysRole() {
 		}
 	}
 
+	//处理用户的邮箱
+	mapUserEmail := make(map[int]string) //用户UserId所对应的邮箱
+	lenUserId := len(userIds)
+	if lenUserId > 0 {
+		userList, err := models.GetWxUserByUserIds(userIds)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+
+		for _, v := range userList {
+			mapUserEmail[int(v.UserId)] = v.Email
+		}
+	}
+
 	for i, v := range list {
+		v.Email = mapUserEmail[v.UserId]
 		if list[i].SellerName == "/" {
 			list[i].SellerName = ""
 		}

+ 20 - 1
controllers/cygx/yanxuan_special.go

@@ -2,6 +2,7 @@ package cygx
 
 import (
 	"encoding/json"
+	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"github.com/tealeg/xlsx"
 	"hongze/hz_crm_api/controllers"
@@ -206,7 +207,7 @@ func (this *YanxuanSpecialController) AuthorList() {
 	//排序字段以及排序方式处理
 	var sortStr string
 	if sortParam != "" && sortType != "" {
-		if sortParam == "CreatTime" {
+		if sortParam == "CreateTime" {
 			if sortType == "asc" {
 				sortStr = " ORDER BY art.create_time ASC "
 			} else {
@@ -229,9 +230,13 @@ func (this *YanxuanSpecialController) AuthorList() {
 				sortStr = " ORDER BY art.pv  DESC "
 			}
 		}
+		if sortStr == "" {
+			sortStr = " ORDER BY a.publish_time  DESC " // 兼容前端老六乱传字段
+		}
 	} else {
 		sortStr = " ORDER BY art.create_time  DESC "
 	}
+	fmt.Println(sortStr)
 
 	total, err := cygx.GetYanxuanSpecialAuthorCount(condition, pars)
 	if err != nil {
@@ -246,6 +251,17 @@ func (this *YanxuanSpecialController) AuthorList() {
 		br.ErrMsg = "获取失败, Err:" + tmpErr.Error()
 		return
 	}
+
+	var userIds []int
+
+	for _, v := range list {
+		userIds = append(userIds, v.UserId)
+	}
+	//获取专栏用户最新的一篇文章信息
+	mapNewTime := cygxService.GetBestNewYanxuanSpecialByUserId(userIds)
+	for _, v := range list {
+		v.ArticlePublishTime = mapNewTime[v.UserId]
+	}
 	resp := new(cygx.GetCygxYanxuanSpecialAuthorItemResp)
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp.List = list
@@ -347,6 +363,9 @@ func (this *YanxuanSpecialController) List() {
 				sortStr = " ORDER BY a.pv  DESC "
 			}
 		}
+		if sortStr == "" {
+			sortStr = " ORDER BY a.publish_time  DESC " // 兼容前端老六乱传字段
+		}
 	} else {
 		sortStr = " ORDER BY a.publish_time  DESC "
 	}

+ 1 - 0
models/cygx/apply_record.go

@@ -37,6 +37,7 @@ type CygxApplyRecord struct {
 
 type CygxApplyRecordResp struct {
 	ApplyRecordId            int    `orm:"column(apply_record_id);pk" description:"申请试用id"`
+	UserId                   int    `description:"用户ID"`
 	BusinessCardUrl          string `description:"名片地址"`
 	RealName                 string `description:"姓名"`
 	CompanyName              string `description:"公司名称"`

+ 15 - 0
models/cygx/cygx_yanxuan_special.go

@@ -198,3 +198,18 @@ func GetYanxuanSpecialBySpecialId(specialId int) (item *CygxYanxuanSpecialItem,
 	err = o.Raw(sql, specialId).QueryRow(&item)
 	return
 }
+
+func GetYanxuanSpecialListBycondition(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecial, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT a.* FROM cygx_yanxuan_special AS a WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	if startSize+pageSize > 0 {
+		sql += ` LIMIT ?,? `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		_, err = o.Raw(sql, pars).QueryRows(&items)
+	}
+	return
+}

+ 8 - 1
models/cygx/cygx_yanxuan_special_user.go

@@ -44,7 +44,7 @@ type CygxYanxuanSpecialAuthorItem struct {
 	Pv                 int    // Pv
 	Uv                 int    // Uv
 	ArticleNum         int    // 已发布的文章数量
-	ArticlePublishTime int    // 最近发布文章的时间
+	ArticlePublishTime string // 最近发布文章的时间
 	FansNum            int    // 粉丝数量
 	ArticleCollectNum  int    // 文章收藏数量
 }
@@ -127,3 +127,10 @@ func GetCygxYanxuanSpecialAuthorByUserId(userId int) (item *CygxYanxuanSpecialAu
 	err = o.Raw(sql, userId).QueryRow(&item)
 	return
 }
+
+type CygxYanxuanSpecialCenterAuthorResp struct {
+	Id          int    //研选专栏ID
+	UserId      int    // 用户ID
+	PublishTime string // 提审过审或驳回时间
+	Title       string // 标题
+}

+ 29 - 0
services/cygx/cygx_yanxuan_special.go

@@ -319,3 +319,32 @@ func AddAddCygxYanxuanSpecialApprovalLog(user *models.WxUserItem, specialId, sta
 	}
 	return
 }
+
+// 获取专栏用户最新的一篇文章信息
+func GetBestNewYanxuanSpecialByUserId(userIds []int) (mapResp map[int]string) {
+	lenArr := len(userIds)
+	if lenArr == 0 {
+		return
+	}
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg(fmt.Sprint("获取研选专栏用户信息失败,GetBestNewYanxuanSpecialByUserId Err ", err, "userIds", userIds), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition += `  AND  a.publish_time = ( SELECT max( b.publish_time ) FROM cygx_yanxuan_special b WHERE a.user_id = b.user_id  AND b.STATUS = 3 )  AND user_id  IN (` + utils.GetOrmInReplace(lenArr) + `) AND a.status = 3  GROUP BY user_id ORDER BY publish_time DESC`
+	pars = append(pars, userIds)
+	list, e := cygx.GetYanxuanSpecialListBycondition(condition, pars, 0, lenArr)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetYanxuanSpecialListBycondition, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]string, 0)
+	for _, v := range list {
+		mapResp[v.UserId] = v.PublishTime.Format(utils.FormatDateTime)
+	}
+	return
+}