default_service.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  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{}.GetTalentInfo(talentId)
  225. platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.GetUserInfo(projectTaskInfo.OpenID)
  226. reTalentDefault := &vo.ReTalentDefault{
  227. TalentId: talentId,
  228. TalentPhone: talentInfo.TalentPhoneNumber,
  229. TaskId: projectTaskInfo.TaskID,
  230. DraftFee: projectTaskInfo.DraftFee,
  231. OpenId: platformKuaishouUserInfo.OpenID,
  232. PlatformId: platformKuaishouUserInfo.PlatformID,
  233. NickName: platformKuaishouUserInfo.NickName,
  234. HeadUri: platformKuaishouUserInfo.HeadUri,
  235. City: platformKuaishouUserInfo.City,
  236. Gender: platformKuaishouUserInfo.Gender,
  237. }
  238. if defaultType == 1 {
  239. reTalentDefault.DefaultTime = projectTaskInfo.SketchMissingTime.Format("2006-01-02 15:04:05")
  240. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  241. } else if defaultType == 2 {
  242. reTalentDefault.DefaultTime = projectTaskInfo.LinkMissingTime.Format("2006-01-02 15:04:05")
  243. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  244. } else if defaultType == 3 {
  245. reTalentDefault.DefaultTime = projectTaskInfo.DataMissingTime.Format("2006-01-02 15:04:05")
  246. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  247. } else if defaultType == 4 {
  248. reTalentDefault.DefaultTime = projectTaskInfo.TerminateTime.Format("2006-01-02 15:04:05")
  249. reTalentDefault.Reason = projectTaskInfo.TerminateReason
  250. terminateOperatorType := projectTaskInfo.TerminateOperatorType
  251. if terminateOperatorType == 1 {
  252. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.TerminateOperator)
  253. reTalentDefault.OperatorName = enterprise.BusinessName
  254. } else if terminateOperatorType == 2 {
  255. operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
  256. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  257. reTalentDefault.OperatorName = subAccount.SubAccountName
  258. } else if terminateOperatorType == 3 {
  259. operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
  260. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  261. reTalentDefault.OperatorName = userName
  262. }
  263. } else if defaultType == 5 {
  264. reTalentDefault.DefaultTime = projectTaskInfo.CancelTime.Format("2006-01-02 15:04:05")
  265. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  266. reTalentDefault.Reason = projectTaskInfo.CancelReason
  267. cancelOperatorType := projectTaskInfo.CancelOperatorType
  268. if cancelOperatorType == 1 {
  269. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.CancelOperator)
  270. reTalentDefault.OperatorName = enterprise.BusinessName
  271. } else if cancelOperatorType == 2 {
  272. operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
  273. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  274. reTalentDefault.OperatorName = subAccount.SubAccountName
  275. } else if cancelOperatorType == 3 {
  276. operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
  277. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  278. reTalentDefault.OperatorName = userName
  279. }
  280. }
  281. reTalentDefaults = append(reTalentDefaults, reTalentDefault)
  282. }
  283. resultMap := make(map[string]interface{})
  284. resultMap["cutRate"] = cutRate
  285. resultMap["reTalentDefaults"] = reTalentDefaults
  286. result = vo.ResultVO{
  287. Page: param.Page,
  288. PageSize: param.PageSize,
  289. Total: total,
  290. Data: resultMap,
  291. }
  292. return result, nil
  293. } else if param.TaskType == 2 {
  294. // 本地生活
  295. var localLifeTaskInfos []entity.LocalLifeTaskInfo
  296. var total int64
  297. var err error
  298. var cutRate int64 // 违约扣款比例
  299. defaultType := param.DefaultType
  300. if defaultType == 1 { // 未传初稿
  301. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListBySketchDefault(param)
  302. autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
  303. infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
  304. cutRate = infoAutoDefault.SketchOtherNotUpload
  305. } else if defaultType == 2 { // 未发作品
  306. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByLinkDefault(param)
  307. autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
  308. infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
  309. cutRate = infoAutoDefault.LinkReplaceNotUpload
  310. } else if defaultType == 3 { // 未传数据
  311. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByDataDefault(param)
  312. autoDefaultId, _ := dao.ProjectDAO{}.GetAutoDefaultId(param.TaskId)
  313. infoAutoDefault, _ := dao.InfoAutoDefaultDao{}.GetValueById(*autoDefaultId)
  314. cutRate = infoAutoDefault.DataReplaceNotUpload
  315. } else if defaultType == 4 { // 终止合作
  316. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByTerminateDefault(param)
  317. } else if defaultType == 5 { // 已解约
  318. localLifeTaskInfos, total, err = dao.LocalLifeTaskInfoDao{}.GetListByCancelDefault(param)
  319. }
  320. if err != nil {
  321. return result, err
  322. }
  323. for _, localLifeTaskInfo := range localLifeTaskInfos {
  324. talentId := localLifeTaskInfo.TalentID
  325. talentInfo, _ := dao.TalentInfoDao{}.GetTalentInfo(talentId)
  326. platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.GetUserInfo(localLifeTaskInfo.OpenID)
  327. reTalentDefault := &vo.ReTalentDefault{
  328. TalentId: talentId,
  329. TalentPhone: talentInfo.TalentPhoneNumber,
  330. TaskId: localLifeTaskInfo.TaskID,
  331. DraftFee: localLifeTaskInfo.DraftFee,
  332. OpenId: platformKuaishouUserInfo.OpenID,
  333. PlatformId: platformKuaishouUserInfo.PlatformID,
  334. NickName: platformKuaishouUserInfo.NickName,
  335. HeadUri: platformKuaishouUserInfo.HeadUri,
  336. City: platformKuaishouUserInfo.City,
  337. Gender: platformKuaishouUserInfo.Gender,
  338. }
  339. if defaultType == 1 {
  340. reTalentDefault.DefaultTime = localLifeTaskInfo.SketchMissingTime.Format("2006-01-02 15:04:05")
  341. reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
  342. } else if defaultType == 2 {
  343. reTalentDefault.DefaultTime = localLifeTaskInfo.LinkMissingTime.Format("2006-01-02 15:04:05")
  344. reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
  345. } else if defaultType == 3 {
  346. reTalentDefault.DefaultTime = localLifeTaskInfo.DataMissingTime.Format("2006-01-02 15:04:05")
  347. reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
  348. } else if defaultType == 4 {
  349. reTalentDefault.DefaultTime = localLifeTaskInfo.TerminateTime.Format("2006-01-02 15:04:05")
  350. reTalentDefault.Reason = localLifeTaskInfo.TerminateReason
  351. terminateOperatorType := localLifeTaskInfo.TerminateOperatorType
  352. if terminateOperatorType == 1 {
  353. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(localLifeTaskInfo.TerminateOperator)
  354. reTalentDefault.OperatorName = enterprise.BusinessName
  355. } else if terminateOperatorType == 2 {
  356. operatorId, _ := strconv.ParseInt(localLifeTaskInfo.TerminateOperator, 10, 64)
  357. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  358. reTalentDefault.OperatorName = subAccount.SubAccountName
  359. } else if terminateOperatorType == 3 {
  360. operatorId, _ := strconv.ParseInt(localLifeTaskInfo.TerminateOperator, 10, 64)
  361. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  362. reTalentDefault.OperatorName = userName
  363. }
  364. } else if defaultType == 5 {
  365. reTalentDefault.DefaultTime = localLifeTaskInfo.CancelTime.Format("2006-01-02 15:04:05")
  366. reTalentDefault.SettleAmount = localLifeTaskInfo.SettleAmount
  367. reTalentDefault.Reason = localLifeTaskInfo.CancelReason
  368. cancelOperatorType := localLifeTaskInfo.CancelOperatorType
  369. if cancelOperatorType == 1 {
  370. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(localLifeTaskInfo.CancelOperator)
  371. reTalentDefault.OperatorName = enterprise.BusinessName
  372. } else if cancelOperatorType == 2 {
  373. operatorId, _ := strconv.ParseInt(localLifeTaskInfo.CancelOperator, 10, 64)
  374. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  375. reTalentDefault.OperatorName = subAccount.SubAccountName
  376. } else if cancelOperatorType == 3 {
  377. operatorId, _ := strconv.ParseInt(localLifeTaskInfo.CancelOperator, 10, 64)
  378. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  379. reTalentDefault.OperatorName = userName
  380. }
  381. }
  382. reTalentDefaults = append(reTalentDefaults, reTalentDefault)
  383. }
  384. resultMap := make(map[string]interface{})
  385. resultMap["cutRate"] = cutRate
  386. resultMap["reTalentDefaults"] = reTalentDefaults
  387. result = vo.ResultVO{
  388. Page: param.Page,
  389. PageSize: param.PageSize,
  390. Total: total,
  391. Data: resultMap,
  392. }
  393. return result, nil
  394. } else {
  395. return result, nil
  396. }
  397. }
  398. // 违约管理——公开任务-违约达人列表角标
  399. func (s DefaultService) GetPublicDefaultTalentCount(param *vo.DefaultSearchParam) (map[string]int64, error) {
  400. res := make(map[string]int64)
  401. var noSketchNum int64
  402. var noLinkNum int64
  403. var noDataNum int64
  404. var endCooperationNum int64
  405. if param.TaskType == 1 {
  406. noSketchNum = dao.ProjectTaskInfoDao{}.CountByDefaultType(param.TaskId, 4)
  407. noLinkNum = dao.ProjectTaskInfoDao{}.CountByDefaultType(param.TaskId, 6)
  408. noDataNum = dao.ProjectTaskInfoDao{}.CountByDefaultType(param.TaskId, 8)
  409. // 终止合作还是解约字段待确认
  410. endCooperationNum = dao.ProjectTaskInfoDao{}.CountByTaskStage(param.TaskId, 16)
  411. } else {
  412. noSketchNum = dao.LocalLifeTaskInfoDao{}.CountByDefaultType(param.TaskId, 4)
  413. noLinkNum = dao.LocalLifeTaskInfoDao{}.CountByDefaultType(param.TaskId, 6)
  414. noDataNum = dao.LocalLifeTaskInfoDao{}.CountByDefaultType(param.TaskId, 8)
  415. // 终止合作还是解约字段待确认
  416. endCooperationNum = dao.LocalLifeTaskInfoDao{}.CountByTaskStage(param.TaskId, 16)
  417. }
  418. res["noSketchNum"] = noSketchNum
  419. res["noLinkNum"] = noLinkNum
  420. res["noDataNum"] = noDataNum
  421. res["endCooperationNum"] = endCooperationNum
  422. return res, nil
  423. }
  424. // 违约管理——定向任务-违约达人列表
  425. func (s DefaultService) GetTargetDefaultTalentList(param *vo.DefaultSearchParam) (vo.ResultVO, error) {
  426. if param.Page <= 0 {
  427. param.Page = 1
  428. }
  429. if param.PageSize <= 0 {
  430. param.PageSize = 10
  431. }
  432. var result vo.ResultVO
  433. var reTalentDefaults []*vo.ReTalentDefault
  434. // 以下代码只考虑了种草
  435. var projectTaskInfos []entity.ProjectTaskInfo
  436. var total int64
  437. var err error
  438. defaultType := param.DefaultType
  439. if defaultType == 4 { // 终止合作
  440. projectTaskInfos, total, err = (&dao.ProjectTaskInfoDao{}).GetListByTerminateDefault(param)
  441. } else if defaultType == 5 { // 已解约
  442. projectTaskInfos, total, err = (&dao.ProjectTaskInfoDao{}).GetListByCancelDefault(param)
  443. }
  444. if err != nil {
  445. return result, err
  446. }
  447. for _, projectTaskInfo := range projectTaskInfos {
  448. talentId := projectTaskInfo.TalentID
  449. talentInfo, _ := dao.TalentInfoDao{}.GetTalentInfo(talentId)
  450. platformKuaishouUserInfo, _ := dao.PlatformKuaishouUserInfoDao{}.GetUserInfo(projectTaskInfo.OpenID)
  451. reTalentDefault := &vo.ReTalentDefault{
  452. TalentId: talentId,
  453. TalentPhone: talentInfo.TalentPhoneNumber,
  454. TaskId: projectTaskInfo.TaskID,
  455. DraftFee: projectTaskInfo.DraftFee,
  456. OpenId: platformKuaishouUserInfo.OpenID,
  457. PlatformId: platformKuaishouUserInfo.PlatformID,
  458. NickName: platformKuaishouUserInfo.NickName,
  459. HeadUri: platformKuaishouUserInfo.HeadUri,
  460. City: platformKuaishouUserInfo.City,
  461. Gender: platformKuaishouUserInfo.Gender,
  462. }
  463. if defaultType == 4 {
  464. reTalentDefault.DefaultTime = projectTaskInfo.TerminateTime.Format("2006-01-02 15:04:05")
  465. reTalentDefault.Reason = projectTaskInfo.TerminateReason
  466. terminateOperatorType := projectTaskInfo.TerminateOperatorType
  467. if terminateOperatorType == 1 {
  468. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.TerminateOperator)
  469. reTalentDefault.OperatorName = enterprise.BusinessName
  470. } else if terminateOperatorType == 2 {
  471. operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
  472. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  473. reTalentDefault.OperatorName = subAccount.SubAccountName
  474. } else if terminateOperatorType == 3 {
  475. operatorId, _ := strconv.ParseInt(projectTaskInfo.TerminateOperator, 10, 64)
  476. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  477. reTalentDefault.OperatorName = userName
  478. }
  479. } else if defaultType == 5 {
  480. reTalentDefault.DefaultTime = projectTaskInfo.CancelTime.Format("2006-01-02 15:04:05")
  481. reTalentDefault.SettleAmount = projectTaskInfo.SettleAmount
  482. cancelOperatorType := projectTaskInfo.CancelOperatorType
  483. if cancelOperatorType == 1 {
  484. enterprise, _ := dao.EnterpriseDao{}.GetEnterprise(projectTaskInfo.CancelOperator)
  485. reTalentDefault.OperatorName = enterprise.BusinessName
  486. } else if cancelOperatorType == 2 {
  487. operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
  488. subAccount, _ := dao.SubAccountDao{}.GetSubAccount(operatorId)
  489. reTalentDefault.OperatorName = subAccount.SubAccountName
  490. } else if cancelOperatorType == 3 {
  491. operatorId, _ := strconv.ParseInt(projectTaskInfo.CancelOperator, 10, 64)
  492. userName, _ := dao.UserDao{}.GetNameByUserId(operatorId)
  493. reTalentDefault.OperatorName = userName
  494. }
  495. }
  496. reTalentDefaults = append(reTalentDefaults, reTalentDefault)
  497. }
  498. result = vo.ResultVO{
  499. Page: param.Page,
  500. PageSize: param.PageSize,
  501. Total: total,
  502. Data: reTalentDefaults,
  503. }
  504. return result, nil
  505. }
  506. // 违约管理——达人解约
  507. func (s DefaultService) CancelTalent(param *vo.TalentCancelParam) error {
  508. if param.TaskId == "" {
  509. return errors.New("taskId is empty")
  510. }
  511. updateData := map[string]interface{}{
  512. "task_stage": 16,
  513. "settle_amount": param.RealPayment,
  514. "real_payment": param.RealPayment,
  515. "cancel_reason": param.CancelReason,
  516. "cancel_time": time.Now(),
  517. }
  518. if param.SubAccountId == 0 {
  519. updateData["cancel_operator_type"] = 1
  520. updateData["cancel_operator"] = param.EnterpriseId
  521. } else {
  522. updateData["cancel_operator_type"] = 2
  523. updateData["cancel_operator"] = strconv.FormatInt(param.SubAccountId, 10)
  524. }
  525. err := dao.ProjectTaskInfoDao{}.UpdateField(param.TaskId, updateData)
  526. if err != nil {
  527. return err
  528. }
  529. return nil
  530. }
  531. // 违约管理——达人批量解约
  532. func (s DefaultService) CancelTalentList(param *vo.TalentCancelParam) error {
  533. if param.TaskIds == nil {
  534. return errors.New("taskIds is empty")
  535. }
  536. updateData := map[string]interface{}{
  537. "task_stage": 16,
  538. "settle_amount": param.RealPayment,
  539. "real_payment": param.RealPayment,
  540. "cancel_reason": param.CancelReason,
  541. "cancel_time": time.Now(),
  542. }
  543. if param.SubAccountId == 0 {
  544. updateData["cancel_operator_type"] = 1
  545. updateData["cancel_operator"] = param.EnterpriseId
  546. } else {
  547. updateData["cancel_operator_type"] = 2
  548. updateData["cancel_operator"] = strconv.FormatInt(param.SubAccountId, 10)
  549. }
  550. err := dao.ProjectTaskInfoDao{}.UpdateFieldBatch(param.TaskIds, updateData)
  551. if err != nil {
  552. return err
  553. }
  554. return nil
  555. }