meta.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package services
  2. import (
  3. "encoding/json"
  4. "eta/eta_mini_crm_ht/models"
  5. "strconv"
  6. "strings"
  7. )
  8. func CreateMeta(authorName string, authorId int, mediaId int, publishTime string, sourceType models.SourceType) (id int64, err error) {
  9. ids, err := models.GetPostUser(authorId, publishTime)
  10. if err != nil {
  11. return
  12. }
  13. var idStrList []string
  14. for _, id := range ids {
  15. idStrList = append(idStrList, strconv.Itoa(id))
  16. }
  17. Meta := models.MetaData{
  18. AuthorName: authorName,
  19. AuthorId: authorId,
  20. SourceId: mediaId,
  21. PublishedTime: publishTime,
  22. }
  23. metaStr, _ := json.Marshal(Meta)
  24. toStr := strings.Join(idStrList, ",")
  25. metaContent := models.MetaInfo{
  26. From: "ADMIN",
  27. Meta: string(metaStr),
  28. MetaType: "USER_NOTICE",
  29. SourceType: sourceType,
  30. Status: models.InitStatusType,
  31. To: toStr,
  32. }
  33. id, err = metaContent.Insert()
  34. return
  35. }
  36. func CreateRefundMeta(toUserId int) (id int64, err error) {
  37. Meta := models.RefundMetaData{
  38. ProductOrderNo: "",
  39. RealName: "",
  40. Result: "",
  41. }
  42. metaStr, _ := json.Marshal(Meta)
  43. toStr := strconv.Itoa(toUserId)
  44. metaContent := models.MetaInfo{
  45. From: "SYSTEM",
  46. Meta: string(metaStr),
  47. MetaType: "SYSTEM_NOTICE",
  48. SourceType: models.RefundSourceType,
  49. Status: models.InitStatusType,
  50. To: toStr,
  51. }
  52. id, err = metaContent.Insert()
  53. return
  54. }