sec_task_list.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package pack
  2. import (
  3. "fmt"
  4. "github.com/tidwall/gjson"
  5. "strconv"
  6. "youngee_m_api/model/gorm_model"
  7. "youngee_m_api/model/http_model"
  8. "github.com/caixw/lib.go/conv"
  9. )
  10. func GormSecTaskListToHttpSecTaskList(secTaskList []*gorm_model.YounggeeSecTaskInfo) []*http_model.SecTaskInfo {
  11. var resTaskTaskList []*http_model.SecTaskInfo
  12. for _, secTask := range secTaskList {
  13. secTaskH := GormSecTaskToHttpSecTask(secTask)
  14. resTaskTaskList = append(resTaskTaskList, secTaskH)
  15. }
  16. return resTaskTaskList
  17. }
  18. func GormSecTaskToHttpSecTask(secTask *gorm_model.YounggeeSecTaskInfo) *http_model.SecTaskInfo {
  19. TalentPlatformInfoSnap := secTask.TalentPlatformInfoSnap
  20. regionCode, _ := strconv.Atoi(conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "region_code"), ""))
  21. fmt.Println("粉丝数: ", strconv.Itoa(secTask.FansNum))
  22. return &http_model.SecTaskInfo{
  23. SecTaskId: secTask.TaskID,
  24. PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname"), ""),
  25. FansCount: strconv.Itoa(secTask.FansNum),
  26. HomePageCaptureUrl: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "home_page_capture_url"), ""),
  27. HomePageUrl: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "home_page_url"), ""),
  28. RegionCode: regionCode,
  29. DetailAddr: conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "detail_addr"), "") + " " + conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "receiver_name"), "") + " " + conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "phone_number"), ""),
  30. CreateDate: conv.MustString(secTask.CreateDate, ""),
  31. SelectDate: conv.MustString(secTask.SelectDate, ""),
  32. DeliveryDate: conv.MustString(secTask.DeliveryDate, ""),
  33. CompleteDate: conv.MustString(secTask.CompleteDate, ""),
  34. IsPayReward: secTask.IsPayReward,
  35. IsPayPayment: secTask.IsPayPayment,
  36. SignedTime: conv.MustString(secTask.SignedTime, "0000"),
  37. SaleNum: secTask.SaleNum,
  38. FreeStrategyId: secTask.FreeStrategyId,
  39. TalentId: secTask.TalentID,
  40. ProductId: secTask.ProductId,
  41. }
  42. }