default_service.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. package service
  2. import (
  3. "errors"
  4. "strconv"
  5. "time"
  6. "youngee_b_api/app/dao"
  7. "youngee_b_api/app/entity"
  8. "youngee_b_api/app/vo"
  9. )
  10. type DefaultService struct{}
  11. // 违约管理——违约公开任务列表
  12. func (s DefaultService) GetPublicDefaultList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
  13. if param.Page <= 0 {
  14. param.Page = 1
  15. }
  16. if param.PageSize <= 0 {
  17. param.PageSize = 10
  18. }
  19. var result vo.ResultVO
  20. // 种草
  21. if param.TaskType == 1 {
  22. reTaskDefaultPublics, total, err := (&dao.ProjectDAO{}).GetProjectPublicList(param)
  23. if err != nil {
  24. return result, err
  25. }
  26. for i := range reTaskDefaultPublics {
  27. // 获取商品详情字段
  28. var creatorName string
  29. var productName string
  30. var productPrice float64
  31. var mainImage string
  32. if reTaskDefaultPublics[i].SubAccountId == 0 {
  33. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reTaskDefaultPublics[i].EnterpriseId)
  34. if err == nil && enterprise != nil {
  35. creatorName = enterprise.BusinessName
  36. }
  37. } else {
  38. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reTaskDefaultPublics[i].SubAccountId)
  39. if err == nil && subAccount != nil {
  40. creatorName = subAccount.SubAccountName
  41. }
  42. }
  43. product, err := dao.ProductDAO{}.GetProductByID(reTaskDefaultPublics[i].ProductId)
  44. if err == nil && product != nil {
  45. productName = product.ProductName
  46. productPrice = product.ProductPrice
  47. }
  48. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(reTaskDefaultPublics[i].ProductId)
  49. reTaskDefaultPublics[i].CreatorName = creatorName
  50. reTaskDefaultPublics[i].ProductName = productName
  51. reTaskDefaultPublics[i].ProductPrice = productPrice
  52. reTaskDefaultPublics[i].MainImage = mainImage
  53. // 获取未传数量字段 0-10分别表示未违约、脚本超时违约、脚本未上传违约、初稿超时违约、初稿未上传违约、链接超时违约、链接未上传违约、数据超时违约、数据未上传违约、解约待处理、解约
  54. projectId := reTaskDefaultPublics[i].TaskId
  55. noSketchNum := dao.ProjectTaskInfoDao{}.CountByDefaultType(projectId, 4)
  56. noLinkNum := dao.ProjectTaskInfoDao{}.CountByDefaultType(projectId, 6)
  57. noDataNum := dao.ProjectTaskInfoDao{}.CountByDefaultType(projectId, 8)
  58. // 终止合作还是解约字段待确认
  59. endCooperationNum := dao.ProjectTaskInfoDao{}.CountByTaskStage(projectId, 16)
  60. reTaskDefaultPublics[i].NoSketchNum = noSketchNum
  61. reTaskDefaultPublics[i].NoLinkNum = noLinkNum
  62. reTaskDefaultPublics[i].NoDataNum = noDataNum
  63. reTaskDefaultPublics[i].EndCooperationNum = endCooperationNum
  64. }
  65. result = vo.ResultVO{
  66. Page: param.Page,
  67. PageSize: param.PageSize,
  68. Total: total,
  69. Data: reTaskDefaultPublics,
  70. }
  71. return result, nil
  72. // 本地生活
  73. } else if param.TaskType == 2 {
  74. reTaskDefaultPublics, total, err := (&dao.ProjectDAO{}).GetProjectPublicList(param)
  75. if err != nil {
  76. return result, err
  77. }
  78. for i := range reTaskDefaultPublics {
  79. // 获取商品详情字段
  80. var creatorName string
  81. var storeName string
  82. var storeLocation string
  83. //var productPrice float64
  84. var mainImage string
  85. if reTaskDefaultPublics[i].SubAccountId == 0 {
  86. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reTaskDefaultPublics[i].EnterpriseId)
  87. if err == nil && enterprise != nil {
  88. creatorName = enterprise.BusinessName
  89. }
  90. } else {
  91. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reTaskDefaultPublics[i].SubAccountId)
  92. if err == nil && subAccount != nil {
  93. creatorName = subAccount.SubAccountName
  94. }
  95. }
  96. store, err := dao.StoreDao{}.GetStoreByID(reTaskDefaultPublics[i].StoreId)
  97. if err == nil && store != nil {
  98. storeName = store.StoreName
  99. storeLocation = store.StoreLocation
  100. }
  101. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByStoreID(reTaskDefaultPublics[i].StoreId)
  102. reTaskDefaultPublics[i].CreatorName = creatorName
  103. reTaskDefaultPublics[i].StoreName = storeName
  104. reTaskDefaultPublics[i].StoreLocation = storeLocation
  105. reTaskDefaultPublics[i].MainImage = mainImage
  106. // 获取未传数量字段 0-10分别表示未违约、脚本超时违约、脚本未上传违约、初稿超时违约、初稿未上传违约、链接超时违约、链接未上传违约、数据超时违约、数据未上传违约、解约待处理、解约
  107. localId := reTaskDefaultPublics[i].TaskId
  108. noSketchNum := dao.LocalLifeTaskInfoDao{}.CountByDefaultType(localId, 4)
  109. noLinkNum := dao.LocalLifeTaskInfoDao{}.CountByDefaultType(localId, 6)
  110. noDataNum := dao.LocalLifeTaskInfoDao{}.CountByDefaultType(localId, 8)
  111. // 终止合作还是解约字段待确认
  112. endCooperationNum := dao.LocalLifeTaskInfoDao{}.CountByTaskStage(localId, 16)
  113. reTaskDefaultPublics[i].NoSketchNum = noSketchNum
  114. reTaskDefaultPublics[i].NoLinkNum = noLinkNum
  115. reTaskDefaultPublics[i].NoDataNum = noDataNum
  116. reTaskDefaultPublics[i].EndCooperationNum = endCooperationNum
  117. }
  118. result = vo.ResultVO{
  119. Page: param.Page,
  120. PageSize: param.PageSize,
  121. Total: total,
  122. Data: reTaskDefaultPublics,
  123. }
  124. return result, nil
  125. } else {
  126. return result, nil
  127. }
  128. }
  129. // 违约管理——违约定向任务列表
  130. func (s DefaultService) GetTargetDefaultList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
  131. if param.Page <= 0 {
  132. param.Page = 1
  133. }
  134. if param.PageSize <= 0 {
  135. param.PageSize = 10
  136. }
  137. var result vo.ResultVO
  138. // 以下代码只考虑了种草
  139. reTaskDefaultTargets, total, err := (&dao.ProjectDAO{}).GetProjectTargetList(param)
  140. if err != nil {
  141. return result, err
  142. }
  143. for i := range reTaskDefaultTargets {
  144. // 获取商品详情字段
  145. var creatorName string
  146. var productName string
  147. var productPrice float64
  148. var mainImage string
  149. if reTaskDefaultTargets[i].SubAccountId == 0 {
  150. enterprise, err := dao.EnterpriseDao{}.GetEnterprise(reTaskDefaultTargets[i].EnterpriseId)
  151. if err == nil && enterprise != nil {
  152. creatorName = enterprise.BusinessName
  153. }
  154. } else {
  155. subAccount, err := dao.SubAccountDao{}.GetSubAccount(reTaskDefaultTargets[i].SubAccountId)
  156. if err == nil && subAccount != nil {
  157. creatorName = subAccount.SubAccountName
  158. }
  159. }
  160. product, err := dao.ProductDAO{}.GetProductByID(reTaskDefaultTargets[i].ProductId)
  161. if err == nil && product != nil {
  162. productName = product.ProductName
  163. productPrice = product.ProductPrice
  164. }
  165. mainImage, err = dao.ProductPhotoDAO{}.GetMainPhotoByProductID(reTaskDefaultTargets[i].ProductId)
  166. reTaskDefaultTargets[i].CreatorName = creatorName
  167. reTaskDefaultTargets[i].ProductName = productName
  168. reTaskDefaultTargets[i].ProductPrice = productPrice
  169. reTaskDefaultTargets[i].MainImage = mainImage
  170. // 终止合作还是解约字段待确认
  171. endCooperationNum := dao.ProjectTaskInfoDao{}.CountByTaskStage(reTaskDefaultTargets[i].TaskId, 17)
  172. reTaskDefaultTargets[i].EndCooperationNum = endCooperationNum
  173. }
  174. result = vo.ResultVO{
  175. Page: param.Page,
  176. PageSize: param.PageSize,
  177. Total: total,
  178. Data: reTaskDefaultTargets,
  179. }
  180. return result, nil
  181. }
  182. // 违约管理——公开任务-违约达人列表
  183. func (s DefaultService) GetPublicDefaultTalentList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
  184. if param.Page <= 0 {
  185. param.Page = 1
  186. }
  187. if param.PageSize <= 0 {
  188. param.PageSize = 10
  189. }
  190. var result vo.ResultVO
  191. var reTalentDefaults []*vo.ReTalentDefault
  192. // 种草
  193. if param.TaskType == 1 {
  194. var projectTaskInfos []entity.ProjectTaskInfo
  195. var total int64
  196. var err error
  197. var cutRate int64 // 违约扣款比例
  198. defaultType := param.DefaultType
  199. if defaultType == 1 { // 未传初稿
  200. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListBySketchDefault(param)
  201. autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
  202. infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
  203. cutRate = infoAutoDefault.SketchOtherNotUpload
  204. } else if defaultType == 2 { // 未发作品
  205. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByLinkDefault(param)
  206. autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
  207. infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
  208. cutRate = infoAutoDefault.LinkReplaceNotUpload
  209. } else if defaultType == 3 { // 未传数据
  210. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByDataDefault(param)
  211. autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
  212. infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
  213. cutRate = infoAutoDefault.DataReplaceNotUpload
  214. } else if defaultType == 4 { // 终止合作
  215. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByTerminateDefault(param)
  216. } else if defaultType == 5 { // 已解约
  217. projectTaskInfos, total, err = dao.ProjectTaskInfoDao{}.GetListByCancelDefault(param)
  218. }
  219. if err != nil {
  220. return result, err
  221. }
  222. for _, projectTaskInfo := range projectTaskInfos {
  223. talentId := projectTaskInfo.TalentID
  224. talentInfo, _ := dao.TalentInfoDao{}.SelectTalentInfo(talentId)
  225. platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.SelectUserInfo(talentId)
  226. reTalentDefault := &vo.ReTalentDefault{
  227. TalentId: talentId,
  228. TalentPhone: talentInfo.TalentPhoneNumber,
  229. TaskId: projectTaskInfo.TaskID,
  230. DraftFee: projectTaskInfo.DraftFee,
  231. OpenId: platformKuaishouUserInfo.OpenId,
  232. NickName: platformKuaishouUserInfo.NickName,
  233. HeadUri: platformKuaishouUserInfo.HeadUri,
  234. City: platformKuaishouUserInfo.City,
  235. Gender: talentInfo.Sex,
  236. }
  237. if defaultType == 1 {
  238. reTalentDefault.DefaultTime = projectTaskInfo.SketchMissingTime.Format("2006-01-02 15:04:05")
  239. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  240. } else if defaultType == 2 {
  241. reTalentDefault.DefaultTime = projectTaskInfo.LinkMissingTime.Format("2006-01-02 15:04:05")
  242. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  243. } else if defaultType == 3 {
  244. reTalentDefault.DefaultTime = projectTaskInfo.DataMissingTime.Format("2006-01-02 15:04:05")
  245. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  246. } else if defaultType == 4 {
  247. reTalentDefault.DefaultTime = projectTaskInfo.TerminateTime.Format("2006-01-02 15:04:05")
  248. reTalentDefault.Reason = projectTaskInfo.TerminateReason
  249. terminateOperatorType := projectTaskInfo.TerminateOperatorType
  250. if terminateOperatorType == 1 {
  251. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.TerminateOperator)
  252. reTalentDefault.OperatorName = enterprise.BusinessName
  253. } else if terminateOperatorType == 2 {
  254. operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
  255. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  256. reTalentDefault.OperatorName = subAccount.SubAccountName
  257. } else if terminateOperatorType == 3 {
  258. operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
  259. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  260. reTalentDefault.OperatorName = userName
  261. }
  262. } else if defaultType == 5 {
  263. reTalentDefault.DefaultTime = projectTaskInfo.CancelTime.Format("2006-01-02 15:04:05")
  264. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  265. reTalentDefault.Reason = projectTaskInfo.CancelReason
  266. cancelOperatorType := projectTaskInfo.CancelOperatorType
  267. if cancelOperatorType == 1 {
  268. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.CancelOperator)
  269. reTalentDefault.OperatorName = enterprise.BusinessName
  270. } else if cancelOperatorType == 2 {
  271. operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
  272. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  273. reTalentDefault.OperatorName = subAccount.SubAccountName
  274. } else if cancelOperatorType == 3 {
  275. operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
  276. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  277. reTalentDefault.OperatorName = userName
  278. }
  279. }
  280. reTalentDefaults = append(reTalentDefaults, reTalentDefault)
  281. }
  282. resultMap := make(map[string]interface{})
  283. resultMap["cutRate"] = cutRate
  284. resultMap["reTalentDefaults"] = reTalentDefaults
  285. result = vo.ResultVO{
  286. Page: param.Page,
  287. PageSize: param.PageSize,
  288. Total: total,
  289. Data: resultMap,
  290. }
  291. return result, nil
  292. // 本地生活
  293. } else if param.TaskType == 2 {
  294. var localLifeTaskInfos []entity.LocalLifeTaskInfo
  295. var total int64
  296. var err error
  297. var cutRate int64 // 违约扣款比例
  298. defaultType := param.DefaultType
  299. if defaultType == 1 { // 未传初稿
  300. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListBySketchDefault(param)
  301. autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
  302. infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
  303. cutRate = infoAutoDefault.SketchOtherNotUpload
  304. } else if defaultType == 2 { // 未发作品
  305. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByLinkDefault(param)
  306. autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
  307. infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
  308. cutRate = infoAutoDefault.LinkReplaceNotUpload
  309. } else if defaultType == 3 { // 未传数据
  310. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByDataDefault(param)
  311. autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
  312. infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
  313. cutRate = infoAutoDefault.DataReplaceNotUpload
  314. } else if defaultType == 4 { // 终止合作
  315. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByTerminateDefault(param)
  316. } else if defaultType == 5 { // 已解约
  317. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByCancelDefault(param)
  318. }
  319. if err != nil {
  320. return result, err
  321. }
  322. for _, localLifeTaskInfo := range localLifeTaskInfos {
  323. talentId := localLifeTaskInfo.TalentID
  324. talentInfo, _ := dao.TalentInfoDao{}.SelectTalentInfo(talentId)
  325. platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.SelectUserInfo(talentId)
  326. reTalentDefault := &vo.ReTalentDefault{
  327. TalentId: talentId,
  328. TalentPhone: talentInfo.TalentPhoneNumber,
  329. TaskId: localLifeTaskInfo.TaskID,
  330. DraftFee: localLifeTaskInfo.DraftFee,
  331. OpenId: platformKuaishouUserInfo.OpenId,
  332. NickName: platformKuaishouUserInfo.NickName,
  333. HeadUri: platformKuaishouUserInfo.HeadUri,
  334. City: platformKuaishouUserInfo.City,
  335. Gender: talentInfo.Sex,
  336. }
  337. if defaultType == 1 {
  338. reTalentDefault.DefaultTime = localLifeTaskInfo.SketchMissingTime.Format("2006-01-02 15:04:05")
  339. reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
  340. } else if defaultType == 2 {
  341. reTalentDefault.DefaultTime = localLifeTaskInfo.LinkMissingTime.Format("2006-01-02 15:04:05")
  342. reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
  343. } else if defaultType == 3 {
  344. reTalentDefault.DefaultTime = localLifeTaskInfo.DataMissingTime.Format("2006-01-02 15:04:05")
  345. reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
  346. } else if defaultType == 4 {
  347. reTalentDefault.DefaultTime = localLifeTaskInfo.TerminateTime.Format("2006-01-02 15:04:05")
  348. reTalentDefault.Reason = localLifeTaskInfo.TerminateReason
  349. terminateOperatorType := localLifeTaskInfo.TerminateOperatorType
  350. if terminateOperatorType == 1 {
  351. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(localLifeTaskInfo.TerminateOperator)
  352. reTalentDefault.OperatorName = enterprise.BusinessName
  353. } else if terminateOperatorType == 2 {
  354. operatorId, _ := strconv.ParseInt(localLifeTaskInfo.TerminateOperator, 10, 64)
  355. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  356. reTalentDefault.OperatorName = subAccount.SubAccountName
  357. } else if terminateOperatorType == 3 {
  358. operatorId, _ := strconv.ParseInt(localLifeTaskInfo.TerminateOperator, 10, 64)
  359. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  360. reTalentDefault.OperatorName = userName
  361. }
  362. } else if defaultType == 5 {
  363. reTalentDefault.DefaultTime = localLifeTaskInfo.CancelTime.Format("2006-01-02 15:04:05")
  364. reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
  365. reTalentDefault.Reason = localLifeTaskInfo.CancelReason
  366. cancelOperatorType := localLifeTaskInfo.CancelOperatorType
  367. if cancelOperatorType == 1 {
  368. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(localLifeTaskInfo.CancelOperator)
  369. reTalentDefault.OperatorName = enterprise.BusinessName
  370. } else if cancelOperatorType == 2 {
  371. operatorId, _ := strconv.ParseInt(localLifeTaskInfo.CancelOperator, 10, 64)
  372. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  373. reTalentDefault.OperatorName = subAccount.SubAccountName
  374. } else if cancelOperatorType == 3 {
  375. operatorId, _ := strconv.ParseInt(localLifeTaskInfo.CancelOperator, 10, 64)
  376. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  377. reTalentDefault.OperatorName = userName
  378. }
  379. }
  380. reTalentDefaults = append(reTalentDefaults, reTalentDefault)
  381. }
  382. resultMap := make(map[string]interface{})
  383. resultMap["cutRate"] = cutRate
  384. resultMap["reTalentDefaults"] = reTalentDefaults
  385. result = vo.ResultVO{
  386. Page: param.Page,
  387. PageSize: param.PageSize,
  388. Total: total,
  389. Data: resultMap,
  390. }
  391. return result, nil
  392. } else {
  393. return result, nil
  394. }
  395. }
  396. // 违约管理——公开任务-违约达人列表角标
  397. func (s DefaultService) GetPublicDefaultTalentCount(param *vo.DefaultSearchParam) (map[string]int64, error) {
  398. res := make(map[string]int64)
  399. var noSketchNum int64
  400. var noLinkNum int64
  401. var noDataNum int64
  402. var endCooperationNum int64
  403. if param.TaskType == 1 {
  404. noSketchNum = dao.ProjectTaskInfoDao{}.CountByDefaultType(param.TaskId, 4)
  405. noLinkNum = dao.ProjectTaskInfoDao{}.CountByDefaultType(param.TaskId, 6)
  406. noDataNum = dao.ProjectTaskInfoDao{}.CountByDefaultType(param.TaskId, 8)
  407. // 终止合作还是解约字段待确认
  408. endCooperationNum = dao.ProjectTaskInfoDao{}.CountByTaskStage(param.TaskId, 16)
  409. } else {
  410. noSketchNum = dao.LocalLifeTaskInfoDao{}.CountByDefaultType(param.TaskId, 4)
  411. noLinkNum = dao.LocalLifeTaskInfoDao{}.CountByDefaultType(param.TaskId, 6)
  412. noDataNum = dao.LocalLifeTaskInfoDao{}.CountByDefaultType(param.TaskId, 8)
  413. // 终止合作还是解约字段待确认
  414. endCooperationNum = dao.LocalLifeTaskInfoDao{}.CountByTaskStage(param.TaskId, 16)
  415. }
  416. res["noSketchNum"] = noSketchNum
  417. res["noLinkNum"] = noLinkNum
  418. res["noDataNum"] = noDataNum
  419. res["endCooperationNum"] = endCooperationNum
  420. return res, nil
  421. }
  422. // 违约管理——定向任务-违约达人列表
  423. func (s DefaultService) GetTargetDefaultTalentList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
  424. if param.Page <= 0 {
  425. param.Page = 1
  426. }
  427. if param.PageSize <= 0 {
  428. param.PageSize = 10
  429. }
  430. var result vo.ResultVO
  431. var reTalentDefaults []*vo.ReTalentDefault
  432. // 以下代码只考虑了种草
  433. var projectTaskInfos []entity.ProjectTaskInfo
  434. var total int64
  435. var err error
  436. defaultType := param.DefaultType
  437. if defaultType == 4 { // 终止合作
  438. projectTaskInfos, total, err = (&dao.ProjectTaskInfoDao{}).GetListByTerminateDefault(param)
  439. } else if defaultType == 5 { // 已解约
  440. projectTaskInfos, total, err = (&dao.ProjectTaskInfoDao{}).GetListByCancelDefault(param)
  441. }
  442. if err != nil {
  443. return result, err
  444. }
  445. for _, projectTaskInfo := range projectTaskInfos {
  446. talentId := projectTaskInfo.TalentID
  447. talentPhone, _ := dao.TalentInfoDao{}.SelectTalentPhone(talentId)
  448. platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.SelectUserInfo(talentId)
  449. reTalentDefault := &vo.ReTalentDefault{
  450. TalentId: talentId,
  451. TalentPhone: *talentPhone,
  452. DraftFee: projectTaskInfo.DraftFee,
  453. OpenId: platformKuaishouUserInfo.OpenId,
  454. NickName: platformKuaishouUserInfo.NickName,
  455. HeadUri: platformKuaishouUserInfo.HeadUri,
  456. City: "-",
  457. }
  458. if defaultType == 4 {
  459. reTalentDefault.DefaultTime = projectTaskInfo.TerminateTime.Format("2006-01-02 15:04:05")
  460. reTalentDefault.Reason = projectTaskInfo.TerminateReason
  461. terminateOperatorType := projectTaskInfo.TerminateOperatorType
  462. if terminateOperatorType == 1 {
  463. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.TerminateOperator)
  464. reTalentDefault.OperatorName = enterprise.BusinessName
  465. } else if terminateOperatorType == 2 {
  466. operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
  467. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  468. reTalentDefault.OperatorName = subAccount.SubAccountName
  469. } else if terminateOperatorType == 3 {
  470. operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
  471. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  472. reTalentDefault.OperatorName = userName
  473. }
  474. } else if defaultType == 5 {
  475. reTalentDefault.DefaultTime = projectTaskInfo.CancelTime.Format("2006-01-02 15:04:05")
  476. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  477. cancelOperatorType := projectTaskInfo.CancelOperatorType
  478. if cancelOperatorType == 1 {
  479. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.CancelOperator)
  480. reTalentDefault.OperatorName = enterprise.BusinessName
  481. } else if cancelOperatorType == 2 {
  482. operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
  483. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  484. reTalentDefault.OperatorName = subAccount.SubAccountName
  485. } else if cancelOperatorType == 3 {
  486. operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
  487. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  488. reTalentDefault.OperatorName = userName
  489. }
  490. }
  491. reTalentDefaults = append(reTalentDefaults, reTalentDefault)
  492. }
  493. result = vo.ResultVO{
  494. Page: param.Page,
  495. PageSize: param.PageSize,
  496. Total: total,
  497. Data: reTalentDefaults,
  498. }
  499. return result, nil
  500. }
  501. // 违约管理——达人解约
  502. func (s DefaultService) CancelTalent(param *vo.TalentCancelParam) error {
  503. if param.TaskId == "" {
  504. return errors.New("taskId is empty")
  505. }
  506. updateData := map[string]interface{}{
  507. "task_stage": 16,
  508. "settle_amount": param.RealPayment,
  509. "real_payment": param.RealPayment,
  510. "cancel_reason": param.CancelReason,
  511. "cancel_time": time.Now(),
  512. }
  513. if param.SubAccountId == 0 {
  514. updateData["cancel_operator_type"] = 1
  515. updateData["cancel_operator"] = param.EnterpriseId
  516. } else {
  517. updateData["cancel_operator_type"] = 2
  518. updateData["cancel_operator"] = strconv.FormatInt(param.SubAccountId, 10)
  519. }
  520. err := dao.ProjectTaskInfoDao{}.UpdateField(param.TaskId, updateData)
  521. if err != nil {
  522. return err
  523. }
  524. return nil
  525. }
  526. // 违约管理——达人批量解约
  527. func (s DefaultService) CancelTalentList(param *vo.TalentCancelParam) error {
  528. if param.TaskIds == nil {
  529. return errors.New("taskIds is empty")
  530. }
  531. updateData := map[string]interface{}{
  532. "task_stage": 16,
  533. "settle_amount": param.RealPayment,
  534. "real_payment": param.RealPayment,
  535. "cancel_reason": param.CancelReason,
  536. "cancel_time": time.Now(),
  537. }
  538. if param.SubAccountId == 0 {
  539. updateData["cancel_operator_type"] = 1
  540. updateData["cancel_operator"] = param.EnterpriseId
  541. } else {
  542. updateData["cancel_operator_type"] = 2
  543. updateData["cancel_operator"] = strconv.FormatInt(param.SubAccountId, 10)
  544. }
  545. err := dao.ProjectTaskInfoDao{}.UpdateFieldBatch(param.TaskIds, updateData)
  546. if err != nil {
  547. return err
  548. }
  549. return nil
  550. }