task_logistics_list.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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)
  17. deliveryTime = deliveryTime[0:19]
  18. return &http_model.TaskLogisticsPreview{
  19. TaskID: conv.MustString(TaskLogisticsInfo.TaskID),
  20. PlatformNickname: conv.MustString(TaskLogisticsInfo.PlatformNickname),
  21. FansCount: conv.MustString(TaskLogisticsInfo.FansCount),
  22. RecruitStrategyID: conv.MustString(TaskLogisticsInfo.RecruitStrategyID),
  23. StrategyID: conv.MustString(TaskLogisticsInfo.StrategyID),
  24. DetailAddr: conv.MustString(TaskLogisticsInfo.DetailAddr),
  25. CompanyName: conv.MustString(TaskLogisticsInfo.CompanyName),
  26. LogisticsNumber: conv.MustString(TaskLogisticsInfo.LogisticsNumber),
  27. DeliveryTime: deliveryTime,
  28. ExplorestoreStarttime: TaskLogisticsInfo.ExplorestoreStarttime,
  29. ExplorestoreEndtime: TaskLogisticsInfo.ExplorestoreEndtime,
  30. ExplorestorePeriod: conv.MustString(TaskLogisticsInfo.ExplorestorePeriod),
  31. CouponCode: conv.MustString(TaskLogisticsInfo.CouponCode),
  32. }
  33. }
  34. func TaskLogisticsToTaskInfo(TaskLogisticss []*http_model.TaskLogistics) []*http_model.TaskLogisticsInfo {
  35. var TaskLogisticsInfos []*http_model.TaskLogisticsInfo
  36. for _, TaskLogistics := range TaskLogisticss {
  37. TaskLogistics := GetTalentInfoStruct(TaskLogistics)
  38. TaskLogisticsInfos = append(TaskLogisticsInfos, TaskLogistics)
  39. }
  40. return TaskLogisticsInfos
  41. }
  42. func GetTalentInfoStruct(TaskLogistics *http_model.TaskLogistics) *http_model.TaskLogisticsInfo {
  43. TalentPlatformInfoSnap := TaskLogistics.Talent.TalentPlatformInfoSnap
  44. TalentPostAddrSnap := TaskLogistics.Talent.TalentPostAddrSnap
  45. return &http_model.TaskLogisticsInfo{
  46. TaskID: TaskLogistics.Talent.TaskID,
  47. PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "PlatformInfo.platform_name")),
  48. FansCount: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count")),
  49. StrategyID: TaskLogistics.Talent.StrategyID,
  50. DetailAddr: conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr")),
  51. CompanyName: TaskLogistics.Logistics.CompanyName,
  52. LogisticsNumber: TaskLogistics.Logistics.LogisticsNumber,
  53. DeliveryTime: conv.MustString(TaskLogistics.Logistics.DeliveryTime),
  54. ExplorestoreStarttime: TaskLogistics.Logistics.ExplorestoreStarttime,
  55. ExplorestoreEndtime: TaskLogistics.Logistics.ExplorestoreEndtime,
  56. ExplorestorePeriod: TaskLogistics.Logistics.ExplorestorePeriod,
  57. CouponCode: TaskLogistics.Logistics.CouponCodeInformation,
  58. }
  59. }