123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- package service
- import (
- "errors"
- "strconv"
- "time"
- "youngee_b_api/app/dao"
- "youngee_b_api/app/entity"
- "youngee_b_api/app/vo"
- )
- type DefaultService struct{}
- // 违约管理——违约公开任务列表
- func (s DefaultService) GetPublicDefaultList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
- if param.Page <= 0 {
- param.Page = 1
- }
- if param.PageSize <= 0 {
- param.PageSize = 10
- }
- var result vo.ResultVO
- // 种草
- if param.TaskType == 1 {
- reTaskDefaultPublics, total, err := (&dao.ProjectDAO{}).GetProjectPublicList(param)
- if err != nil {
- return result, err
- }
- for i := range reTaskDefaultPublics {
- // 获取商品详情字段
- var creatorName string
- var productName string
- var productPrice float64
- var mainImage string
- if reTaskDefaultPublics[i].SubAccountId == 0 {
- enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reTaskDefaultPublics[i].EnterpriseId)
- if err == nil && enterprise != nil {
- creatorName = enterprise.BusinessName
- }
- } else {
- subAccount, err := dao.SubAccountDao{}.GetSubAccount(reTaskDefaultPublics[i].SubAccountId)
- if err == nil && subAccount != nil {
- creatorName = subAccount.SubAccountName
- }
- }
- product, err := dao.ProductDAO{}.GetProductByID(reTaskDefaultPublics[i].ProductId)
- if err == nil && product != nil {
- productName = product.ProductName
- productPrice = product.ProductPrice
- }
- mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(reTaskDefaultPublics[i].ProductId)
- reTaskDefaultPublics[i].CreatorName = creatorName
- reTaskDefaultPublics[i].ProductName = productName
- reTaskDefaultPublics[i].ProductPrice = productPrice
- reTaskDefaultPublics[i].MainImage = mainImage
- // 获取未传数量字段 0-10分别表示未违约、脚本超时违约、脚本未上传违约、初稿超时违约、初稿未上传违约、链接超时违约、链接未上传违约、数据超时违约、数据未上传违约、解约待处理、解约
- projectId := reTaskDefaultPublics[i].TaskId
- noSketchNum := dao.ProjectTaskInfoDao{}.CountByDefaultType(projectId, 4)
- noLinkNum := dao.ProjectTaskInfoDao{}.CountByDefaultType(projectId, 6)
- noDataNum := dao.ProjectTaskInfoDao{}.CountByDefaultType(projectId, 8)
- // 终止合作还是解约字段待确认
- endCooperationNum := dao.ProjectTaskInfoDao{}.CountByTaskStage(projectId, 16)
- reTaskDefaultPublics[i].NoSketchNum = noSketchNum
- reTaskDefaultPublics[i].NoLinkNum = noLinkNum
- reTaskDefaultPublics[i].NoDataNum = noDataNum
- reTaskDefaultPublics[i].EndCooperationNum = endCooperationNum
- }
- result = vo.ResultVO{
- Page: param.Page,
- PageSize: param.PageSize,
- Total: total,
- Data: reTaskDefaultPublics,
- }
- return result, nil
- // 本地生活
- } else if param.TaskType == 2 {
- reTaskDefaultPublics, total, err := (&dao.ProjectDAO{}).GetProjectPublicList(param)
- if err != nil {
- return result, err
- }
- for i := range reTaskDefaultPublics {
- // 获取商品详情字段
- var creatorName string
- var storeName string
- var storeLocation string
- //var productPrice float64
- var mainImage string
- if reTaskDefaultPublics[i].SubAccountId == 0 {
- enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reTaskDefaultPublics[i].EnterpriseId)
- if err == nil && enterprise != nil {
- creatorName = enterprise.BusinessName
- }
- } else {
- subAccount, err := dao.SubAccountDao{}.GetSubAccount(reTaskDefaultPublics[i].SubAccountId)
- if err == nil && subAccount != nil {
- creatorName = subAccount.SubAccountName
- }
- }
- store, err := dao.StoreDao{}.GetStoreByID(reTaskDefaultPublics[i].StoreId)
- if err == nil && store != nil {
- storeName = store.StoreName
- storeLocation = store.StoreLocation
- }
- mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(reTaskDefaultPublics[i].StoreId)
- reTaskDefaultPublics[i].CreatorName = creatorName
- reTaskDefaultPublics[i].StoreName = storeName
- reTaskDefaultPublics[i].StoreLocation = storeLocation
- reTaskDefaultPublics[i].MainImage = mainImage
- // 获取未传数量字段 0-10分别表示未违约、脚本超时违约、脚本未上传违约、初稿超时违约、初稿未上传违约、链接超时违约、链接未上传违约、数据超时违约、数据未上传违约、解约待处理、解约
- localId := reTaskDefaultPublics[i].TaskId
- noSketchNum := dao.LocalLifeTaskInfoDao{}.CountByDefaultType(localId, 4)
- noLinkNum := dao.LocalLifeTaskInfoDao{}.CountByDefaultType(localId, 6)
- noDataNum := dao.LocalLifeTaskInfoDao{}.CountByDefaultType(localId, 8)
- // 终止合作还是解约字段待确认
- endCooperationNum := dao.LocalLifeTaskInfoDao{}.CountByTaskStage(localId, 16)
- reTaskDefaultPublics[i].NoSketchNum = noSketchNum
- reTaskDefaultPublics[i].NoLinkNum = noLinkNum
- reTaskDefaultPublics[i].NoDataNum = noDataNum
- reTaskDefaultPublics[i].EndCooperationNum = endCooperationNum
- }
- result = vo.ResultVO{
- Page: param.Page,
- PageSize: param.PageSize,
- Total: total,
- Data: reTaskDefaultPublics,
- }
- return result, nil
- } else {
- return result, nil
- }
- }
- // 违约管理——违约定向任务列表
- func (s DefaultService) GetTargetDefaultList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
- if param.Page <= 0 {
- param.Page = 1
- }
- if param.PageSize <= 0 {
- param.PageSize = 10
- }
- var result vo.ResultVO
- // 以下代码只考虑了种草
- reTaskDefaultTargets, total, err := (&dao.ProjectDAO{}).GetProjectTargetList(param)
- if err != nil {
- return result, err
- }
- for i := range reTaskDefaultTargets {
- // 获取商品详情字段
- var creatorName string
- var productName string
- var productPrice float64
- var mainImage string
- if reTaskDefaultTargets[i].SubAccountId == 0 {
- enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reTaskDefaultTargets[i].EnterpriseId)
- if err == nil && enterprise != nil {
- creatorName = enterprise.BusinessName
- }
- } else {
- subAccount, err := dao.SubAccountDao{}.GetSubAccount(reTaskDefaultTargets[i].SubAccountId)
- if err == nil && subAccount != nil {
- creatorName = subAccount.SubAccountName
- }
- }
- product, err := dao.ProductDAO{}.GetProductByID(reTaskDefaultTargets[i].ProductId)
- if err == nil && product != nil {
- productName = product.ProductName
- productPrice = product.ProductPrice
- }
- mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(reTaskDefaultTargets[i].ProductId)
- reTaskDefaultTargets[i].CreatorName = creatorName
- reTaskDefaultTargets[i].ProductName = productName
- reTaskDefaultTargets[i].ProductPrice = productPrice
- reTaskDefaultTargets[i].MainImage = mainImage
- // 终止合作还是解约字段待确认
- endCooperationNum := dao.ProjectTaskInfoDao{}.CountByTaskStage(reTaskDefaultTargets[i].TaskId, 17)
- reTaskDefaultTargets[i].EndCooperationNum = endCooperationNum
- }
- result = vo.ResultVO{
- Page: param.Page,
- PageSize: param.PageSize,
- Total: total,
- Data: reTaskDefaultTargets,
- }
- return result, nil
- }
- // 违约管理——公开任务-违约达人列表
- func (s DefaultService) GetPublicDefaultTalentList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
- if param.Page <= 0 {
- param.Page = 1
- }
- if param.PageSize <= 0 {
- param.PageSize = 10
- }
- var result vo.ResultVO
- var reTalentDefaults []*vo.ReTalentDefault
- // 种草
- if param.TaskType == 1 {
- var projectTaskInfos []entity.ProjectTaskInfo
- var total int64
- var err error
- var cutRate int64 // 违约扣款比例
- defaultType := param.DefaultType
- if defaultType == 1 { // 未传初稿
- projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListBySketchDefault(param)
- autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
- infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
- cutRate = infoAutoDefault.SketchOtherNotUpload
- } else if defaultType == 2 { // 未发作品
- projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByLinkDefault(param)
- autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
- infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
- cutRate = infoAutoDefault.LinkReplaceNotUpload
- } else if defaultType == 3 { // 未传数据
- projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByDataDefault(param)
- autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
- infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
- cutRate = infoAutoDefault.DataReplaceNotUpload
- } else if defaultType == 4 { // 终止合作
- projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTerminateDefault(param)
- } else if defaultType == 5 { // 已解约
- projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByCancelDefault(param)
- }
- if err != nil {
- return result, err
- }
- for _, projectTaskInfo := range projectTaskInfos {
- talentId := projectTaskInfo.TalentID
- talentInfo, _ := dao.TalentInfoDao{}.SelectTalentInfo(talentId)
- platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.SelectUserInfo(talentId)
- reTalentDefault := &vo.ReTalentDefault{
- TalentId: talentId,
- TalentPhone: talentInfo.TalentPhoneNumber,
- TaskId: projectTaskInfo.TaskID,
- DraftFee: projectTaskInfo.DraftFee,
- OpenId: platformKuaishouUserInfo.OpenId,
- NickName: platformKuaishouUserInfo.NickName,
- HeadUri: platformKuaishouUserInfo.HeadUri,
- City: platformKuaishouUserInfo.City,
- Gender: talentInfo.Sex,
- }
- if defaultType == 1 {
- reTalentDefault.DefaultTime = projectTaskInfo.SketchMissingTime.Format("2006-01-02 15:04:05")
- reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
- } else if defaultType == 2 {
- reTalentDefault.DefaultTime = projectTaskInfo.LinkMissingTime.Format("2006-01-02 15:04:05")
- reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
- } else if defaultType == 3 {
- reTalentDefault.DefaultTime = projectTaskInfo.DataMissingTime.Format("2006-01-02 15:04:05")
- reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
- } else if defaultType == 4 {
- reTalentDefault.DefaultTime = projectTaskInfo.TerminateTime.Format("2006-01-02 15:04:05")
- reTalentDefault.Reason = projectTaskInfo.TerminateReason
- terminateOperatorType := projectTaskInfo.TerminateOperatorType
- if terminateOperatorType == 1 {
- enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.TerminateOperator)
- reTalentDefault.OperatorName = enterprise.BusinessName
- } else if terminateOperatorType == 2 {
- operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
- subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
- reTalentDefault.OperatorName = subAccount.SubAccountName
- } else if terminateOperatorType == 3 {
- operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
- userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
- reTalentDefault.OperatorName = userName
- }
- } else if defaultType == 5 {
- reTalentDefault.DefaultTime = projectTaskInfo.CancelTime.Format("2006-01-02 15:04:05")
- reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
- reTalentDefault.Reason = projectTaskInfo.CancelReason
- cancelOperatorType := projectTaskInfo.CancelOperatorType
- if cancelOperatorType == 1 {
- enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.CancelOperator)
- reTalentDefault.OperatorName = enterprise.BusinessName
- } else if cancelOperatorType == 2 {
- operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
- subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
- reTalentDefault.OperatorName = subAccount.SubAccountName
- } else if cancelOperatorType == 3 {
- operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
- userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
- reTalentDefault.OperatorName = userName
- }
- }
- reTalentDefaults = append(reTalentDefaults, reTalentDefault)
- }
- resultMap := make(map[string]interface{})
- resultMap["cutRate"] = cutRate
- resultMap["reTalentDefaults"] = reTalentDefaults
- result = vo.ResultVO{
- Page: param.Page,
- PageSize: param.PageSize,
- Total: total,
- Data: resultMap,
- }
- return result, nil
- // 本地生活
- } else if param.TaskType == 2 {
- var localLifeTaskInfos []entity.LocalLifeTaskInfo
- var total int64
- var err error
- var cutRate int64 // 违约扣款比例
- defaultType := param.DefaultType
- if defaultType == 1 { // 未传初稿
- localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListBySketchDefault(param)
- autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
- infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
- cutRate = infoAutoDefault.SketchOtherNotUpload
- } else if defaultType == 2 { // 未发作品
- localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByLinkDefault(param)
- autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
- infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
- cutRate = infoAutoDefault.LinkReplaceNotUpload
- } else if defaultType == 3 { // 未传数据
- localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByDataDefault(param)
- autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
- infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
- cutRate = infoAutoDefault.DataReplaceNotUpload
- } else if defaultType == 4 { // 终止合作
- localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByTerminateDefault(param)
- } else if defaultType == 5 { // 已解约
- localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByCancelDefault(param)
- }
- if err != nil {
- return result, err
- }
- for _, localLifeTaskInfo := range localLifeTaskInfos {
- talentId := localLifeTaskInfo.TalentID
- talentInfo, _ := dao.TalentInfoDao{}.SelectTalentInfo(talentId)
- platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.SelectUserInfo(talentId)
- reTalentDefault := &vo.ReTalentDefault{
- TalentId: talentId,
- TalentPhone: talentInfo.TalentPhoneNumber,
- TaskId: localLifeTaskInfo.TaskID,
- DraftFee: localLifeTaskInfo.DraftFee,
- OpenId: platformKuaishouUserInfo.OpenId,
- NickName: platformKuaishouUserInfo.NickName,
- HeadUri: platformKuaishouUserInfo.HeadUri,
- City: platformKuaishouUserInfo.City,
- Gender: talentInfo.Sex,
- }
- if defaultType == 1 {
- reTalentDefault.DefaultTime = localLifeTaskInfo.SketchMissingTime.Format("2006-01-02 15:04:05")
- reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
- } else if defaultType == 2 {
- reTalentDefault.DefaultTime = localLifeTaskInfo.LinkMissingTime.Format("2006-01-02 15:04:05")
- reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
- } else if defaultType == 3 {
- reTalentDefault.DefaultTime = localLifeTaskInfo.DataMissingTime.Format("2006-01-02 15:04:05")
- reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
- } else if defaultType == 4 {
- reTalentDefault.DefaultTime = localLifeTaskInfo.TerminateTime.Format("2006-01-02 15:04:05")
- reTalentDefault.Reason = localLifeTaskInfo.TerminateReason
- terminateOperatorType := localLifeTaskInfo.TerminateOperatorType
- if terminateOperatorType == 1 {
- enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(localLifeTaskInfo.TerminateOperator)
- reTalentDefault.OperatorName = enterprise.BusinessName
- } else if terminateOperatorType == 2 {
- operatorId, _ := strconv.ParseInt(localLifeTaskInfo.TerminateOperator, 10, 64)
- subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
- reTalentDefault.OperatorName = subAccount.SubAccountName
- } else if terminateOperatorType == 3 {
- operatorId, _ := strconv.ParseInt(localLifeTaskInfo.TerminateOperator, 10, 64)
- userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
- reTalentDefault.OperatorName = userName
- }
- } else if defaultType == 5 {
- reTalentDefault.DefaultTime = localLifeTaskInfo.CancelTime.Format("2006-01-02 15:04:05")
- reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
- reTalentDefault.Reason = localLifeTaskInfo.CancelReason
- cancelOperatorType := localLifeTaskInfo.CancelOperatorType
- if cancelOperatorType == 1 {
- enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(localLifeTaskInfo.CancelOperator)
- reTalentDefault.OperatorName = enterprise.BusinessName
- } else if cancelOperatorType == 2 {
- operatorId, _ := strconv.ParseInt(localLifeTaskInfo.CancelOperator, 10, 64)
- subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
- reTalentDefault.OperatorName = subAccount.SubAccountName
- } else if cancelOperatorType == 3 {
- operatorId, _ := strconv.ParseInt(localLifeTaskInfo.CancelOperator, 10, 64)
- userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
- reTalentDefault.OperatorName = userName
- }
- }
- reTalentDefaults = append(reTalentDefaults, reTalentDefault)
- }
- resultMap := make(map[string]interface{})
- resultMap["cutRate"] = cutRate
- resultMap["reTalentDefaults"] = reTalentDefaults
- result = vo.ResultVO{
- Page: param.Page,
- PageSize: param.PageSize,
- Total: total,
- Data: resultMap,
- }
- return result, nil
- } else {
- return result, nil
- }
- }
- // 违约管理——公开任务-违约达人列表角标
- func (s DefaultService) GetPublicDefaultTalentCount(param *vo.DefaultSearchParam) (map[string]int64, error) {
- res := make(map[string]int64)
- var noSketchNum int64
- var noLinkNum int64
- var noDataNum int64
- var endCooperationNum int64
- if param.TaskType == 1 {
- noSketchNum = dao.ProjectTaskInfoDao{}.CountByDefaultType(param.TaskId, 4)
- noLinkNum = dao.ProjectTaskInfoDao{}.CountByDefaultType(param.TaskId, 6)
- noDataNum = dao.ProjectTaskInfoDao{}.CountByDefaultType(param.TaskId, 8)
- // 终止合作还是解约字段待确认
- endCooperationNum = dao.ProjectTaskInfoDao{}.CountByTaskStage(param.TaskId, 16)
- } else {
- noSketchNum = dao.LocalLifeTaskInfoDao{}.CountByDefaultType(param.TaskId, 4)
- noLinkNum = dao.LocalLifeTaskInfoDao{}.CountByDefaultType(param.TaskId, 6)
- noDataNum = dao.LocalLifeTaskInfoDao{}.CountByDefaultType(param.TaskId, 8)
- // 终止合作还是解约字段待确认
- endCooperationNum = dao.LocalLifeTaskInfoDao{}.CountByTaskStage(param.TaskId, 16)
- }
- res["noSketchNum"] = noSketchNum
- res["noLinkNum"] = noLinkNum
- res["noDataNum"] = noDataNum
- res["endCooperationNum"] = endCooperationNum
- return res, nil
- }
- // 违约管理——定向任务-违约达人列表
- func (s DefaultService) GetTargetDefaultTalentList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
- if param.Page <= 0 {
- param.Page = 1
- }
- if param.PageSize <= 0 {
- param.PageSize = 10
- }
- var result vo.ResultVO
- var reTalentDefaults []*vo.ReTalentDefault
- // 以下代码只考虑了种草
- var projectTaskInfos []entity.ProjectTaskInfo
- var total int64
- var err error
- defaultType := param.DefaultType
- if defaultType == 4 { // 终止合作
- projectTaskInfos, total, err = (&dao.ProjectTaskInfoDao{}).GetListByTerminateDefault(param)
- } else if defaultType == 5 { // 已解约
- projectTaskInfos, total, err = (&dao.ProjectTaskInfoDao{}).GetListByCancelDefault(param)
- }
- if err != nil {
- return result, err
- }
- for _, projectTaskInfo := range projectTaskInfos {
- talentId := projectTaskInfo.TalentID
- talentPhone, _ := dao.TalentInfoDao{}.SelectTalentPhone(talentId)
- platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.SelectUserInfo(talentId)
- reTalentDefault := &vo.ReTalentDefault{
- TalentId: talentId,
- TalentPhone: *talentPhone,
- DraftFee: projectTaskInfo.DraftFee,
- OpenId: platformKuaishouUserInfo.OpenId,
- NickName: platformKuaishouUserInfo.NickName,
- HeadUri: platformKuaishouUserInfo.HeadUri,
- City: "-",
- }
- if defaultType == 4 {
- reTalentDefault.DefaultTime = projectTaskInfo.TerminateTime.Format("2006-01-02 15:04:05")
- reTalentDefault.Reason = projectTaskInfo.TerminateReason
- terminateOperatorType := projectTaskInfo.TerminateOperatorType
- if terminateOperatorType == 1 {
- enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.TerminateOperator)
- reTalentDefault.OperatorName = enterprise.BusinessName
- } else if terminateOperatorType == 2 {
- operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
- subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
- reTalentDefault.OperatorName = subAccount.SubAccountName
- } else if terminateOperatorType == 3 {
- operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
- userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
- reTalentDefault.OperatorName = userName
- }
- } else if defaultType == 5 {
- reTalentDefault.DefaultTime = projectTaskInfo.CancelTime.Format("2006-01-02 15:04:05")
- reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
- cancelOperatorType := projectTaskInfo.CancelOperatorType
- if cancelOperatorType == 1 {
- enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.CancelOperator)
- reTalentDefault.OperatorName = enterprise.BusinessName
- } else if cancelOperatorType == 2 {
- operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
- subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
- reTalentDefault.OperatorName = subAccount.SubAccountName
- } else if cancelOperatorType == 3 {
- operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
- userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
- reTalentDefault.OperatorName = userName
- }
- }
- reTalentDefaults = append(reTalentDefaults, reTalentDefault)
- }
- result = vo.ResultVO{
- Page: param.Page,
- PageSize: param.PageSize,
- Total: total,
- Data: reTalentDefaults,
- }
- return result, nil
- }
- // 违约管理——达人解约
- func (s DefaultService) CancelTalent(param *vo.TalentCancelParam) error {
- if param.TaskId == "" {
- return errors.New("taskId is empty")
- }
- updateData := map[string]interface{}{
- "task_stage": 16,
- "settle_amount": param.RealPayment,
- "real_payment": param.RealPayment,
- "cancel_reason": param.CancelReason,
- "cancel_time": time.Now(),
- }
- if param.SubAccountId == 0 {
- updateData["cancel_operator_type"] = 1
- updateData["cancel_operator"] = param.EnterpriseId
- } else {
- updateData["cancel_operator_type"] = 2
- updateData["cancel_operator"] = strconv.FormatInt(param.SubAccountId, 10)
- }
- err := dao.ProjectTaskInfoDao{}.UpdateField(param.TaskId, updateData)
- if err != nil {
- return err
- }
- return nil
- }
- // 违约管理——达人批量解约
- func (s DefaultService) CancelTalentList(param *vo.TalentCancelParam) error {
- if param.TaskIds == nil {
- return errors.New("taskIds is empty")
- }
- updateData := map[string]interface{}{
- "task_stage": 16,
- "settle_amount": param.RealPayment,
- "real_payment": param.RealPayment,
- "cancel_reason": param.CancelReason,
- "cancel_time": time.Now(),
- }
- if param.SubAccountId == 0 {
- updateData["cancel_operator_type"] = 1
- updateData["cancel_operator"] = param.EnterpriseId
- } else {
- updateData["cancel_operator_type"] = 2
- updateData["cancel_operator"] = strconv.FormatInt(param.SubAccountId, 10)
- }
- err := dao.ProjectTaskInfoDao{}.UpdateFieldBatch(param.TaskIds, updateData)
- if err != nil {
- return err
- }
- return nil
- }
|