task_info_service.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package service
  2. import (
  3. "youngee_b_api/app/dao"
  4. "youngee_b_api/app/entity"
  5. "youngee_b_api/app/vo"
  6. )
  7. type TaskInfoService struct{}
  8. func (t TaskInfoService) LogisticsTalentList(param *vo.LogisticsTalentParam) (*vo.ResultVO, error) {
  9. if param.Page <= 0 {
  10. param.Page = 1
  11. }
  12. if param.PageSize <= 0 {
  13. param.PageSize = 10
  14. }
  15. var reLogisticsTalents []*vo.ReLogisticsTalent
  16. var total int64
  17. result := vo.ResultVO{
  18. Page: param.Page,
  19. PageSize: param.PageSize,
  20. Total: total,
  21. Data: reLogisticsTalents,
  22. }
  23. var projectTaskInfos []*entity.ProjectTaskInfo
  24. var err error
  25. projectId := param.ProjectId
  26. if param.Status == 1 { // 待发货
  27. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 4, nil, param.Page, param.PageSize)
  28. } else if param.Status == 2 { // 待签收
  29. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 5, &param.DeliveryTime, param.Page, param.PageSize)
  30. } else if param.Status == 3 { // 已签收
  31. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 6, nil, param.Page, param.PageSize)
  32. }
  33. if err != nil {
  34. return nil, err
  35. }
  36. for _, projectTaskInfo := range projectTaskInfos {
  37. // 获取达人信息
  38. talentInfo, err := dao.TalentInfoDao{}.SelectTalentInfo(projectTaskInfo.TalentID)
  39. if err != nil {
  40. return nil, err
  41. }
  42. regionName, err := dao.RegionInfoDao{}.SelectRegion(talentInfo.VisitStoreRegion)
  43. if err != nil {
  44. regionName = ""
  45. }
  46. taskLogistics, err := dao.TaskLogisticsDao{}.SelectTaskLogistics(projectTaskInfo.TaskID)
  47. if err != nil {
  48. return nil, err
  49. }
  50. talentPreview := &vo.TalentPreview{
  51. TalentId: projectTaskInfo.TalentID,
  52. TalentPhoto: talentInfo.Avatar,
  53. TalentName: talentInfo.TalentWxNickname,
  54. Account: "",
  55. Location: regionName,
  56. }
  57. reLogisticsTalent := &vo.ReLogisticsTalent{
  58. TalentPostAddrSnap: projectTaskInfo.TalentPostAddrSnap,
  59. ReTalentPreview: talentPreview,
  60. LogisticsId: taskLogistics.LogisticsID,
  61. CompanyName: taskLogistics.CompanyName,
  62. LogisticsNumber: taskLogistics.LogisticsNumber,
  63. Operator: "",
  64. //DeliveryTime: taskLogistics.DeliveryTime.Format("2006-01-02 15:04:05"),
  65. //SignedTime: taskLogistics.SignedTime.Format("2006-01-02 15:04:05"),
  66. }
  67. if param.Status == 2 {
  68. reLogisticsTalent.DeliveryTime = projectTaskInfo.DeliveryDate.Format("2006-01-02 15:04:05")
  69. }
  70. if param.Status == 3 {
  71. reLogisticsTalent.SignedTime = projectTaskInfo.SignedTime.Format("2006-01-02 15:04:05")
  72. }
  73. reLogisticsTalents = append(reLogisticsTalents, reLogisticsTalent)
  74. }
  75. result = vo.ResultVO{
  76. Page: param.Page,
  77. PageSize: param.PageSize,
  78. Total: total,
  79. Data: reLogisticsTalents,
  80. }
  81. return &result, nil
  82. }