作者 yangfu

Merge remote-tracking branch 'origin/dev' into test

# Conflicts:
#	conf/dev.conf
... ... @@ -12,7 +12,7 @@ aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}"
#redis相关配置
redis_add = "${REDIS_HOST||192.168.100.102}"
redis_add = "${REDIS_HOST||127.0.0.1}"
redis_add_port = "${REDIS_PORT||6379}"
redis_auth = "123456"
... ... @@ -38,7 +38,7 @@ user_center_app_secret ="cykbjnfqgctn"
#Html5
h5_host = "http://web-open-test.fjmaimaimai.com"
h5_host = "http://mmm-web-open-test.fjmaimaimai.com"
#审核中心
suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com"
... ...
... ... @@ -305,3 +305,9 @@ func (this *BaseController) Finish() {
log.Debug(fmt.Sprintf("<====Send to uid(%d) ucid(%v) client: %d byte\nRequestId:%s RspBodyData: %s", this.Header.Uid, this.Header.UserId, length, this.Header.GetRequestId(), string(strByte)))
}
}
//func(this *BaseController)Get(){
// if strings.HasSuffix(this.Ctx.Request.RequestURI,".mp3"){
// this.Ctx.ResponseWriter.Header().Set("Content-Type","audio/mpeg")
// }
//}
... ...
... ... @@ -12,7 +12,7 @@ type ChanceController struct {
controllers.BaseController
}
//IComment
//IComment 我来评论
// @router /iComment [post]
func (this *ChanceController) IComment() {
var msg *protocol.ResponseMessage
... ... @@ -54,7 +54,7 @@ func (this *ChanceController) IComments() {
msg = protocol.NewReturnResponse(chance.IComments(header, request))
}
//Comments
//Comments 评论列表
// @router /comments [post]
func (this *ChanceController) Comments() {
var msg *protocol.ResponseMessage
... ... @@ -72,10 +72,31 @@ func (this *ChanceController) Comments() {
return
}
header := controllers.GetRequestHeader(this.Ctx)
request.SourceType = protocol.SourceTypeChance
//request.SourceType = protocol.SourceTypeChance
msg = protocol.NewReturnResponse(chance.Comments(header, request))
}
//Thumbsups 点赞列表
// @router /thumbsups [post]
func (this *ChanceController) Thumbsups() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.ThumbsupsRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.Thumbsups(header, request))
}
//Favorite
// @router /favorite [post]
func (this *ChanceController) Favorite() {
... ... @@ -139,7 +160,7 @@ func (this *ChanceController) CommentDetailsMulti() {
msg = protocol.NewReturnResponse(chance.CommentDetailsMulti(header, request))
}
//SympathyAction
//SympathyAction 机会点赞/收藏
//@router /sympathyAction [post]
func (this *ChanceController) SympathyAction() {
var msg *protocol.ResponseMessage
... ... @@ -294,27 +315,6 @@ func (this *ChanceController) MySubmitChance() {
msg = protocol.NewReturnResponse(chance.MySubmitChance(header, request))
}
//ChancePool 机会池
//@router /chancePool [post]
func (this *ChanceController) ChancePool() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.ChancePoolRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}
//ChanceDetail 机会详情
//@router /chanceDetail [post]
func (this *ChanceController) ChanceDetail() {
... ... @@ -488,3 +488,87 @@ func (this *ChanceController) MyApproveChance() {
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.MyApproveChance(header, request))
}
//MyCollectChance 我的收藏
//@router /myCollectChance [post]
func (this *ChanceController) MyCollectChance() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.MyCollectChanceRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.MyCollectChance(header, request))
}
//MyThumbUpChance 我点赞的机会
//@router /myThumbUpChance [post]
func (this *ChanceController) MyThumbUpChance() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.MyThumbUpChanceRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.MyThumbUpChance(header, request))
}
//MyComment 我的评论
//@router /myComment [post]
func (this *ChanceController) MyComment() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.MyCommentRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.MyComment(header, request))
}
//ChancePool 机会池
//@router /chancePool [post]
func (this *ChanceController) ChancePool() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.ChancePoolRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
}
... ...
... ... @@ -12,7 +12,7 @@ type MessageController struct {
controllers.BaseController
}
//MessageCenter
//MessageCenter 消息中心
// @router /messageCenter [post]
func (this *MessageController) MessageCenter() {
var msg *protocol.ResponseMessage
... ... @@ -159,7 +159,7 @@ func (this *MessageController) MsgCompanyNotice() {
msg = protocol.NewReturnResponse(message.MsgCompanyNotice(header, request))
}
//MsgChanceApprove 机会审核消息
//MsgChanceApprove 消息中心-机会审核消息
//@router /msgChanceApprove [post]
func (this *MessageController) MsgChanceApprove() {
var msg *protocol.ResponseMessage
... ... @@ -179,3 +179,66 @@ func (this *MessageController) MsgChanceApprove() {
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(message.MsgChanceApprove(header, request))
}
//MsgChanceSubmit 消息中心-我提交的
//@router /msgChanceSubmit [post]
func (this *MessageController) MsgChanceSubmit() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.MsgChanceSubmitRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(message.MsgChanceSubmit(header, request))
}
//MsgChanceComment 消息中心-互动消息.评论
//@router /msgChanceComment [post]
func (this *MessageController) MsgChanceComment() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.MsgChanceCommentRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(message.MsgChanceComment(header, request))
}
//MsgChanceThumbUp 消息中心-互动消息.点赞
//@router /msgChanceThumbUp [post]
func (this *MessageController) MsgChanceThumbUp() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *protocol.MsgChanceThumbUpRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(message.MsgChanceThumbUp(header, request))
}
... ...
... ... @@ -49,7 +49,7 @@ spec:
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
- mountPath: /var/www/opp-dev/file
- mountPath: /var/www/opp/file
name: mmmjihuitest-pvc1
ports:
- containerPort: 8080
... ...
... ... @@ -3,6 +3,7 @@ package main
import (
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
_ "github.com/go-sql-driver/mysql"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/config"
... ... @@ -13,6 +14,7 @@ import (
"opp/internal/utils"
_ "opp/routers"
"os"
"strings"
"time"
)
... ... @@ -71,6 +73,8 @@ func init() {
log.Info(fmt.Sprintf("env REDIS_HOST:%v", os.Getenv("REDIS_HOST")))
log.Info(fmt.Sprintf("env REDIS_PORT:%v", os.Getenv("REDIS_PORT")))
log.Info(fmt.Sprintf("env aliyun_file_access:%v", os.Getenv("aliyun_file_access")))
//mime.AddExtensionType(".mp3","audio/mpeg")
}
func main() {
... ... @@ -79,6 +83,14 @@ func main() {
}()
log.Info("app on start!")
log.Info("Beego Run Mode:", beego.BConfig.RunMode)
beego.InsertFilter("file/opp/*", beego.BeforeStatic, FilterBeforeStatic)
beego.Run()
}
var FilterBeforeStatic = func(ctx *context.Context) {
if strings.HasSuffix(ctx.Request.RequestURI, ".mp3") {
//If-Modified-Since
//ctx.Request.Header.Add("If-Modified-Since","")
ctx.ResponseWriter.Header().Add("Content-Type", "audio/mpeg")
}
}
... ...
... ... @@ -103,8 +103,7 @@ func GetAuditFlowProcessBy(processId, uid int64) (v *AuditFlowProcess, err error
}
//当前审批批次已经结束 唤醒下一批次审批人
func UpdatetAuditFlowProcessToNext(chanceId int64, level int, uids []int64) (err error) {
o := orm.NewOrm()
func UpdatetAuditFlowProcessToNext(o orm.Ormer, chanceId int64, level int, uids []int64) (err error) {
sql := "update audit_flow_process set enable_status =1,is_active=1,update_at=now() where chance_id=? and level=? and uid in (?)"
if err = utils.ExecuteSQLWithOrmer(o, sql, chanceId, level, utils.JoinInt64s(uids, ",")); err != nil {
return
... ... @@ -113,8 +112,7 @@ func UpdatetAuditFlowProcessToNext(chanceId int64, level int, uids []int64) (err
}
//或签 有一人已经通过 同批次在审核状态置为无效
func UpdatetAuditFlowProcessNoApprove(chanceId int64, level int, reviewStatus int) (err error) {
o := orm.NewOrm()
func UpdatetAuditFlowProcessNoApprove(o orm.Ormer, chanceId int64, level int, reviewStatus int) (err error) {
sql := "update audit_flow_process set enable_status =0,is_active=0,update_at=now() where chance_id=? and level=? and review_status=?"
if err = utils.ExecuteSQLWithOrmer(o, sql, chanceId, level, reviewStatus); err != nil {
return
... ...
... ... @@ -152,7 +152,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int,
sql := `select a.*,b.images,speechs,videos
from (
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
where user_id=? and company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id>?) and enable_status=1
where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id>?) and enable_status=1
order by create_at desc
limit ?
) a left JOIN chance_data b on a.id =b.chance_id`
... ... @@ -160,14 +160,87 @@ limit ?
sqlCount := fmt.Sprintf(`select count(0) from (
select id from chance
where user_id=? and company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
order by create_at desc
) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil {
if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
return
}
}
return
}
func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from (
select id collect_id,source_id,create_at collect_time from chance_favorite where (0=? or id>?) and user_id =? and enable_status=1
and source_type=1
and (mark_flag&2)>0
)a left outer join chance b on a.source_id = b.id
)a left outer join chance_data b on a.source_id =b.chance_id
order by collect_time desc
limit ?`)
sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&2)>0`
if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, lastId, lastId, uid, pageSize); err != nil {
return
}
}
return
}
func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from (
select id collect_id,source_id,create_at collect_time from chance_favorite where (0=? or id>?) and user_id =? and enable_status=1
and source_type=1
and (mark_flag&1)>0
)a left outer join chance b on a.source_id = b.id
)a left outer join chance_data b on a.source_id =b.chance_id
order by collect_time desc
limit ?`)
sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&2)>0`
if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, lastId, lastId, uid, pageSize); err != nil {
return
}
}
return
}
//我的评论
func GetChanceComment(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := fmt.Sprintf(`select a.*,b.content commented_content,b.create_at commented_time,b.user_id commented_user_id
from (
select a.*,b.images,b.speechs,b.videos from (
select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from (
select id,content,view_total,zan_total,comment_total,source_type,source_id,create_at comment_time from comment
where user_id =? and (?=0 or id>?)
)a left outer join chance b on a.source_id = b.id and source_type=1
)a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1
)a left outer join comment b on a.source_id = b.id and a.source_type=2
order by create_at desc
limit ?`)
sqlCount := `select count(0) from comment
where user_id =?`
if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, pageSize); err != nil {
return
}
}
... ...
... ... @@ -81,12 +81,12 @@ func DeleteChanceFavorite(id int64) (err error) {
//按1.用户id 2.公司id 3.标记类型 4.机会类型编号 5.最后编号 6.页数
//获取用户点赞收藏机会
func GetChanceFavorites(userId, companyId int64, markFlag, chanceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) {
sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc")
sql.Where(fmt.Sprintf("user_id=%d", userId))
sql.Where(fmt.Sprintf("company_id=%d", companyId))
if chanceType > 0 {
sql.Where(fmt.Sprintf("chance_type=%d", chanceType))
if sourceType > 0 {
sql.Where(fmt.Sprintf("source_type=%d", sourceType))
}
if markFlag > 0 {
sql.Where(fmt.Sprintf("mark_flag&%d>0", markFlag))
... ...
... ... @@ -40,6 +40,8 @@ const (
SqlUserMsgUnRead = "select * from user_msg where source_id=? and company_id=? and receive_user_id=? and msg_type=? and is_read=0 order by create_at desc" //特定未读消息
//用户消息 - 按 1.源id 2.接收者id 3.消息类型
SqlUserMsg = "select * from user_msg where source_id=? and receive_user_id=? and msg_type=? " //特定未读消息
//删除消息
SqlDeleteUserMsg = "delete from user_msg where source_id=? and source_type=? and receive_user_id=? and msg_type=? " //特定未读消息
)
func (t *UserMsg) TableName() string {
... ... @@ -115,7 +117,7 @@ GROUP BY msg_type`
func UpdateUserMsgSetRead(userId int64, companyId int64, msgType int, msgId int64) (err error) {
o := orm.NewOrm()
sql := `update user_msg set is_read = 1
where receive_user_id = ? and company_id=? and is_public=1 `
where receive_user_id = ? and company_id=? `
if msgType > 0 {
sql += fmt.Sprintf(" and (msg_type & %v)>0", msgType)
}
... ... @@ -153,7 +155,7 @@ func GetUserMsgs(userId, companyId int64, msgType int, sourceType int, lastId in
//获取公告消息列表
func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pageSize int, v interface{}) (total int, err error) {
sql := `select b.id,b.title,unix_timestamp(b.update_at) update_at,a.is_read `
sql := `select a.id msg_id,b.id,b.title,unix_timestamp(a.create_at)*1000 update_at,a.is_read `
sqlCount := `select count(0) `
where := `from user_msg a,bulletin b where a.receive_user_id =? and a.company_id=? and a.source_id = b.id and a.msg_type=? and a.company_id=? and b.status=2 `
sqlCount += where
... ... @@ -166,7 +168,7 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag
if v == nil {
return
}
where += ` order by b.update_at desc`
where += ` order by a.create_at desc`
sql += where + " limit ?"
if err = utils.ExecuteQueryAll(v, sql, userId, companyId, msgType, companyId, pageSize); err != nil {
return
... ... @@ -197,3 +199,29 @@ from user_msg where receive_user_id=? and source_type=1 and msg_type=? `
}
return
}
//获取机会评论消息
func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) {
sql := `select a.*,b.content commented_content,b.create_at commented_time,b.user_id commented_user_id from (
select a.*,b.images,b.speechs,b.videos from (
select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status from (
select id,message content,source_type,source_id,create_at comment_time from user_msg
where receive_user_id =? and (?=0 or id>?) and msg_type=?
)a left outer join chance b on a.source_id = b.id and source_type=1
)a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1
)a left outer join comment b on a.source_id = b.id and a.source_type=2
order by create_at desc
LIMIT ?`
sqlCount := `select count(0)
from user_msg where receive_user_id=? and source_type=1 and msg_type=? `
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, msgType); err != nil {
return
}
if v != nil {
if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, msgType, pageSize); err != nil {
return
}
}
return
}
... ...
... ... @@ -69,10 +69,10 @@ type FavoriteResponse struct {
/*SympathyAction 点赞,收藏*/
type SympathyActionRequest struct {
MarkType int `json:"mark_type" valid:"Required"` // 1.赞 2.收藏
SourceType int `json:"source_type" valid:"Required"` //protocol.SourceType //机会 评论
Id int64 `json:"id" valid:"Required"`
SympathyType int `json:"sympathy_type"` //1:标记 0:取消标记
MarkType int `json:"markType" valid:"Required"` // 1.赞 2.收藏
SourceType int `json:"sourceType" valid:"Required"` //protocol.SourceType //1.机会 2.评论
Id int64 `json:"id" valid:"Required"` //机会编号 / 评论编号
SympathyType int `json:"sympathyType"` //1:标记 0:取消标记
}
type SympathyActionResponse struct {
}
... ... @@ -181,7 +181,7 @@ type MyApproveChanceResponse struct {
//我的审核机会列表
type ChanceApproveItemOrm struct {
ChanceUserId int64 `orm:"column(chance_user_id)"`
ChanceUserId int64 `orm:"column(user_id)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
Images string `orm:"column(images)"`
... ... @@ -198,9 +198,39 @@ type ChanceApproveItemOrm struct {
ChanceId int64 `orm:"column(chance_id)"` // 机会id
}
/*MyCollectChance 我的收藏*/
type MyCollectChanceRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
}
type MyCollectChanceResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
/*MyThumbUpChance 我点赞的机会*/
type MyThumbUpChanceRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
}
type MyThumbUpChanceResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
/*MyComment 我的评论*/
type MyCommentRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
}
type MyCommentResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
//机会池列表
type ChancePoolItemOrm struct {
Id int64 `orm:"column(id)"`
ChanceId int64 `orm:"column(id)"`
Uid int64 `orm:"column(user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
... ... @@ -210,12 +240,90 @@ type ChancePoolItemOrm struct {
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
//ApproveData string `json:"approveData"` //审核数据
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
}
//机会池收藏列表项
type ChanceCollectItemOrm struct {
ChanceId int64 `orm:"column(id)"`
ChanceUserId int64 `orm:"column(user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
//ApproveData string `json:"approveData"` //审核数据
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
CollectId int64 `orm:"column(collect_id)"` //收藏id
CollectTime time.Time `orm:"column(collect_time)"` //收藏时间
}
//机会池收藏列表项
type ChanceThumbUpItemOrm struct {
ChanceId int64 `orm:"column(id)"`
ChanceUserId int64 `orm:"column(user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
//ApproveData string `json:"approveData"` //审核数据
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
CollectId int64 `orm:"column(collect_id)"` //收藏id
CollectTime time.Time `orm:"column(collect_time)"` //收藏时间
}
//我的评论
type ChanceCommentItemOrm struct {
//ChanceId int64 `orm:"column(id)"`
Uid int64 `orm:"column(chance_user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
CommentId int64 `orm:"column(id)"`
CommentContent string `orm:"column(content)"`
CommentTime time.Time `orm:"column(comment_time)"`
//被评论的对象
CommentedUserId int64 `orm:"column(commented_user_id)"`
CommentedContent string `orm:"column(commented_content)"`
CommentedTime time.Time `orm:"column(commented_time)"` //收藏时间
//评论对象类型
SourceType int `orm:"column(source_type)"`
SourceId int64 `orm:"column(source_id)"`
}
/*ChanceDetail 机会详情*/
... ... @@ -224,13 +332,13 @@ type ChanceDetailRequest struct {
}
type ChanceDetailResponse struct {
ChanceDetail ChanceItem `json:"chance"`
ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
StatisticData interface{} `json:"statisticData"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
ApproveData *ApproveData `json:"approveData"`
ApproveProcess []*ProcessItem `json:"approveProcess"`
ApproveAccess *ApproveAccess `json:"approveAccess"` //
ChanceType NameItem `json:"chanceType"` //机会类型
ChanceTemplate NameItem `json:"template"` //机会模板
ReviewStatus int `json:"review_status"` //审核状态 1:待审核 2:被退回 3:已通过
ReviewStatus int `json:"reviewStatus"` //审核状态 1:待审核 2:被退回 3:已通过
}
type ChanceType struct {
... ... @@ -260,7 +368,8 @@ type ChanceCalculateScoreRequest struct {
Score Score `json:"score"`
}
type ChanceCalculateScoreResponse struct {
DiscoveryScore float64 `json:"discoveryScore"` //发现分
DiscoveryScore float64 `json:"discoveryScore"` //发现分
DiscoveryScorePercent int `json:"discoveryScorePercent"` //发现分-百分比
}
/*ChanceDelete 机会删除*/
... ... @@ -313,6 +422,20 @@ type Form struct {
Required int8 `json:"required"`
}
//清楚未填写的表单数据
func ClearEmptyForm(inputFormList []*Form) (FormList []*Form) {
if len(inputFormList) == 0 {
return
}
for i := range inputFormList {
item := inputFormList[i]
if len(item.Value) > 0 {
FormList = append(FormList, item)
}
}
return
}
//语音
type Speech struct {
Path string `json:"path"`
... ... @@ -347,21 +470,27 @@ type ChanceTotalItem struct {
//机会列表 通用项
type CommonListItem struct {
Chance ChanceItem `json:"chance,omitempty"` //机会详情
ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
Approve interface{} `json:"approve,omitempty"` //审核人 审核信息(时间) Approve
ApproveData interface{} `json:"approveData,omitempty"` //审核数据(公开状态 评分) ApproveData
Message interface{} `json:"message,omitempty"` //消息
Comment interface{} `json:"comment,omitempty"` //评论
ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
ReviewStatus int `json:"reviewStatus"` //审核状态
Chance ChanceItem `json:"chance,omitempty"` //机会详情
ChanceData interface{} `json:"statisticData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
Approve interface{} `json:"approve,omitempty"` //审核人 审核信息(时间) Approve
ApproveData interface{} `json:"approveData,omitempty"` //审核数据(公开状态 评分) ApproveData
Message interface{} `json:"message,omitempty"` //消息
CommentData interface{} `json:"commentData,omitempty"` //评论
CollectData interface{} `json:"collectData,omitempty"` //收藏数据
ThumbUpData interface{} `json:"thumbUpData,omitempty"` //点赞数据
//我审核的-通过
Score interface{} `json:"score,omitempty"`
//模板
ChanceType interface{} `json:"chanceType,omitempty"` //机会类型
ChanceTemplate interface{} `json:"template,omitempty"` //机会模板
//我评论的 评论数据
CommentedData interface{} `json:"commentedData,omitempty"`
SourceType int `json:"sourceType,omitempty"` //类型 1:机会 2:评论
ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
ReviewStatus int `json:"reviewStatus"` //审核状态
}
type ChanceItem struct {
Id int64 `json:"id"`
... ... @@ -375,8 +504,28 @@ type ChanceItem struct {
type ChanceData struct {
ThumbsUpTotal int `json:"thumbsupTotal"` //点赞总数
CommentTotal int `json:"commentTotal"` //评论总数
PageViewTotal int `json:"pageView"` //评论总数
PageViewTotal int `json:"pageViewTotal"` //评论总数
IsThumbsUp bool `json:"isThumbsUp"` //是否点赞 1 点赞, 0 没有点赞
IsCollect bool `json:"isCollect"` //是否收藏 1 是 0 否
}
//收藏数据
type CollectData struct {
Id int64 `json:"id"`
CollectTime int64 `json:"collectTime"` //收藏时间
}
//点赞数据
type ThumbUpData struct {
Id int64 `json:"id"`
Content string `json:"content"` //点赞内容
ThumbUpTime int64 `json:"thumbUpTime"` //收藏时间
}
IsThumbsUp bool `json:"thumbsup"` //是否点赞 1 点赞, 0 没有点赞
IsCollect bool `json:"isCollect"` //是否收藏 1 是 0 否
//评论内容
type CommentData struct {
Id int64 `json:"id"` //评论编号
Content string `json:"content"` //评论内容
CommentTime int64 `json:"commentTime"` //评论时间
}
... ...
... ... @@ -90,8 +90,9 @@ type VisibleObject struct {
//评分
type Score struct {
BasicScore float64 `json:"basicScore"` //基础评分
ExtraScore float64 `json:"extraScore"` //额外分
ValueScore float64 `json:"valueScore"` //价值分
DiscoveryScore float64 `json:"discoveryScore"` //发现分
BasicScore float64 `json:"basicScore"` //基础评分
ExtraScore float64 `json:"extraScore"` //额外分
ValueScore float64 `json:"valueScore"` //价值分
DiscoveryScore float64 `json:"discoveryScore"` //发现分
DiscoveryScorePercent int `json:"discoveryScorePercent"` //发现分-百分比
}
... ...
... ... @@ -9,7 +9,7 @@ const (
/*IComment */
type ICommentRequest struct {
Content string `json:"content" valid:"Required"`
SourceType int `json:"type" valid:"Required"`
SourceType int `json:"type" valid:"Required"` //1.机会 2:评论
Id int64 `json:"id" valid:"Required"`
}
type ICommentResponse struct {
... ... @@ -39,23 +39,42 @@ type CommentsRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
SourceId int64 `json:"id" valid:"Required"`
SourceType int
SourceType int `json:"sourceType" valid:"Required"` //1:机会 2:评论
}
type CommentsResponse struct {
Total int `json:"total"`
Comments []*Comments `json:"comments"`
Total int `json:"total"`
}
/*Thumbsups 点赞列表*/
type ThumbsupsRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
SourceId int64 `json:"id" valid:"Required"`
SourceType int `json:"sourceType" valid:"Required"` //1:机会 2:评论
}
type ThumbsupsResponse struct {
Thumbups []*Thumbups `json:"thumbups"`
Total int `json:"total"`
}
/*评论列表*/
type Comments struct {
Id int64 `json:"id"`
Provider *BaseUserInfo `json:"provider"`
Content string `json:"content"`
ViewTotal int `json:"pageView"`
CommentTotal int `json:"commentTotal"`
ZanTotal int `json:"zanTotal"`
CreateTime int64 `json:"createTime"`
IsZan int `json:"is_zan"` //0:未点赞 1:点赞
Id int64 `json:"id"`
CreateTime int64 `json:"createTime"`
Content string `json:"content"`
Provider *BaseUserInfo `json:"provider"`
ViewTotal int `json:"pageViewTotal"`
CommentTotal int `json:"commentTotal"`
ZanTotal int `json:"thumbsupTotal"`
IsZan int `json:"isThumbsUp"` //0:未点赞 1:点赞
}
type Thumbups struct {
Id int64 `json:"id"`
CreateTime int64 `json:"createTime"`
Provider *BaseUserInfo `json:"provider"`
}
/*CommentDetailsMulti */
... ...
... ... @@ -13,3 +13,11 @@ func Test_Err(t *testing.T) {
bt2, _ := json.Marshal(normalmsg)
t.Log(string(bt2))
}
func Test_Ceil(t *testing.T) {
value := 90.12
intValue := int(value)
t.Log(intValue)
t.Log(0.38 * 0.3)
}
... ...
... ... @@ -42,9 +42,21 @@ var errmessge ErrorMap = map[int]string{
5203: "审批服务器操作失败",
5204: "评分或者公开状态不能为空",
5205: "机会未审核通过,不能修改评分或者公开状态",
5206: "未找到审批节点或者无权限",
//模板相关
5301: "机会模板不存在",
//消息相关
5401: "消息不存在",
//评分相关
5501: "基础评分不符合要求",
5502: "附加评分不符合要求",
5503: "价值评分不符合要求",
5510: "评分配置不存在,请联系管理员",
5511: "发现分计算不一致,请重新提交",
}
const (
... ... @@ -52,7 +64,7 @@ const (
MsgTypeCommend = 2 //表彰
MsgTypeInteraction = 4 //互动消息
MsgTypeAudit = 8 //机会审核
MsgTypeAuditBy = 16 //机会被审核消息
MsgTypeAuditBy = 16 //机会被审核消息-我提交的
MsgTypeComment = 32 //评论
MsgTypeThumbUp = 64 //点赞
)
... ... @@ -61,6 +73,9 @@ var (
MessageApproving = "提交了一条%v机会消息,需要您审核"
MessageApproveSuccess = "审核通过你提交的%v机会"
MessageApproveReject = "退回您了提交的%v机会"
MessageZanChance = "点赞了您发布的机会"
MessageZanComment = "点赞了您发布的评论"
)
/*MessageCenter */
... ... @@ -104,12 +119,14 @@ type MsgInteractiveResponse struct {
}
type UserMsg struct {
Id int64 `json:"msgId"`
MsgId int64 `json:"msgId"`
BulletinId int64 `json:"-"`
SourceType int `json:"msgType"`
Content string `json:"content"`
CreateAt int64 `json:"msgTime"`
IsRead int `json:"isRead"`
//机会 //评论
Link string `json:"link,omitempty"`
}
type Message struct {
... ... @@ -206,6 +223,36 @@ type MsgChanceApproveResponse struct {
Total int `json:"total"`
}
/*MsgChanceSubmit 我提交的*/
type MsgChanceSubmitRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
}
type MsgChanceSubmitResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
/*MsgChanceComment 消息中心-互动消息.评论*/
type MsgChanceCommentRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
}
type MsgChanceCommentResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
/*MsgChanceThumbUp 息中心-互动消息.点赞*/
type MsgChanceThumbUpRequest struct {
LastId int64 `json:"lastId"`
PageSize int `json:"pageSize" valid:"Required"`
}
type MsgChanceThumbUpResponse struct {
List []CommonListItem `json:"list"`
Total int `json:"total"`
}
//我的审核机会列表
type MsgChanceApproveItemOrm struct {
ChanceUserId int64 `orm:"column(chance_user_id)"`
... ...
... ... @@ -177,6 +177,22 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "MyCollectChance",
Router: `/myCollectChance`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "MyComment",
Router: `/myComment`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "MySubmitChance",
Router: `/mySubmitChance`,
AllowHTTPMethods: []string{"post"},
... ... @@ -185,6 +201,14 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "MyThumbUpChance",
Router: `/myThumbUpChance`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "Permission",
Router: `/permission`,
AllowHTTPMethods: []string{"post"},
... ... @@ -223,6 +247,14 @@ func init() {
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"],
beego.ControllerComments{
Method: "Thumbsups",
Router: `/thumbsups`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:CommendController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:CommendController"],
beego.ControllerComments{
Method: "Company",
... ... @@ -297,6 +329,30 @@ func init() {
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgChanceComment",
Router: `/msgChanceComment`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgChanceSubmit",
Router: `/msgChanceSubmit`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgChanceThumbUp",
Router: `/msgChanceThumbUp`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"],
beego.ControllerComments{
Method: "MsgCompanyNotice",
Router: `/msgCompanyNotice`,
AllowHTTPMethods: []string{"post"},
... ...
... ... @@ -185,6 +185,7 @@ func GetChanceMarkData(userId, companyId int64, sourceId int64) (flag int, err e
)
if v, err = models.GetChanceFavorite(userId, companyId, sourceId, protocol.SourceTypeChance); err != nil {
if err == orm.ErrNoRows {
//log.Error(userId, companyId, sourceId, err)
return 0, nil
}
return
... ...
... ... @@ -2,8 +2,10 @@ package agg
import (
"fmt"
"github.com/astaxie/beego/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/internal/utils"
"opp/models"
"opp/protocol"
"time"
... ... @@ -134,6 +136,16 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou
return
}
//删除已发送的消息
func DeleteSendedMsg(sourceId int64, sourceType int, receiverId int64, msgType int) (err error) {
o := orm.NewOrm()
log.Info(fmt.Sprintf("删除消息 接收者:%v 来源编号:%v 来源类型:%v 消息类型:%v", receiverId, sourceId, sourceType, msgType))
if err = utils.ExecuteSQLWithOrmer(o, models.SqlDeleteUserMsg, sourceId, sourceType, receiverId, msgType); err != nil {
log.Error(err)
}
return
}
//打印消息日志
func logMsg(msg *models.UserMsg, name string) {
log.Info(fmt.Sprintf("发送消息 消息类型:%v Receiver:%v(%v) Message:%v SourceId:%v SourceType:%v",
... ...
... ... @@ -52,7 +52,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces
Approver: userCompany.NickName,
Uid: userCompany.Id,
Sign: ApproveSign,
Type: 1,
Type: 2,
}
for i := range process {
var (
... ... @@ -274,6 +274,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
approveItemResponse ApproveItemResponse
mapProcess = make(map[string]interface{})
mapChance = make(map[string]interface{})
result *protocol.ChanceCalculateScoreResponse
)
rsp = &protocol.ChanceApproveResponse{}
//TODO:测试注入
... ... @@ -298,7 +299,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
}
if process, err = models.GetAuditFlowProcessBy(request.ProcessId, header.UserId); err != nil {
log.Error(request.ProcessId, header.UserId, err)
err = protocol.NewErrWithMessage(5202)
err = protocol.NewErrWithMessage(5206)
return
}
if chance.ReviewStatus != protocol.ReviewStatusAuditging {
... ... @@ -307,6 +308,16 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
return
}
{
//计算发现分
if result, err = ChanceCalculateScore(header, &protocol.ChanceCalculateScoreRequest{Score: request.ApproveData.Score}); err != nil {
log.Error("计算发现分错误:", err)
//err = protocol.NewErrWithMessage(5511)
return
}
request.ApproveData.Score.DiscoveryScore = result.DiscoveryScore
request.ApproveData.Score.DiscoveryScorePercent = result.DiscoveryScorePercent
}
{
mapProcess["ReviewStatus"] = int8(request.ReviewStatus)
mapProcess["ApproveTime"] = time.Now()
if request.ReviewStatus == protocol.ReviewStatusPass {
... ... @@ -332,29 +343,42 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
return
}
log.Info(fmt.Sprintf("用户%v 更新机会审核状态 process_id:%v 状态:%v", header.UserId, process.Id, request.ReviewStatus))
orm := orm.NewOrm()
orm.Begin()
if request.ReviewStatus == protocol.ReviewStatusReturn {
mapChance["ReviewStatus"] = int8(request.ReviewStatus) //退回也要更新审核状态
//增加一条待处理记录到审核列表
//生成提交记录
if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, chance.AuditTemplateId, protocol.ReviewStatusWait)); err != nil {
log.Error(err)
orm.Rollback()
return
}
}
{
//更新下一批次的审核人
var nextApprovers []int64
if err = agg.SendApprovedMsg(chance.UserId, "",
header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
log.Error(err)
orm.Rollback()
return
}
if approveItemResponse.IsOver == 1 {
//结束审批
{
mapChance["ReviewStatus"] = int8(request.ReviewStatus)
}
//发送审核结果消息给提交人
for i := range approveItemResponse.MessageData.ApplyUserMessage {
message := approveItemResponse.MessageData.ApplyUserMessage[i]
nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus); err != nil {
log.Error(err)
return
}
}
//更新同批次的为审核的状态置为无效
if err = models.UpdatetAuditFlowProcessNoApprove(chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
log.Error(err)
return
}
//for i := range approveItemResponse.MessageData.ApplyUserMessage {
// message := approveItemResponse.MessageData.ApplyUserMessage[i]
// nextApprovers = append(nextApprovers, message.ReceiverInfo.ReceiverUid)
// if err = agg.SendApprovedMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
// header.CompanyId, chance.Id, chance.ChanceTypeId, request.ReviewStatus, protocol.MsgTypeAuditBy); err != nil {
// log.Error(err)
// return
// }
//}
} else {
//发送下一个消息给下一流程的审核人
for i := range approveItemResponse.MessageData.ApproveMessage {
... ... @@ -363,26 +387,27 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
if err = agg.SendApproveMsg(message.ReceiverInfo.ReceiverUid, message.ReceiverInfo.ReceiverName,
header.CompanyId, chance.Id, chance.ChanceTypeId, protocol.ReviewStatusAuditging); err != nil {
log.Error(err)
orm.Rollback()
return
}
}
//更新下一批次的审核人 同批次的为审核的状态置为无效
if len(nextApprovers) != 0 {
if err = models.UpdatetAuditFlowProcessToNext(chance.Id, chance.AuditLevel+1, nextApprovers); err != nil {
if err = models.UpdatetAuditFlowProcessToNext(orm, chance.Id, chance.AuditLevel+1, nextApprovers); err != nil {
log.Error(err)
orm.Rollback()
log.Info(fmt.Sprintf("更新机会失败 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
return
}
log.Info(fmt.Sprintf("更新机会 chance_id:%v 下一批次审批人员:%v", chance.Id, nextApprovers))
if err = models.UpdatetAuditFlowProcessNoApprove(chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
if err = models.UpdatetAuditFlowProcessNoApprove(orm, chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
log.Error(err)
orm.Rollback()
return
}
}
}
}
orm := orm.NewOrm()
orm.Begin()
if err = utils.UpdateTableByMapWithOrmer(orm, process, mapProcess); err != nil {
log.Error("更新机会审核流程 状态失败 process_id:", process.Id, err)
orm.Rollback()
... ... @@ -393,6 +418,14 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
log.Error("更新机会审核状态失败 chance_id:", chance.Id, err)
return
}
if request.ReviewStatus == protocol.ReviewStatusReturn || approveItemResponse.IsOver == 1 {
//更新同批次的为审核的状态置为无效
if err = models.UpdatetAuditFlowProcessNoApprove(orm, chance.Id, chance.AuditLevel, protocol.ReviewStatusAuditging); err != nil {
log.Error(err)
orm.Rollback()
return
}
}
if request.ApproveData.PublicData.PublishStatus == protocol.PublicToDepartment {
if err = utils.ExecuteSQLWithOrmer(orm, models.SqlDeleteChanceDepartment, chance.Id); err != nil {
log.Error(err)
... ... @@ -469,12 +502,13 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance)
item := &protocol.ProcessItem{
Id: process.Id,
ReviewStatus: int(process.ReviewStatus),
ApproveWay: int(process.AuditFlowType),
ApproveWay: int(process.ActionType),
ApproveType: process.AuditFlowType,
Uid: process.Uid,
Name: process.UserName,
}
if item.ApproveWay == protocol.AuditBySpecailUser {
item.ApproveWay = protocol.AuditByUser
if item.ApproveType == protocol.AuditBySpecailUser {
item.ApproveType = protocol.AuditByUser
}
if item.ReviewStatus != protocol.ReviewStatusAuditging {
item.ApproveTime = process.ApproveTime.Unix() * 1000
... ...
... ... @@ -65,13 +65,15 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
chanceType int
incre int = 1
table string = "comment"
message string = protocol.MessageZanComment
)
rsp = &protocol.SympathyActionResponse{}
if chanceFavoirte, err = models.GetChanceFavorite(header.Uid, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows {
if chanceFavoirte, err = models.GetChanceFavorite(header.UserId, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows {
log.Error(err)
return
}
if request.SourceType == protocol.SourceTypeChance {
message = protocol.MessageZanChance
if chance, err = models.GetChanceById(request.Id); err != nil {
log.Error("机会不存在", err)
return
... ... @@ -102,7 +104,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
}
}
if exists {
if err = models.UpdateChanceFavorite(header.Uid, header.CompanyId, request.Id, 1<<(uint(request.MarkType-1))); err != nil {
if err = models.UpdateChanceFavorite(header.UserId, header.CompanyId, request.Id, 1<<(uint(request.MarkType-1))); err != nil {
log.Error(request.MarkType, err)
return
}
... ... @@ -111,7 +113,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
//add
chanceFavoirte = &models.ChanceFavorite{
Id: idgen.Next(),
UserId: header.Uid,
UserId: header.UserId,
CompanyId: header.CompanyId,
MarkFlag: request.SympathyType,
SourceType: request.SourceType,
... ... @@ -124,7 +126,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
log.Error(err)
return
} else {
log.Debug(fmt.Sprintf("SympathyAction user:%d id:%d sympathy:%v", header.Uid, request.Id, request.SympathyType))
log.Debug(fmt.Sprintf("SympathyAction user:%d id:%d sympathy:%v", header.UserId, request.Id, request.SympathyType))
goto END
}
END:
... ... @@ -134,6 +136,11 @@ END:
}
if request.SympathyType == protocol.UnMarkFlag {
incre = -1
//删除点赞消息
agg.DeleteSendedMsg(chance.Id, protocol.SourceTypeChance, chance.UserId, protocol.MsgTypeThumbUp)
} else {
//发送点赞消息
agg.SendMsg(chance.UserId, fmt.Sprintf("%v", chance.UserId), chance.CompanyId, chance.Id, 1, message, protocol.MsgTypeThumbUp)
}
if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) {
//
... ... @@ -276,7 +283,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
}
//生成提交记录
if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, template.Id)); err != nil {
if _, err = orm.Insert(GenAuditFlowProcess_Submit(header, chance.Id, template.Id, protocol.ReviewStatusSubmit)); err != nil {
log.Error(err)
orm.Rollback()
return
... ... @@ -487,6 +494,7 @@ func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceC
chance *models.Chance
mapChance = make(map[string]interface{})
approveData protocol.ApproveData
result *protocol.ChanceCalculateScoreResponse
)
if chance, err = models.GetChanceByIdAndEnable(request.ChanceId); err != nil {
err = protocol.NewErrWithMessage(5101) //不存在
... ... @@ -496,6 +504,13 @@ func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceC
err = protocol.NewErrWithMessage(5205)
return
}
if result, err = ChanceCalculateScore(header, &protocol.ChanceCalculateScoreRequest{Score: request.Score}); err != nil {
log.Error("计算发现分错误:", err)
//err = protocol.NewErrWithMessage(5511)
return
}
request.Score.DiscoveryScore = result.DiscoveryScore
request.Score.DiscoveryScorePercent = result.DiscoveryScorePercent
//TODO:角色检查权限
if e := json.Unmarshal([]byte(chance.ApproveData), &approveData); e == nil {
approveData.Score = request.Score
... ... @@ -505,7 +520,7 @@ func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceC
mapChance["BasicScore"] = request.Score.BasicScore
mapChance["ExtraScore"] = request.Score.ExtraScore
mapChance["ValueScore"] = request.Score.ValueScore
mapChance["DiscoveryScore"] = request.Score.DiscoveryScore
mapChance["DiscoveryScore"] = result.DiscoveryScore
}
orm := orm.NewOrm()
orm.Begin()
... ... @@ -521,10 +536,60 @@ func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceC
//计算发现分
func ChanceCalculateScore(header *protocol.RequestHeader, request *protocol.ChanceCalculateScoreRequest) (rsp *protocol.ChanceCalculateScoreResponse, err error) {
var ()
//TODO:取配置数据
var (
config *models.SysConfig
scoreConfig protocol.ScoreConfig
sum float64
)
rsp = &protocol.ChanceCalculateScoreResponse{}
rsp.DiscoveryScore = request.Score.BasicScore*1.0 + request.Score.ExtraScore*1.0 + request.Score.ValueScore*1.0
if config, err = models.GetSysConfigByCompanyId(int(header.CompanyId), models.KeyScore); err != nil {
err = protocol.NewErrWithMessage(5510)
log.Error(header.CompanyId, err)
return
}
if err = json.Unmarshal([]byte(config.Content), &scoreConfig); err != nil {
err = protocol.NewErrWithMessage(5510)
log.Error(err)
return
}
{
basic := request.Score.BasicScore
if basic < scoreConfig.BasicScore.Min || basic > scoreConfig.BasicScore.Max {
err = protocol.NewErrWithMessage(5501)
log.Error(fmt.Sprintf("%v out range[%v:%v]", basic, scoreConfig.BasicScore.Min, scoreConfig.BasicScore.Max))
return
}
sum += scoreConfig.BasicScore.Max * scoreConfig.DiscoveryScore.BasicFactor
}
{
extral := request.Score.ExtraScore
if extral < scoreConfig.ExtraScore.Min || extral > scoreConfig.ExtraScore.Max {
err = protocol.NewErrWithMessage(5502)
log.Error(fmt.Sprintf("%v out range[%v:%v]", extral, scoreConfig.ExtraScore.Min, scoreConfig.ExtraScore.Max))
return
}
sum += scoreConfig.ExtraScore.Max * scoreConfig.DiscoveryScore.ExtraFactor
}
{
value := request.Score.ValueScore
if value < scoreConfig.ValueScore.Min || value > scoreConfig.ValueScore.Max {
err = protocol.NewErrWithMessage(5502)
log.Error(fmt.Sprintf("%v out range[%v:%v]", value, scoreConfig.ValueScore.Min, scoreConfig.ValueScore.Max))
return
}
sum += scoreConfig.ValueScore.Max * scoreConfig.DiscoveryScore.ValueFactor
}
rsp.DiscoveryScore = request.Score.BasicScore*scoreConfig.DiscoveryScore.BasicFactor + request.Score.ExtraScore*scoreConfig.DiscoveryScore.ExtraFactor + request.Score.ValueScore*scoreConfig.DiscoveryScore.ValueFactor
rsp.DiscoveryScorePercent = int((rsp.DiscoveryScore / sum) * 100)
log.Debug(fmt.Sprintf("计算发现-> score_config:%v score:%v 总分:%v 发现分:%v 发现分百分比:%v", common.AssertJson(scoreConfig), common.AssertJson(request.Score), sum, rsp.DiscoveryScore, rsp.DiscoveryScorePercent))
//发现分不为0
if request.Score.DiscoveryScore != 0 {
if request.Score.DiscoveryScore != 0 && rsp.DiscoveryScore != request.Score.DiscoveryScore {
log.Error(fmt.Sprintf("input :%v out:%v want:%v", request.Score.DiscoveryScore, rsp.DiscoveryScore, request.Score.DiscoveryScore))
err = protocol.NewErrWithMessage(5511)
return
}
}
return
}
... ... @@ -542,7 +607,7 @@ func ChancePermission(header *protocol.RequestHeader, request *protocol.ChancePe
}
//生成审批流-提交记录
func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64) (v *models.AuditFlowProcess) {
func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64, reviewStatus int) (v *models.AuditFlowProcess) {
v = &models.AuditFlowProcess{
Id: idgen.Next(),
ChanceId: chanceId,
... ... @@ -551,7 +616,7 @@ func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64,
UpdateAt: time.Now(),
ApproveTime: time.Now(),
EnableStatus: 1,
ReviewStatus: protocol.ReviewStatusSubmit,
ReviewStatus: int8(reviewStatus),
}
if approver, err := models.GetUsersById(header.Uid); err != nil {
log.Error(err)
... ... @@ -759,6 +824,8 @@ func getParentDepartmentors(pid int) (ids []int64) {
func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceStatisticsRequest) (rsp *protocol.ChanceStatisticsResponse, err error) {
var (
chanceType []*models.ChanceType
total int
sum int
)
if chanceType, err = models.GetChanceTypeAll(header.CompanyId); err != nil {
log.Error(err)
... ... @@ -767,12 +834,18 @@ func ChanceStatistics(header *protocol.RequestHeader, request *protocol.ChanceSt
rsp = &protocol.ChanceStatisticsResponse{}
for i := range chanceType {
item := chanceType[i]
if total, err = models.GetChancePool(header.UserId, header.CompanyId, item.Id, 0, 0, nil); err != nil {
log.Error(err)
return
}
sum += total
rsp.List = append(rsp.List, protocol.ChanceTotalItem{
Id: item.Id,
Name: item.Name,
Total: i * 2,
Total: total,
})
}
rsp.ChanceTotal = sum
return
}
... ... @@ -849,7 +922,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
commItem := protocol.CommonListItem{}
{
item := protocol.ChanceItem{
Id: chance.Id,
Id: chance.ChanceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
... ... @@ -867,7 +940,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ
CommentTotal: chance.CommentTotal,
PageViewTotal: chance.ViewTotal,
}
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.Id); err != nil {
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.ChanceId); err != nil {
log.Error(err)
continue
}
... ... @@ -903,7 +976,6 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
total int
provider *protocol.BaseUserInfo
)
rsp = &protocol.MyApproveChanceResponse{}
if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
... ... @@ -922,9 +994,10 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil {
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
log.Error(chance.ChanceUserId, header.CompanyId, err)
err = nil
//return
} else {
item := protocol.ChanceItem{
... ... @@ -966,6 +1039,264 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
return
}
// 我的收藏
func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollectChanceRequest) (rsp *protocol.MyCollectChanceResponse, err error) {
var (
myChances []protocol.ChanceCollectItemOrm
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceCollect(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MyCollectChanceResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
commItem.ReviewStatus = chance.ReviewStatus
if len(chance.SourceContent) == 0 { //机会删除
commItem.ChanceStatus = protocol.ChanceStatusDelete
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
//return
} else {
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
//CreateTime: chance.CreateTime.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = clearEmptyForm(item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
commItem.ReviewStatus = chance.ReviewStatus
{
var chanceData = protocol.ChanceData{
ThumbsUpTotal: chance.ZanTotal,
CommentTotal: chance.CommentTotal,
PageViewTotal: chance.ViewTotal,
}
chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, chance.ChanceId)
commItem.ChanceData = chanceData
}
{
//做一次查询 查回所有的模板数据
commItem.ChanceTemplate = getTemplate(chance.TemplateId)
commItem.ChanceType = getChanceType(chance.ChanceTypeId)
}
{
//收藏数据
commItem.CollectData = protocol.CollectData{
Id: chance.CollectId,
CollectTime: chance.CollectTime.Unix() * 1000,
}
}
rsp.List = append(rsp.List, commItem)
}
return
}
//我点赞的机会
func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUpChanceRequest) (rsp *protocol.MyThumbUpChanceResponse, err error) {
var (
myChances []protocol.ChanceThumbUpItemOrm
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MyThumbUpChanceResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
commItem.ReviewStatus = chance.ReviewStatus
if len(chance.SourceContent) == 0 { //机会删除
commItem.ChanceStatus = protocol.ChanceStatusDelete
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
//return
} else {
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = clearEmptyForm(item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
commItem.ReviewStatus = chance.ReviewStatus
{
var chanceData = protocol.ChanceData{
ThumbsUpTotal: chance.ZanTotal,
CommentTotal: chance.CommentTotal,
PageViewTotal: chance.ViewTotal,
}
chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, chance.ChanceId)
commItem.ChanceData = chanceData
}
{
//做一次查询 查回所有的模板数据
commItem.ChanceTemplate = getTemplate(chance.TemplateId)
commItem.ChanceType = getChanceType(chance.ChanceTypeId)
}
{
//收藏数据
commItem.ThumbUpData = protocol.ThumbUpData{
Id: chance.CollectId,
ThumbUpTime: chance.CollectTime.Unix() * 1000,
}
}
rsp.List = append(rsp.List, commItem)
}
return
}
//我的评论
func MyComment(header *protocol.RequestHeader, request *protocol.MyCommentRequest) (rsp *protocol.MyCommentResponse, err error) {
var (
myChances []protocol.ChanceCommentItemOrm
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceComment(header.UserId, request.LastId, request.PageSize, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MyCommentResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
if chance.SourceType == protocol.SourceTypeChance {
commItem.ReviewStatus = chance.ReviewStatus
if len(chance.SourceContent) == 0 { //机会删除
commItem.ChanceStatus = protocol.ChanceStatusDelete
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
//return
} else {
item := protocol.ChanceItem{
Id: chance.SourceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = clearEmptyForm(item.FormList)
jsonUnmarshal(chance.Images, &item.Pictures)
jsonUnmarshal(chance.Voices, &item.Speechs)
jsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
commItem.ReviewStatus = chance.ReviewStatus
//{
// var chanceData = protocol.ChanceData{
// ThumbsUpTotal: chance.ZanTotal,
// CommentTotal: chance.CommentTotal,
// PageViewTotal: chance.ViewTotal,
// }
// chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, chance.SourceType)
// commItem.ChanceData = chanceData
//}
//{
// //做一次查询 查回所有的模板数据
// commItem.ChanceTemplate = getTemplate(chance.TemplateId)
// commItem.ChanceType = getChanceType(chance.ChanceTypeId)
//}
}
if chance.SourceType == protocol.SourceTypeComment {
commItem.CommentedData = protocol.CommentData{
Id: chance.SourceId,
Content: chance.CommentedContent,
CommentTime: chance.CommentedTime.Unix() * 1000,
}
}
commItem.CommentData = protocol.CommentData{
Id: chance.CommentId,
CommentTime: chance.CommentTime.Unix() * 1000,
Content: chance.CommentContent,
}
commItem.SourceType = chance.SourceType
rsp.List = append(rsp.List, commItem)
}
return
}
//获取机会点赞/收藏状态
func getChanceMarkFlag(header *protocol.RequestHeader, chanceId int64) (isThumbsUp, isCollect bool, err error) {
var flag int
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chanceId); err != nil {
log.Error(err)
return
}
isThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan
isCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
return
}
//获取模板
func getTemplate(templateId int) protocol.NameItem {
if template, e := models.GetAuditTemplateById(int64(templateId)); e == nil {
item := protocol.NameItem{
Id: int(template.Id),
Name: template.Name,
}
return item
} else {
log.Error(templateId, e)
}
return protocol.NameItem{}
}
//获取机会一级分类
func getChanceType(chanceTypeId int) protocol.NameItem {
if template, e := models.GetChanceTypeById(chanceTypeId); e == nil {
item := protocol.NameItem{
Id: int(template.Id),
Name: template.Name,
}
return item
} else {
log.Error(chanceTypeId, e)
}
return protocol.NameItem{}
}
func jsonUnmarshal(jsonData string, v interface{}) {
if len(jsonData) == 0 {
return
... ... @@ -998,6 +1329,7 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
approveProcess *protocol.ChanceApproveProcessResponse
//chanceType *models.ChanceType
//tempalte *models.AuditTemplate
table string = "chance"
)
rsp = &protocol.ChanceDetailResponse{}
if chance, err = models.GetChanceById(request.Id); err != nil {
... ... @@ -1024,6 +1356,11 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
err = protocol.NewErrWithMessage(5101)
return
}
if chance.ReviewStatus == protocol.ReviewStatusPass {
if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "view_total", 1, request.Id)) {
//
}
}
//用户信息
if provider, err = agg.GetUserBaseInfo(chance.UserId, header.CompanyId); err != nil {
log.Error(err)
... ... @@ -1051,6 +1388,22 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail
rsp.ApproveProcess = approveProcess.ApproveProcess
rsp.ApproveAccess = approveProcess.ApproveAccess
}
{
var flag int
var chanceData = protocol.ChanceData{
ThumbsUpTotal: chance.ZanTotal,
CommentTotal: chance.CommentTotal,
PageViewTotal: chance.ViewTotal,
}
if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.Id); err != nil {
log.Error(err)
return
}
chanceData.IsThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan
chanceData.IsCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect
rsp.StatisticData = chanceData
}
return
}
... ...
... ... @@ -2,6 +2,7 @@ package chance
import (
"fmt"
"github.com/astaxie/beego/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
"opp/internal/utils"
... ... @@ -19,6 +20,8 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
chance *models.Chance
updateTable interface{}
updateMap = make(map[string]interface{})
recevierId int64
sourceId int64
)
switch request.SourceType {
case protocol.SourceTypeChance:
... ... @@ -28,15 +31,22 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
}
updateTable = chance
updateMap["CommentTotal"] = chance.CommentTotal + 1
recevierId = chance.UserId
sourceId = chance.Id
break
case protocol.SourceTypeComment:
if comment, err = models.GetCommentById(request.Id); err != nil {
log.Error(err)
return
}
updateTable = comment
recevierId = comment.UserId
sourceId = comment.Id
updateMap["CommentTotal"] = comment.CommentTotal + 1
break
default:
err = fmt.Errorf("unknow source_type:%v", request.SourceType)
return
}
newComment := &models.Comment{
Id: idgen.Next(),
... ... @@ -46,8 +56,11 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
CreateAt: time.Now(),
SourceId: request.Id,
}
if _, err = models.AddComment(newComment); err != nil {
orm := orm.NewOrm()
orm.Begin()
if _, err = orm.Insert(newComment); err != nil {
log.Error(err)
orm.Rollback()
return
}
if baseUserInfo, err = agg.GetUserBaseInfo(header.Uid, header.CompanyId); err != nil {
... ... @@ -55,12 +68,22 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
return
}
if updateTable != nil {
utils.UpdateTableByMap(updateTable, updateMap)
if err = utils.UpdateTableByMapWithOrmer(orm, updateTable, updateMap); err != nil {
log.Error(err)
orm.Rollback()
return
}
}
if err = agg.SendMsg(recevierId, "", header.CompanyId, sourceId, request.SourceType, request.Content, protocol.MsgTypeComment); err != nil {
log.Error(err)
orm.Rollback()
return
}
orm.Commit()
rsp = &protocol.ICommentResponse{
Id: newComment.Id,
Content: newComment.Content,
CreateTime: newComment.CreateAt.Unix(),
CreateTime: newComment.CreateAt.Unix() * 1000,
Provider: baseUserInfo,
}
return
... ... @@ -128,7 +151,7 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
Id: comment.Id,
Provider: baseUserInfo,
Content: comment.Content,
CreateTime: comment.CreateAt.Unix(),
CreateTime: comment.CreateAt.Unix() * 1000,
ViewTotal: comment.ViewTotal,
ZanTotal: comment.ZanTotal,
CommentTotal: comment.CommentTotal,
... ... @@ -141,6 +164,39 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
return
}
//点赞列表
func Thumbsups(header *protocol.RequestHeader, request *protocol.ThumbsupsRequest) (rsp *protocol.ThumbsupsResponse, err error) {
var (
favorites []*models.ChanceFavorite
total int
baseUserInfo *protocol.BaseUserInfo
)
rsp = &protocol.ThumbsupsResponse{}
if favorites, total, err = models.GetChanceFavorites(header.UserId, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.LastId, request.PageSize); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
return
}
for i := range favorites {
f := favorites[i]
if baseUserInfo, err = agg.GetUserBaseInfo(f.UserId, header.CompanyId); err != nil {
log.Error(err)
//return
continue
}
item := &protocol.Thumbups{
Id: f.Id,
Provider: baseUserInfo,
CreateTime: f.CreateAt.Unix() * 1000,
}
rsp.Thumbups = append(rsp.Thumbups, item)
}
rsp.Total = total
return
}
//评论详情-不带地下评论
func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.CommentDetailsSingleRequest) (rsp *protocol.CommentDetailsSingleResponse, err error) {
var (
... ...
... ... @@ -17,15 +17,25 @@ import (
func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCenterRequest) (rsp *protocol.MessageCenterResponse, err error) {
var ()
rsp = &protocol.MessageCenterResponse{}
err = models.GetUserMsgTotals(header.Uid, header.CompanyId, request.MsgType, &rsp.Totals)
err = models.GetUserMsgTotals(header.UserId, header.CompanyId, request.MsgType, &rsp.Totals)
return
}
//标记已读
func MsgCenterRead(header *protocol.RequestHeader, request *protocol.MsgCenterReadRequest) (rsp *protocol.MsgCenterReadResponse, err error) {
var ()
//rsp =&protocol.MsgCenterReadResponse{}
err = models.UpdateUserMsgSetRead(header.Uid, header.CompanyId, request.MsgType, request.MsgId)
var (
msg *models.UserMsg
)
rsp = &protocol.MsgCenterReadResponse{}
if msg, err = models.GetUserMsgById(request.MsgId); err != nil {
log.Error(err)
err = protocol.NewErrWithMessage(5401)
return
}
if msg.IsRead == 1 {
return
}
err = models.UpdateUserMsgSetRead(header.UserId, header.CompanyId, request.MsgType, request.MsgId)
if err != nil {
log.Error(err)
}
... ... @@ -35,7 +45,8 @@ func MsgCenterRead(header *protocol.RequestHeader, request *protocol.MsgCenterRe
//标记全部已读
func MsgCenterAllRead(header *protocol.RequestHeader, request *protocol.MsgCenterAllReadRequest) (rsp *protocol.MsgCenterAllReadResponse, err error) {
var ()
err = models.UpdateUserMsgSetRead(header.Uid, header.CompanyId, request.MsgType, 0)
rsp = &protocol.MsgCenterAllReadResponse{}
err = models.UpdateUserMsgSetRead(header.UserId, header.CompanyId, request.MsgType, 0)
if err != nil {
log.Error(err)
}
... ... @@ -48,7 +59,7 @@ func MsgInteractive(header *protocol.RequestHeader, request *protocol.MsgInterac
userMsgs []*models.UserMsg
)
rsp = &protocol.MsgInteractiveResponse{}
userMsgs, rsp.Total, err = models.GetUserMsgs(header.Uid, header.CompanyId, request.MsgType, request.SourceType, request.LastId, request.PageSize)
userMsgs, rsp.Total, err = models.GetUserMsgs(header.UserId, header.CompanyId, request.MsgType, request.SourceType, request.LastId, request.PageSize)
if err != nil {
log.Error(err)
return
... ... @@ -60,7 +71,7 @@ func MsgInteractive(header *protocol.RequestHeader, request *protocol.MsgInterac
for i := range userMsgs {
msg := userMsgs[i]
userMsg := &protocol.UserMsg{
Id: msg.Id,
BulletinId: msg.Id,
Content: msg.Message,
CreateAt: msg.CreateAt.Unix(),
IsRead: int(msg.IsRead),
... ... @@ -155,6 +166,7 @@ func AnnouncementRead(header *protocol.RequestHeader, request *protocol.Announce
//消息中心-公司公告
func MsgCompanyNotice(header *protocol.RequestHeader, request *protocol.MsgCompanyNoticeRequest) (rsp *protocol.MsgCompanyNoticeResponse, err error) {
type MsgBulletin struct {
MsgId int64 `orm:"column(msg_id)"`
Id int `orm:"column(id)"`
Title string `orm:"column(title)"`
UpdateTime int64 `orm:"column(update_at)"`
... ... @@ -173,11 +185,13 @@ func MsgCompanyNotice(header *protocol.RequestHeader, request *protocol.MsgCompa
for i := range msgBulletins {
tmp := msgBulletins[i]
rsp.Lists = append(rsp.Lists, protocol.UserMsg{
Id: int64(tmp.Id),
MsgId: tmp.MsgId,
BulletinId: int64(tmp.Id),
SourceType: models.MsgTypeBulletin,
Content: tmp.Title,
CreateAt: tmp.UpdateTime,
IsRead: int(tmp.IsRead),
Link: fmt.Sprintf("%v/#/ability/announcement?id=%v&uid=%v&oppo=", beego.AppConfig.String("h5_host"), tmp.Id, header.UserId),
})
}
return
... ... @@ -241,6 +255,192 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc
return
}
// 消息中心-我提交的
func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChanceSubmitRequest) (rsp *protocol.MsgChanceSubmitResponse, err error) {
var (
myChances []protocol.MsgChanceApproveItemOrm
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeAuditBy, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MsgChanceSubmitResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
commItem.ReviewStatus = chance.ReviewStatus
if len(chance.SourceContent) == 0 { //机会删除
commItem.ChanceStatus = protocol.ChanceStatusDelete
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
continue
} else {
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = agg.ClearEmptyForm(item.FormList)
utils.JsonUnmarshal(chance.Images, &item.Pictures)
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
utils.JsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
if chance.ReviewStatus == protocol.ReviewStatusPass {
var approveData *protocol.ApproveData
utils.JsonUnmarshal(chance.ApproveData, &approveData)
if approveData != nil {
commItem.Score = approveData.Score
}
}
//审核完有审核数据
commItem.Message = chance.Message
rsp.List = append(rsp.List, commItem)
}
return
}
// 消息中心-互动消息.评论
func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanceCommentRequest) (rsp *protocol.MsgChanceCommentResponse, err error) {
var (
myChances []protocol.ChanceCommentItemOrm
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceCommentMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeComment, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MsgChanceCommentResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
if chance.SourceType == protocol.SourceTypeChance {
commItem.ReviewStatus = chance.ReviewStatus
if len(chance.SourceContent) == 0 { //机会删除
commItem.ChanceStatus = protocol.ChanceStatusDelete
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
//return
} else {
item := protocol.ChanceItem{
Id: chance.SourceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = protocol.ClearEmptyForm(item.FormList)
utils.JsonUnmarshal(chance.Images, &item.Pictures)
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
utils.JsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
commItem.ReviewStatus = chance.ReviewStatus
}
if chance.SourceType == protocol.SourceTypeComment {
commItem.CommentedData = protocol.CommentData{
Id: chance.SourceId,
Content: chance.CommentedContent,
CommentTime: chance.CommentedTime.Unix() * 1000,
}
}
commItem.CommentData = protocol.CommentData{
Id: chance.CommentId,
CommentTime: chance.CommentTime.Unix() * 1000,
Content: chance.CommentContent,
}
commItem.SourceType = chance.SourceType
rsp.List = append(rsp.List, commItem)
}
return
}
//消息中心-互动消息.点赞
func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanceThumbUpRequest) (rsp *protocol.MsgChanceThumbUpResponse, err error) {
var (
myChances []protocol.ChanceCommentItemOrm
total int
provider *protocol.BaseUserInfo
)
if total, err = models.GetChanceCommentMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeThumbUp, &myChances); err != nil {
if err == orm.ErrNoRows {
err = nil
return
}
log.Error(err)
return
}
rsp = &protocol.MsgChanceThumbUpResponse{Total: total}
for i := 0; i < len(myChances); i++ {
chance := myChances[i]
commItem := protocol.CommonListItem{}
if chance.SourceType == protocol.SourceTypeChance {
commItem.ReviewStatus = chance.ReviewStatus
if len(chance.SourceContent) == 0 { //机会删除
commItem.ChanceStatus = protocol.ChanceStatusDelete
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
//return
} else {
item := protocol.ChanceItem{
Id: chance.SourceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
}
utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
item.FormList = protocol.ClearEmptyForm(item.FormList)
utils.JsonUnmarshal(chance.Images, &item.Pictures)
utils.JsonUnmarshal(chance.Voices, &item.Speechs)
utils.JsonUnmarshal(chance.Videos, &item.Videos)
commItem.Chance = item
}
}
commItem.ReviewStatus = chance.ReviewStatus
}
if chance.SourceType == protocol.SourceTypeComment {
commItem.CommentedData = protocol.CommentData{
Id: chance.SourceId,
Content: chance.CommentedContent,
CommentTime: chance.CommentedTime.Unix() * 1000,
}
}
commItem.ThumbUpData = protocol.ThumbUpData{
Id: chance.CommentId,
ThumbUpTime: chance.CommentTime.Unix() * 1000,
Content: chance.CommentContent,
}
commItem.SourceType = chance.SourceType
rsp.List = append(rsp.List, commItem)
}
return
}
//H5公告详情
func H5Announcement(header *protocol.RequestHeader, request *protocol.AnnouncementRequest) (rsp *protocol.AnnouncementResponse, err error) {
var (
... ... @@ -299,7 +499,10 @@ func H5Announcement(header *protocol.RequestHeader, request *protocol.Announceme
return
}
if userMsg.IsRead == 0 { //判断是否可以置为 已读
if bulletin.AllowClose == 2 && bulletin != nil && bulletin.Id != 0 {
//if bulletin.AllowClose == 2 && bulletin != nil && bulletin.Id != 0 {
// setRead = true
//}
if bulletin.AllowClose == 0 {
setRead = true
}
}
... ...
... ... @@ -373,6 +373,21 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis
for flag = 1; flag <= (protocol.MyAuditChanceReturn); flag = flag << 1 {
total = 0
switch flag {
case protocol.CollectStatic: //收藏
if total, err = models.GetChanceCollect(header.UserId, 0, 0, nil); err != nil {
log.Error(err)
}
break
case protocol.ZanStatic: //点赞
if total, err = models.GetChanceThumbUp(header.UserId, 0, 0, nil); err != nil {
log.Error(err)
}
break
case protocol.CommentStatic: //评论
if total, err = models.GetChanceComment(header.UserId, 0, 0, nil); err != nil {
log.Error(err)
}
break
case protocol.MyCommitChance:
if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil {
log.Error(err)
... ...