作者 yangfu

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

  1 +package models
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "github.com/astaxie/beego/orm"
  8 +)
  9 +
  10 +type AuditFlowLog struct {
  11 + Id int `orm:"column(id);auto" description:"唯一编号"`
  12 + ChanceId int64 `orm:"column(chance_id)" description:"表chance.id 所属机会编号"`
  13 + Content string `orm:"column(content);size(500)" description:"内容 json"`
  14 + ApproveUserId int64 `orm:"column(approve_user_id)" description:"审核人用户编号"`
  15 + CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now" description:"创建时间"`
  16 + Code int `orm:"column(code)" description:"消息编码"`
  17 +}
  18 +
  19 +func (t *AuditFlowLog) TableName() string {
  20 + return "audit_flow_log"
  21 +}
  22 +
  23 +func init() {
  24 + orm.RegisterModel(new(AuditFlowLog))
  25 +}
  26 +
  27 +// AddAuditFlowLog insert a new AuditFlowLog into database and returns
  28 +// last inserted Id on success.
  29 +func AddAuditFlowLog(m *AuditFlowLog) (id int64, err error) {
  30 + o := orm.NewOrm()
  31 + id, err = o.Insert(m)
  32 + return
  33 +}
  34 +
  35 +// GetAuditFlowLogById retrieves AuditFlowLog by Id. Returns error if
  36 +// Id doesn't exist
  37 +func GetAuditFlowLogById(id int) (v *AuditFlowLog, err error) {
  38 + o := orm.NewOrm()
  39 + v = &AuditFlowLog{Id: id}
  40 + if err = o.Read(v); err == nil {
  41 + return v, nil
  42 + }
  43 + return nil, err
  44 +}
  45 +
  46 +// UpdateAuditFlowLog updates AuditFlowLog by Id and returns error if
  47 +// the record to be updated doesn't exist
  48 +func UpdateAuditFlowLogById(m *AuditFlowLog) (err error) {
  49 + o := orm.NewOrm()
  50 + v := AuditFlowLog{Id: m.Id}
  51 + // ascertain id exists in the database
  52 + if err = o.Read(&v); err == nil {
  53 + var num int64
  54 + if num, err = o.Update(m); err == nil {
  55 + fmt.Println("Number of records updated in database:", num)
  56 + }
  57 + }
  58 + return
  59 +}
  60 +
  61 +// DeleteAuditFlowLog deletes AuditFlowLog by Id and returns error if
  62 +// the record to be deleted doesn't exist
  63 +func DeleteAuditFlowLog(id int) (err error) {
  64 + o := orm.NewOrm()
  65 + v := AuditFlowLog{Id: id}
  66 + // ascertain id exists in the database
  67 + if err = o.Read(&v); err == nil {
  68 + var num int64
  69 + if num, err = o.Delete(&AuditFlowLog{Id: id}); err == nil {
  70 + fmt.Println("Number of records deleted in database:", num)
  71 + }
  72 + }
  73 + return
  74 +}
