作者 yangfu

我的审核

@@ -30,6 +30,8 @@ type AuditFlowProcess struct { @@ -30,6 +30,8 @@ type AuditFlowProcess struct {
30 UserName string `orm:"column(user_name);size(50)" description:"用户名-冗余"` 30 UserName string `orm:"column(user_name);size(50)" description:"用户名-冗余"`
31 RoleName string `orm:"column(role_name);size(50)" description:"角色名-冗余"` 31 RoleName string `orm:"column(role_name);size(50)" description:"角色名-冗余"`
32 RoleId int `orm:"column(role_id);size(50)" description:"角色id-冗余"` 32 RoleId int `orm:"column(role_id);size(50)" description:"角色id-冗余"`
  33 + ApproveMessage string `orm:"column(approve_message);size(50)" description:"审核消息-冗余"`
  34 + TemplateId int `orm:"column(template_id);size(50)" description:"模板编号-冗余"`
33 } 35 }
34 36
35 func (t *AuditFlowProcess) TableName() string { 37 func (t *AuditFlowProcess) TableName() string {
@@ -128,7 +128,7 @@ order by create_at desc @@ -128,7 +128,7 @@ order by create_at desc
128 func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { 128 func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) {
129 sql := `select a.*,b.images,b.speechs,b.videos from ( 129 sql := `select a.*,b.images,b.speechs,b.videos from (
130 select a.*,b.user_id,b.source_content,b.enable_status from ( 130 select a.*,b.user_id,b.source_content,b.enable_status from (
131 -select id,approve_time,approve_data,uid,chance_id 131 +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 (?) and (?=0 or id>?) 132 from audit_flow_process where uid=? and enable_status =1 and review_status in (?) and (?=0 or id>?)
133 )a left outer join chance b on a.chance_id = b.id 133 )a left outer join chance b on a.chance_id = b.id
134 )a left outer join chance_data b on a.chance_id =b.chance_id 134 )a left outer join chance_data b on a.chance_id =b.chance_id
@@ -48,6 +48,11 @@ const ( @@ -48,6 +48,11 @@ const (
48 PublicToCompany = 2 //公司公开 48 PublicToCompany = 2 //公司公开
49 ) 49 )
50 50
  51 +const (
  52 + ChanceStatusDelete = 1 //删除
  53 + ChanceStatusClose = 2 //关闭
  54 +)
  55 +
51 /*Favorite */ 56 /*Favorite */
52 type FavoriteRequest struct { 57 type FavoriteRequest struct {
53 ObjectType int `json:"object_type" valid:"Required"` //收藏 点赞 58 ObjectType int `json:"object_type" valid:"Required"` //收藏 点赞
@@ -208,12 +213,12 @@ type MyApproveChanceResponse struct { @@ -208,12 +213,12 @@ type MyApproveChanceResponse struct {
208 //机会列表 通用项 213 //机会列表 通用项
209 type CommonListItem struct { 214 type CommonListItem struct {
210 Chance ChanceItem `json:"chance,omitempty"` //机会详情 215 Chance ChanceItem `json:"chance,omitempty"` //机会详情
211 - ChanceData ChanceData `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)  
212 - Approve Approve `json:"approve,omitempty"` //审核人 审核信息(时间)  
213 - ApproveData ApproveData `json:"ApproveData"` //审核数据(公开状态 评分) 216 + ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData
  217 + Approve interface{} `json:"approve,omitempty"` //审核人 审核信息(时间) Approve
  218 + ApproveData interface{} `json:"ApproveData,omitempty"` //审核数据(公开状态 评分) ApproveData
214 Message interface{} `json:"message,omitempty"` 219 Message interface{} `json:"message,omitempty"`
215 Comment interface{} `json:"comment,omitempty"` 220 Comment interface{} `json:"comment,omitempty"`
216 - ChanceStatus int `json:"chanceStatus,omitempty"` //1.删除 2.关闭 221 + ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
217 } 222 }
218 223
219 type ChanceData struct { 224 type ChanceData struct {
@@ -243,7 +248,7 @@ type ChanceItem struct { @@ -243,7 +248,7 @@ type ChanceItem struct {
243 type ChanceApproveItemOrm struct { 248 type ChanceApproveItemOrm struct {
244 ChanceUserId int64 `orm:"column(chance_user_id)"` 249 ChanceUserId int64 `orm:"column(chance_user_id)"`
245 SourceContent string `orm:"column(source_content)"` 250 SourceContent string `orm:"column(source_content)"`
246 - ChanceEnableStatus string `orm:"column(enable_status)"` 251 + ChanceEnableStatus int `orm:"column(enable_status)"`
247 Images string `orm:"column(images)"` 252 Images string `orm:"column(images)"`
248 Voices string `orm:"column(speechs)"` 253 Voices string `orm:"column(speechs)"`
249 Videos string `orm:"column(videos)"` 254 Videos string `orm:"column(videos)"`
@@ -251,7 +256,9 @@ type ChanceApproveItemOrm struct { @@ -251,7 +256,9 @@ type ChanceApproveItemOrm struct {
251 Id int64 `orm:"column(id)"` //审核id 256 Id int64 `orm:"column(id)"` //审核id
252 ApproveTime time.Time `orm:"column(approve_time)"` 257 ApproveTime time.Time `orm:"column(approve_time)"`
253 ApproveData string `orm:"column(approve_data)"` 258 ApproveData string `orm:"column(approve_data)"`
  259 + ApproveMessage string `orm:"column(approve_message)"`
254 ApproveUserId int64 `orm:"column(uid)"` 260 ApproveUserId int64 `orm:"column(uid)"`
  261 + ProcessCreateTime time.Time `orm:"column(process_create_time)"`
255 ChanceId int64 `orm:"column(chance_id)"` // 机会id 262 ChanceId int64 `orm:"column(chance_id)"` // 机会id
256 } 263 }
257 264
@@ -67,8 +67,9 @@ type Role struct { @@ -67,8 +67,9 @@ type Role struct {
67 } 67 }
68 68
69 type Approve struct { 69 type Approve struct {
70 - Provider BaseUserInfo `json:"provider"` 70 + //Provider *BaseUserInfo `json:"provider"`
71 ProcessId int64 `json:"processId"` 71 ProcessId int64 `json:"processId"`
  72 + CreateTime int64 `json:"createTime"`
72 ApproveTime int64 `json:"approveTime"` 73 ApproveTime int64 `json:"approveTime"`
73 } 74 }
74 75
@@ -53,6 +53,12 @@ const ( @@ -53,6 +53,12 @@ const (
53 MsgTypeAudit = 8 //机会审核 53 MsgTypeAudit = 8 //机会审核
54 ) 54 )
55 55
  56 +var (
  57 + MessageApproving = "提交了一条%v机会消息,需要您审核"
  58 + MessageApproveSuccess = "审核通过你提交的%v机会"
  59 + MessageApproveReject = "退回您了提交的%v机会"
  60 +)
  61 +
56 /*MessageCenter */ 62 /*MessageCenter */
57 type MessageCenterRequest struct { 63 type MessageCenterRequest struct {
58 MsgType int `json:"msgType" valid:"Required"` 64 MsgType int `json:"msgType" valid:"Required"`
@@ -236,12 +236,17 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -236,12 +236,17 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
236 auditConfig *protocol.AuditConfig 236 auditConfig *protocol.AuditConfig
237 auditFlows []*models.AuditFlowProcess 237 auditFlows []*models.AuditFlowProcess
238 suplusApprove SuplusApprove 238 suplusApprove SuplusApprove
  239 + chanceType *models.ChanceType
239 ) 240 )
240 //1.模板是否存在 241 //1.模板是否存在
241 if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil { 242 if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil {
242 log.Error("模板不存在:", request.AuditTemplateId, err) 243 log.Error("模板不存在:", request.AuditTemplateId, err)
243 return 244 return
244 } 245 }
  246 + if chanceType, err = models.GetChanceTypeById(template.ChanceTypeId); err != nil {
  247 + log.Error("一级分类不存在:", request.AuditTemplateId, err)
  248 + return
  249 + }
245 auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover} 250 auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover}
246 orm := orm.NewOrm() 251 orm := orm.NewOrm()
247 orm.Begin() 252 orm.Begin()
@@ -284,6 +289,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit @@ -284,6 +289,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit
284 return 289 return
285 } 290 }
286 for i := 0; i < len(auditFlows); i++ { 291 for i := 0; i < len(auditFlows); i++ {
  292 + auditFlows[i].ApproveMessage = fmt.Sprintf(protocol.MessageApproving, chanceType.Name)
  293 + //auditFlows[i].TemplateId = int(template.Id)
287 if _, err = orm.Insert(auditFlows[i]); err != nil { 294 if _, err = orm.Insert(auditFlows[i]); err != nil {
288 log.Error(err) 295 log.Error(err)
289 orm.Rollback() 296 orm.Rollback()
@@ -660,6 +667,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat @@ -660,6 +667,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat
660 RoleName: roleName, 667 RoleName: roleName,
661 UserName: approver.NickName, 668 UserName: approver.NickName,
662 ReviewStatus: protocol.ReviewStatusAuditging, 669 ReviewStatus: protocol.ReviewStatusAuditging,
  670 + TemplateId: int(templateId),
663 } 671 }
664 if config.Level == 1 { 672 if config.Level == 1 {
665 item.IsActive = 1 673 item.IsActive = 1
@@ -799,7 +807,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove @@ -799,7 +807,7 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
799 provider *protocol.BaseUserInfo 807 provider *protocol.BaseUserInfo
800 ) 808 )
801 rsp = &protocol.MyApproveChanceResponse{} 809 rsp = &protocol.MyApproveChanceResponse{}
802 - if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil { 810 + if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil {
803 if err == orm.ErrNoRows { 811 if err == orm.ErrNoRows {
804 err = nil 812 err = nil
805 return 813 return
@@ -807,14 +815,20 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove @@ -807,14 +815,20 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
807 log.Error(err) 815 log.Error(err)
808 return 816 return
809 } 817 }
810 - if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil {  
811 - log.Error(err)  
812 - return  
813 - }  
814 rsp = &protocol.MyApproveChanceResponse{Total: total} 818 rsp = &protocol.MyApproveChanceResponse{Total: total}
815 for i := 0; i < len(myChances); i++ { 819 for i := 0; i < len(myChances); i++ {
816 chance := myChances[i] 820 chance := myChances[i]
817 commItem := protocol.CommonListItem{} 821 commItem := protocol.CommonListItem{}
  822 + if len(chance.SourceContent) == 0 { //机会删除
  823 + commItem.ChanceStatus = protocol.ChanceStatusDelete
  824 + } else if chance.ChanceEnableStatus == 0 { //机会关闭
  825 + commItem.ChanceStatus = protocol.ChanceStatusClose
  826 + } else {
  827 + if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil {
  828 + commItem.ChanceStatus = protocol.ChanceStatusDelete
  829 + log.Error(err)
  830 + //return
  831 + } else {
818 item := protocol.ChanceItem{ 832 item := protocol.ChanceItem{
819 Id: chance.Id, 833 Id: chance.Id,
820 Provider: provider, 834 Provider: provider,
@@ -824,13 +838,24 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove @@ -824,13 +838,24 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove
824 jsonUnmarshal(chance.Images, &item.Pictures) 838 jsonUnmarshal(chance.Images, &item.Pictures)
825 jsonUnmarshal(chance.Voices, &item.Speechs) 839 jsonUnmarshal(chance.Voices, &item.Speechs)
826 jsonUnmarshal(chance.Videos, &item.Videos) 840 jsonUnmarshal(chance.Videos, &item.Videos)
827 -  
828 - {  
829 commItem.Chance = item 841 commItem.Chance = item
830 } 842 }
  843 + }
  844 + commItem.Approve = protocol.Approve{
  845 + ProcessId: chance.Id,
  846 + //Provider:provider,
  847 + CreateTime: chance.ProcessCreateTime.Unix() * 1000,
  848 + ApproveTime: chance.ApproveTime.Unix() * 1000,
  849 + }
  850 + //审核完有审核数据
  851 + if request.ReviewStatus == protocol.ReviewStatusAuditging {
  852 + commItem.Message = chance.ApproveMessage
  853 + }
  854 + if request.ReviewStatus == protocol.ReviewStatusPass {
  855 + jsonUnmarshal(chance.ApproveData, &commItem.ApproveData)
  856 + }
831 rsp.List = append(rsp.List, commItem) 857 rsp.List = append(rsp.List, commItem)
832 } 858 }
833 -  
834 return 859 return
835 } 860 }
836 861