12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- package service
- import (
- "youngee_b_api/app/dao"
- "youngee_b_api/app/entity"
- "youngee_b_api/app/vo"
- )
- type TaskInfoService struct{}
- func (t TaskInfoService) LogisticsTalentList(param *vo.LogisticsTalentParam) (*vo.ResultVO, error) {
- if param.Page <= 0 {
- param.Page = 1
- }
- if param.PageSize <= 0 {
- param.PageSize = 10
- }
- var reLogisticsTalents []*vo.ReLogisticsTalent
- var total int64
- result := vo.ResultVO{
- Page: param.Page,
- PageSize: param.PageSize,
- Total: total,
- Data: reLogisticsTalents,
- }
- var projectTaskInfos []*entity.ProjectTaskInfo
- var err error
- projectId := param.ProjectId
- if param.Status == 1 { // 待发货
- projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 4, nil, param.Page, param.PageSize)
- } else if param.Status == 2 { // 待签收
- projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 5, ¶m.DeliveryTime, param.Page, param.PageSize)
- } else if param.Status == 3 { // 已签收
- projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 6, nil, param.Page, param.PageSize)
- }
- if err != nil {
- return nil, err
- }
- for _, projectTaskInfo := range projectTaskInfos {
- // 获取达人信息
- talentInfo, err := dao.TalentInfoDao{}.SelectTalentInfo(projectTaskInfo.TalentID)
- if err != nil {
- return nil, err
- }
- regionName, err := dao.RegionInfoDao{}.SelectRegion(talentInfo.VisitStoreRegion)
- if err != nil {
- regionName = ""
- }
- taskLogistics, err := dao.TaskLogisticsDao{}.SelectTaskLogistics(projectTaskInfo.TaskID)
- if err != nil {
- return nil, err
- }
- talentPreview := &vo.TalentPreview{
- TalentId: projectTaskInfo.TalentID,
- TalentPhoto: talentInfo.Avatar,
- TalentName: talentInfo.TalentWxNickname,
- Account: "",
- Location: regionName,
- }
- reLogisticsTalent := &vo.ReLogisticsTalent{
- TalentPostAddrSnap: projectTaskInfo.TalentPostAddrSnap,
- ReTalentPreview: talentPreview,
- LogisticsId: taskLogistics.LogisticsID,
- CompanyName: taskLogistics.CompanyName,
- LogisticsNumber: taskLogistics.LogisticsNumber,
- Operator: "",
- //DeliveryTime: taskLogistics.DeliveryTime.Format("2006-01-02 15:04:05"),
- //SignedTime: taskLogistics.SignedTime.Format("2006-01-02 15:04:05"),
- }
- if param.Status == 2 {
- reLogisticsTalent.DeliveryTime = projectTaskInfo.DeliveryDate.Format("2006-01-02 15:04:05")
- }
- if param.Status == 3 {
- reLogisticsTalent.SignedTime = projectTaskInfo.SignedTime.Format("2006-01-02 15:04:05")
- }
- reLogisticsTalents = append(reLogisticsTalents, reLogisticsTalent)
- }
- result = vo.ResultVO{
- Page: param.Page,
- PageSize: param.PageSize,
- Total: total,
- Data: reLogisticsTalents,
- }
- return &result, nil
- }
|