@@ -131,10 +131,9 @@ func GetAuditFlowProcessList(chanceId int64) (v []*AuditFlowProcess, err error) @@ -131,10 +131,9 @@ func GetAuditFlowProcessList(chanceId int64) (v []*AuditFlowProcess, err error)
131 } 131 }
132 132
133 //删除机会时关闭所有审核信息 133 //删除机会时关闭所有审核信息
134 -func CloseAuditFlowProcess(chanceId int64) (err error) {  
135 - o := orm.NewOrm() 134 +func CloseAuditFlowProcess(orm orm.Ormer, chanceId int64) (err error) {
136 sql := "update audit_flow_process set enable_status =0,is_active=0,update_at=now() where chance_id=?" 135 sql := "update audit_flow_process set enable_status =0,is_active=0,update_at=now() where chance_id=?"
137 - if err = utils.ExecuteSQLWithOrmer(o, sql, chanceId); err != nil { 136 + if err = utils.ExecuteSQLWithOrmer(orm, sql, chanceId); err != nil {
138 return 137 return
139 } 138 }
140 return 139 return
@@ -154,7 +153,7 @@ func GetAuditFlowProcessApproved(chanceId int64, level int) (v *[]AuditFlowProce @@ -154,7 +153,7 @@ func GetAuditFlowProcessApproved(chanceId int64, level int) (v *[]AuditFlowProce
154 func GetAuditFlowProcessByReview(chanceId int64, level int, reviewStatus int) (v *AuditFlowProcess, err error) { 153 func GetAuditFlowProcessByReview(chanceId int64, level int, reviewStatus int) (v *AuditFlowProcess, err error) {
155 o := orm.NewOrm() 154 o := orm.NewOrm()
156 sql := "select * from audit_flow_process where chance_id=? and level=? and is_active=1 and review_status=? and enable_status=1" 155 sql := "select * from audit_flow_process where chance_id=? and level=? and is_active=1 and review_status=? and enable_status=1"
157 - if err = o.Raw(sql, chanceId, level, reviewStatus).QueryRow(&v); err != nil { 156 + if err = utils.ExecuteQueryOneWithOrmer(o, &v, sql, chanceId, level, reviewStatus); err != nil {
158 return 157 return
159 } 158 }
160 return 159 return
@@ -12,6 +12,7 @@ type AuditTemplate struct { @@ -12,6 +12,7 @@ type AuditTemplate struct {
12 CompanyId int `orm:"column(company_id)" description:"公司id"` 12 CompanyId int `orm:"column(company_id)" description:"公司id"`
13 ChanceTypeId int `orm:"column(chance_type_id)" description:"机会类型编号"` 13 ChanceTypeId int `orm:"column(chance_type_id)" description:"机会类型编号"`
14 Name string `orm:"column(name);size(20)" description:"子分类名称"` 14 Name string `orm:"column(name);size(20)" description:"子分类名称"`
  15 + Code string `orm:"column(code);size(50);null" description:"编码"`
15 Doc string `orm:"column(doc);size(255)" description:"说明"` 16 Doc string `orm:"column(doc);size(255)" description:"说明"`
16 Icon string `orm:"column(icon);size(255)" description:"图标"` 17 Icon string `orm:"column(icon);size(255)" description:"图标"`
17 NoticeType int8 `orm:"column(notice_type)" description:"通知方式"` 18 NoticeType int8 `orm:"column(notice_type)" description:"通知方式"`
@@ -32,6 +32,8 @@ type Chance struct { @@ -32,6 +32,8 @@ type Chance struct {
32 PublishStatus int `orm:"column(publish_status)" description:"公开状态 0未公开、1部门公开、2公司公开"` 32 PublishStatus int `orm:"column(publish_status)" description:"公开状态 0未公开、1部门公开、2公司公开"`
33 ApproveData string `orm:"column(approve_data)" description:"审核数据 冗余"` 33 ApproveData string `orm:"column(approve_data)" description:"审核数据 冗余"`
34 AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"` 34 AuditLevel int `orm:"column(audit_level)" description:"当前审批步骤"`
  35 + ApproveTime time.Time `orm:"column(approve_time);type(timestamp)" description:"审批时间"`
  36 + Code string `orm:"column(code)" description:"机会编码 一级编码+二级编码"`
35 } 37 }
36 38
37 func (t *Chance) TableName() string { 39 func (t *Chance) TableName() string {
@@ -103,7 +105,7 @@ func DeleteChance(id int64) (err error) { @@ -103,7 +105,7 @@ func DeleteChance(id int64) (err error) {
103 func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { 105 func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
104 sql := `select a.*,b.images,speechs,videos 106 sql := `select a.*,b.images,speechs,videos
105 from ( 107 from (
106 -select id,user_id,create_at,source_content,approve_data,review_status from chance 108 +select id,user_id,create_at,update_at,approve_time chance_approve_time,source_content,approve_data,review_status from chance
107 where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) 109 where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?)
108 order by create_at desc 110 order by create_at desc
109 limit ? 111 limit ?
@@ -112,7 +114,6 @@ limit ? @@ -112,7 +114,6 @@ limit ?
112 sqlCount := fmt.Sprintf(`select count(0) from ( 114 sqlCount := fmt.Sprintf(`select count(0) from (
113 select id,user_id,create_at,source_content from chance 115 select id,user_id,create_at,source_content from chance
114 where user_id=? and company_id=? and review_status in (%v) 116 where user_id=? and company_id=? and review_status in (%v)
115 -order by create_at desc  
116 ) a left JOIN chance_data b on a.id =b.chance_id`, utils.JoinInt8s(reviewStatus, ",")) 117 ) a left JOIN chance_data b on a.id =b.chance_id`, utils.JoinInt8s(reviewStatus, ","))
117 if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil { 118 if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil {
118 return 119 return
@@ -127,7 +128,7 @@ order by create_at desc @@ -127,7 +128,7 @@ order by create_at desc
127 128
128 func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { 129 func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
129 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( 130 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
130 -select a.*,b.user_id,b.source_content,b.enable_status,b.review_status from ( 131 +select a.*,b.user_id,b.source_content,b.enable_status,b.review_status,b.create_at,b.update_at,b.approve_time chance_approve_time from (
131 select id,approve_time,approve_data,uid,chance_id,approve_message,create_at process_create_time 132 select id,approve_time,approve_data,uid,chance_id,approve_message,create_at process_create_time
132 from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) and (?=0 or id<?) 133 from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) and (?=0 or id<?)
133 )a left outer join chance b on a.chance_id = b.id 134 )a left outer join chance b on a.chance_id = b.id
@@ -177,7 +178,7 @@ order by create_at desc @@ -177,7 +178,7 @@ order by create_at desc
177 func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { 178 func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
178 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( 179 sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
179 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 ( 180 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 (
180 -select id collect_id,source_id,create_at collect_time from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1 181 +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
181 and source_type=1 182 and source_type=1
182 and (mark_flag&2)>0 183 and (mark_flag&2)>0
183 )a left outer join chance b on a.source_id = b.id 184 )a left outer join chance b on a.source_id = b.id
@@ -208,7 +209,7 @@ and (mark_flag&1)>0 @@ -208,7 +209,7 @@ and (mark_flag&1)>0
208 order by collect_time desc 209 order by collect_time desc
209 limit ?`) 210 limit ?`)
210 211
211 - sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&1)>0` 212 + sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&1)>0 and source_type=1`
212 if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil { 213 if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil {
213 return 214 return
214 } 215 }
@@ -220,6 +221,15 @@ limit ?`) @@ -220,6 +221,15 @@ limit ?`)
220 return 221 return
221 } 222 }
222 223
  224 +//我点赞的
  225 +func GetChanceThumbup(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
  226 + sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&1)>0 and source_type=1`
  227 + if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil {
  228 + return
  229 + }
  230 + return
  231 +}
  232 +
223 //我的评论 233 //我的评论
224 func GetChanceComment(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { 234 func GetChanceComment(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
225 sql := fmt.Sprintf(`select a.*,b.content commented_content,b.create_at commented_time,b.user_id commented_user_id 235 sql := fmt.Sprintf(`select a.*,b.content commented_content,b.create_at commented_time,b.user_id commented_user_id
@@ -20,6 +20,7 @@ type ChanceFavorite struct { @@ -20,6 +20,7 @@ type ChanceFavorite struct {
20 EnableStatus int `orm:"column(enable_status)" description:"1:有效 0:无效"` 20 EnableStatus int `orm:"column(enable_status)" description:"1:有效 0:无效"`
21 CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"` 21 CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
22 UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"删除时间"` 22 UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"删除时间"`
  23 + ChanceId int64 `orm:"column(chance_id)" description:"机会编号"`
23 } 24 }
24 25
25 func (t *ChanceFavorite) TableName() string { 26 func (t *ChanceFavorite) TableName() string {
@@ -9,6 +9,7 @@ import ( @@ -9,6 +9,7 @@ import (
9 type ChanceType struct { 9 type ChanceType struct {
10 Id int `orm:"column(id);auto" json:"id"` 10 Id int `orm:"column(id);auto" json:"id"`
11 Name string `orm:"column(name);size(50)" description:"机会类型名称" json:"name"` 11 Name string `orm:"column(name);size(50)" description:"机会类型名称" json:"name"`
  12 + Code string `orm:"column(code);size(50);null" description:"编码"`
12 Icon string `orm:"column(icon);size(500);null" description:"图标地址" json:"icon"` 13 Icon string `orm:"column(icon);size(500);null" description:"图标地址" json:"icon"`
13 CompanyId int `orm:"column(company_id)" description:"表company.id 公司编号" json:"-"` 14 CompanyId int `orm:"column(company_id)" description:"表company.id 公司编号" json:"-"`
14 SortNum int `orm:"column(sort_num);null" description:"序号 公司下的序号" json:"-"` 15 SortNum int `orm:"column(sort_num);null" description:"序号 公司下的序号" json:"-"`
@@ -92,7 +92,7 @@ func GetUserCompanyByUserId(uid int64, companyId int64) (v *UserCompany, err err @@ -92,7 +92,7 @@ func GetUserCompanyByUserId(uid int64, companyId int64) (v *UserCompany, err err
92 //获取公司信息 92 //获取公司信息
93 func GetUserCompanyBy(id int64, companyId int64) (v *UserCompany, err error) { 93 func GetUserCompanyBy(id int64, companyId int64) (v *UserCompany, err error) {
94 o := orm.NewOrm() 94 o := orm.NewOrm()
95 - sql := "select * from user_company where id=? and company_id=? and enable=1" // 95 + sql := "select * from user_company where id=? and company_id=? " //and enable=1
96 if err = o.Raw(sql, id, companyId).QueryRow(&v); err == nil { 96 if err = o.Raw(sql, id, companyId).QueryRow(&v); err == nil {
97 return v, nil 97 return v, nil
98 } 98 }
@@ -20,6 +20,7 @@ type UserMsg struct { @@ -20,6 +20,7 @@ type UserMsg struct {
20 IsPublic int8 `orm:"column(is_public)" description:"1:公开 0:不公开"` 20 IsPublic int8 `orm:"column(is_public)" description:"1:公开 0:不公开"`
21 IsRead int8 `orm:"column(is_read)" description:"1:已读 0:未读"` 21 IsRead int8 `orm:"column(is_read)" description:"1:已读 0:未读"`
22 CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now" description:"创建时间"` 22 CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now" description:"创建时间"`
  23 + ChanceId int64 `orm:"column(chance_id)" description:"机会编号"`
23 } 24 }
24 25
25 const ( 26 const (
@@ -105,9 +106,9 @@ func DeleteUserMsg(id int64) (err error) { @@ -105,9 +106,9 @@ func DeleteUserMsg(id int64) (err error) {
105 func GetUserMsgTotals(userId int64, companyId int64, msgType int, v interface{}) (err error) { 106 func GetUserMsgTotals(userId int64, companyId int64, msgType int, v interface{}) (err error) {
106 o := orm.NewOrm() 107 o := orm.NewOrm()
107 sql := `select COUNT(*) as total,msg_type from user_msg 108 sql := `select COUNT(*) as total,msg_type from user_msg
108 -where (msg_type & ?)>0 and receive_user_id = ? and is_public=1 and is_read=0 and company_id=? 109 +where (msg_type & ?)>0 and receive_user_id = ? and is_read=0 and company_id=?
109 GROUP BY msg_type` 110 GROUP BY msg_type`
110 - if _, err = o.Raw(sql, msgType, userId, companyId).QueryRows(v); err == nil { 111 + if err = utils.ExecuteQueryAllWithOrmer(o, v, sql, msgType, userId, companyId); err == nil {
111 return 112 return
112 } 113 }
113 return 114 return
@@ -180,11 +181,11 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag @@ -180,11 +181,11 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag
180 func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) { 181 func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) {
181 sql := `select a.*,b.images,b.speechs,b.videos from ( 182 sql := `select a.*,b.images,b.speechs,b.videos from (
182 select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from ( 183 select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from (
183 -select id,company_id,receive_user_id,message,source_id,is_read 184 +select id,company_id,receive_user_id,message,source_id,is_read,chance_id,create_at msg_time
184 from user_msg where receive_user_id=? and source_type=1 and (?=0 or id<?) and msg_type=? 185 from user_msg where receive_user_id=? and source_type=1 and (?=0 or id<?) and msg_type=?
185 )a left outer join chance b on a.source_id = b.id 186 )a left outer join chance b on a.source_id = b.id
186 )a left outer join chance_data b on a.source_id =b.chance_id 187 )a left outer join chance_data b on a.source_id =b.chance_id
187 -order by a.create_at desc 188 +order by a.msg_time desc
188 LIMIT ?` 189 LIMIT ?`
189 190
190 sqlCount := `select count(0) 191 sqlCount := `select count(0)
@@ -205,12 +206,12 @@ func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interfa @@ -205,12 +206,12 @@ func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interfa
205 sql := `select a.*,b.content commented_content,b.create_at commented_time,b.user_id commented_user_id from ( 206 sql := `select a.*,b.content commented_content,b.create_at commented_time,b.user_id commented_user_id from (
206 select a.*,b.images,b.speechs,b.videos from ( 207 select a.*,b.images,b.speechs,b.videos from (
207 select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status from ( 208 select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status from (
208 -select id,message content,source_type,source_id,create_at comment_time from user_msg 209 +select id,message content,source_type,source_id,is_read,create_at comment_time,chance_id from user_msg
209 where receive_user_id =? and (?=0 or id<?) and msg_type=? 210 where receive_user_id =? and (?=0 or id<?) and msg_type=?
210 )a left outer join chance b on a.source_id = b.id and source_type=1 211 )a left outer join chance b on a.source_id = b.id and source_type=1
211 )a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1 212 )a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1
212 )a left outer join comment b on a.source_id = b.id and a.source_type=2 213 )a left outer join comment b on a.source_id = b.id and a.source_type=2
213 -order by create_at desc 214 +order by a.comment_time desc
214 LIMIT ?` 215 LIMIT ?`
215 216
216 sqlCount := `select count(0) 217 sqlCount := `select count(0)
@@ -73,6 +73,7 @@ type SympathyActionRequest struct { @@ -73,6 +73,7 @@ type SympathyActionRequest struct {
73 SourceType int `json:"sourceType" valid:"Required"` //protocol.SourceType //1.机会 2.评论 73 SourceType int `json:"sourceType" valid:"Required"` //protocol.SourceType //1.机会 2.评论
74 Id int64 `json:"id" valid:"Required"` //机会编号 / 评论编号 74 Id int64 `json:"id" valid:"Required"` //机会编号 / 评论编号
75 SympathyType int `json:"sympathyType"` //1:标记 0:取消标记 75 SympathyType int `json:"sympathyType"` //1:标记 0:取消标记
  76 + ChanceId int64 `json:"chanceId"` //机会编号
76 } 77 }
77 type SympathyActionResponse struct { 78 type SympathyActionResponse struct {
78 } 79 }
@@ -132,7 +133,7 @@ type ChanceUpdateRequest struct { @@ -132,7 +133,7 @@ type ChanceUpdateRequest struct {
132 Speechs []Speech `json:"speechs"` 133 Speechs []Speech `json:"speechs"`
133 Pictures []Picture `json:"pictures"` 134 Pictures []Picture `json:"pictures"`
134 Videos []Video `json:"videos"` 135 Videos []Video `json:"videos"`
135 - RelatedDepartment int64 `json:"relatedDepartments" valid:"Required"` 136 + RelatedDepartment int64 `json:"relatedDepartments"`
136 137
137 IsPublish bool `json:"isPublish"` //是否重新发布 138 IsPublish bool `json:"isPublish"` //是否重新发布
138 } 139 }
@@ -184,6 +185,8 @@ type ChanceItemOrm struct { @@ -184,6 +185,8 @@ type ChanceItemOrm struct {
184 Id int64 `orm:"column(id)"` 185 Id int64 `orm:"column(id)"`
185 Uid int64 `orm:"column(user_id)"` 186 Uid int64 `orm:"column(user_id)"`
186 CreateTime time.Time `orm:"column(create_at)"` 187 CreateTime time.Time `orm:"column(create_at)"`
  188 + UpdateTime time.Time `orm:"column(update_at)"`
  189 + ApproveTime time.Time `orm:"column(chance_approve_time)"`
187 SourceContent string `orm:"column(source_content)"` 190 SourceContent string `orm:"column(source_content)"`
188 Images string `orm:"column(images)"` 191 Images string `orm:"column(images)"`
189 Voices string `orm:"column(speechs)"` 192 Voices string `orm:"column(speechs)"`
@@ -206,13 +209,16 @@ type MyApproveChanceResponse struct { @@ -206,13 +209,16 @@ type MyApproveChanceResponse struct {
206 209
207 //我的审核机会列表 210 //我的审核机会列表
208 type ChanceApproveItemOrm struct { 211 type ChanceApproveItemOrm struct {
209 - ChanceUserId int64 `orm:"column(user_id)"`  
210 - SourceContent string `orm:"column(source_content)"`  
211 - ChanceEnableStatus int `orm:"column(enable_status)"`  
212 - Images string `orm:"column(images)"`  
213 - Voices string `orm:"column(speechs)"`  
214 - Videos string `orm:"column(videos)"`  
215 - ReviewStatus int `orm:"column(review_status)"` 212 + ChanceUserId int64 `orm:"column(user_id)"`
  213 + CreateTime time.Time `orm:"column(create_at)"`
  214 + UpdateTime time.Time `orm:"column(update_at)"`
  215 + ChanceApproveTime time.Time `orm:"column(chance_approve_time)"`
  216 + SourceContent string `orm:"column(source_content)"`
  217 + ChanceEnableStatus int `orm:"column(enable_status)"`
  218 + Images string `orm:"column(images)"`
  219 + Voices string `orm:"column(speechs)"`
  220 + Videos string `orm:"column(videos)"`
  221 + ReviewStatus int `orm:"column(review_status)"`
216 222
217 Id int64 `orm:"column(id)"` //审核id 223 Id int64 `orm:"column(id)"` //审核id
218 ApproveTime time.Time `orm:"column(approve_time)"` 224 ApproveTime time.Time `orm:"column(approve_time)"`
@@ -295,6 +301,9 @@ type ChanceCollectItemOrm struct { @@ -295,6 +301,9 @@ type ChanceCollectItemOrm struct {
295 301
296 CollectId int64 `orm:"column(collect_id)"` //收藏id 302 CollectId int64 `orm:"column(collect_id)"` //收藏id
297 CollectTime time.Time `orm:"column(collect_time)"` //收藏时间 303 CollectTime time.Time `orm:"column(collect_time)"` //收藏时间
  304 +
  305 + //chance_id
  306 + //ChanceId int64 `orm:"column(id)"`
298 } 307 }
299 308
300 //机会池收藏列表项 309 //机会池收藏列表项
@@ -323,7 +332,7 @@ type ChanceThumbUpItemOrm struct { @@ -323,7 +332,7 @@ type ChanceThumbUpItemOrm struct {
323 332
324 //我的评论 333 //我的评论
325 type ChanceCommentItemOrm struct { 334 type ChanceCommentItemOrm struct {
326 - //ChanceId int64 `orm:"column(id)"` 335 + ChanceId int64 `orm:"column(chance_id)"`
327 Uid int64 `orm:"column(chance_user_id)"` 336 Uid int64 `orm:"column(chance_user_id)"`
328 CreateTime time.Time `orm:"column(create_at)"` 337 CreateTime time.Time `orm:"column(create_at)"`
329 SourceContent string `orm:"column(source_content)"` 338 SourceContent string `orm:"column(source_content)"`
@@ -349,6 +358,7 @@ type ChanceCommentItemOrm struct { @@ -349,6 +358,7 @@ type ChanceCommentItemOrm struct {
349 //评论对象类型 358 //评论对象类型
350 SourceType int `orm:"column(source_type)"` 359 SourceType int `orm:"column(source_type)"`
351 SourceId int64 `orm:"column(source_id)"` 360 SourceId int64 `orm:"column(source_id)"`
  361 + IsRead int64 `orm:"column(is_read)"`
352 } 362 }
353 363
354 /*ChanceDetail 机会详情*/ 364 /*ChanceDetail 机会详情*/
@@ -518,15 +528,48 @@ type CommonListItem struct { @@ -518,15 +528,48 @@ type CommonListItem struct {
518 528
519 ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭 529 ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
520 ReviewStatus int `json:"reviewStatus"` //审核状态 530 ReviewStatus int `json:"reviewStatus"` //审核状态
  531 +
  532 + ChanceId int64 `json:"chanceId"` //机会编号
  533 +}
  534 +
  535 +type MsgCommonListItem struct {
  536 + MsgId int64 `json:"msgId"` //消息id
  537 + Chance ChanceItem `json:"chance,omitempty"` //机会详情
  538 + //ChanceData interface{} `json:"statisticData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
  539 + //Approve interface{} `json:"approve,omitempty"` //审核人 审核信息(时间) Approve
  540 + //ApproveData interface{} `json:"approveData,omitempty"` //审核数据(公开状态 评分) ApproveData
  541 + Message interface{} `json:"message,omitempty"` //消息
  542 + CommentData interface{} `json:"commentData,omitempty"` //评论
  543 + CollectData interface{} `json:"collectData,omitempty"` //收藏数据
  544 + ThumbUpData interface{} `json:"thumbUpData,omitempty"` //点赞数据
  545 + //我审核的-通过
  546 + Score interface{} `json:"score,omitempty"`
  547 +
  548 + //模板
  549 + //ChanceType interface{} `json:"chanceType,omitempty"` //机会类型
  550 + //ChanceTemplate interface{} `json:"template,omitempty"` //机会模板
  551 +
  552 + //我评论的 评论数据
  553 + CommentedData interface{} `json:"commentedData,omitempty"`
  554 +
  555 + SourceType int `json:"sourceType,omitempty"` //类型 1:机会 2:评论
  556 + ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
  557 + ReviewStatus int `json:"reviewStatus"` //审核状态
  558 +
  559 + IsRead bool `json:"isRead"`
  560 + ChanceId int64 `json:"chanceId"` //机会编号
521 } 561 }
522 type ChanceItem struct { 562 type ChanceItem struct {
523 - Id int64 `json:"id"`  
524 - CreateTime int64 `json:"createTime"`  
525 - Provider *BaseUserInfo `json:"provider"`  
526 - FormList []*Form `json:"formList" valid:"Required"`  
527 - Speechs []Speech `json:"speechs"`  
528 - Pictures []Picture `json:"pictures"`  
529 - Videos []Video `json:"videos"` 563 + Id int64 `json:"id"`
  564 + CreateTime int64 `json:"createTime"`
  565 + CreateTimeCopy int64 `json:"createTimeCopy"`
  566 + UpdateTime int64 `json:"updateTime"`
  567 + ApproveTime int64 `json:"approveTime"`
  568 + Provider *BaseUserInfo `json:"provider"`
  569 + FormList []*Form `json:"formList" valid:"Required"`
  570 + Speechs []Speech `json:"speechs"`
  571 + Pictures []Picture `json:"pictures"`
  572 + Videos []Video `json:"videos"`
530 } 573 }
531 type ChanceData struct { 574 type ChanceData struct {
532 ThumbsUpTotal int `json:"thumbsupTotal"` //点赞总数 575 ThumbsUpTotal int `json:"thumbsupTotal"` //点赞总数
@@ -548,6 +591,7 @@ type ThumbUpData struct { @@ -548,6 +591,7 @@ type ThumbUpData struct {
548 Id int64 `json:"id"` 591 Id int64 `json:"id"`
549 Content string `json:"content"` //点赞内容 592 Content string `json:"content"` //点赞内容
550 ThumbUpTime int64 `json:"thumbUpTime"` //收藏时间 593 ThumbUpTime int64 `json:"thumbUpTime"` //收藏时间
  594 + //IsRead bool `json:"is_read"` //是否已读
551 } 595 }
552 596
553 //评论内容 597 //评论内容
@@ -555,4 +599,6 @@ type CommentData struct { @@ -555,4 +599,6 @@ type CommentData struct {
555 Id int64 `json:"id"` //评论编号 599 Id int64 `json:"id"` //评论编号
556 Content string `json:"content"` //评论内容 600 Content string `json:"content"` //评论内容
557 CommentTime int64 `json:"commentTime"` //评论时间 601 CommentTime int64 `json:"commentTime"` //评论时间
  602 + //IsRead bool `json:"isRead"` //是否已读
  603 + Provider interface{} `json:"provider,omitempty"`
558 } 604 }
@@ -65,10 +65,10 @@ type Comments struct { @@ -65,10 +65,10 @@ type Comments struct {
65 Content string `json:"content"` 65 Content string `json:"content"`
66 Provider *BaseUserInfo `json:"provider"` 66 Provider *BaseUserInfo `json:"provider"`
67 67
68 - ViewTotal int `json:"pageViewTotal"`  
69 - CommentTotal int `json:"commentTotal"`  
70 - ZanTotal int `json:"thumbsupTotal"`  
71 - IsZan int `json:"isThumbsUp"` //0:未点赞 1:点赞 68 + ViewTotal int `json:"pageViewTotal"`
  69 + CommentTotal int `json:"commentTotal"`
  70 + ZanTotal int `json:"thumbsupTotal"`
  71 + IsZan bool `json:"isThumbsUp"` //0:未点赞 1:点赞
72 } 72 }
73 73
74 type Thumbups struct { 74 type Thumbups struct {
@@ -43,6 +43,7 @@ var errmessge ErrorMap = map[int]string{ @@ -43,6 +43,7 @@ var errmessge ErrorMap = map[int]string{
43 5204: "评分或者公开状态不能为空", 43 5204: "评分或者公开状态不能为空",
44 5205: "机会未审核通过,不能修改评分或者公开状态", 44 5205: "机会未审核通过,不能修改评分或者公开状态",
45 5206: "未找到审批节点或者无权限", 45 5206: "未找到审批节点或者无权限",
  46 + 5207: "公司管理员未设置",
46 47
47 //模板相关 48 //模板相关
48 5301: "机会模板不存在", 49 5301: "机会模板不存在",
@@ -125,7 +126,7 @@ type UserMsg struct { @@ -125,7 +126,7 @@ type UserMsg struct {
125 MsgId int64 `json:"msgId"` 126 MsgId int64 `json:"msgId"`
126 BulletinId int64 `json:"-"` 127 BulletinId int64 `json:"-"`
127 SourceType int `json:"msgType"` 128 SourceType int `json:"msgType"`
128 - Content string `json:"content"` 129 + Content string `json:"title"`
129 CreateAt int64 `json:"msgTime"` 130 CreateAt int64 `json:"msgTime"`
130 IsRead int `json:"isRead"` 131 IsRead int `json:"isRead"`
131 //机会 //评论 132 //机会 //评论
@@ -222,8 +223,8 @@ type MsgChanceApproveRequest struct { @@ -222,8 +223,8 @@ type MsgChanceApproveRequest struct {
222 PageSize int `json:"pageSize" valid:"Required"` 223 PageSize int `json:"pageSize" valid:"Required"`
223 } 224 }
224 type MsgChanceApproveResponse struct { 225 type MsgChanceApproveResponse struct {
225 - List []CommonListItem `json:"list"`  
226 - Total int `json:"total"` 226 + List []MsgCommonListItem `json:"list"`
  227 + Total int `json:"total"`
227 } 228 }
228 229
229 /*MsgChanceSubmit 我提交的*/ 230 /*MsgChanceSubmit 我提交的*/
@@ -232,8 +233,8 @@ type MsgChanceSubmitRequest struct { @@ -232,8 +233,8 @@ type MsgChanceSubmitRequest struct {
232 PageSize int `json:"pageSize" valid:"Required"` 233 PageSize int `json:"pageSize" valid:"Required"`
233 } 234 }
234 type MsgChanceSubmitResponse struct { 235 type MsgChanceSubmitResponse struct {
235 - List []CommonListItem `json:"list"`  
236 - Total int `json:"total"` 236 + List []MsgCommonListItem `json:"list"`
  237 + Total int `json:"total"`
237 } 238 }
238 239
239 /*MsgChanceComment 消息中心-互动消息.评论*/ 240 /*MsgChanceComment 消息中心-互动消息.评论*/
@@ -242,8 +243,8 @@ type MsgChanceCommentRequest struct { @@ -242,8 +243,8 @@ type MsgChanceCommentRequest struct {
242 PageSize int `json:"pageSize" valid:"Required"` 243 PageSize int `json:"pageSize" valid:"Required"`
243 } 244 }
244 type MsgChanceCommentResponse struct { 245 type MsgChanceCommentResponse struct {
245 - List []CommonListItem `json:"list"`  
246 - Total int `json:"total"` 246 + List []MsgCommonListItem `json:"list"`
  247 + Total int `json:"total"`
247 } 248 }
248 249
249 /*MsgChanceThumbUp 息中心-互动消息.点赞*/ 250 /*MsgChanceThumbUp 息中心-互动消息.点赞*/
@@ -252,8 +253,8 @@ type MsgChanceThumbUpRequest struct { @@ -252,8 +253,8 @@ type MsgChanceThumbUpRequest struct {
252 PageSize int `json:"pageSize" valid:"Required"` 253 PageSize int `json:"pageSize" valid:"Required"`
253 } 254 }
254 type MsgChanceThumbUpResponse struct { 255 type MsgChanceThumbUpResponse struct {
255 - List []CommonListItem `json:"list"`  
256 - Total int `json:"total"` 256 + List []MsgCommonListItem `json:"list"`
  257 + Total int `json:"total"`
257 } 258 }
258 259
259 //我的审核机会列表 260 //我的审核机会列表
@@ -272,7 +273,7 @@ type MsgChanceApproveItemOrm struct { @@ -272,7 +273,7 @@ type MsgChanceApproveItemOrm struct {
272 CreateTime time.Time `orm:"column(create_at)"` 273 CreateTime time.Time `orm:"column(create_at)"`
273 Message string `orm:"column(message)"` 274 Message string `orm:"column(message)"`
274 IsRead int64 `orm:"column(isRead)"` 275 IsRead int64 `orm:"column(isRead)"`
275 - ChanceId int64 `orm:"column(source_id)"` // 机会id 276 + ChanceId int64 `orm:"column(chance_id)"` // 机会id
276 //EnableStatus int `orm:"column(enable_status)"` 277 //EnableStatus int `orm:"column(enable_status)"`
277 } 278 }
278 279
@@ -51,6 +51,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int @@ -51,6 +51,7 @@ func SendApproveMsg(receiverId int64, name string, companyId int64, chanceId int
51 SourceType: protocol.SourceTypeChance, 51 SourceType: protocol.SourceTypeChance,
52 IsPublic: 0, 52 IsPublic: 0,
53 CreateAt: time.Now(), 53 CreateAt: time.Now(),
  54 + ChanceId: chanceId,
54 } 55 }
55 if _, err = models.AddUserMsg(userMsg); err != nil { 56 if _, err = models.AddUserMsg(userMsg); err != nil {
56 return 57 return
@@ -110,11 +111,11 @@ func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId in @@ -110,11 +111,11 @@ func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId in
110 return 111 return
111 } 112 }
112 format = fmt.Sprintf(format, chanceType.Name) 113 format = fmt.Sprintf(format, chanceType.Name)
113 - return SendMsg(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType) 114 + return SendMsg(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType, chanceId)
114 } 115 }
115 116
116 //发送消息 117 //发送消息
117 -func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sourceType int, message string, msgType int) (err error) { 118 +func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sourceType int, message string, msgType int, chanceId int64) (err error) {
118 var ( 119 var (
119 userMsg *models.UserMsg 120 userMsg *models.UserMsg
120 ) 121 )
@@ -128,6 +129,7 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou @@ -128,6 +129,7 @@ func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sou
128 SourceType: sourceType, 129 SourceType: sourceType,
129 IsPublic: 0, 130 IsPublic: 0,
130 CreateAt: time.Now(), 131 CreateAt: time.Now(),
  132 + ChanceId: chanceId,
131 } 133 }
132 if _, err = models.AddUserMsg(userMsg); err != nil { 134 if _, err = models.AddUserMsg(userMsg); err != nil {
133 return 135 return
@@ -151,3 +153,27 @@ func logMsg(msg *models.UserMsg, name string) { @@ -151,3 +153,27 @@ func logMsg(msg *models.UserMsg, name string) {
151 log.Info(fmt.Sprintf("发送消息 消息类型:%v Receiver:%v(%v) Message:%v SourceId:%v SourceType:%v", 153 log.Info(fmt.Sprintf("发送消息 消息类型:%v Receiver:%v(%v) Message:%v SourceId:%v SourceType:%v",
152 msg.MsgType, msg.ReceiveUserId, name, msg.Message, msg.SourceId, msg.SourceType)) 154 msg.MsgType, msg.ReceiveUserId, name, msg.Message, msg.SourceId, msg.SourceType))
153 } 155 }
  156 +
  157 +//保查审核日志
  158 +func SaveApproveLog(orm orm.Ormer, code int, userId int64, chanceId int64, param ...interface{}) (err error) {
  159 + var (
  160 + message string
  161 + ok bool
  162 + )
  163 + if message, ok = protocol.ApproveLog[code]; !ok {
  164 + err = fmt.Errorf("approve log not exists code:%v", code)
  165 + return
  166 + }
  167 + message = fmt.Sprintf(message, param...)
  168 + if _, err = orm.Insert(&models.AuditFlowLog{
  169 + ChanceId: chanceId,
  170 + Content: message,
  171 + ApproveUserId: userId,
  172 + CreateAt: time.Now(),
  173 + Code: code,
  174 + }); err != nil {
  175 + log.Error(err)
  176 + }
  177 + log.Debug(fmt.Sprintf("保存审核日志: code:%v userId:%v chanceId:%v message:%v", code, userId, chanceId, message))
  178 + return
  179 +}
  1 +package agg
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "fmt"
  6 + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
  7 + "opp/internal/utils"
  8 +)
  9 +
  10 +//模块编号
  11 +const (
  12 + M_ENTERPRISE string = "ENTERPRISE" //企业基础设置
  13 + M_SYSTEM string = "SYSTEM" //系统设置
  14 + M_SYSTEM_OPPORTUNITY string = "SYSTEM_OPPORTUNITY" //机会管理
  15 + M_ENTERPRISE_PROFILE string = "ENTERPRISE_PROFILE" //企业信息维护
  16 + M_ENTERPRISE_ORGANIZATION string = "ENTERPRISE_ORGANIZATION" //组织架构设置
  17 + M_ENTERPRISE_EMPLOYEE_POST string = "ENTERPRISE_EMPLOYEE-POST" //员工职位设置
  18 + M_ENTERPRISE_EMPLOYEE_ROLE string = "ENTERPRISE_EMPLOYEE-ROLE" //员工角色/权限设置
  19 + M_ENTERPRISE_EMPLOYEE string = "ENTERPRISE_EMPLOYEE" //员工设置
  20 + M_SYSTEM_OPPORTUNITY_TEMPLATE string = "SYSTEM_OPPORTUNITY-TEMPLATE" //机会模板管理
  21 + M_SYSTEM_RATING string = "SYSTEM_RATING" //评分模式设置
  22 + M_SYSTEM_ANNOUNCEMENT string = "SYSTEM_ANNOUNCEMENT" //公告管理
  23 +)
  24 +
  25 +type CodeToObject func() PermissionOptionObject
  26 +
  27 +var CodePermissionObject = map[string]CodeToObject{
  28 + M_ENTERPRISE_ORGANIZATION: NewPermissionOptionBase, //公司组织架构设置
  29 + M_ENTERPRISE_EMPLOYEE_POST: NewPermissionOptionBase, //公司职务管理
  30 + M_ENTERPRISE_EMPLOYEE_ROLE: NewPermissionOptionBase, //员工角色/权限设置
  31 + M_ENTERPRISE_EMPLOYEE: NewPermissionOptionBase, //公司员工管理
  32 + M_ENTERPRISE: NewPermissionOptionBase, //企业基础设置(大节点)
  33 + M_SYSTEM: NewPermissionOptionBase, //系统设置(大节点)
  34 + M_ENTERPRISE_PROFILE: NewPermissionOptionBase, //企业信息维护
  35 + M_SYSTEM_OPPORTUNITY_TEMPLATE: NewPermissionOptionBase, //机会模板管理
  36 + M_SYSTEM_RATING: NewPermissionOptionBase, //评分模式
  37 + M_SYSTEM_OPPORTUNITY: NewOptionOpportunity, //机会管理
  38 + M_SYSTEM_ANNOUNCEMENT: NewPermissionOptionBase, //公告管理
  39 +}
  40 +
  41 +type PermissionOptionObject interface {
  42 + // StringUnmarshal(string) error
  43 + // ObjectMarshal() string
  44 + GetValidFunc(string) func(UserObject) bool
  45 + MergeObject(string) error
  46 +}
  47 +
  48 +type UserObject struct {
  49 + UserId int64 `json:"user_id"`
  50 + CompanyId int64 `json:"company_id"`
  51 + UserCompanyId int64 `json:"user_company_id"`
  52 +}
  53 +
  54 +//PermissionOptionBase 基本权限
  55 +type PermissionOptionBase struct {
  56 + Check int8 `json:"check"`
  57 +}
  58 +
  59 +var (
  60 + _ PermissionOptionObject = &PermissionOptionBase{}
  61 +)
  62 +
  63 +func NewPermissionOptionBase() PermissionOptionObject {
  64 + return &PermissionOptionBase{
  65 + Check: 1,
  66 + }
  67 +}
  68 +
  69 +func (p *PermissionOptionBase) ValidDefault(obj UserObject) bool {
  70 + if p.Check == 1 {
  71 + return true
  72 + }
  73 + return false
  74 +}
  75 +
  76 +//GetValidFunc PermissionOptionBase 接口实现
  77 +func (p *PermissionOptionBase) GetValidFunc(k string) func(UserObject) bool {
  78 + m := map[string]func(UserObject) bool{
  79 + "default": p.ValidDefault,
  80 + }
  81 + if _, ok := m[k]; ok {
  82 + return m[k]
  83 + }
  84 + return nil
  85 +}
  86 +
  87 +func (p *PermissionOptionBase) MergeObject(jsonString string) error {
  88 + var obj PermissionOptionBase
  89 + err := json.Unmarshal([]byte(jsonString), &obj)
  90 + if err != nil {
  91 + return err
  92 + }
  93 + if obj.Check > p.Check {
  94 + p.Check = obj.Check
  95 + }
  96 + return nil
  97 +}
  98 +
  99 +// //StringUnmarshal PermissionOptionBase 接口实现
  100 +// func (p *PermissionOptionBase) StringUnmarshal(s string) error {
  101 +// err := json.Unmarshal([]byte(s), p)
  102 +// return err
  103 +// }
  104 +
  105 +// //ObjectMarshal PermissionOptionBase 接口实现
  106 +// func (p *PermissionOptionBase) ObjectMarshal() string {
  107 +// bt, err := json.Marshal(p)
  108 +// if err != nil {
  109 +// return ""
  110 +// }
  111 +// return string(bt)
  112 +// }
  113 +
  114 +/*
  115 +机会管理模块
  116 +CheckOpp
  117 +CheckDeparment
  118 +OptionOpportunity
  119 +*/
  120 +
  121 +//CheckDeparment 特殊的查看条件设定中关于部门的设定
  122 +type CheckDeparment struct {
  123 + Id int64 `json:"id"`
  124 + Name string `json:"name,omitempty"`
  125 + Wait int `json:"wait"`
  126 + OpenAll int `json:"open_all"`
  127 + OpenDepart int `json:"open_depart"`
  128 +}
  129 +
  130 +//CheckOpp 特殊的查看条件设定
  131 +type CheckOpp struct {
  132 + Departments []CheckDeparment `json:"departments"`
  133 +}
  134 +
  135 +//OptionOpportunity 机会管理 高级权限设置
  136 +type OptionOpportunity struct {
  137 + Check int `json:"check"`
  138 + CheckMap map[int]int `json:"-"`
  139 + CheckOption CheckOpp `json:"check_option"`
  140 + EditSorce int `json:"edit_sorce"`
  141 + EditPublicStatus int `json:"edit_public_status"`
  142 + CloseChance int `json:"close_chance"`
  143 + EditChance int `json:"edit_chance"`
  144 +}
  145 +
  146 +/*
  147 +机会管理高级设置中的 check
  148 +1:禁止查看所有机会:禁止查看所有机会(除自己提交过的机会及可执行审核操作的机会)
  149 +2:仅查看自己部门和公开机会:查看对自己部门公开的机会+公司公开的机会
  150 +3:特定部门的机会:自由配置选定部门的待审核、公司公开、部门公开的机会+查看对自己部门公开的机会
  151 +4:查看所有机会:查看所有部门的待审核机会、公开机会及部门公开机会
  152 +*/
  153 +const (
  154 + OpportunityCheckLv1 int = 1
  155 + OpportunityCheckLv2 int = 2
  156 + OpportunityCheckLv3 int = 3
  157 + OpportunityCheckLv4 int = 4
  158 +)
  159 +
  160 +var (
  161 + _ PermissionOptionObject = &OptionOpportunity{}
  162 +)
  163 +
  164 +func NewOptionOpportunity() PermissionOptionObject {
  165 + return &OptionOpportunity{
  166 + Check: OpportunityCheckLv4,
  167 + CheckMap: make(map[int]int),
  168 + CheckOption: CheckOpp{
  169 + Departments: []CheckDeparment{},
  170 + },
  171 + }
  172 +}
  173 +
  174 +//GetValidFunc PermissionOptionBase 接口实现
  175 +func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool {
  176 + m := map[string]func(UserObject) bool{
  177 + "check": p.ValidCheck,
  178 + }
  179 + if _, ok := m[k]; ok {
  180 + return m[k]
  181 + }
  182 + return nil
  183 +}
  184 +
  185 +//MergeObject PermissionOptionBase 接口实现
  186 +func (p *OptionOpportunity) MergeObject(jsonString string) error {
  187 + var obj OptionOpportunity
  188 + err := json.Unmarshal([]byte(jsonString), &obj)
  189 + if err != nil {
  190 + return err
  191 + }
  192 + if p.CheckMap == nil {
  193 + p.CheckMap = make(map[int]int)
  194 + }
  195 + p.CheckMap[obj.Check] = 1
  196 + departMap := make(map[int64]*CheckDeparment)
  197 + for k := range p.CheckOption.Departments {
  198 + i := p.CheckOption.Departments[k].Id
  199 + departMap[i] = &p.CheckOption.Departments[k]
  200 + }
  201 + //列表合并
  202 + for k := range obj.CheckOption.Departments {
  203 + i := obj.CheckOption.Departments[k].Id
  204 + if _, ok := departMap[i]; ok {
  205 + if obj.CheckOption.Departments[k].OpenAll > departMap[i].OpenAll {
  206 + departMap[i].OpenAll = obj.CheckOption.Departments[k].OpenAll
  207 + }
  208 + if obj.CheckOption.Departments[k].OpenDepart > departMap[i].OpenDepart {
  209 + departMap[i].OpenDepart = obj.CheckOption.Departments[k].OpenDepart
  210 + }
  211 + if obj.CheckOption.Departments[k].Wait > departMap[i].Wait {
  212 + departMap[i].Wait = obj.CheckOption.Departments[k].Wait
  213 + }
  214 + } else {
  215 +
  216 + departMap[i] = &obj.CheckOption.Departments[k]
  217 +
  218 + }
  219 + }
  220 + p.CheckOption.Departments = make([]CheckDeparment, 0)
  221 + for k := range departMap {
  222 + p.CheckOption.Departments = append(p.CheckOption.Departments, *departMap[k])
  223 + }
  224 + if obj.CloseChance > p.CloseChance {
  225 + p.CloseChance = obj.CloseChance
  226 + }
  227 + if obj.EditPublicStatus > p.EditPublicStatus {
  228 + p.EditPublicStatus = obj.EditPublicStatus
  229 + }
  230 + if obj.EditSorce > p.EditSorce {
  231 + p.EditSorce = obj.EditSorce
  232 + }
  233 + if obj.EditChance > p.EditChance {
  234 + p.EditChance = obj.EditChance
  235 + }
  236 + return nil
  237 +}
  238 +
  239 +func (p *OptionOpportunity) ValidCheck(obj UserObject) bool {
  240 + if p.Check > 0 {
  241 + return true
  242 + }
  243 + return false
  244 +}
  245 +
  246 +func (p *OptionOpportunity) ValidEditSorce(obj UserObject) bool {
  247 + if p.EditSorce > 0 {
  248 + return true
  249 + }
  250 + return false
  251 +}
  252 +func (p *OptionOpportunity) ValidEditPublicStatus(obj UserObject) bool {
  253 + if p.EditPublicStatus > 0 {
  254 + return true
  255 + }
  256 + return false
  257 +}
  258 +
  259 +func GetUserPermission(userCompanyid int64) (map[string]PermissionOptionObject, error) {
  260 + type CodeOpptionData struct {
  261 + Code string `orm:"column(code)"`
  262 + Opption string `orm:"column(opption)"`
  263 + }
  264 + const datasql string = `SELECT a.code,a.opption
  265 + FROM role_menu AS a
  266 + JOIN user_role AS b ON a.role_id = b.role_id
  267 + JOIN role AS c ON a.role_id = c.id
  268 + WHERE b.user_company_id=? AND c.delete_at =0`
  269 + var (
  270 + data []CodeOpptionData
  271 + err error
  272 + objMap = make(map[string]PermissionOptionObject)
  273 + )
  274 + err = utils.ExecuteQueryAll(&data, datasql, userCompanyid)
  275 + if err != nil {
  276 + e := fmt.Errorf("EXCUTE SQL ERR:%s", err)
  277 + return nil, e
  278 + }
  279 + for _, v := range data {
  280 + if _, ok := objMap[v.Code]; ok {
  281 + err = objMap[v.Code].MergeObject(v.Opption)
  282 + if err != nil {
  283 + log.Warn(err.Error())
  284 + }
  285 + continue
  286 + }
  287 + if fn, ok := CodePermissionObject[v.Code]; ok {
  288 + obj := fn()
  289 + if err = json.Unmarshal([]byte(v.Opption), obj); err != nil {
  290 + log.Debug("解析权限配置option 失败%s", err)
  291 + }
  292 + objMap[v.Code] = obj
  293 + } else {
  294 + log.Error("未知code:%s", v.Code)
  295 + }
  296 +
  297 + }
  298 + return objMap, nil
  299 +}
@@ -15,6 +15,7 @@ import ( @@ -15,6 +15,7 @@ import (
15 "opp/models" 15 "opp/models"
16 "opp/protocol" 16 "opp/protocol"
17 "opp/services/agg" 17 "opp/services/agg"
  18 + "strings"
18 "time" 19 "time"
19 ) 20 )
20 21
@@ -320,6 +321,8 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro @@ -320,6 +321,8 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
320 { 321 {
321 mapProcess["ReviewStatus"] = int8(request.ReviewStatus) 322 mapProcess["ReviewStatus"] = int8(request.ReviewStatus)
322 mapProcess["ApproveTime"] = time.Now() 323 mapProcess["ApproveTime"] = time.Now()
  324 + mapProcess["IsActive"] = int8(0)
  325 + mapChance["ApproveTime"] = time.Now()
323 if request.ReviewStatus == protocol.ReviewStatusPass { 326 if request.ReviewStatus == protocol.ReviewStatusPass {
324 mapProcess["BasicScore"] = request.ApproveData.Score.BasicScore 327 mapProcess["BasicScore"] = request.ApproveData.Score.BasicScore
325 mapProcess["ExtraScore"] = request.ApproveData.Score.ExtraScore 328 mapProcess["ExtraScore"] = request.ApproveData.Score.ExtraScore
@@ -408,6 +411,11 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro @@ -408,6 +411,11 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro
408 } 411 }
409 } 412 }
410 } 413 }
  414 + if err = saveApproveMsgByApproveData(orm, request.ReviewStatus, chance, request.ApproveData); err != nil {
  415 + orm.Rollback()
  416 + log.Error("发送审核日志失败", err)
  417 + return
  418 + }
411 if err = utils.UpdateTableByMapWithOrmer(orm, process, mapProcess); err != nil { 419 if err = utils.UpdateTableByMapWithOrmer(orm, process, mapProcess); err != nil {
412 log.Error("更新机会审核流程 状态失败 process_id:", process.Id, err) 420 log.Error("更新机会审核流程 状态失败 process_id:", process.Id, err)
413 orm.Rollback() 421 orm.Rollback()
@@ -465,6 +473,40 @@ func ProcessIntegrate(header *protocol.RequestHeader, request *ProcessIntegrateR @@ -465,6 +473,40 @@ func ProcessIntegrate(header *protocol.RequestHeader, request *ProcessIntegrateR
465 return 473 return
466 } 474 }
467 475
  476 +//发送审核日志
  477 +func saveApproveMsgByApproveData(orm orm.Ormer, reviewStatus int, chance *models.Chance, approveData protocol.ApproveData) (err error) {
  478 + var (
  479 + parames = make([]interface{}, 0)
  480 + code = 0
  481 + )
  482 + if reviewStatus == protocol.ReviewStatusReturn {
  483 + //发送退回日志
  484 + code = 3
  485 + }
  486 + if reviewStatus == protocol.ReviewStatusPass {
  487 + //发送通过日志
  488 + score := approveData.Score
  489 + parames = append(parames, []interface{}{score.BasicScore, score.ExtraScore, score.ValueScore}...)
  490 + if approveData.PublicData.PublishStatus == protocol.PublicToCompany {
  491 + code = 4
  492 + }
  493 + if approveData.PublicData.PublishStatus == protocol.PublicToDepartment {
  494 + code = 5
  495 + var department []string
  496 + for i := range approveData.PublicData.VisibleObjects {
  497 + v := approveData.PublicData.VisibleObjects[i]
  498 + department = append(department, v.Name)
  499 + }
  500 + parames = append(parames, strings.Join(department, ","))
  501 + }
  502 + }
  503 + if err = agg.SaveApproveLog(orm, code, chance.UserId, chance.Id, parames...); err != nil {
  504 + log.Error(err)
  505 + return
  506 + }
  507 + return
  508 +}
  509 +
468 //系统审核状态转为审核类型 reviewStatus - > approveType 510 //系统审核状态转为审核类型 reviewStatus - > approveType
469 func ConverReviewStatus(reviewStatus int) (approveType int) { 511 func ConverReviewStatus(reviewStatus int) (approveType int) {
470 if reviewStatus == protocol.ReviewStatusPass { 512 if reviewStatus == protocol.ReviewStatusPass {
@@ -513,7 +555,7 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) @@ -513,7 +555,7 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance)
513 if item.ReviewStatus != protocol.ReviewStatusAuditging { 555 if item.ReviewStatus != protocol.ReviewStatusAuditging {
514 item.ApproveTime = process.ApproveTime.Unix() * 1000 556 item.ApproveTime = process.ApproveTime.Unix() * 1000
515 } 557 }
516 - switch item.ApproveWay { 558 + switch item.ApproveType {
517 case protocol.AuditByDepartmentor: 559 case protocol.AuditByDepartmentor:
518 break 560 break
519 case protocol.AuditByUser: 561 case protocol.AuditByUser:
@@ -12,6 +12,7 @@ import ( @@ -12,6 +12,7 @@ import (
12 "opp/models" 12 "opp/models"
13 "opp/protocol" 13 "opp/protocol"
14 "opp/services/agg" 14 "opp/services/agg"
  15 + "strings"
15 "time" 16 "time"
16 ) 17 )
17 18
@@ -76,13 +77,18 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -76,13 +77,18 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
76 log.Error(err) 77 log.Error(err)
77 return 78 return
78 } 79 }
  80 + if chance, err = models.GetChanceById(request.ChanceId); err != nil {
  81 + log.Error(request.Id, "机会不存在", err)
  82 + err = protocol.NewErrWithMessage(5101)
  83 + return
  84 + }
79 if request.SourceType == protocol.SourceTypeChance { 85 if request.SourceType == protocol.SourceTypeChance {
80 message = protocol.MessageZanChance 86 message = protocol.MessageZanChance
81 - if chance, err = models.GetChanceById(request.Id); err != nil {  
82 - log.Error(request.Id, "机会不存在", err)  
83 - err = protocol.NewErrWithMessage(5101)  
84 - return  
85 - } 87 + //if chance, err = models.GetChanceById(request.Id); err != nil {
  88 + // log.Error(request.Id, "机会不存在", err)
  89 + // err = protocol.NewErrWithMessage(5101)
  90 + // return
  91 + //}
86 sourceId = chance.Id 92 sourceId = chance.Id
87 userId = chance.UserId 93 userId = chance.UserId
88 chanceType = chance.ChanceTypeId 94 chanceType = chance.ChanceTypeId
@@ -140,6 +146,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -140,6 +146,7 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
140 ChanceType: chanceType, 146 ChanceType: chanceType,
141 CreateAt: time.Now(), 147 CreateAt: time.Now(),
142 EnableStatus: 1, 148 EnableStatus: 1,
  149 + ChanceId: request.ChanceId,
143 } 150 }
144 if _, err = models.AddChanceFavorite(chanceFavoirte); err != nil { 151 if _, err = models.AddChanceFavorite(chanceFavoirte); err != nil {
145 log.Error(err) 152 log.Error(err)
@@ -159,7 +166,9 @@ END: @@ -159,7 +166,9 @@ END:
159 agg.DeleteSendedMsg(sourceId, request.SourceType, userId, protocol.MsgTypeThumbUp) 166 agg.DeleteSendedMsg(sourceId, request.SourceType, userId, protocol.MsgTypeThumbUp)
160 } else { 167 } else {
161 //发送点赞消息 168 //发送点赞消息
162 - agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, 1, message, protocol.MsgTypeThumbUp) 169 + if header.UserId != userId {
  170 + agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, request.SourceType, message, protocol.MsgTypeThumbUp, request.ChanceId)
  171 + }
163 } 172 }
164 if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) { 173 if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) {
165 // 174 //
@@ -336,6 +345,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -336,6 +345,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
336 AuditLevel: 1, 345 AuditLevel: 1,
337 ReviewStatus: protocol.ReviewStatusAuditging, 346 ReviewStatus: protocol.ReviewStatusAuditging,
338 DepartmentId: request.RelatedDepartment, 347 DepartmentId: request.RelatedDepartment,
  348 + Code: fmt.Sprintf("%v%v", chanceType.Code, template.Code),
339 } 349 }
340 if _, err = orm.Insert(chance); err != nil { 350 if _, err = orm.Insert(chance); err != nil {
341 log.Error(err) 351 log.Error(err)
@@ -403,6 +413,12 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -403,6 +413,12 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
403 return 413 return
404 } 414 }
405 } 415 }
  416 + //发送提交日志
  417 + if err = agg.SaveApproveLog(orm, 1, header.UserId, chance.Id); err != nil {
  418 + log.Error(err)
  419 + orm.Rollback()
  420 + return
  421 + }
406 orm.Commit() 422 orm.Commit()
407 423
408 rsp = &protocol.ChanceSubmitResponse{} 424 rsp = &protocol.ChanceSubmitResponse{}
@@ -448,14 +464,19 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate @@ -448,14 +464,19 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
448 //} 464 //}
449 if _, e := models.GetAuditFlowProcessByReview(request.Id, 0, protocol.ReviewStatusWait); e == nil { 465 if _, e := models.GetAuditFlowProcessByReview(request.Id, 0, protocol.ReviewStatusWait); e == nil {
450 request.IsPublish = true 466 request.IsPublish = true
  467 + updateMap["DepartmentId"] = request.RelatedDepartment
  468 + //log.Info(fmt.Sprintf("机会编辑 is_publish:%v chance.review_status:%v 是否是本人:%v",request.IsPublish,chance.ReviewStatus,chance.UserId==header.UserId))
  469 + } else {
  470 + log.Info(fmt.Sprintf("机会编辑 chance_id:%v chance.review_status:%v 无待处理 审核数据", request.Id, chance.ReviewStatus))
451 } 471 }
452 } else { 472 } else {
453 request.IsPublish = false 473 request.IsPublish = false
  474 + log.Info(fmt.Sprintf("机会编辑 is_publish:%v chance.review_status:%v 是否是本人:%v", request.IsPublish, chance.ReviewStatus, chance.UserId == header.UserId))
454 } 475 }
455 //TODO:非本人 1.需要验证角色权限 2是否是审核人 3.是否是本人 (目前本人才可以审核) 476 //TODO:非本人 1.需要验证角色权限 2是否是审核人 3.是否是本人 (目前本人才可以审核)
456 - if chance.UserId != header.Uid { 477 + if chance.UserId != header.UserId {
457 err = protocol.NewErrWithMessage(5206) 478 err = protocol.NewErrWithMessage(5206)
458 - log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v", header.Uid, chance.Id)) 479 + log.Error(fmt.Sprintf("user:%v 无权限操作机会 chance:%v", header.UserId, chance.Id))
459 return 480 return
460 } 481 }
461 //1.模板是否存在 482 //1.模板是否存在
@@ -474,7 +495,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate @@ -474,7 +495,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
474 updateMap["AuditTemplateConfig"] = common.AssertJson(auditConfig) 495 updateMap["AuditTemplateConfig"] = common.AssertJson(auditConfig)
475 updateMap["Content"] = request.Content 496 updateMap["Content"] = request.Content
476 updateMap["SourceContent"] = common.AssertJson(request.FormList) 497 updateMap["SourceContent"] = common.AssertJson(request.FormList)
477 - updateMap["DepartmentId"] = request.RelatedDepartment  
478 498
479 if err = utils.UpdateTableByMapWithOrmer(orm, &models.Chance{Id: chance.Id}, updateMap); err != nil { 499 if err = utils.UpdateTableByMapWithOrmer(orm, &models.Chance{Id: chance.Id}, updateMap); err != nil {
480 log.Error(err) 500 log.Error(err)
@@ -560,6 +580,12 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate @@ -560,6 +580,12 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate
560 } 580 }
561 } 581 }
562 } 582 }
  583 + //发送提交日志
  584 + if err = agg.SaveApproveLog(orm, 1, chance.UserId, chance.Id); err != nil {
  585 + log.Error(err)
  586 + orm.Rollback()
  587 + return
  588 + }
563 } 589 }
564 } 590 }
565 orm.Commit() 591 orm.Commit()
@@ -620,12 +646,43 @@ func ChanceChangePublish(header *protocol.RequestHeader, request *protocol.Chanc @@ -620,12 +646,43 @@ func ChanceChangePublish(header *protocol.RequestHeader, request *protocol.Chanc
620 } 646 }
621 } 647 }
622 } 648 }
  649 +
  650 + if err = saveApproveMsgChangePublic(orm, chance, request.PublicData); err != nil {
  651 + log.Error(err)
  652 + orm.Rollback()
  653 + return
  654 + }
623 orm.Commit() 655 orm.Commit()
624 //TODO:添加log 656 //TODO:添加log
625 rsp = &protocol.ChanceChangePublishResponse{} 657 rsp = &protocol.ChanceChangePublishResponse{}
626 return 658 return
627 } 659 }
628 660
  661 +//发送审核日志
  662 +func saveApproveMsgChangePublic(orm orm.Ormer, chance *models.Chance, approveData protocol.PublicData) (err error) {
  663 + var (
  664 + parames = make([]interface{}, 0)
  665 + code = 0
  666 + )
  667 + if approveData.PublishStatus == protocol.PublicToCompany {
  668 + code = 7
  669 + }
  670 + if approveData.PublishStatus == protocol.PublicToDepartment {
  671 + code = 8
  672 + var department []string
  673 + for i := range approveData.VisibleObjects {
  674 + v := approveData.VisibleObjects[i]
  675 + department = append(department, v.Name)
  676 + }
  677 + parames = append(parames, strings.Join(department, ","))
  678 + }
  679 + if err = agg.SaveApproveLog(orm, code, chance.UserId, chance.Id, parames...); err != nil {
  680 + log.Error(err)
  681 + return
  682 + }
  683 + return
  684 +}
  685 +
629 //修改评分 686 //修改评分
630 func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceChangeScoreRequest) (rsp *protocol.ChanceChangeScoreResponse, err error) { 687 func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceChangeScoreRequest) (rsp *protocol.ChanceChangeScoreResponse, err error) {
631 var ( 688 var (
@@ -667,6 +724,17 @@ func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceC @@ -667,6 +724,17 @@ func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceC
667 orm.Rollback() 724 orm.Rollback()
668 return 725 return
669 } 726 }
  727 + //修改评分日志
  728 + if err = agg.SaveApproveLog(orm, 9, chance.UserId, chance.Id, request.Score.BasicScore, request.Score.ExtraScore, request.Score.ValueScore); err != nil {
  729 + log.Error(err)
  730 + return
  731 + }
  732 +
  733 + //if err = agg.SaveApproveLog(orm,9,chance.UserId,chance.Id,request.Score.BasicScore,request.Score.ExtraScore,request.Score.ValueScore);err!=nil{
  734 + // log.Error(err)
  735 + // return
  736 + //}
  737 +
670 orm.Commit() 738 orm.Commit()
671 rsp = &protocol.ChanceChangeScoreResponse{ 739 rsp = &protocol.ChanceChangeScoreResponse{
672 DiscoveryScore: result.DiscoveryScore, 740 DiscoveryScore: result.DiscoveryScore,
@@ -781,6 +849,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related @@ -781,6 +849,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related
781 approver *models.User 849 approver *models.User
782 roleIds []int 850 roleIds []int
783 roleId int 851 roleId int
  852 + admin *models.UserCompany
784 ) 853 )
785 if configs, err = models.GetAuditFlowConfigsLevel(templateId, 1); err != nil { 854 if configs, err = models.GetAuditFlowConfigsLevel(templateId, 1); err != nil {
786 if err == orm.ErrNoRows { 855 if err == orm.ErrNoRows {
@@ -842,8 +911,16 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related @@ -842,8 +911,16 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related
842 911
843 if company.AdminId == 0 { 912 if company.AdminId == 0 {
844 err = fmt.Errorf("GenAuditFlowProcess:company.admin is not set") 913 err = fmt.Errorf("GenAuditFlowProcess:company.admin is not set")
  914 + err = protocol.NewErrWithMessage(5207)
845 return 915 return
846 } 916 }
  917 +
  918 + if admin, err = models.GetUserCompanyByUserId(company.AdminId, header.CompanyId); err != nil {
  919 + err = fmt.Errorf("GenAuditFlowProcess:company.admin is not set")
  920 + err = protocol.NewErrWithMessage(5207)
  921 + return
  922 + }
  923 +
847 //3.生成审核列表 924 //3.生成审核列表
848 for i := range configs { 925 for i := range configs {
849 config := configs[i] 926 config := configs[i]
@@ -882,14 +959,14 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related @@ -882,14 +959,14 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, related
882 for j := 0; j < len(userIds); j++ { 959 for j := 0; j < len(userIds); j++ {
883 uid := userIds[j] 960 uid := userIds[j]
884 if uid == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //审批人为空 转交给管理员 961 if uid == 0 && auditConfig.NoApprover == protocol.NoApproverToAdmin { //审批人为空 转交给管理员
885 - uid = company.AdminId 962 + uid = admin.Id
886 } 963 }
887 if uid == 0 { 964 if uid == 0 {
888 - uid = company.AdminId 965 + uid = admin.Id
889 } 966 }
890 if uid == header.UserId { //审核人自己 转交给管理员 967 if uid == header.UserId { //审核人自己 转交给管理员
891 log.Info(fmt.Sprintf("生成机会审批流-转给管理员:chance_id:%v audit_level:%v audit_user:%v -> admin:%v", chanceId, config.Level, uid, company.AdminId)) 968 log.Info(fmt.Sprintf("生成机会审批流-转给管理员:chance_id:%v audit_level:%v audit_user:%v -> admin:%v", chanceId, config.Level, uid, company.AdminId))
892 - uid = company.AdminId 969 + uid = admin.Id
893 } 970 }
894 if approver, err = models.GetUserByUcid(uid); err != nil { 971 if approver, err = models.GetUserByUcid(uid); err != nil {
895 log.Error(uid, err) 972 log.Error(uid, err)
@@ -934,7 +1011,8 @@ func resolveActionType(t uint) string { @@ -934,7 +1011,8 @@ func resolveActionType(t uint) string {
934 //获取部门长用户列表 1011 //获取部门长用户列表
935 func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) (ids []int64, err error) { 1012 func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) (ids []int64, err error) {
936 var ( 1013 var (
937 - departments *models.Department 1014 + departments *models.Department
  1015 + lastDepartmentId int
938 ) 1016 )
939 //if err = models.GetUserDepartments(header.UserId, header.CompanyId, &departments); err != nil { 1017 //if err = models.GetUserDepartments(header.UserId, header.CompanyId, &departments); err != nil {
940 // log.Error(header.UserId,header.CompanyId,err) 1018 // log.Error(header.UserId,header.CompanyId,err)
@@ -944,19 +1022,37 @@ func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64) @@ -944,19 +1022,37 @@ func getDepartmentors(header *protocol.RequestHeader, relatedDeparmentId int64)
944 log.Error(relatedDeparmentId, err) 1022 log.Error(relatedDeparmentId, err)
945 return 1023 return
946 } 1024 }
947 - if len(departments.Managers) > 0 {  
948 - var tmpIds []int64  
949 - if err = json.Unmarshal([]byte(departments.Managers), &tmpIds); err == nil {  
950 - if len(tmpIds) > 0 {  
951 - ids = append(ids, tmpIds...) 1025 + //部门长
  1026 + for {
  1027 + if len(departments.Managers) > 0 {
  1028 + var tmpIds []int64
  1029 + if e := json.Unmarshal([]byte(departments.Managers), &tmpIds); e == nil {
  1030 + if len(tmpIds) > 0 {
  1031 + ids = append(ids, tmpIds...)
  1032 + }
  1033 + break
  1034 + } else {
  1035 + log.Error(e)
952 } 1036 }
  1037 + //break
  1038 + }
  1039 + if departments.ParentId != 0 {
  1040 + //relatedDeparmentId = int64departments.ParentId
  1041 + lastDepartmentId = departments.ParentId
  1042 + if departments, err = models.GetDepartmentById(int(departments.ParentId)); err != nil {
  1043 + log.Error(relatedDeparmentId, err)
  1044 + err = nil
  1045 + break
  1046 + }
  1047 + } else {
  1048 + break
953 } 1049 }
954 } 1050 }
955 //部门长不存在 1051 //部门长不存在
956 if len(ids) == 0 { 1052 if len(ids) == 0 {
957 ids = append(ids, 0) 1053 ids = append(ids, 0)
958 } 1054 }
959 - log.Info(fmt.Sprintf("生成机会审批流-部门:department_id:%v managers:%v ids:%v", relatedDeparmentId, departments.Managers, ids)) 1055 + log.Info(fmt.Sprintf("生成机会审批流-部门:department_id:%v managers:%v ids:%v last_department_id:%v", relatedDeparmentId, departments.Managers, ids, lastDepartmentId))
960 return 1056 return
961 } 1057 }
962 1058
@@ -1057,9 +1153,14 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh @@ -1057,9 +1153,14 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh
1057 commItem := protocol.CommonListItem{} 1153 commItem := protocol.CommonListItem{}
1058 { 1154 {
1059 item := protocol.ChanceItem{ 1155 item := protocol.ChanceItem{
1060 - Id: chance.Id,  
1061 - Provider: provider,  
1062 - CreateTime: chance.CreateTime.Unix() * 1000, 1156 + Id: chance.Id,
  1157 + Provider: provider,
  1158 + CreateTime: chance.CreateTime.Unix() * 1000,
  1159 + UpdateTime: chance.UpdateTime.Unix() * 1000,
  1160 + ApproveTime: chance.ApproveTime.Unix() * 1000,
  1161 + }
  1162 + if item.ApproveTime < 0 {
  1163 + item.ApproveTime = 0
1063 } 1164 }
1064 jsonUnmarshal(chance.SourceContent, &item.FormList) 1165 jsonUnmarshal(chance.SourceContent, &item.FormList)
1065 item.FormList = clearEmptyForm(item.FormList) 1166 item.FormList = clearEmptyForm(item.FormList)
@@ -1185,10 +1286,17 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove @@ -1185,10 +1286,17 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
1185 //return 1286 //return
1186 } else { 1287 } else {
1187 item := protocol.ChanceItem{ 1288 item := protocol.ChanceItem{
1188 - Id: chance.ChanceId,  
1189 - Provider: provider, 1289 + Id: chance.ChanceId,
  1290 + Provider: provider,
  1291 + CreateTime: chance.CreateTime.Unix() * 1000,
  1292 + UpdateTime: chance.UpdateTime.Unix() * 1000,
  1293 + ApproveTime: chance.ChanceApproveTime.Unix() * 1000,
  1294 + //CreateTime:chance.c
1190 //CreateTime: chance.CreateTime.Unix() * 1000, 1295 //CreateTime: chance.CreateTime.Unix() * 1000,
1191 } 1296 }
  1297 + if item.ApproveTime < 0 {
  1298 + item.ApproveTime = 0
  1299 + }
1192 jsonUnmarshal(chance.SourceContent, &item.FormList) 1300 jsonUnmarshal(chance.SourceContent, &item.FormList)
1193 item.FormList = clearEmptyForm(item.FormList) 1301 item.FormList = clearEmptyForm(item.FormList)
1194 jsonUnmarshal(chance.Images, &item.Pictures) 1302 jsonUnmarshal(chance.Images, &item.Pictures)
@@ -1287,6 +1395,7 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect @@ -1287,6 +1395,7 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect
1287 Id: chance.CollectId, 1395 Id: chance.CollectId,
1288 CollectTime: chance.CollectTime.Unix() * 1000, 1396 CollectTime: chance.CollectTime.Unix() * 1000,
1289 } 1397 }
  1398 + //commItem.ChanceId = chance.ChanceId
1290 } 1399 }
1291 rsp.List = append(rsp.List, commItem) 1400 rsp.List = append(rsp.List, commItem)
1292 } 1401 }
@@ -1614,15 +1723,26 @@ func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDelete @@ -1614,15 +1723,26 @@ func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDelete
1614 err = protocol.NewErrWithMessage(5202) 1723 err = protocol.NewErrWithMessage(5202)
1615 return 1724 return
1616 } 1725 }
1617 - if err = utils.UpdateTableByMap(chance, map[string]interface{}{ 1726 + orm := orm.NewOrm()
  1727 + orm.Begin()
  1728 + //发送提交日志
  1729 + if err = agg.SaveApproveLog(orm, 2, chance.UserId, chance.Id); err != nil {
  1730 + log.Error(err)
  1731 + orm.Rollback()
  1732 + return
  1733 + }
  1734 + if err = utils.UpdateTableByMapWithOrmer(orm, chance, map[string]interface{}{
1618 "EnableStatus": int8(0), 1735 "EnableStatus": int8(0),
1619 }); err != nil { 1736 }); err != nil {
1620 log.Error(err) 1737 log.Error(err)
  1738 + orm.Rollback()
1621 return 1739 return
1622 } 1740 }
1623 - if err = models.CloseAuditFlowProcess(chance.Id); err != nil { 1741 + if err = models.CloseAuditFlowProcess(orm, chance.Id); err != nil {
1624 log.Error(err) 1742 log.Error(err)
  1743 + orm.Rollback()
1625 return 1744 return
1626 } 1745 }
  1746 + orm.Commit()
1627 return 1747 return
1628 } 1748 }
@@ -74,7 +74,7 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) @@ -74,7 +74,7 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest)
74 return 74 return
75 } 75 }
76 } 76 }
77 - if err = agg.SendMsg(recevierId, "", header.CompanyId, sourceId, request.SourceType, request.Content, protocol.MsgTypeComment); err != nil { 77 + if err = agg.SendMsg(recevierId, "", header.CompanyId, sourceId, request.SourceType, request.Content, protocol.MsgTypeComment, request.Id); err != nil {
78 log.Error(err) 78 log.Error(err)
79 orm.Rollback() 79 orm.Rollback()
80 return 80 return
@@ -139,7 +139,8 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) @@ -139,7 +139,8 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
139 return 139 return
140 } 140 }
141 rsp = &protocol.CommentsResponse{ 141 rsp = &protocol.CommentsResponse{
142 - Total: total, 142 + Total: total,
  143 + Comments: make([]*protocol.Comments, 0),
143 } 144 }
144 for i := range comments { 145 for i := range comments {
145 comment := comments[i] 146 comment := comments[i]
@@ -155,9 +156,10 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) @@ -155,9 +156,10 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest)
155 ViewTotal: comment.ViewTotal, 156 ViewTotal: comment.ViewTotal,
156 ZanTotal: comment.ZanTotal, 157 ZanTotal: comment.ZanTotal,
157 CommentTotal: comment.CommentTotal, 158 CommentTotal: comment.CommentTotal,
  159 + IsZan: false,
