task_logistics_list.go 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. }