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, "", param.Page, param.PageSize) } else if param.Status == 2 { // 待签收 projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 5, param.DeliveryTime, param.Page, param.PageSize) } else if param.Status == 3 { // 已签收 projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTaskStage(projectId, 6, "", 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 } func (t TaskInfoService) SelectionRewardCashDetail(param *vo.SelectionRewardCashParam) (*vo.ReSelectionRewardCash, error) { if param.Page == 0 { param.Page = 1 } if param.PageSize == 0 { param.PageSize = 10 } selectionInfo, err := dao.SelectionInfoDAO{}.GetSelectionInfoById(param.SelectionId) if err != nil { return nil, err } rewardPoolAmount := selectionInfo.EstimatedCost rewardPoolCashed := selectionInfo.TaskReward secTaskInfos, total, err1 := dao.SecTaskInfoDao{}.GetRewardDetailByRewardStage(param.SelectionId, 2, param.Order, param.Page, param.PageSize) if err1 != nil { return nil, err1 } var talentRewardMsgs []vo.TalentRewardMsg for _, secTaskInfo := range secTaskInfos { talentInfo, _ := dao.TalentInfoDao{}.SelectTalentInfo(secTaskInfo.TalentID) talentRewardMsg := vo.TalentRewardMsg{ PhotoUrl: talentInfo.Avatar, Nickname: talentInfo.TalentNickname, Account: talentInfo.TalentWxOpenid, Gender: talentInfo.Sex, OrderNum: secTaskInfo.SaleActual, CashTime: secTaskInfo.WithdrawDate.Format("2006-01-02 15:04:05"), } talentRewardMsgs = append(talentRewardMsgs, talentRewardMsg) } talentMsgList := vo.ResultVO{ Page: param.Page, PageSize: param.PageSize, Total: total, Data: talentRewardMsgs, } reSelectionRewardCash := &vo.ReSelectionRewardCash{ RewardPoolAmount: rewardPoolAmount, RewardPoolCashed: rewardPoolCashed, CashedRate: rewardPoolCashed / rewardPoolAmount, TalentNum: total, TalentMsgList: talentMsgList, } return reSelectionRewardCash, nil }