158 } 160 }
159 if exists, _ = models.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlagZan); exists { 161 if exists, _ = models.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlagZan); exists {
160 - item.IsZan = 1 162 + item.IsZan = true
161 } 163 }
162 rsp.Comments = append(rsp.Comments, item) 164 rsp.Comments = append(rsp.Comments, item)
163 } 165 }
@@ -221,9 +223,10 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm @@ -221,9 +223,10 @@ func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.Comm
221 ViewTotal: comment.ViewTotal, 223 ViewTotal: comment.ViewTotal,
222 ZanTotal: comment.ZanTotal, 224 ZanTotal: comment.ZanTotal,
223 CommentTotal: comment.CommentTotal, 225 CommentTotal: comment.CommentTotal,
  226 + IsZan: false,
224 } 227 }
225 if exists, _ = models.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlagZan); exists { 228 if exists, _ = models.ExitsChanceFavorite(header.UserId, header.CompanyId, comment.Id, protocol.MarkFlagZan); exists {
226 - rsp.Comment.IsZan = 1 229 + rsp.Comment.IsZan = true
227 } 230 }
228 return 231 return
229 } 232 }
@@ -15,9 +15,43 @@ import ( @@ -15,9 +15,43 @@ import (
15 ) 15 )
16 16
17 func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCenterRequest) (rsp *protocol.MessageCenterResponse, err error) { 17 func MessageCenter(header *protocol.RequestHeader, request *protocol.MessageCenterRequest) (rsp *protocol.MessageCenterResponse, err error) {
18 - var () 18 + var (
  19 + list []*protocol.MessageTotal
  20 + interactionCount int
  21 + )
19 rsp = &protocol.MessageCenterResponse{} 22 rsp = &protocol.MessageCenterResponse{}
  23 + if request.MsgType&protocol.MsgTypeInteraction > 0 {
  24 + if request.MsgType&protocol.MsgTypeThumbUp == 0 {
  25 + request.MsgType |= protocol.MsgTypeThumbUp
  26 + }
  27 + if request.MsgType&protocol.MsgTypeComment == 0 {
  28 + request.MsgType |= protocol.MsgTypeComment
  29 + }
  30 + if request.MsgType&protocol.MsgTypeAuditBy == 0 {
  31 + request.MsgType |= protocol.MsgTypeAuditBy
  32 + }
  33 + }
20 err = models.GetUserMsgTotals(header.UserId, header.CompanyId, request.MsgType, &rsp.Totals) 34 err = models.GetUserMsgTotals(header.UserId, header.CompanyId, request.MsgType, &rsp.Totals)
  35 + for i := range rsp.Totals {
  36 + item := rsp.Totals[i]
  37 + if item.MsgType == protocol.MsgTypeThumbUp {
  38 + interactionCount += item.MsgTotal
  39 + continue
  40 + }
  41 + if item.MsgType == protocol.MsgTypeComment {
  42 + interactionCount += item.MsgTotal
  43 + continue
  44 + }
  45 + if item.MsgType == protocol.MsgTypeAuditBy {
  46 + interactionCount += item.MsgTotal
  47 + continue
  48 + }
  49 + list = append(list, item)
  50 + }
  51 + if interactionCount > 0 {
  52 + list = append(list, &protocol.MessageTotal{MsgType: protocol.MsgTypeInteraction, MsgTotal: interactionCount})
  53 + }
  54 + rsp.Totals = list
21 return 55 return
22 } 56 }
23 57
@@ -215,30 +249,30 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -215,30 +249,30 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc
215 rsp = &protocol.MsgChanceApproveResponse{Total: total} 249 rsp = &protocol.MsgChanceApproveResponse{Total: total}
216 for i := 0; i < len(myChances); i++ { 250 for i := 0; i < len(myChances); i++ {
217 chance := myChances[i] 251 chance := myChances[i]
218 - commItem := protocol.CommonListItem{} 252 + commItem := protocol.MsgCommonListItem{}
219 commItem.ReviewStatus = chance.ReviewStatus 253 commItem.ReviewStatus = chance.ReviewStatus
220 if len(chance.SourceContent) == 0 { //机会删除 254 if len(chance.SourceContent) == 0 { //机会删除
221 commItem.ChanceStatus = protocol.ChanceStatusDelete 255 commItem.ChanceStatus = protocol.ChanceStatusDelete
222 } else if chance.ChanceEnableStatus == 0 { //机会关闭 256 } else if chance.ChanceEnableStatus == 0 { //机会关闭
223 commItem.ChanceStatus = protocol.ChanceStatusClose 257 commItem.ChanceStatus = protocol.ChanceStatusClose
  258 + }
  259 +
  260 + if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
  261 + commItem.ChanceStatus = protocol.ChanceStatusDelete
  262 + log.Error(err)
  263 + continue
224 } else { 264 } else {
225 - if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {  
226 - commItem.ChanceStatus = protocol.ChanceStatusDelete  
227 - log.Error(err)  
228 - continue  
229 - } else {  
230 - item := protocol.ChanceItem{  
231 - Id: chance.ChanceId,  
232 - Provider: provider,  
233 - CreateTime: chance.CreateTime.Unix() * 1000,  
234 - }  
235 - utils.JsonUnmarshal(chance.SourceContent, &item.FormList)  
236 - item.FormList = agg.ClearEmptyForm(item.FormList)  
237 - utils.JsonUnmarshal(chance.Images, &item.Pictures)  
238 - utils.JsonUnmarshal(chance.Voices, &item.Speechs)  
239 - utils.JsonUnmarshal(chance.Videos, &item.Videos)  
240 - commItem.Chance = item 265 + item := protocol.ChanceItem{
  266 + Id: chance.ChanceId,
  267 + Provider: provider,
  268 + CreateTime: chance.CreateTime.Unix() * 1000,
241 } 269 }
  270 + utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
  271 + item.FormList = agg.ClearEmptyForm(item.FormList)
  272 + utils.JsonUnmarshal(chance.Images, &item.Pictures)
  273 + utils.JsonUnmarshal(chance.Voices, &item.Speechs)
  274 + utils.JsonUnmarshal(chance.Videos, &item.Videos)
  275 + commItem.Chance = item
242 } 276 }
243 277
244 if chance.ReviewStatus == protocol.ReviewStatusPass { 278 if chance.ReviewStatus == protocol.ReviewStatusPass {
@@ -248,8 +282,11 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -248,8 +282,11 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc
248 commItem.Score = approveData.Score 282 commItem.Score = approveData.Score
249 } 283 }
250 } 284 }
  285 + commItem.MsgId = chance.Id
