task_info_service.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. // 达人物流管理
  9. func (t TaskInfoService) LogisticsTalentList(param *vo.LogisticsTalentParam) (*vo.ResultVO, error) {
  10. if param.Page <= 0 {
  11. param.Page = 1
  12. }
  13. if param.PageSize <= 0 {
  14. param.PageSize = 10
  15. }
  16. var reLogisticsTalents []*vo.ReLogisticsTalent
  17. var total int64
  18. result := vo.ResultVO{
  19. Page: param.Page,
  20. PageSize: param.PageSize,
  21. Total: total,
  22. Data: reLogisticsTalents,
  23. }
  24. var projectTaskInfos []*entity.ProjectTaskInfo
  25. var err error
  26. projectId := param.ProjectId
  27. if param.Status == 1 { // 待发货
  28. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 4, "", param.Page, param.PageSize)
  29. } else if param.Status == 2 { // 待签收
  30. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 5, param.DeliveryTime, param.Page, param.PageSize)
  31. } else if param.Status == 3 { // 已签收
  32. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 6, "", param.Page, param.PageSize)
  33. }
  34. if err != nil {
  35. return nil, err
  36. }
  37. for _, projectTaskInfo := range projectTaskInfos {
  38. // 获取达人信息
  39. talentInfo, err := dao.TalentInfoDao{}.SelectTalentInfo(projectTaskInfo.TalentID)
  40. if err != nil {
  41. return nil, err
  42. }
  43. regionName, err := dao.RegionInfoDao{}.SelectRegion(talentInfo.VisitStoreRegion)
  44. if err != nil {
  45. regionName = ""
  46. }
  47. taskLogistics, err := dao.TaskLogisticsDao{}.SelectTaskLogistics(projectTaskInfo.TaskID)
  48. if err != nil {
  49. return nil, err
  50. }
  51. talentPreview := &vo.TalentPreview{
  52. TalentId: projectTaskInfo.TalentID,
  53. TalentPhoto: talentInfo.Avatar,
  54. TalentName: talentInfo.TalentWxNickname,
  55. Account: "",
  56. Location: regionName,
  57. }
  58. reLogisticsTalent := &vo.ReLogisticsTalent{
  59. TalentPostAddrSnap: projectTaskInfo.TalentPostAddrSnap,
  60. ReTalentPreview: talentPreview,
  61. LogisticsId: taskLogistics.LogisticsID,
  62. CompanyName: taskLogistics.CompanyName,
  63. LogisticsNumber: taskLogistics.LogisticsNumber,
  64. Operator: "",
  65. //DeliveryTime: taskLogistics.DeliveryTime.Format("2006-01-02 15:04:05"),
  66. //SignedTime: taskLogistics.SignedTime.Format("2006-01-02 15:04:05"),
  67. }
  68. if param.Status == 2 {
  69. reLogisticsTalent.DeliveryTime = projectTaskInfo.DeliveryDate.Format("2006-01-02 15:04:05")
  70. }
  71. if param.Status == 3 {
  72. reLogisticsTalent.SignedTime = projectTaskInfo.SignedTime.Format("2006-01-02 15:04:05")
  73. }
  74. reLogisticsTalents = append(reLogisticsTalents, reLogisticsTalent)
  75. }
  76. result = vo.ResultVO{
  77. Page: param.Page,
  78. PageSize: param.PageSize,
  79. Total: total,
  80. Data: reLogisticsTalents,
  81. }
  82. return &result, nil
  83. }
  84. func (t TaskInfoService) SelectionRewardCashDetail(param *vo.SelectionRewardCashParam) (*vo.ReSelectionRewardCash, error) {
  85. if param.Page == 0 {
  86. param.Page = 1
  87. }
  88. if param.PageSize == 0 {
  89. param.PageSize = 10
  90. }
  91. selectionInfo, err := dao.SelectionInfoDAO{}.GetSelectionInfoById(param.SelectionId)
  92. if err != nil {
  93. return nil, err
  94. }
  95. rewardPoolAmount := selectionInfo.EstimatedCost
  96. rewardPoolCashed := selectionInfo.TaskReward
  97. secTaskInfos, total, err1 := dao.SecTaskInfoDao{}.GetRewardDetailByRewardStage(param.SelectionId, 2, param.Order, param.Page, param.PageSize)
  98. if err1 != nil {
  99. return nil, err1
  100. }
  101. var talentRewardMsgs []vo.TalentRewardMsg
  102. for _, secTaskInfo := range secTaskInfos {
  103. talentInfo, _ := dao.TalentInfoDao{}.SelectTalentInfo(secTaskInfo.TalentID)
  104. talentRewardMsg := vo.TalentRewardMsg{
  105. PhotoUrl: talentInfo.Avatar,
  106. Nickname: talentInfo.TalentNickname,
  107. Account: talentInfo.TalentWxOpenid,
  108. Gender: talentInfo.Sex,
  109. OrderNum: secTaskInfo.SaleActual,
  110. CashTime: secTaskInfo.WithdrawDate.Format("2006-01-02 15:04:05"),
  111. }
  112. talentRewardMsgs = append(talentRewardMsgs, talentRewardMsg)
  113. }
  114. talentMsgList := vo.ResultVO{
  115. Page: param.Page,
  116. PageSize: param.PageSize,
  117. Total: total,
  118. Data: talentRewardMsgs,
  119. }
  120. reSelectionRewardCash := &vo.ReSelectionRewardCash{
  121. RewardPoolAmount: rewardPoolAmount,
  122. RewardPoolCashed: rewardPoolCashed,
  123. CashedRate: rewardPoolCashed / rewardPoolAmount,
  124. TalentNum: total,
  125. TalentMsgList: talentMsgList,
  126. }
  127. return reSelectionRewardCash, nil
  128. }