同时修改平台id
This commit is contained in:
parent
e261364482
commit
e45d806d91
@ -273,10 +273,12 @@ func (b *CaseComment) AddCaseCommentHighQuality(c *gin.Context) {
|
||||
println(user)
|
||||
str := fmt.Sprintf("%+v", user) // %+v 会带上字段名
|
||||
fmt.Println(str)
|
||||
fmt.Println(caseComment.PlatformId)
|
||||
println("========")
|
||||
// 发放积分-优质留言-1010 修改
|
||||
userService := service.UserService{}
|
||||
user,err = userService.ReportUserScore(tx, result.ProjectId, caseComment.CaseId, caseComment.PlatformId, scoreType, user)
|
||||
reportPlatformId := caseComment.PlatformId
|
||||
reportPlatformId,user,err = userService.ReportUserScore(tx, result.ProjectId, caseComment.CaseId, caseComment.PlatformId, scoreType, user)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
@ -286,10 +288,10 @@ func (b *CaseComment) AddCaseCommentHighQuality(c *gin.Context) {
|
||||
println(user)
|
||||
str2 := fmt.Sprintf("%+v", user) // %+v 会带上字段名
|
||||
fmt.Println(str2)
|
||||
fmt.Println(reportPlatformId)
|
||||
|
||||
// 上报用户参与情况-只上报优质留言-佳动力
|
||||
if caseComment.PlatformId == 2 {
|
||||
println(11)
|
||||
if reportPlatformId == 2 {
|
||||
err = userService.ReportCaseRecord(tx, result.ProjectId, caseComment.CaseId, user)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
@ -63,7 +63,7 @@ func (r *UserService) HandleUserImage(wxAvatar string) (ossPath string, err erro
|
||||
|
||||
// ReportUserScore 发放积分
|
||||
// scoreType : 积分类型(1:完成阅读 2:阅读时间满足 3:优质留言 4:再次优质留言 )
|
||||
func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId int64, scoreType int, user *model.User) (reportUser *model.User, err error) {
|
||||
func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId int64, scoreType int, user *model.User) (reportPlatformId int64, reportUser *model.User, err error) {
|
||||
maps := make(map[string]interface{})
|
||||
// // 获取项目关联平台
|
||||
// projectPlatformDao := dao.ProjectPlatformDao{}
|
||||
@ -119,7 +119,7 @@ func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId
|
||||
maps["mobile_encryption"] = user.MobileEncryption
|
||||
users, err := userDao.GetUserList(maps)
|
||||
if err != nil {
|
||||
return user,nil
|
||||
return platformId,user,nil
|
||||
}
|
||||
for _, m := range users {
|
||||
// 检测积分是否已在其他平台发放过
|
||||
@ -147,7 +147,7 @@ func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId
|
||||
recordScore, _ = recordScoreDao.GetRecordScore(maps)
|
||||
if recordScore != nil {
|
||||
// 积分已发放过
|
||||
return user,nil
|
||||
return platformId,user,nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,13 +159,13 @@ func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId
|
||||
maps["platform_id"] = platformId
|
||||
projectPlatform, err := projectPlatformDao.GetProjectPlatform(maps)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
|
||||
// 检测福利开关
|
||||
if projectPlatform.IsWelfare == 0 {
|
||||
// 福利未开
|
||||
return user,nil
|
||||
return platformId,user,nil
|
||||
}
|
||||
|
||||
// 获取需发放积分
|
||||
@ -206,7 +206,7 @@ func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId
|
||||
projectPlatformWhiteService := ProjectPlatformWhiteService{}
|
||||
isWhite, err = projectPlatformWhiteService.CheckProjectPlatformWhiteByUser(user, projectId, platformId)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,14 +223,14 @@ func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId
|
||||
maps["platform_id"] = platformId
|
||||
casePlatform, err := casePlatformDao.GetCasePlatform(maps)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
|
||||
// 检测全部积分是否已发放完毕
|
||||
remainingScore := projectPlatform.SingleCaseScore - casePlatform.IssuedScore
|
||||
if remainingScore <= 0 {
|
||||
// 积分已发放完毕
|
||||
return user,nil
|
||||
return platformId,user,nil
|
||||
}
|
||||
|
||||
// 新增发放记录-每发一次记录一次
|
||||
@ -247,7 +247,7 @@ func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId
|
||||
|
||||
recordScore, err = recordScoreDao.AddRecordScore(tx, recordScore)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
|
||||
// 获取用户参与记录
|
||||
@ -258,38 +258,38 @@ func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId
|
||||
maps["user_id"] = user.UserId
|
||||
caseUser, _ := caseUserDao.GetCaseUserUseTx(tx, maps)
|
||||
if caseUser == nil {
|
||||
return user,errors.New("用户还未完成该病例阅读,请稍后再试")
|
||||
return platformId,user,errors.New("用户还未完成该病例阅读,请稍后再试")
|
||||
}
|
||||
|
||||
// 累计用户领取积分数据
|
||||
err = caseUserDao.Inc(tx, caseUser.CaseUserId, "total_score", score)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
|
||||
// 累计平台发放积分数据
|
||||
err = casePlatformDao.Inc(tx, casePlatform.CasePlatformId, "issued_score", score)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
|
||||
// 累计发放积分数据
|
||||
caseDao := dao.CaseDao{}
|
||||
err = caseDao.Inc(tx, caseId, "issued_score", score)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
|
||||
// 发放积分-
|
||||
if platformId != 1 && platformId != 2 {
|
||||
return user,errors.New("积分发放失败")
|
||||
return platformId,user,errors.New("积分发放失败")
|
||||
}
|
||||
|
||||
// 肝胆相照
|
||||
if platformId == 1 && score > 0 {
|
||||
_, err = app.ReportUserScore(appScoreTypeStr, user.UserIden, score)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,21 +299,20 @@ func (r *UserService) ReportUserScore(tx *gorm.DB, projectId, caseId, platformId
|
||||
caseDao := dao.CaseDao{}
|
||||
result, err := caseDao.GetCaseById(caseId)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
|
||||
_, err = superKangaroo.ReportUserScore(caseId, user.UserIden, superScoreTypeStr, recordScore, result)
|
||||
if err != nil {
|
||||
return user,err
|
||||
return platformId,user,err
|
||||
}
|
||||
}
|
||||
|
||||
return user,nil
|
||||
return platformId,user,nil
|
||||
}
|
||||
|
||||
// ReportCaseRecord 上报用户参与情况-只上报优质留言
|
||||
func (r *UserService) ReportCaseRecord(tx *gorm.DB, projectId, caseId int64, user *model.User) (err error) {
|
||||
println(22)
|
||||
caseUserDao := dao.CaseUserDao{}
|
||||
maps := make(map[string]interface{})
|
||||
maps["case_id"] = caseId
|
||||
|
||||
@ -108,9 +108,6 @@ func ReportUserScore(bonuspointsNote, userUuid string, bonuspoints int) (g *Repo
|
||||
|
||||
utils.LogJsonInfo("获取app数据返回", g)
|
||||
|
||||
println("获取app数据返回")
|
||||
println(g)
|
||||
|
||||
if g.Code != 200 {
|
||||
if g.Msg != "" {
|
||||
return g, errors.New(g.Msg)
|
||||
|
||||
@ -160,9 +160,6 @@ func ReportCaseRecord(requestData ReportCaseRecordRequest) (g *ReportCaseRecordR
|
||||
|
||||
utils.LogJsonInfo("获取超级袋鼠数据返回", g)
|
||||
|
||||
println("获取超级袋鼠数据返回")
|
||||
println(g)
|
||||
|
||||
if g.Code != 1 && g.Code != "1" && g.Code != float64(1) {
|
||||
if g.Msg != "" {
|
||||
return g, errors.New(g.Msg)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user