251 //审核完有审核数据 286 //审核完有审核数据
252 commItem.Message = chance.Message 287 commItem.Message = chance.Message
  288 + commItem.IsRead = chance.IsRead == 1
  289 + commItem.ChanceId = chance.ChanceId
253 rsp.List = append(rsp.List, commItem) 290 rsp.List = append(rsp.List, commItem)
254 } 291 }
255 return 292 return
@@ -273,30 +310,30 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance @@ -273,30 +310,30 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance
273 rsp = &protocol.MsgChanceSubmitResponse{Total: total} 310 rsp = &protocol.MsgChanceSubmitResponse{Total: total}
274 for i := 0; i < len(myChances); i++ { 311 for i := 0; i < len(myChances); i++ {
275 chance := myChances[i] 312 chance := myChances[i]
276 - commItem := protocol.CommonListItem{} 313 + commItem := protocol.MsgCommonListItem{}
277 commItem.ReviewStatus = chance.ReviewStatus 314 commItem.ReviewStatus = chance.ReviewStatus
278 if len(chance.SourceContent) == 0 { //机会删除 315 if len(chance.SourceContent) == 0 { //机会删除
279 commItem.ChanceStatus = protocol.ChanceStatusDelete 316 commItem.ChanceStatus = protocol.ChanceStatusDelete
280 } else if chance.ChanceEnableStatus == 0 { //机会关闭 317 } else if chance.ChanceEnableStatus == 0 { //机会关闭
281 commItem.ChanceStatus = protocol.ChanceStatusClose 318 commItem.ChanceStatus = protocol.ChanceStatusClose
  319 + }
  320 +
  321 + if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
  322 + commItem.ChanceStatus = protocol.ChanceStatusDelete
  323 + log.Error(err)
  324 + continue
282 } else { 325 } else {
283 - if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {  
284 - commItem.ChanceStatus = protocol.ChanceStatusDelete  
285 - log.Error(err)  
286 - continue  
287 - } else {  
288 - item := protocol.ChanceItem{  
289 - Id: chance.ChanceId,  
290 - Provider: provider,  
291 - CreateTime: chance.CreateTime.Unix() * 1000,  
292 - }  
293 - utils.JsonUnmarshal(chance.SourceContent, &item.FormList)  
294 - item.FormList = agg.ClearEmptyForm(item.FormList)  
295 - utils.JsonUnmarshal(chance.Images, &item.Pictures)  
296 - utils.JsonUnmarshal(chance.Voices, &item.Speechs)  
297 - utils.JsonUnmarshal(chance.Videos, &item.Videos)  
298 - commItem.Chance = item 326 + item := protocol.ChanceItem{
  327 + Id: chance.ChanceId,
  328 + Provider: provider,
  329 + CreateTime: chance.CreateTime.Unix() * 1000,
299 } 330 }
  331 + utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
  332 + item.FormList = agg.ClearEmptyForm(item.FormList)
  333 + utils.JsonUnmarshal(chance.Images, &item.Pictures)
  334 + utils.JsonUnmarshal(chance.Voices, &item.Speechs)
  335 + utils.JsonUnmarshal(chance.Videos, &item.Videos)
  336 + commItem.Chance = item
300 } 337 }
301 338
302 if chance.ReviewStatus == protocol.ReviewStatusPass { 339 if chance.ReviewStatus == protocol.ReviewStatusPass {
@@ -306,8 +343,11 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance @@ -306,8 +343,11 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance
306 commItem.Score = approveData.Score 343 commItem.Score = approveData.Score
307 } 344 }
308 } 345 }
  346 + commItem.IsRead = chance.IsRead == 1
