local_life.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/sirupsen/logrus"
  6. "youngee_b_api/db"
  7. "youngee_b_api/model/common_model"
  8. "youngee_b_api/model/http_model"
  9. )
  10. var LocalLife *localLife
  11. type localLife struct {
  12. }
  13. func (*localLife) GetFullLocalLifeList(ctx context.Context, pageSize, pageNum int32, supplierId int, condition *common_model.SLocalLifeCondition) (*http_model.FullListData, error) {
  14. // 1. 查询本地生活任务基本信息
  15. fullLocals, total, err := db.GetFullLocalLifeList(ctx, pageSize, pageNum, condition)
  16. if err != nil {
  17. logrus.WithContext(ctx).Errorf("[fullLocals service] call GetFullLocalLifeList error,err:%+v", err)
  18. return nil, err
  19. }
  20. var fullLocalData *http_model.FullListData
  21. fullLocalData = &http_model.FullListData{}
  22. fullLocalData.Total = total
  23. for _, fullLocal := range fullLocals {
  24. var fullLocalPreview *http_model.FullPreview
  25. fullLocalPreview = &http_model.FullPreview{}
  26. fullLocalPreview.LocalId = fullLocal.LocalId
  27. fullLocalPreview.LocalName = fullLocal.LocalName
  28. fullLocalPreview.TaskStatus = fullLocal.TaskStatus
  29. fullLocalPreview.LocalPlatform = fullLocal.LocalPlatform
  30. fullLocalPreview.TaskForm = fullLocal.TaskForm
  31. fullLocalPreview.LocalType = fullLocal.LocalType
  32. fullLocalPreview.LocalContentType = fullLocal.ContentType
  33. fullLocalData.FullPreview = append(fullLocalData.FullPreview, fullLocalPreview)
  34. }
  35. // 2. 查询本地生活补充信息:门店信息,招募策略
  36. for _, project := range fullLocalData.FullPreview {
  37. // 2.1. 门店信息
  38. storeInfo, productErr := db.FindStoreById(ctx, project.StoreId)
  39. if productErr != nil {
  40. return nil, productErr
  41. }
  42. if storeInfo != nil {
  43. project.StoreId = storeInfo.StoreId
  44. // project.ProductPrice = storeInfo.S
  45. project.StoreName = storeInfo.StoreName
  46. }
  47. // 2.2. 门店图片信息
  48. productPhotoInfo, productPhotoErr := db.GetStorePhotoByStoreID(ctx, project.StoreId)
  49. if productPhotoErr != nil {
  50. return nil, productPhotoErr
  51. }
  52. if productPhotoInfo != nil {
  53. for _, photo := range productPhotoInfo {
  54. fmt.Println(photo)
  55. if photo.Symbol == 1 {
  56. project.ProductPhotoSymbol = 1
  57. project.ProductPhotoUrl = photo.PhotoUrl
  58. project.ProductPhotoUid = photo.PhotoUid
  59. }
  60. }
  61. }
  62. // 2.3. 招募策略信息
  63. recruitStrategyInfo, recruitErr := db.GetRecruitStrategyByProjectId(ctx, project.LocalId)
  64. if recruitErr != nil {
  65. return nil, recruitErr
  66. }
  67. if recruitStrategyInfo != nil {
  68. for _, strategy := range recruitStrategyInfo {
  69. var recruitStrategy *http_model.EasyRecruitStrategy
  70. recruitStrategy = &http_model.EasyRecruitStrategy{}
  71. recruitStrategy.StrategyId = strategy.StrategyID
  72. recruitStrategy.FeeForm = strategy.FeeForm
  73. recruitStrategy.RecruitNumber = strategy.RecruitNumber
  74. project.RecruitStrategy = append(project.RecruitStrategy, recruitStrategy)
  75. }
  76. }
  77. // 2.4. 判断是否加入商单
  78. //sProjectCount, sProjectErr := db.UpdateSProjectByProjectIdAndSupplierId(ctx, project.LocalId, supplierId)
  79. //if sProjectErr != nil {
  80. // return nil, sProjectErr
  81. //}
  82. //if sProjectCount > 0 {
  83. // project.AddToListStatus = 1
  84. //} else {
  85. // project.AddToListStatus = 2
  86. //}
  87. }
  88. return fullLocalData, nil
  89. }