bill.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. package controllers
  2. import (
  3. "fmt"
  4. "hongze/hongze_api/models"
  5. "hongze/hongze_api/services"
  6. "hongze/hongze_api/utils"
  7. "strconv"
  8. "time"
  9. )
  10. //年度账单
  11. type BillController struct {
  12. BaseAuthController
  13. }
  14. // @Title 年度账单接口
  15. // @Description 年度账单接口
  16. // @Success 200 {object} models.BillDetailResp
  17. // @router /detail [get]
  18. func (this *BillController) Detail() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. this.Data["json"] = br
  22. this.ServeJSON()
  23. }()
  24. user := this.User
  25. if user == nil {
  26. br.Msg = "请登录"
  27. br.ErrMsg = "请登录,用户信息为空"
  28. br.Ret = 600
  29. return
  30. }
  31. uid := user.UserId
  32. userInfo, err := services.GetWxUserItemByUserId(uid,utils.WxPlatform)
  33. if err != nil {
  34. br.Ret = 600
  35. br.Msg = "登录失败"
  36. br.ErrMsg = "登录失败,判断权限失败:" + err.Error()
  37. return
  38. }
  39. permission, err := services.CheckUserPermission(uid)
  40. if err != nil {
  41. br.Msg = "登录失败"
  42. br.ErrMsg = "登录失败,判断权限失败:" + err.Error()
  43. return
  44. }
  45. if permission != 0 {
  46. br.Msg = "判断用户是否有权限失败"
  47. br.ErrMsg = "判断用户是否有权限失败:uid:" + strconv.Itoa(uid)
  48. br.Ret = 600
  49. br.IsSendEmail = false
  50. return
  51. }
  52. startDate := "2020-01-01 00:00:00"
  53. endDate := time.Now().Format(utils.FormatDate)
  54. var realName, togetherDay, createDate string
  55. resp := new(models.BillDetailResp)
  56. if user.RealName == "" {
  57. realName = user.NickName
  58. } else {
  59. realName = user.RealName
  60. }
  61. if !user.CreatedTime.IsZero() {
  62. sub := time.Now().Sub(user.CreatedTime)
  63. if sub <= 0 {
  64. sub = 1
  65. }
  66. expireDay := fmt.Sprintf("%v", int(sub.Hours()/24))
  67. togetherDay = expireDay
  68. createDate = user.CreatedTime.Format("2006年01月02日")
  69. } else {
  70. sub := time.Now().Sub(user.LastUpdatedTime)
  71. if sub <= 0 {
  72. sub = 1
  73. }
  74. expireDay := fmt.Sprintf("%v", int(sub.Hours()/24))
  75. togetherDay = expireDay
  76. createDate = user.LastUpdatedTime.Format("2006年01月02日")
  77. }
  78. if togetherDay == "0" {
  79. togetherDay = "1"
  80. }
  81. //uid = 41555
  82. firstReadReportType, firstReadReportTitle, err := models.GetFirstReportInfo(uid, startDate)
  83. if err != nil && err.Error() != utils.ErrNoRow() {
  84. br.Msg = "获取数据失败"
  85. br.ErrMsg = "获取数据失败GetFirstReportInfo,Err:" + err.Error()
  86. return
  87. }
  88. listenCount, listenVideoPlaySeconds, err := models.GetListenInfo(uid, startDate)
  89. if err != nil && err.Error() != utils.ErrNoRow() {
  90. br.Msg = "获取数据失败"
  91. br.ErrMsg = "获取数据失败GetListenInfo,Err:" + err.Error()
  92. return
  93. }
  94. maxReadReportCount, maxReadReportDate, err := models.GetMaxReadReportInfo(uid, startDate)
  95. if err != nil && err.Error() != utils.ErrNoRow() {
  96. br.Msg = "获取数据失败"
  97. br.ErrMsg = "获取数据失败GetMaxReadReportInfo,Err:" + err.Error()
  98. return
  99. }
  100. latestTime, latestCreateTime, err := models.GetLatestReadReportInfo(uid, startDate)
  101. if err != nil && err.Error() != utils.ErrNoRow() {
  102. br.Msg = "获取数据失败"
  103. br.ErrMsg = "获取数据失败GetLatestReadReportInfo,Err:" + err.Error()
  104. return
  105. }
  106. var lastestCreateDate string
  107. var VideoPlaySeconds float64
  108. if !latestCreateTime.IsZero() {
  109. lastestCreateDate = latestCreateTime.Format(utils.FormatDate)
  110. addCreateTime := latestCreateTime
  111. hour := latestCreateTime.Hour()
  112. if hour > 6 || hour <= 18 {
  113. rand := utils.GetRandInt(18, 23)
  114. addHour := rand - hour
  115. if addHour >= 0 {
  116. hh, _ := time.ParseDuration(strconv.Itoa(addHour) + "h")
  117. hh1 := addCreateTime.Add(hh)
  118. latestTime = hh1.Format("15:04:05")
  119. }
  120. }
  121. }
  122. if lastestCreateDate != "" {
  123. rddpReadCount, rddpVideoPlaySeconds, err := models.GetRddpReadReportCountByDate(uid, lastestCreateDate)
  124. if err != nil && err.Error() != utils.ErrNoRow() {
  125. br.Msg = "获取数据失败"
  126. br.ErrMsg = "获取数据失败GetRddpReadReportCountByDate,Err:" + err.Error()
  127. return
  128. }
  129. weekReadCount, err := models.GetWeekReadReportCountByDate(uid, lastestCreateDate)
  130. if err != nil && err.Error() != utils.ErrNoRow() {
  131. br.Msg = "获取数据失败"
  132. br.ErrMsg = "获取数据失败GetWeekReadReportCountByDate,Err:" + err.Error()
  133. return
  134. }
  135. var weekVideoPlaySeconds float64
  136. if rddpReadCount <= 0 {
  137. weekVideoPlaySeconds = float64(utils.GetRandInt(3, 300)) / float64(10.00)
  138. } else {
  139. weekVideoPlaySeconds = float64(weekReadCount) * (rddpVideoPlaySeconds / float64(rddpReadCount))
  140. }
  141. VideoPlaySeconds = utils.FixFloat(rddpVideoPlaySeconds+weekVideoPlaySeconds, 2)
  142. }
  143. maxOpenReportClassify, maxOpenReportCount, err := models.GetOpenReadReportInfo(uid, startDate)
  144. if err != nil && err.Error() != utils.ErrNoRow() {
  145. br.Msg = "获取数据失败"
  146. br.ErrMsg = "获取数据失败GetOpenReadReportInfo,Err:" + err.Error()
  147. return
  148. }
  149. rddpTotalPlaySeconds, rddpTotal, err := models.GetRddpTotalReadDuration(uid, startDate)
  150. if err != nil && err.Error() != utils.ErrNoRow() {
  151. br.Msg = "获取数据失败"
  152. br.ErrMsg = "获取数据失败GetRddpTotalReadDuration,Err:" + err.Error()
  153. return
  154. }
  155. weekTotal, err := models.GetWeekTotalRead(uid, startDate)
  156. if err != nil && err.Error() != utils.ErrNoRow() {
  157. br.Msg = "获取数据失败"
  158. br.ErrMsg = "获取数据失败GetRddpTotalReadDuration,Err:" + err.Error()
  159. return
  160. }
  161. totalReadDuration := 0.00
  162. if rddpTotal <= 0 {
  163. totalReadDuration = rddpTotalPlaySeconds + float64(weekTotal)*float64(120.00) //(float64(utils.GetRandInt(150, 155))/float64(10.00))
  164. } else {
  165. totalReadDuration = rddpTotalPlaySeconds + float64(weekTotal)*float64(120.00) //(rddpTotalPlaySeconds/float64(rddpTotal))*float64(weekTotal)
  166. }
  167. fmt.Println(uid, rddpTotalPlaySeconds, weekTotal, totalReadDuration)
  168. dayType := `day`
  169. dayTotal, err := models.GetWeekTotalReadByType(uid, dayType, startDate)
  170. if err != nil && err.Error() != utils.ErrNoRow() {
  171. br.Msg = "获取数据失败"
  172. br.ErrMsg = "获取数据失败GetWeekTotalReadByType,Err:" + err.Error() + ";report_type:" + dayType
  173. return
  174. }
  175. weekType := `week`
  176. weekReportReadTotal, err := models.GetWeekTotalReadByType(uid, weekType, startDate)
  177. if err != nil && err.Error() != utils.ErrNoRow() {
  178. br.Msg = "获取数据失败"
  179. br.ErrMsg = "获取数据失败GetWeekTotalReadByType,Err:" + err.Error() + ";report_type:" + weekType
  180. return
  181. }
  182. twoWeekType := `two_week`
  183. twoWeekTotal, err := models.GetWeekTotalReadByType(uid, twoWeekType, startDate)
  184. if err != nil && err.Error() != utils.ErrNoRow() {
  185. br.Msg = "获取数据失败"
  186. br.ErrMsg = "获取数据失败GetWeekTotalReadByType,Err:" + err.Error() + ";report_type:" + twoWeekType
  187. return
  188. }
  189. monthType := `month`
  190. monthTotal, err := models.GetWeekTotalReadByType(uid, dayType, startDate)
  191. if err != nil && err.Error() != utils.ErrNoRow() {
  192. br.Msg = "获取数据失败"
  193. br.ErrMsg = "获取数据失败GetWeekTotalReadByType,Err:" + err.Error() + ";report_type:" + monthType
  194. return
  195. }
  196. rddpReadTotal, err := models.GetRddpTotalReadByType(uid, startDate)
  197. if err != nil && err.Error() != utils.ErrNoRow() {
  198. br.Msg = "获取数据失败"
  199. br.ErrMsg = "获取数据失败GetRddpTotalReadByType,Err:" + err.Error() + ";report_type:" + monthType
  200. return
  201. }
  202. var learnDay int
  203. rddpLearnDay, err := models.GetRddpLearnDay(uid, startDate, endDate)
  204. if err != nil && err.Error() != utils.ErrNoRow() {
  205. br.Msg = "获取数据失败"
  206. br.ErrMsg = "获取数据失败GetRddpLearnDay,Err:" + err.Error() + ";report_type:" + monthType
  207. return
  208. }
  209. weekLearnDay, err := models.GetWeekpLearnDay(uid, startDate)
  210. if err != nil && err.Error() != utils.ErrNoRow() {
  211. br.Msg = "获取数据失败"
  212. br.ErrMsg = "获取数据失败GetWeekpLearnDay,Err:" + err.Error() + ";report_type:" + monthType
  213. return
  214. }
  215. if rddpLearnDay >= weekLearnDay {
  216. learnDay = rddpLearnDay
  217. } else {
  218. learnDay = weekLearnDay
  219. }
  220. if learnDay <= 0 {
  221. learnDay = 1
  222. }
  223. resp.RealName = realName
  224. resp.TogetherDay = togetherDay
  225. resp.CreateDate = createDate
  226. if firstReadReportType == "rddp" {
  227. resp.FirstReadReportType = "日度点评"
  228. } else if firstReadReportType == "day" {
  229. resp.FirstReadReportType = "晨报"
  230. } else if firstReadReportType == "week" {
  231. resp.FirstReadReportType = "周报"
  232. } else if firstReadReportType == "two_week" {
  233. resp.FirstReadReportType = "双周报"
  234. } else if firstReadReportType == "month" {
  235. resp.FirstReadReportType = "月报"
  236. } else {
  237. resp.FirstReadReportType = "其他"
  238. }
  239. resp.FirstReadReportTitle = firstReadReportTitle
  240. resp.ListenReportCount = listenCount
  241. resp.ListenReportDuration = utils.FixFloat((listenVideoPlaySeconds / 60.00), 2)
  242. resp.MaxReadReportCount = maxReadReportCount
  243. resp.MaxReadReportDate = maxReadReportDate.Format("2006年01月02日")
  244. if lastestCreateDate == "" {
  245. resp.LatestReadReportDate = ""
  246. } else {
  247. lastestDate, _ := time.Parse("2006-01-02", lastestCreateDate)
  248. resp.LatestReadReportDate = lastestDate.Format("2006年01月02日")
  249. }
  250. resp.LatestReadReportTime = latestTime
  251. resp.LatestReadReportDateDuration = VideoPlaySeconds
  252. resp.MaxOpenReportClassify = maxOpenReportClassify
  253. resp.MaxOpenReportCount = maxOpenReportCount
  254. resp.TotalReadDuration = totalReadDuration
  255. resp.TotalReportDayCount = dayTotal
  256. resp.TotalReportWeekCount = weekReportReadTotal
  257. resp.TotalReportTwoWeekCount = twoWeekTotal
  258. resp.TotalReportMonthCount = monthTotal
  259. resp.TotalReportRddpCount = rddpReadTotal
  260. resp.LearnDay = learnDay
  261. resp.TotalReport = dayTotal + weekReportReadTotal + twoWeekTotal + monthTotal + rddpReadTotal
  262. {
  263. annualReport := new(models.AnnualReport)
  264. annualReport.AnnualReportDate = "2020"
  265. annualReport.UserId = uid
  266. annualReport.Mobile = userInfo.Mobile
  267. annualReport.Email = userInfo.Email
  268. annualReport.CompanyId = userInfo.CompanyId
  269. annualReport.RealName = realName
  270. annualReport.TogetherDay = togetherDay
  271. annualReport.CreateDate = createDate
  272. annualReport.FirstReadReportType = firstReadReportType
  273. annualReport.FirstReadReportTitle = firstReadReportTitle
  274. annualReport.ListenReportCount = listenCount
  275. annualReport.ListenReportDuration = listenVideoPlaySeconds
  276. annualReport.MaxReadReportDate = resp.MaxReadReportDate
  277. annualReport.MaxReadReportCount = resp.MaxReadReportCount
  278. annualReport.LatestReadReportDate = resp.LatestReadReportDate
  279. annualReport.LatestReadReportTime = resp.LatestReadReportTime
  280. annualReport.LatestReadReportDateDuration = resp.LatestReadReportDateDuration
  281. annualReport.MaxOpenReportClassify = resp.MaxOpenReportClassify
  282. annualReport.MaxOpenReportCount = resp.MaxOpenReportCount
  283. annualReport.TotalReadDuration = resp.TotalReadDuration
  284. annualReport.TotalReportDayCount = resp.TotalReportDayCount
  285. annualReport.TotalReportWeekCount = resp.TotalReportWeekCount
  286. annualReport.TotalReportMonthCount = resp.TotalReportMonthCount
  287. annualReport.TotalReportTwoWeekCount = resp.TotalReportTwoWeekCount
  288. annualReport.TotalReportRddpCount = resp.TotalReportRddpCount
  289. annualReport.TotalReport = resp.TotalReport
  290. annualReport.LearnDay = resp.LearnDay
  291. annualReport.CreateTime = time.Now()
  292. go models.AddAnnualReport(annualReport)
  293. }
  294. br.Ret = 200
  295. br.Success = true
  296. br.Msg = "获取成功"
  297. br.Data = resp
  298. }
  299. //
  300. //func init123() {
  301. // fmt.Println("start")
  302. // msg := ""
  303. // defer func() {
  304. // if msg != "" {
  305. // fmt.Println("err:" + msg)
  306. // }
  307. // }()
  308. // list, err := models.GetWxUserAll()
  309. // if err != nil {
  310. // msg = "GetWxUserAll Err:" + err.Error()
  311. // return
  312. // }
  313. // for _, user := range list {
  314. // uid := user.UserId
  315. // existCount, err := models.GetAnnualReportCount(uid)
  316. // if err != nil {
  317. // msg = "GetAnnualReportCount Err:" + err.Error()
  318. // return
  319. // }
  320. // if existCount > 0 {
  321. // continue
  322. // }
  323. // userInfo, err := models.GetWxUserItemByUserId(uid)
  324. // if err != nil {
  325. // msg = "GetWxUserItemByUserId Err:" + err.Error()
  326. // return
  327. // }
  328. // permission, err := services.CheckUserPermission(uid)
  329. // if err != nil {
  330. // msg = "GetWxUserItemByUserId Err:" + err.Error()
  331. // return
  332. // }
  333. // if permission != 0 {
  334. // msg = "判断用户是否有权限失败"
  335. // return
  336. // }
  337. // startDate := "2020-01-01 00:00:00"
  338. // endDate := time.Now().Format(utils.FormatDate)
  339. // var realName, togetherDay, createDate string
  340. //
  341. // resp := new(models.BillDetailResp)
  342. // if user.RealName == "" {
  343. // realName = user.NickName
  344. // } else {
  345. // realName = user.RealName
  346. // }
  347. // if !user.CreatedTime.IsZero() {
  348. // sub := time.Now().Sub(user.CreatedTime)
  349. // if sub <= 0 {
  350. // sub = 1
  351. // }
  352. // expireDay := fmt.Sprintf("%v", int(sub.Hours()/24))
  353. // togetherDay = expireDay
  354. // createDate = user.CreatedTime.Format("2006年01月02日")
  355. // } else {
  356. // sub := time.Now().Sub(user.LastUpdatedTime)
  357. // if sub <= 0 {
  358. // sub = 1
  359. // }
  360. // expireDay := fmt.Sprintf("%v", int(sub.Hours()/24))
  361. // togetherDay = expireDay
  362. // createDate = user.LastUpdatedTime.Format("2006年01月02日")
  363. // }
  364. // if togetherDay == "0" {
  365. // togetherDay = "1"
  366. // }
  367. // //uid = 41555
  368. //
  369. // firstReadReportType, firstReadReportTitle, err := models.GetFirstReportInfo(uid, startDate)
  370. // if err != nil && err.Error() != utils.ErrNoRow() {
  371. // msg = "获取数据失败GetFirstReportInfo,Err:" + err.Error()
  372. // return
  373. // }
  374. // listenCount, listenVideoPlaySeconds, err := models.GetListenInfo(uid, startDate)
  375. // if err != nil && err.Error() != utils.ErrNoRow() {
  376. // msg = "获取数据失败GetListenInfo,Err:" + err.Error()
  377. // return
  378. // }
  379. // maxReadReportCount, maxReadReportDate, err := models.GetMaxReadReportInfo(uid, startDate)
  380. // if err != nil && err.Error() != utils.ErrNoRow() {
  381. // msg = "获取数据失败GetMaxReadReportInfo,Err:" + err.Error()
  382. // return
  383. // }
  384. //
  385. // latestTime, latestCreateTime, err := models.GetLatestReadReportInfo(uid, startDate)
  386. // if err != nil && err.Error() != utils.ErrNoRow() {
  387. // msg = "获取数据失败GetLatestReadReportInfo,Err:" + err.Error()
  388. // return
  389. // }
  390. //
  391. // var lastestCreateDate string
  392. // var VideoPlaySeconds float64
  393. // if !latestCreateTime.IsZero() {
  394. // lastestCreateDate = latestCreateTime.Format(utils.FormatDate)
  395. // addCreateTime := latestCreateTime
  396. // hour := latestCreateTime.Hour()
  397. // if hour > 6 || hour <= 18 {
  398. // rand := utils.GetRandInt(18, 23)
  399. // addHour := rand - hour
  400. // if addHour >= 0 {
  401. // hh, _ := time.ParseDuration(strconv.Itoa(addHour) + "h")
  402. // hh1 := addCreateTime.Add(hh)
  403. // latestTime = hh1.Format("15:04:05")
  404. // }
  405. // }
  406. // }
  407. // if lastestCreateDate != "" {
  408. // rddpReadCount, rddpVideoPlaySeconds, err := models.GetRddpReadReportCountByDate(uid, lastestCreateDate)
  409. // if err != nil && err.Error() != utils.ErrNoRow() {
  410. // msg = "获取数据失败GetRddpReadReportCountByDate,Err:" + err.Error()
  411. // return
  412. // }
  413. // weekReadCount, err := models.GetWeekReadReportCountByDate(uid, lastestCreateDate)
  414. // if err != nil && err.Error() != utils.ErrNoRow() {
  415. // msg = "获取数据失败GetWeekReadReportCountByDate,Err:" + err.Error()
  416. // return
  417. // }
  418. // var weekVideoPlaySeconds float64
  419. // if rddpReadCount <= 0 {
  420. // weekVideoPlaySeconds = float64(utils.GetRandInt(3, 300)) / float64(10.00)
  421. // } else {
  422. // weekVideoPlaySeconds = float64(weekReadCount) * (rddpVideoPlaySeconds / float64(rddpReadCount))
  423. // }
  424. // VideoPlaySeconds = utils.FixFloat(rddpVideoPlaySeconds+weekVideoPlaySeconds, 2)
  425. // }
  426. //
  427. // maxOpenReportClassify, maxOpenReportCount, err := models.GetOpenReadReportInfo(uid, startDate)
  428. // if err != nil && err.Error() != utils.ErrNoRow() {
  429. // msg = "获取数据失败GetOpenReadReportInfo,Err:" + err.Error()
  430. // return
  431. // }
  432. //
  433. // rddpTotalPlaySeconds, rddpTotal, err := models.GetRddpTotalReadDuration(uid, startDate)
  434. // if err != nil && err.Error() != utils.ErrNoRow() {
  435. // msg = "获取数据失败GetRddpTotalReadDuration,Err:" + err.Error()
  436. // return
  437. // }
  438. //
  439. // weekTotal, err := models.GetWeekTotalRead(uid, startDate)
  440. // if err != nil && err.Error() != utils.ErrNoRow() {
  441. // msg = "获取数据失败GetRddpTotalReadDuration,Err:" + err.Error()
  442. // return
  443. // }
  444. // totalReadDuration := 0.00
  445. // if rddpTotal <= 0 {
  446. // totalReadDuration = rddpTotalPlaySeconds + float64(weekTotal)*float64(120.00) //(float64(utils.GetRandInt(150, 155))/float64(10.00))
  447. // } else {
  448. // totalReadDuration = rddpTotalPlaySeconds + float64(weekTotal)*float64(120.00) //(rddpTotalPlaySeconds/float64(rddpTotal))*float64(weekTotal)
  449. // }
  450. // fmt.Println(uid, rddpTotalPlaySeconds, weekTotal, totalReadDuration)
  451. // dayType := `day`
  452. // dayTotal, err := models.GetWeekTotalReadByType(uid, dayType, startDate)
  453. // if err != nil && err.Error() != utils.ErrNoRow() {
  454. // msg = "获取数据失败GetWeekTotalReadByType,Err:" + err.Error()
  455. // return
  456. // }
  457. // weekType := `week`
  458. // weekReportReadTotal, err := models.GetWeekTotalReadByType(uid, weekType, startDate)
  459. // if err != nil && err.Error() != utils.ErrNoRow() {
  460. // msg = "获取数据失败GetWeekTotalReadByType,Err:" + err.Error()
  461. // return
  462. // }
  463. // twoWeekType := `two_week`
  464. // twoWeekTotal, err := models.GetWeekTotalReadByType(uid, twoWeekType, startDate)
  465. // if err != nil && err.Error() != utils.ErrNoRow() {
  466. // msg = "获取数据失败GetWeekTotalReadByType,Err:" + err.Error()
  467. // return
  468. // }
  469. // monthType := `month`
  470. // monthTotal, err := models.GetWeekTotalReadByType(uid, dayType, startDate)
  471. // if err != nil && err.Error() != utils.ErrNoRow() {
  472. // msg = "获取数据失败GetWeekTotalReadByType,Err:" + err.Error()
  473. // return
  474. // }
  475. //
  476. // rddpReadTotal, err := models.GetRddpTotalReadByType(uid, startDate)
  477. // if err != nil && err.Error() != utils.ErrNoRow() {
  478. // msg = "获取数据失败GetRddpTotalReadByType,Err:" + err.Error()
  479. // return
  480. // }
  481. //
  482. // var learnDay int
  483. // rddpLearnDay, err := models.GetRddpLearnDay(uid, startDate, endDate)
  484. // if err != nil && err.Error() != utils.ErrNoRow() {
  485. // msg = "获取数据失败GetRddpLearnDay,Err:" + err.Error()
  486. // return
  487. // }
  488. //
  489. // weekLearnDay, err := models.GetWeekpLearnDay(uid, startDate)
  490. // if err != nil && err.Error() != utils.ErrNoRow() {
  491. // msg = "获取数据失败GetWeekpLearnDay,Err:" + err.Error() + ";report_type:" + monthType
  492. // return
  493. // }
  494. // if rddpLearnDay >= weekLearnDay {
  495. // learnDay = rddpLearnDay
  496. // } else {
  497. // learnDay = weekLearnDay
  498. // }
  499. // if learnDay <= 0 {
  500. // learnDay = 1
  501. // }
  502. // resp.RealName = realName
  503. // resp.TogetherDay = togetherDay
  504. // resp.CreateDate = createDate
  505. // if firstReadReportType == "rddp" {
  506. // resp.FirstReadReportType = "日度点评"
  507. // } else if firstReadReportType == "day" {
  508. // resp.FirstReadReportType = "晨报"
  509. // } else if firstReadReportType == "week" {
  510. // resp.FirstReadReportType = "周报"
  511. // } else if firstReadReportType == "two_week" {
  512. // resp.FirstReadReportType = "双周报"
  513. // } else if firstReadReportType == "month" {
  514. // resp.FirstReadReportType = "月报"
  515. // } else {
  516. // resp.FirstReadReportType = "其他"
  517. // }
  518. // resp.FirstReadReportTitle = firstReadReportTitle
  519. // resp.ListenReportCount = listenCount
  520. // resp.ListenReportDuration = utils.FixFloat((listenVideoPlaySeconds / 60.00), 2)
  521. // resp.MaxReadReportCount = maxReadReportCount
  522. // resp.MaxReadReportDate = maxReadReportDate.Format("2006年01月02日")
  523. // if lastestCreateDate == "" {
  524. // resp.LatestReadReportDate = ""
  525. // } else {
  526. // lastestDate, _ := time.Parse("2006-01-02", lastestCreateDate)
  527. // resp.LatestReadReportDate = lastestDate.Format("2006年01月02日")
  528. // }
  529. // resp.LatestReadReportTime = latestTime
  530. // resp.LatestReadReportDateDuration = VideoPlaySeconds
  531. // resp.MaxOpenReportClassify = maxOpenReportClassify
  532. // resp.MaxOpenReportCount = maxOpenReportCount
  533. // resp.TotalReadDuration = totalReadDuration
  534. // resp.TotalReportDayCount = dayTotal
  535. // resp.TotalReportWeekCount = weekReportReadTotal
  536. // resp.TotalReportTwoWeekCount = twoWeekTotal
  537. // resp.TotalReportMonthCount = monthTotal
  538. // resp.TotalReportRddpCount = rddpReadTotal
  539. // resp.LearnDay = learnDay
  540. // resp.TotalReport = dayTotal + weekReportReadTotal + twoWeekTotal + monthTotal + rddpReadTotal
  541. //
  542. // {
  543. //
  544. // annualReport := new(models.AnnualReport)
  545. // annualReport.AnnualReportDate = "2020"
  546. // annualReport.UserId = uid
  547. // annualReport.Mobile = userInfo.Mobile
  548. // annualReport.Email = userInfo.Email
  549. // annualReport.CompanyId = userInfo.CompanyId
  550. // annualReport.RealName = realName
  551. // annualReport.TogetherDay = togetherDay
  552. // annualReport.CreateDate = createDate
  553. // annualReport.FirstReadReportType = firstReadReportType
  554. // annualReport.FirstReadReportTitle = firstReadReportTitle
  555. // annualReport.ListenReportCount = listenCount
  556. // annualReport.ListenReportDuration = listenVideoPlaySeconds
  557. // annualReport.MaxReadReportDate = resp.MaxReadReportDate
  558. // annualReport.MaxReadReportCount = resp.MaxReadReportCount
  559. // annualReport.LatestReadReportDate = resp.LatestReadReportDate
  560. // annualReport.LatestReadReportTime = resp.LatestReadReportTime
  561. // annualReport.LatestReadReportDateDuration = resp.LatestReadReportDateDuration
  562. // annualReport.MaxOpenReportClassify = resp.MaxOpenReportClassify
  563. // annualReport.MaxOpenReportCount = resp.MaxOpenReportCount
  564. // annualReport.TotalReadDuration = resp.TotalReadDuration
  565. // annualReport.TotalReportDayCount = resp.TotalReportDayCount
  566. // annualReport.TotalReportWeekCount = resp.TotalReportWeekCount
  567. // annualReport.TotalReportMonthCount = resp.TotalReportMonthCount
  568. // annualReport.TotalReportTwoWeekCount = resp.TotalReportTwoWeekCount
  569. // annualReport.TotalReportRddpCount = resp.TotalReportRddpCount
  570. // annualReport.TotalReport = resp.TotalReport
  571. // annualReport.LearnDay = resp.LearnDay
  572. // annualReport.CreateTime = time.Now()
  573. // models.AddAnnualReport(annualReport)
  574. // }
  575. // }
  576. // return
  577. // fmt.Println("end")
  578. //}