12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package services
- import (
- "encoding/json"
- "fmt"
- "hongze/hongze_api/cache"
- "hongze/hongze_api/models"
- "hongze/hongze_api/utils"
- )
- func Task() {
- fmt.Println("start")
- //InitSetUnionId()
- //FixUnionId()
- fmt.Println("end")
- //go AutoUpdateUserView()
- }
- // AutoUpdateUserView 自动添加阅读记录
- func AutoUpdateUserView() {
- defer func() {
- if err := recover(); err != nil {
- fmt.Println("[AutoUpdateUserView]", err)
- }
- }()
- for {
- utils.Rc.Brpop(utils.CACHE_KEY_USER_VIEW, func(b []byte) {
- var userViewRedisData cache.UserViewRedisData
- if err := json.Unmarshal(b, &userViewRedisData); err != nil {
- go utils.SendEmail(utils.APPNAME+" "+utils.RunMode+" 失败提醒", fmt.Sprint("AutoUpdateUserView ERR:", err, ";response data:", string(b)), utils.EmailSendToUsers)
- //}
- //if _, err := models.AddLogs(&log); err != nil {
- // fmt.Println("AddLogs:", err.Error(), log)
- } else {
- err = models.UpdateCompanyProductViewData(userViewRedisData.CompanyId, userViewRedisData.ProductId, userViewRedisData.ViewTime)
- if err != nil {
- go utils.SendEmail(utils.APPNAME+" "+utils.RunMode+" 失败提醒", fmt.Sprint("AutoUpdateUserView Update CompanyProduct ERR:", err, ";response data:", string(b)), utils.EmailSendToUsers)
- }
- }
- })
- }
- }
|