company_approval_message.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package company_approval_message
  2. import (
  3. "encoding/json"
  4. "hongze/hongze_yb/models/tables/company_approval_message"
  5. "time"
  6. )
  7. //消息来源类型,1:客户,2:合同,3:用印,4:指标替换,5:问答社区,6:问答评论,7:视频评论,8:线上路演评论
  8. const (
  9. CompanyApprovalMessageSourceTypeByCompany = 1
  10. CompanyApprovalMessageSourceTypeByContract = 2
  11. CompanyApprovalMessageSourceTypeBySeal = 3
  12. CompanyApprovalMessageSourceTypeByEdbInfo = 4
  13. CompanyApprovalMessageSourceTypeByQuestion = 5
  14. CompanyApprovalMessageSourceTypeByQuestionComment = 6
  15. CompanyApprovalMessageSourceTypeByVideoComment = 7
  16. CompanyApprovalMessageSourceTypeByRoadVideoComment = 8
  17. )
  18. // 1:申请消息,2:审批结果,3:消息通知
  19. const (
  20. CompanyApprovalMessageMessageTypeByApply = 1
  21. CompanyApprovalMessageMessageTypeByApprovalResult = 2
  22. CompanyApprovalMessageMessageTypeByMessage = 3
  23. )
  24. //审批状态,1:待审批,2:已审批,3:已驳回
  25. const (
  26. CompanyApprovalMessageApprovalStatusByPending = 1
  27. CompanyApprovalMessageApprovalStatusByApproved = 2
  28. CompanyApprovalMessageApprovalStatusByRejected = 3
  29. )
  30. // MessageInfo 消息主要内容
  31. type MessageInfo struct {
  32. CompanyName string `json:"company_name"`
  33. ProductId int `json:"product_id"`
  34. CompanyProductStatus string `json:"company_product_status"`
  35. Title string `json:"title"`
  36. Content string `json:"content"`
  37. UserId uint64 `json:"user_id"`
  38. UserName string `json:"user_name"`
  39. CreateTime time.Time `json:"create_time"`
  40. Extra string `json:"extra" description:"附加字段"`
  41. MessageSource string `json:"message_source" description:"消息来源:问答社区/视频社区/线上路演"`
  42. }
  43. // AddCompanyApprovalMessage 添加系统消息
  44. // @params createUserId int "消息创建人id"
  45. // @params receiveUserId int "消息接收人id"
  46. // @params companyApprovalId int "消息对应的id"
  47. func AddCompanyApprovalMessage(createUserId, receiveUserId, companyId, companyApprovalId int, msgType, sourceType, approvalStatus int8, companyName, remark, content string, messageInfo MessageInfo) (err error) {
  48. messageInfoStr, err := json.Marshal(messageInfo)
  49. if err != nil {
  50. return
  51. }
  52. msgItem := &company_approval_message.CompanyApprovalMessage{
  53. //ID: 0,
  54. CreateUserID: createUserId,
  55. ReceiveUserID: receiveUserId,
  56. MessageStatus: 0, //消息状态:0未读,1:已读,2:作废
  57. Remark: remark,
  58. Content: content,
  59. CompanyID: companyId,
  60. CompanyName: companyName,
  61. CreateTime: time.Now(),
  62. ModifyTime: time.Now(),
  63. CompanyApprovalID: companyApprovalId,
  64. ApprovalStatus: approvalStatus, //审批状态,1:待审批,2:已审批,3:已驳回
  65. OperationStatus: 1, //消息状态:1:待审批,2:已审批
  66. MessageType: msgType, //1:申请消息,2:审批结果,3:消息通知
  67. SourceType: sourceType, //消息来源,1:客户,2:合同,3:用印
  68. MessageInfo: string(messageInfoStr), //消息主要内容,json数据
  69. }
  70. err = msgItem.Create()
  71. return
  72. }
  73. // CancelCompanyApprovalMessage 消息作废
  74. func CancelCompanyApprovalMessage(companyApprovalId int, sourceType int8) (err error) {
  75. err = company_approval_message.Cancel(companyApprovalId, sourceType)
  76. return
  77. }