task_logistics_list.go 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. package pack
  2. import (
  3. "youngee_b_api/model/http_model"
  4. "github.com/tidwall/gjson"
  5. "github.com/issue9/conv"
  6. )
  7. func MGormTaskLogisticsInfoListToHttpTaskLogisticsPreviewList(gormTaskLogisticsInfos []*http_model.TaskLogisticsInfo) []*http_model.TaskLogisticsPreview {
  8. var httpProjectPreviews []*http_model.TaskLogisticsPreview
  9. for _, gormTaskLogisticsInfo := range gormTaskLogisticsInfos {
  10. httpTaskLogisticsPreview := MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(gormTaskLogisticsInfo)
  11. httpProjectPreviews = append(httpProjectPreviews, httpTaskLogisticsPreview)
  12. }
  13. return httpProjectPreviews
  14. }
  15. func MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(TaskLogisticsInfo *http_model.TaskLogisticsInfo) *http_model.TaskLogisticsPreview {
  16. deliveryTime := conv.MustString(TaskLogisticsInfo.DeliveryTime)[0:19]
  17. //signedTime := conv.MustString(TaskLogisticsInfo.SignedTime)[0:19]
  18. SignedTime := ""
  19. if TaskLogisticsInfo.SignedTime == "" {
  20. SignedTime = ""
  21. } else {
  22. SignedTime = TaskLogisticsInfo.SignedTime[:19]
  23. }
  24. return &http_model.TaskLogisticsPreview{
  25. TaskID: TaskLogisticsInfo.TaskID,
  26. PlatformNickname: conv.MustString(TaskLogisticsInfo.PlatformNickname),
  27. FansCount: conv.MustString(TaskLogisticsInfo.FansCount),
  28. RecruitStrategyID: conv.MustString(TaskLogisticsInfo.RecruitStrategyID),
  29. StrategyID: conv.MustString(TaskLogisticsInfo.StrategyID),
  30. DetailAddr: conv.MustString(TaskLogisticsInfo.DetailAddr),
  31. CompanyName: conv.MustString(TaskLogisticsInfo.CompanyName),
  32. LogisticsNumber: conv.MustString(TaskLogisticsInfo.LogisticsNumber),
  33. DeliveryTime: deliveryTime,
  34. SignedTime: SignedTime,
  35. ExplorestoreStarttime: TaskLogisticsInfo.ExplorestoreStarttime,
  36. ExplorestoreEndtime: TaskLogisticsInfo.ExplorestoreEndtime,
  37. ExplorestorePeriod: conv.MustString(TaskLogisticsInfo.ExplorestorePeriod),
  38. CouponCode: conv.MustString(TaskLogisticsInfo.CouponCode),
  39. }
  40. }
  41. func TaskLogisticsToTaskInfo(TaskLogisticss []*http_model.TaskLogistics) []*http_model.TaskLogisticsInfo {
  42. var TaskLogisticsInfos []*http_model.TaskLogisticsInfo
  43. for _, TaskLogistics := range TaskLogisticss {
  44. TaskLogistics := GetTalentInfoStruct(TaskLogistics)
  45. TaskLogisticsInfos = append(TaskLogisticsInfos, TaskLogistics)
  46. }
  47. return TaskLogisticsInfos
  48. }
  49. func GetTalentInfoStruct(TaskLogistics *http_model.TaskLogistics) *http_model.TaskLogisticsInfo {
  50. TalentPlatformInfoSnap := TaskLogistics.Talent.TalentPlatformInfoSnap
  51. TalentPostAddrSnap := TaskLogistics.Talent.TalentPostAddrSnap
  52. SignedTime := ""
  53. if TaskLogistics.Logistics.SignedTime == nil {
  54. SignedTime = ""
  55. } else {
  56. SignedTime = conv.MustString(TaskLogistics.Logistics.SignedTime, "")
  57. }
  58. return &http_model.TaskLogisticsInfo{
  59. TaskID: TaskLogistics.Talent.TaskID,
  60. PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname")),
  61. FansCount: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count")),
  62. StrategyID: TaskLogistics.Talent.StrategyID,
  63. DetailAddr: TaskLogistics.Region + conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr")),
  64. CompanyName: TaskLogistics.Logistics.CompanyName,
  65. LogisticsNumber: TaskLogistics.Logistics.LogisticsNumber,
  66. DeliveryTime: conv.MustString(TaskLogistics.Logistics.DeliveryTime),
  67. SignedTime: SignedTime,
  68. ExplorestoreStarttime: TaskLogistics.Logistics.ExplorestoreStarttime,
  69. ExplorestoreEndtime: TaskLogistics.Logistics.ExplorestoreEndtime,
  70. ExplorestorePeriod: TaskLogistics.Logistics.ExplorestorePeriod,
  71. CouponCode: TaskLogistics.Logistics.CouponCodeInformation,
  72. }
  73. }
  74. func MGormSpecialTaskLogisticsInfoListToHttpTaskLogisticsPreviewList(gormTaskLogisticsInfos []*http_model.SpecialTaskLogisticsInfo) []*http_model.SpecialTaskLogisticsPreview {
  75. var httpProjectPreviews []*http_model.SpecialTaskLogisticsPreview
  76. for _, gormTaskLogisticsInfo := range gormTaskLogisticsInfos {
  77. httpTaskLogisticsPreview := MGormSpecialTaskLogisticsInfoToHttpTaskLogisticsPreview(gormTaskLogisticsInfo)
  78. httpProjectPreviews = append(httpProjectPreviews, httpTaskLogisticsPreview)
  79. }
  80. return httpProjectPreviews
  81. }
  82. func MGormSpecialTaskLogisticsInfoToHttpTaskLogisticsPreview(TaskLogisticsInfo *http_model.SpecialTaskLogisticsInfo) *http_model.SpecialTaskLogisticsPreview {
  83. deliveryTime := conv.MustString(TaskLogisticsInfo.DeliveryTime, "")
  84. deliveryTime = deliveryTime[0:19]
  85. SignedTime := ""
  86. if TaskLogisticsInfo.SignedTime == "" {
  87. SignedTime = ""
  88. } else {
  89. SignedTime = TaskLogisticsInfo.SignedTime[:19]
  90. }
  91. return &http_model.SpecialTaskLogisticsPreview{
  92. TaskID: conv.MustString(TaskLogisticsInfo.TaskID, ""),
  93. PlatformNickname: conv.MustString(TaskLogisticsInfo.PlatformNickname, ""),
  94. FansCount: conv.MustString(TaskLogisticsInfo.FansCount, ""),
  95. DetailAddr: conv.MustString(TaskLogisticsInfo.DetailAddr, ""),
  96. CompanyName: conv.MustString(TaskLogisticsInfo.CompanyName, ""),
  97. LogisticsNumber: conv.MustString(TaskLogisticsInfo.LogisticsNumber, ""),
  98. DeliveryTime: deliveryTime,
  99. ExplorestoreStarttime: TaskLogisticsInfo.ExplorestoreStarttime,
  100. ExplorestoreEndtime: TaskLogisticsInfo.ExplorestoreEndtime,
  101. ExplorestorePeriod: conv.MustString(TaskLogisticsInfo.ExplorestorePeriod, ""),
  102. CouponCode: conv.MustString(TaskLogisticsInfo.CouponCode, ""),
  103. SignedTime: SignedTime,
  104. }
  105. }
  106. func SpecialTaskLogisticsToTaskInfo(TaskLogisticss []*http_model.SpecialTaskLogistics) []*http_model.SpecialTaskLogisticsInfo {
  107. var TaskLogisticsInfos []*http_model.SpecialTaskLogisticsInfo
  108. for _, TaskLogistics := range TaskLogisticss {
  109. TaskLogistics := GetSpecialTalentInfoStruct(TaskLogistics)
  110. TaskLogisticsInfos = append(TaskLogisticsInfos, TaskLogistics)
  111. }
  112. return TaskLogisticsInfos
  113. }
  114. func GetSpecialTalentInfoStruct(TaskLogistics *http_model.SpecialTaskLogistics) *http_model.SpecialTaskLogisticsInfo {
  115. TalentPlatformInfoSnap := TaskLogistics.Talent.TalentPlatformInfoSnap
  116. TalentPostAddrSnap := TaskLogistics.Talent.TalentPostAddrSnap
  117. SignedTime := ""
  118. if TaskLogistics.Logistics.SignedTime == nil {
  119. SignedTime = ""
  120. } else {
  121. SignedTime = conv.MustString(TaskLogistics.Logistics.SignedTime, "")
  122. }
  123. return &http_model.SpecialTaskLogisticsInfo{
  124. TaskID: TaskLogistics.Talent.TaskID,
  125. PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname"), ""),
  126. FansCount: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count"), ""),
  127. DetailAddr: conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr"), "") + TaskLogistics.Region,
  128. CompanyName: TaskLogistics.Logistics.CompanyName,
  129. LogisticsNumber: TaskLogistics.Logistics.LogisticsNumber,
  130. DeliveryTime: conv.MustString(TaskLogistics.Logistics.DeliveryTime, ""),
  131. ExplorestoreStarttime: TaskLogistics.Logistics.ExplorestoreStarttime,
  132. ExplorestoreEndtime: TaskLogistics.Logistics.ExplorestoreEndtime,
  133. ExplorestorePeriod: TaskLogistics.Logistics.ExplorestorePeriod,
  134. CouponCode: TaskLogistics.Logistics.CouponCodeInformation,
  135. SignedTime: SignedTime,
  136. }
  137. }