309 //审核完有审核数据 347 //审核完有审核数据
310 commItem.Message = chance.Message 348 commItem.Message = chance.Message
  349 + commItem.MsgId = chance.Id
  350 + commItem.ChanceId = chance.ChanceId
311 rsp.List = append(rsp.List, commItem) 351 rsp.List = append(rsp.List, commItem)
312 } 352 }
313 return 353 return
@@ -331,7 +371,7 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -331,7 +371,7 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc
331 rsp = &protocol.MsgChanceCommentResponse{Total: total} 371 rsp = &protocol.MsgChanceCommentResponse{Total: total}
332 for i := 0; i < len(myChances); i++ { 372 for i := 0; i < len(myChances); i++ {
333 chance := myChances[i] 373 chance := myChances[i]
334 - commItem := protocol.CommonListItem{} 374 + commItem := protocol.MsgCommonListItem{}
335 if chance.SourceType == protocol.SourceTypeChance { 375 if chance.SourceType == protocol.SourceTypeChance {
336 commItem.ReviewStatus = chance.ReviewStatus 376 commItem.ReviewStatus = chance.ReviewStatus
337 if len(chance.SourceContent) == 0 { //机会删除 377 if len(chance.SourceContent) == 0 { //机会删除
@@ -360,10 +400,16 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -360,10 +400,16 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc
360 commItem.ReviewStatus = chance.ReviewStatus 400 commItem.ReviewStatus = chance.ReviewStatus
361 } 401 }
362 if chance.SourceType == protocol.SourceTypeComment { 402 if chance.SourceType == protocol.SourceTypeComment {
  403 + if provider, err = agg.GetUserBaseInfo(chance.CommentedUserId, header.CompanyId); err != nil {
  404 + commItem.ChanceStatus = protocol.ChanceStatusDelete
  405 + log.Error(err)
  406 + //return
  407 + }
363 commItem.CommentedData = protocol.CommentData{ 408 commItem.CommentedData = protocol.CommentData{
364 Id: chance.SourceId, 409 Id: chance.SourceId,
365 Content: chance.CommentedContent, 410 Content: chance.CommentedContent,
366 CommentTime: chance.CommentedTime.Unix() * 1000, 411 CommentTime: chance.CommentedTime.Unix() * 1000,
  412 + Provider: provider,
367 } 413 }
368 } 414 }
369 commItem.CommentData = protocol.CommentData{ 415 commItem.CommentData = protocol.CommentData{
@@ -371,7 +417,10 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -371,7 +417,10 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc
371 CommentTime: chance.CommentTime.Unix() * 1000, 417 CommentTime: chance.CommentTime.Unix() * 1000,
372 Content: chance.CommentContent, 418 Content: chance.CommentContent,
373 } 419 }
  420 + commItem.IsRead = chance.IsRead == 1
374 commItem.SourceType = chance.SourceType 421 commItem.SourceType = chance.SourceType
  422 + commItem.MsgId = chance.CommentId
  423 + commItem.ChanceId = chance.ChanceId
375 rsp.List = append(rsp.List, commItem) 424 rsp.List = append(rsp.List, commItem)
376 } 425 }
377 return 426 return
@@ -395,39 +444,45 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -395,39 +444,45 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc
395 rsp = &protocol.MsgChanceThumbUpResponse{Total: total} 444 rsp = &protocol.MsgChanceThumbUpResponse{Total: total}
396 for i := 0; i < len(myChances); i++ { 445 for i := 0; i < len(myChances); i++ {
397 chance := myChances[i] 446 chance := myChances[i]
398 - commItem := protocol.CommonListItem{} 447 + commItem := protocol.MsgCommonListItem{}
399 if chance.SourceType == protocol.SourceTypeChance { 448 if chance.SourceType == protocol.SourceTypeChance {
400 commItem.ReviewStatus = chance.ReviewStatus 449 commItem.ReviewStatus = chance.ReviewStatus
401 if len(chance.SourceContent) == 0 { //机会删除 450 if len(chance.SourceContent) == 0 { //机会删除
402 commItem.ChanceStatus = protocol.ChanceStatusDelete 451 commItem.ChanceStatus = protocol.ChanceStatusDelete
403 } else if chance.ChanceEnableStatus == 0 { //机会关闭 452 } else if chance.ChanceEnableStatus == 0 { //机会关闭
404 commItem.ChanceStatus = protocol.ChanceStatusClose 453 commItem.ChanceStatus = protocol.ChanceStatusClose
  454 + }
  455 +
  456 + if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
  457 + commItem.ChanceStatus = protocol.ChanceStatusDelete
  458 + log.Error(err)
  459 + //return
405 } else { 460 } else {
406 - if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {  
407 - commItem.ChanceStatus = protocol.ChanceStatusDelete  
408 - log.Error(err)  
409 - //return  
410 - } else {  
411 - item := protocol.ChanceItem{  
412 - Id: chance.SourceId,  
413 - Provider: provider,  
414 - CreateTime: chance.CreateTime.Unix() * 1000,  
415 - }  
416 - utils.JsonUnmarshal(chance.SourceContent, &item.FormList)  
417 - item.FormList = protocol.ClearEmptyForm(item.FormList)  
418 - utils.JsonUnmarshal(chance.Images, &item.Pictures)  
419 - utils.JsonUnmarshal(chance.Voices, &item.Speechs)  
420 - utils.JsonUnmarshal(chance.Videos, &item.Videos)  
421 - commItem.Chance = item 461 + item := protocol.ChanceItem{
  462 + Id: chance.SourceId,
  463 + Provider: provider,
  464 + CreateTime: chance.CreateTime.Unix() * 1000,
422 } 465 }
  466 + utils.JsonUnmarshal(chance.SourceContent, &item.FormList)
  467 + item.FormList = protocol.ClearEmptyForm(item.FormList)
  468 + utils.JsonUnmarshal(chance.Images, &item.Pictures)
  469 + utils.JsonUnmarshal(chance.Voices, &item.Speechs)
  470 + utils.JsonUnmarshal(chance.Videos, &item.Videos)
  471 + commItem.Chance = item
423 } 472 }
424 commItem.ReviewStatus = chance.ReviewStatus 473 commItem.ReviewStatus = chance.ReviewStatus
425 } 474 }
426 if chance.SourceType == protocol.SourceTypeComment { 475 if chance.SourceType == protocol.SourceTypeComment {
  476 + if provider, err = agg.GetUserBaseInfo(chance.CommentedUserId, header.CompanyId); err != nil {
  477 + commItem.ChanceStatus = protocol.ChanceStatusDelete
  478 + log.Error(err)
  479 + //return
  480 + }
427 commItem.CommentedData = protocol.CommentData{ 481 commItem.CommentedData = protocol.CommentData{
428 Id: chance.SourceId, 482 Id: chance.SourceId,
429 Content: chance.CommentedContent, 483 Content: chance.CommentedContent,
430 CommentTime: chance.CommentedTime.Unix() * 1000, 484 CommentTime: chance.CommentedTime.Unix() * 1000,
  485 + Provider: provider,
431 } 486 }
432 } 487 }
433 commItem.ThumbUpData = protocol.ThumbUpData{ 488 commItem.ThumbUpData = protocol.ThumbUpData{
@@ -435,7 +490,10 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc @@ -435,7 +490,10 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc
435 ThumbUpTime: chance.CommentTime.Unix() * 1000, 490 ThumbUpTime: chance.CommentTime.Unix() * 1000,
436 Content: chance.CommentContent, 491 Content: chance.CommentContent,
437 } 492 }
  493 + commItem.IsRead = chance.IsRead == 1
438 commItem.SourceType = chance.SourceType 494 commItem.SourceType = chance.SourceType
  495 + commItem.MsgId = chance.CommentId
  496 + commItem.ChanceId = chance.ChanceId
439 rsp.List = append(rsp.List, commItem) 497 rsp.List = append(rsp.List, commItem)
440 } 498 }
441 return 499 return
@@ -89,7 +89,7 @@ func UploadFile(request *protocol.FileRequest) (rsp *protocol.FileResponse, err @@ -89,7 +89,7 @@ func UploadFile(request *protocol.FileRequest) (rsp *protocol.FileResponse, err
89 log.Error(err) 89 log.Error(err)
90 return 90 return
91 } 91 }
92 - rsp.Paths = append(rsp.Paths, filepath.Join(virtualPath, filename)) 92 + rsp.Paths = append(rsp.Paths, virtualPath+"/"+filename)
93 ResizeImage(request.FileType, sourcePath, prefix, subfix, f) 93 ResizeImage(request.FileType, sourcePath, prefix, subfix, f)
94 } 94 }
95 return 95 return