优质留言上报用户参与情况-只上报优质留言-佳动力
This commit is contained in:
@@ -261,3 +261,85 @@ func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReportCaseRecord 上报用户参与情况-只上报优质留言
|
||||
func (r *UserService) ReportCaseRecord(tx *gorm.DB, projectId, caseId int64, user *model.User) (err error) {
|
||||
caseUserDao := dao.CaseUserDao{}
|
||||
maps := make(map[string]interface{})
|
||||
maps["project_id"] = projectId
|
||||
maps["case_id"] = caseId
|
||||
maps["user_id"] = user.UserId
|
||||
caseUser, err := caseUserDao.GetCaseUser(maps)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
recordScoreDao := dao.RecordScoreDao{}
|
||||
caseCommentDao := dao.CaseCommentDao{}
|
||||
|
||||
// 获取积分发放记录
|
||||
maps = make(map[string]interface{})
|
||||
maps["project_id"] = projectId
|
||||
maps["case_id"] = caseId
|
||||
maps["platform_id"] = caseUser.PlatformId
|
||||
maps["user_id"] = user.UserId
|
||||
recordScores, _ := recordScoreDao.GetRecordScoreListUseTx(tx, maps)
|
||||
|
||||
// 获取用户评论
|
||||
maps = make(map[string]interface{})
|
||||
maps["case_id"] = caseId
|
||||
maps["platform_id"] = caseUser.PlatformId
|
||||
maps["user_id"] = user.UserId
|
||||
maps["status"] = 1
|
||||
caseComments, _ := caseCommentDao.GetCaseCommentList(maps)
|
||||
|
||||
// 组装请求数据
|
||||
requestData := superKangaroo.ReportCaseRecordRequest{
|
||||
CaseUserId: fmt.Sprintf("%d", caseUser.CaseUserId),
|
||||
Sid: fmt.Sprintf("%d", caseUser.CaseId),
|
||||
TslUid: user.UserIden,
|
||||
Credit1: 0,
|
||||
Credit2: 0,
|
||||
Credit3: 0,
|
||||
Credit4: 0,
|
||||
HasRemark: 0,
|
||||
Remark: nil,
|
||||
}
|
||||
|
||||
// 积分
|
||||
for _, v3 := range recordScores {
|
||||
if v3.Type == 1 {
|
||||
requestData.Credit1 = v3.Score
|
||||
}
|
||||
|
||||
if v3.Type == 2 {
|
||||
requestData.Credit2 = v3.Score
|
||||
}
|
||||
|
||||
if v3.Type == 3 {
|
||||
requestData.Credit4 = v3.Score
|
||||
}
|
||||
}
|
||||
|
||||
// 评论
|
||||
if len(caseComments) > 0 {
|
||||
requestData.Remark = make([]*superKangaroo.RemarkRequest, len(caseComments))
|
||||
|
||||
requestData.HasRemark = 1
|
||||
for i2, comment := range caseComments {
|
||||
remarkDto := &superKangaroo.RemarkRequest{
|
||||
Remark: comment.Content,
|
||||
CreateTime: time.Time(comment.CreatedAt).Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
|
||||
requestData.Remark[i2] = remarkDto
|
||||
}
|
||||
}
|
||||
|
||||
_, err = superKangaroo.ReportCaseRecord(requestData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user