task_logistics_list.go 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package pack
  2. import (
  3. "youngee_m_api/model/http_model"
  4. "github.com/caixw/lib.go/conv"
  5. "github.com/tidwall/gjson"
  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, "")
  17. deliveryTime = deliveryTime[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: conv.MustString(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. ExplorestoreStarttime: TaskLogisticsInfo.ExplorestoreStarttime,
  35. ExplorestoreEndtime: TaskLogisticsInfo.ExplorestoreEndtime,
  36. ExplorestorePeriod: conv.MustString(TaskLogisticsInfo.ExplorestorePeriod, ""),
  37. CouponCode: conv.MustString(TaskLogisticsInfo.CouponCode, ""),
  38. SignedTime: SignedTime,
  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: conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr"), "") + TaskLogistics.Region,
  64. CompanyName: TaskLogistics.Logistics.CompanyName,
  65. LogisticsNumber: TaskLogistics.Logistics.LogisticsNumber,
  66. DeliveryTime: conv.MustString(TaskLogistics.Logistics.DeliveryTime, ""),
  67. ExplorestoreStarttime: TaskLogistics.Logistics.ExplorestoreStarttime,
  68. ExplorestoreEndtime: TaskLogistics.Logistics.ExplorestoreEndtime,
  69. ExplorestorePeriod: TaskLogistics.Logistics.ExplorestorePeriod,
  70. CouponCode: TaskLogistics.Logistics.CouponCodeInformation,
  71. SignedTime: SignedTime,
  72. }
  73. }