正在显示
4 个修改的文件
包含
42 行增加
和
3 行删除
| @@ -47,6 +47,8 @@ const ( | @@ -47,6 +47,8 @@ const ( | ||
| 47 | SqlUserMsg = "select * from user_msg where source_id=? and receive_user_id=? and msg_type=? " //特定未读消息 | 47 | SqlUserMsg = "select * from user_msg where source_id=? and receive_user_id=? and msg_type=? " //特定未读消息 |
| 48 | //删除消息 | 48 | //删除消息 |
| 49 | SqlDeleteUserMsg = "delete from user_msg where source_id=? and source_type=? and receive_user_id=? and msg_type=? " //特定未读消息 | 49 | SqlDeleteUserMsg = "delete from user_msg where source_id=? and source_type=? and receive_user_id=? and msg_type=? " //特定未读消息 |
| 50 | + | ||
| 51 | + SqlBulletinUnRead = `select id,source_id from user_msg where msg_type=? and is_read =0 and receive_user_id = ?` | ||
| 50 | ) | 52 | ) |
| 51 | 53 | ||
| 52 | func (t *UserMsg) TableName() string { | 54 | func (t *UserMsg) TableName() string { |
| @@ -122,7 +124,7 @@ GROUP BY msg_type` | @@ -122,7 +124,7 @@ GROUP BY msg_type` | ||
| 122 | func UpdateUserMsgSetRead(userId int64, companyId int64, msgType int, msgId int64) (err error) { | 124 | func UpdateUserMsgSetRead(userId int64, companyId int64, msgType int, msgId int64) (err error) { |
| 123 | o := orm.NewOrm() | 125 | o := orm.NewOrm() |
| 124 | sql := `update user_msg set is_read = 1 | 126 | sql := `update user_msg set is_read = 1 |
| 125 | - where receive_user_id = ? and company_id=? and source_type<>3` | 127 | + where receive_user_id = ? and company_id=?` |
| 126 | if msgType > 0 { | 128 | if msgType > 0 { |
| 127 | sql += fmt.Sprintf(" and (msg_type & %v)>0", msgType) | 129 | sql += fmt.Sprintf(" and (msg_type & %v)>0", msgType) |
| 128 | } | 130 | } |
| @@ -99,6 +99,8 @@ type TemplatesResponse struct { | @@ -99,6 +99,8 @@ type TemplatesResponse struct { | ||
| 99 | type TemplateRequest struct { | 99 | type TemplateRequest struct { |
| 100 | ChanceTypeId int `json:"chanceTypeId" valid:"Required"` | 100 | ChanceTypeId int `json:"chanceTypeId" valid:"Required"` |
| 101 | TemplateId int `json:"templateId" valid:"Required"` | 101 | TemplateId int `json:"templateId" valid:"Required"` |
| 102 | + | ||
| 103 | + ChanceId int64 `json:"chanceId" ` //机会编号 ios特殊使用 | ||
| 102 | } | 104 | } |
| 103 | type TemplateResponse struct { | 105 | type TemplateResponse struct { |
| 104 | Template *Template `json:"template"` | 106 | Template *Template `json:"template"` |
| @@ -255,14 +255,26 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) | @@ -255,14 +255,26 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) | ||
| 255 | var ( | 255 | var ( |
| 256 | templates *models.AuditTemplate | 256 | templates *models.AuditTemplate |
| 257 | forms []*models.AuditForm | 257 | forms []*models.AuditForm |
| 258 | + chance *models.Chance | ||
| 258 | ) | 259 | ) |
| 259 | rsp = &protocol.TemplateResponse{} | 260 | rsp = &protocol.TemplateResponse{} |
| 260 | if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil { | 261 | if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil { |
| 261 | log.Error(fmt.Sprintf("公司:%v chance_type_id:%v id:%v无模板 ", header.CompanyId, request.ChanceTypeId, request.TemplateId), err) | 262 | log.Error(fmt.Sprintf("公司:%v chance_type_id:%v id:%v无模板 ", header.CompanyId, request.ChanceTypeId, request.TemplateId), err) |
| 262 | return | 263 | return |
| 263 | } | 264 | } |
| 265 | + if request.ChanceId > 0 { | ||
| 266 | + if chance, err = models.GetChanceById(request.ChanceId); err == nil { | ||
| 267 | + if chance.EnableStatus == 0 { | ||
| 268 | + err = protocol.NewErrWithMessage(5101) | ||
| 269 | + return | ||
| 270 | + } | ||
| 271 | + if chance.Status == models.ChanceStatusClose { //只有一个报错码5101 机会删除 | ||
| 272 | + err = protocol.NewCustomMessage(5101, "该机会已被关闭或您没有权限查看") | ||
| 273 | + return | ||
| 274 | + } | ||
| 275 | + } | ||
| 276 | + } | ||
| 264 | item := templates | 277 | item := templates |
| 265 | - //TODO:检查模板可见 | ||
| 266 | // | 278 | // |
| 267 | //查询表单 | 279 | //查询表单 |
| 268 | if forms, err = models.GetAuditForms(header.CompanyId, item.Id); err != nil { | 280 | if forms, err = models.GetAuditForms(header.CompanyId, item.Id); err != nil { |
| @@ -510,6 +522,14 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | @@ -510,6 +522,14 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | ||
| 510 | err = protocol.NewErrWithMessage(5101) | 522 | err = protocol.NewErrWithMessage(5101) |
| 511 | return | 523 | return |
| 512 | } | 524 | } |
| 525 | + if chance.EnableStatus == 0 { | ||
| 526 | + err = protocol.NewErrWithMessage(5101) | ||
| 527 | + return | ||
| 528 | + } | ||
| 529 | + if chance.Status == models.ChanceStatusClose { //只有一个报错码5101 机会删除 | ||
| 530 | + err = protocol.NewCustomMessage(5101, "该机会已被关闭或您没有权限查看") | ||
| 531 | + return | ||
| 532 | + } | ||
| 513 | //1.模板是否存在 | 533 | //1.模板是否存在 |
| 514 | if template, err = models.GetAuditTemplateById(int64(chance.AuditTemplateId)); err != nil { | 534 | if template, err = models.GetAuditTemplateById(int64(chance.AuditTemplateId)); err != nil { |
| 515 | log.Error("模板不存在:", chance.AuditTemplateId, err) | 535 | log.Error("模板不存在:", chance.AuditTemplateId, err) |
| @@ -102,8 +102,23 @@ func checkBulletinCanRead(sourceId int64) bool { | @@ -102,8 +102,23 @@ func checkBulletinCanRead(sourceId int64) bool { | ||
| 102 | 102 | ||
| 103 | //标记全部已读 | 103 | //标记全部已读 |
| 104 | func MsgCenterAllRead(header *protocol.RequestHeader, request *protocol.MsgCenterAllReadRequest) (rsp *protocol.MsgCenterAllReadResponse, err error) { | 104 | func MsgCenterAllRead(header *protocol.RequestHeader, request *protocol.MsgCenterAllReadRequest) (rsp *protocol.MsgCenterAllReadResponse, err error) { |
| 105 | - var () | 105 | + var ( |
| 106 | + userMsgs []*models.UserMsg | ||
| 107 | + ) | ||
| 106 | rsp = &protocol.MsgCenterAllReadResponse{} | 108 | rsp = &protocol.MsgCenterAllReadResponse{} |
| 109 | + if request.MsgType == protocol.MsgTypeBulletin { | ||
| 110 | + if e := utils.ExecuteQueryAll(&userMsgs, models.SqlBulletinUnRead, protocol.MsgTypeBulletin, header.UserId); e == nil { | ||
| 111 | + for i := range userMsgs { | ||
| 112 | + if checkBulletinCanRead(userMsgs[i].SourceId) { | ||
| 113 | + e = models.UpdateUserMsgSetRead(header.UserId, header.CompanyId, protocol.MsgTypeBulletin, userMsgs[i].Id) | ||
| 114 | + if e != nil { | ||
| 115 | + log.Error(e) | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + return | ||
| 121 | + } | ||
| 107 | err = models.UpdateUserMsgSetRead(header.UserId, header.CompanyId, request.MsgType, 0) | 122 | err = models.UpdateUserMsgSetRead(header.UserId, header.CompanyId, request.MsgType, 0) |
| 108 | if err != nil { | 123 | if err != nil { |
| 109 | log.Error(err) | 124 | log.Error(err) |
-
请 注册 或 登录 后发表评论