作者 yangfu

机会编码

... ... @@ -12,6 +12,7 @@ type AuditTemplate struct {
CompanyId int `orm:"column(company_id)" description:"公司id"`
ChanceTypeId int `orm:"column(chance_type_id)" description:"机会类型编号"`
Name string `orm:"column(name);size(20)" description:"子分类名称"`
Code string `orm:"column(code);size(50);null" description:"编码"`
Doc string `orm:"column(doc);size(255)" description:"说明"`
Icon string `orm:"column(icon);size(255)" description:"图标"`
NoticeType int8 `orm:"column(notice_type)" description:"通知方式"`
... ...
... ... @@ -33,6 +33,7 @@ type Chance struct {
ApproveData string `orm:"column(approve_data)" description:"审核数据 冗余"`
AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"`
ApproveTime time.Time `orm:"column(approve_time);type(timestamp)" description:"审批时间"`
Code string `orm:"column(code)" description:"机会编码 一级编码+二级编码"`
}
func (t *Chance) TableName() string {
... ... @@ -177,7 +178,7 @@ order by create_at desc
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
select id collect_id,source_id,create_at collect_time,chance_id 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
... ... @@ -208,7 +209,7 @@ and (mark_flag&1)>0
order by collect_time desc
limit ?`)
sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&1)>0`
sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&1)>0 and source_type=1`
if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil {
return
}
... ...
... ... @@ -20,6 +20,7 @@ type ChanceFavorite struct {
EnableStatus int `orm:"column(enable_status)" description:"1:有效 0:无效"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"删除时间"`
ChanceId int64 `orm:"column(chance_id)" description:"机会编号"`
}
func (t *ChanceFavorite) TableName() string {
... ...
... ... @@ -9,6 +9,7 @@ import (
type ChanceType struct {
Id int `orm:"column(id);auto" json:"id"`
Name string `orm:"column(name);size(50)" description:"机会类型名称" json:"name"`
Code string `orm:"column(code);size(50);null" description:"编码"`
Icon string `orm:"column(icon);size(500);null" description:"图标地址" json:"icon"`
CompanyId int `orm:"column(company_id)" description:"表company.id 公司编号" json:"-"`
SortNum int `orm:"column(sort_num);null" description:"序号 公司下的序号" json:"-"`
... ...
... ... @@ -20,6 +20,7 @@ type UserMsg struct {
IsPublic int8 `orm:"column(is_public)" description:"1:公开 0:不公开"`
IsRead int8 `orm:"column(is_read)" description:"1:已读 0:未读"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now" description:"创建时间"`
ChanceId int64 `orm:"column(chance_id)" description:"机会编号"`
}
const (
... ... @@ -180,11 +181,11 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag
func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) {
sql := `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,company_id,receive_user_id,message,source_id,is_read
select id,company_id,receive_user_id,message,source_id,is_read,chance_id,create_at msg_time
from user_msg where receive_user_id=? and source_type=1 and (?=0 or id<?) and msg_type=?
)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 a.create_at desc
order by a.msg_time desc
LIMIT ?`
sqlCount := `select count(0)
... ... @@ -205,12 +206,12 @@ func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interfa
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,is_read,create_at comment_time from user_msg
select id,message content,source_type,source_id,is_read,create_at comment_time,chance_id 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 a.create_at desc
order by a.comment_time desc
LIMIT ?`
sqlCount := `select count(0)
... ...
... ... @@ -73,6 +73,7 @@ type SympathyActionRequest struct {
SourceType int `json:"sourceType" valid:"Required"` //protocol.SourceType //1.机会 2.评论
Id int64 `json:"id" valid:"Required"` //机会编号 / 评论编号
SympathyType int `json:"sympathyType"` //1:标记 0:取消标记
ChanceId int64 `json:"chanceId"` //机会编号
}
type SympathyActionResponse struct {
}
... ... @@ -300,6 +301,9 @@ type ChanceCollectItemOrm struct {
CollectId int64 `orm:"column(collect_id)"` //收藏id
CollectTime time.Time `orm:"column(collect_time)"` //收藏时间
//chance_id
//ChanceId int64 `orm:"column(id)"`
}
//机会池收藏列表项
... ... @@ -328,7 +332,7 @@ type ChanceThumbUpItemOrm struct {
//我的评论
type ChanceCommentItemOrm struct {
//ChanceId int64 `orm:"column(id)"`
ChanceId int64 `orm:"column(chance_id)"`
Uid int64 `orm:"column(chance_user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
... ... @@ -524,6 +528,8 @@ type CommonListItem struct {
ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
ReviewStatus int `json:"reviewStatus"` //审核状态
ChanceId int64 `json:"chanceId"` //机会编号
}
type MsgCommonListItem struct {
... ... @@ -551,6 +557,7 @@ type MsgCommonListItem struct {
ReviewStatus int `json:"reviewStatus"` //审核状态
IsRead bool `json:"isRead"`
ChanceId int64 `json:"chanceId"` //机会编号
}
type ChanceItem struct {
Id int64 `json:"id"`
... ...
... ... @@ -273,7 +273,7 @@ type MsgChanceApproveItemOrm struct {
CreateTime time.Time `orm:"column(create_at)"`
Message string `orm:"column(message)"`
IsRead int64 `orm:"column(isRead)"`
ChanceId int64 `orm:"column(source_id)"` // 机会id
ChanceId int64 `orm:"column(chance_id)"` // 机会id
//EnableStatus int `orm:"column(enable_status)"`
}
... ...
... ... @@ -51,6 +51,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int
SourceType: protocol.SourceTypeChance,
IsPublic: 0,
CreateAt: time.Now(),
ChanceId: chanceId,
}
if _, err = models.AddUserMsg(userMsg); err != nil {
return
... ... @@ -110,11 +111,11 @@ func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId in
return
}
format = fmt.Sprintf(format, chanceType.Name)
return SendMsg(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType)
return SendMsg(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType, chanceId)
}
//发送消息
func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sourceType int, message string, msgType int) (err error) {
func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sourceType int, message string, msgType int, chanceId int64) (err error) {
var (
userMsg *models.UserMsg
)
... ... @@ -128,6 +129,7 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou
SourceType: sourceType,
IsPublic: 0,
CreateAt: time.Now(),
ChanceId: chanceId,
}
if _, err = models.AddUserMsg(userMsg); err != nil {
return
... ...
... ... @@ -77,13 +77,18 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
log.Error(err)
return
}
if request.SourceType == protocol.SourceTypeChance {
message = protocol.MessageZanChance
if chance, err = models.GetChanceById(request.Id); err != nil {
if chance, err = models.GetChanceById(request.ChanceId); err != nil {
log.Error(request.Id, "机会不存在", err)
err = protocol.NewErrWithMessage(5101)
return
}
if request.SourceType == protocol.SourceTypeChance {
message = protocol.MessageZanChance
//if chance, err = models.GetChanceById(request.Id); err != nil {
// log.Error(request.Id, "机会不存在", err)
// err = protocol.NewErrWithMessage(5101)
// return
//}
sourceId = chance.Id
userId = chance.UserId
chanceType = chance.ChanceTypeId
... ... @@ -141,6 +146,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
ChanceType: chanceType,
CreateAt: time.Now(),
EnableStatus: 1,
ChanceId: request.ChanceId,
}
if _, err = models.AddChanceFavorite(chanceFavoirte); err != nil {
log.Error(err)
... ... @@ -160,7 +166,9 @@ END:
agg.DeleteSendedMsg(sourceId, request.SourceType, userId, protocol.MsgTypeThumbUp)
} else {
//发送点赞消息
agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, request.SourceType, message, protocol.MsgTypeThumbUp)
if header.UserId != userId {
agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, request.SourceType, message, protocol.MsgTypeThumbUp, request.ChanceId)
}
}
if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) {
//
... ... @@ -337,6 +345,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
AuditLevel: 1,
ReviewStatus: protocol.ReviewStatusAuditging,
DepartmentId: request.RelatedDepartment,
Code: fmt.Sprintf("%v%v", chanceType.Code, template.Code),
}
if _, err = orm.Insert(chance); err != nil {
log.Error(err)
... ... @@ -1386,6 +1395,7 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect
Id: chance.CollectId,
CollectTime: chance.CollectTime.Unix() * 1000,
}
//commItem.ChanceId = chance.ChanceId
}
rsp.List = append(rsp.List, commItem)
}
... ...
... ... @@ -74,7 +74,7 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
return
}
}
if err = agg.SendMsg(recevierId, "", header.CompanyId, sourceId, request.SourceType, request.Content, protocol.MsgTypeComment); err != nil {
if err = agg.SendMsg(recevierId, "", header.CompanyId, sourceId, request.SourceType, request.Content, protocol.MsgTypeComment, request.Id); err != nil {
log.Error(err)
orm.Rollback()
return
... ...
... ... @@ -286,6 +286,7 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc
//审核完有审核数据
commItem.Message = chance.Message
commItem.IsRead = chance.IsRead == 1
commItem.ChanceId = chance.ChanceId
rsp.List = append(rsp.List, commItem)
}
return
... ... @@ -346,6 +347,7 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance
//审核完有审核数据
commItem.Message = chance.Message
commItem.MsgId = chance.Id
commItem.ChanceId = chance.ChanceId
rsp.List = append(rsp.List, commItem)
}
return
... ... @@ -418,6 +420,7 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc
commItem.IsRead = chance.IsRead == 1
commItem.SourceType = chance.SourceType
commItem.MsgId = chance.CommentId
commItem.ChanceId = chance.ChanceId
rsp.List = append(rsp.List, commItem)
}
return
... ... @@ -490,6 +493,7 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc
commItem.IsRead = chance.IsRead == 1
commItem.SourceType = chance.SourceType
commItem.MsgId = chance.CommentId
commItem.ChanceId = chance.ChanceId
rsp.List = append(rsp.List, commItem)
}
return
... ...
... ... @@ -379,7 +379,7 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis
}
break
case protocol.ZanStatic: //点赞
if total, err = models.GetChanceThumbup(header.UserId, 0, 0, nil); err != nil {
if total, err = models.GetChanceThumbUp(header.UserId, 0, 0, nil); err != nil {
log.Error(err)
}
break
... ...