diff --git a/app/hdl/friend_circle/hdl_dynamic.go b/app/hdl/friend_circle/hdl_dynamic.go index f4d3797..50f26bd 100644 --- a/app/hdl/friend_circle/hdl_dynamic.go +++ b/app/hdl/friend_circle/hdl_dynamic.go @@ -27,7 +27,7 @@ import ( // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Param req body md.GetDynamicReq false "筛选条件" -// @Success 200 {object} md.GetDynamicResp "生成的黑名单id" +// @Success 200 {object} md.GetDynamicResp "具体数据" // @Failure 400 {object} md.Response "具体错误" // @Router /api/friendCircleSettings/dynamic/index [POST] func GetDynamic(c *gin.Context) { @@ -65,11 +65,15 @@ func GetDynamic(c *gin.Context) { if req.Limit == 0 { req.Limit = 10 } + userIdInterface := make([]interface{}, len(userIds)) + for index, value := range userIds { + userIdInterface[index] = value + } aliasName := md2.EggFriendCircleEsAlias boolQuery := elastic.NewBoolQuery() if userIds != nil { - boolQuery.Filter(elastic.NewTermsQuery("uid", userIds)) + boolQuery.Filter(elastic.NewTermsQuery("uid", userIdInterface...)) } if req.BeginAt != "" && req.EndAt != "" { boolQuery.Filter(elastic.NewRangeQuery("created_at").Gte(req.BeginAt).Lte(req.EndAt).Format("yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis")) @@ -81,12 +85,8 @@ func GetDynamic(c *gin.Context) { Sort("created_at", true). Pretty(true). Do(context.Background()) - if err != nil { - e.OutErr(c, e.ERR, err.Error()) - return - } - var docs []md.EggFriendCircleNode + var docs []*md.EggFriendCircleNode var docUserIds []int64 var total int64 // 检查是否有结果 @@ -101,7 +101,7 @@ func GetDynamic(c *gin.Context) { } docUserIds = append(docUserIds, doc.Uid) doc.IndexId = hit.Id - docs = append(docs, doc) + docs = append(docs, &doc) } } @@ -133,7 +133,7 @@ func GetDynamic(c *gin.Context) { userMap[user.Id] = user.Nickname } scheme, domain := svc.ImageBucket(db.Db) - list := make([]md.DynamicRespNode, len(docs)) + list := make([]md.DynamicRespNode, 0, len(docs)) for _, doc := range docs { switch doc.Kind { case 1: @@ -142,9 +142,9 @@ func GetDynamic(c *gin.Context) { doc.Username = adminMap[doc.Uid] } imageStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image) - videoStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video) - images := strings.Split(imageStr, ";") - videos := strings.Split(videoStr, ";") + videos := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video) + var images []string + utils.Unserialize([]byte(imageStr), &images) temp := md.DynamicRespNode{ IndexId: doc.IndexId, Uid: doc.Uid, @@ -290,22 +290,17 @@ func ReleaseDynamic(c *gin.Context) { scheme, domain := svc.ImageBucket(db.Db) var imageStr string if len(req.Image) > 0 { - imageStr = strings.Join(req.Image, ";") + imageStr = utils.SerializeStr(req.Image) imageStr = strings.ReplaceAll(imageStr, fmt.Sprintf("%s://%s/", scheme, domain), "{{tempHost}}") } - var videoStr string - if len(req.Video) > 0 { - videoStr = strings.Join(req.Video, ";") - videoStr = strings.ReplaceAll(videoStr, fmt.Sprintf("%s://%s/", scheme, domain), "{{tempHost}}") - } now := time.Now() m := md2.EggFriendCircleEs{ Uid: int64(user.AdmId), Kind: req.Kind, Content: req.Content, Image: imageStr, - Video: videoStr, + Video: req.Video, LikesNums: 0, ShareNums: 0, CommentNums: 0, diff --git a/app/md/friend_circle/md_dynamic.go b/app/md/friend_circle/md_dynamic.go index f8b82c9..79a69a2 100644 --- a/app/md/friend_circle/md_dynamic.go +++ b/app/md/friend_circle/md_dynamic.go @@ -34,7 +34,7 @@ type DynamicRespNode struct { Kind int32 `json:"kind" label:"类型(1:普通 2:官方)"` // 类型(1:普通 2:官方) Content string `json:"content" label:"文本内容"` // 文本内容 Image []string `json:"image" label:"图片"` // 图片 - Video []string `json:"video" label:"视频"` // 视频 + Video string `json:"video" label:"视频"` // 视频 State int32 `json:"state" label:"状态(1:正常 2:隐藏)"` // 状态(1:正常 2:隐藏) IsTopUp int32 `json:"is_top_up" label:"是否置顶(1:是 2:否)"` // 是否置顶(1:是 2:否) IsPraise int32 `json:"is_praise" label:"是否被表扬(1:是 2:否)"` // 是否被表扬(1:是 2:否) @@ -62,7 +62,7 @@ type ReleaseDynamicReq struct { Kind int32 `json:"kind"` // 类型(1:普通 2:官方) Content string `json:"content"` // 文本内容 Image []string `json:"image"` // 图片 - Video []string `json:"video"` // 视频 + Video string `json:"video"` // 视频 State int32 `json:"state"` // 状态(1:正常 2:隐藏) IsTopUp int32 `json:"is_top_up"` // 是否置顶(1:是 2:否) IsPraise int32 `json:"is_praise"` // 是否被表扬(1:是 2:否) diff --git a/app/svc/im/svc_customer_service.go b/app/svc/im/svc_customer_service.go index 86bccd0..067a1d1 100644 --- a/app/svc/im/svc_customer_service.go +++ b/app/svc/im/svc_customer_service.go @@ -4,7 +4,6 @@ import ( "applet/app/db" "applet/app/db/im/model" md "applet/app/md/im" - "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "errors" "time" ) @@ -12,14 +11,14 @@ import ( func PageCustomerService(req md.PageCustomerServiceReq) (err error, resp md.PageCustomerServiceResp) { var userId int64 if req.Phone != "" { - userDb := implement.NewUserDb(db.Db) - user, err := userDb.UserGetOneByParams(map[string]interface{}{ - "phone": req.Phone, - }) + var user model.User + get, err := db.DbIm.Where("phone_number = ?", req.Phone).Get(&user) if err != nil { - return err, md.PageCustomerServiceResp{} + return err, resp + } + if get { + userId = user.Id } - userId = user.Id } sess := db.DbIm.Where("1=1") diff --git a/app/svc/im/svc_send_red_package_ord.go b/app/svc/im/svc_send_red_package_ord.go index 252516c..2ee5641 100644 --- a/app/svc/im/svc_send_red_package_ord.go +++ b/app/svc/im/svc_send_red_package_ord.go @@ -2,8 +2,10 @@ package svc import ( "applet/app/db" + model2 "applet/app/db/im/model" md "applet/app/md/im" "applet/app/utils" + "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" "errors" "fmt" @@ -16,9 +18,46 @@ type PageSendRedPackageOrdJoinUser struct { } func PageSendRedPackageOrd(req md.PageSendRedPackageOrdReq) (err error, resp md.PageSendRedPackageOrdResp) { + userDb := implement.NewUserDb(db.Db) + var phones []string + if req.InviteCode != "" { + user1, err := userDb.UserGetOneByParams(map[string]interface{}{ + "key": "system_invite_code", + "value": req.InviteCode, + }) + if err != nil { + return err, md.PageSendRedPackageOrdResp{} + } + if user1 != nil { + phones = append(phones, user1.Phone) + } + user2, err := userDb.UserGetOneByParams(map[string]interface{}{ + "key": "custom_invite_code", + "value": req.InviteCode, + }) + if err != nil { + return err, md.PageSendRedPackageOrdResp{} + } + if user2 != nil { + phones = append(phones, user2.Phone) + } + } + var imUsers []model2.User + err = db.DbIm.In("phone_number", phones).Find(&imUsers) + if err != nil { + return err, md.PageSendRedPackageOrdResp{} + } + var imUserIds []int64 + for _, imUser := range imUsers { + imUserIds = append(imUserIds, imUser.Id) + } + if req.Uid != 0 { + imUserIds = append(imUserIds, int64(req.Uid)) + } + sess := db.DbIm.Table("im_send_red_package_ord").Where("1=1") if req.Phone != "" { - sess.And("user.phone LIKE ?", "%"+req.Phone+"%") + sess.And("user.phone_number LIKE ?", "%"+req.Phone+"%") } if req.Nickname != "" { sess.And("user.nickname LIKE ?", "%"+req.Nickname+"%") @@ -29,8 +68,8 @@ func PageSendRedPackageOrd(req md.PageSendRedPackageOrdReq) (err error, resp md. if req.State != 0 { sess.And("im_send_red_package_ord.state = ?", req.State) } - if req.Uid != 0 { - sess.And("im_send_red_package_ord.uid = ?", req.Uid) + if len(imUserIds) != 0 { + sess.In("im_send_red_package_ord.uid", imUserIds) } if req.RedPacketType != 0 { sess.And("im_send_red_package_ord.red_packet_type = ?", req.RedPacketType) @@ -41,9 +80,7 @@ func PageSendRedPackageOrd(req md.PageSendRedPackageOrdReq) (err error, resp md. if req.StartTimeEnd != "" { sess.And("im_send_red_package_ord.create_time <= ?", req.StartTimeEnd) } - if req.InviteCode != "" { - sess.And("user.invite_code = ?", req.InviteCode) - } + sess.Join("LEFT", "user", "im_send_red_package_ord.uid = user.id") var mm []*PageSendRedPackageOrdJoinUser diff --git a/app/task/init.go b/app/task/init.go index 93c26a0..ebc4517 100644 --- a/app/task/init.go +++ b/app/task/init.go @@ -91,12 +91,13 @@ func initTasks() { jobs[taskMd.CronEggEnergyDealPlatformRevenueData] = taskEggEnergyDealPlatformRevenueData jobs[taskMd.CronEggEnergyDealFundData] = taskEggEnergyDealFundData jobs[taskMd.CronEggEnergyUserEggScore] = taskCronEggEnergyUserEggScore - jobs[taskMd.CornEggEnergyAutoReleaseTeamEggEnergy] = taskEggEnergyAutoReleaseTeamEggEnergy // 蛋蛋能量-自动释放团队蛋蛋能量到个人能量 - jobs[taskMd.CornSettlementStarLevelDividends] = taskEggEnergySettlementStarLevelDividends // 蛋蛋能量-结算星级分红 - jobs[taskMd.CornEggEnergyDealUserPublicPlatoonPunish] = taskEggEnergyDealUserPublicPlatoonPunish // 蛋蛋能量-公排处罚 - jobs[taskMd.CornEggEnergyAutoAdjustPrice] = taskEggEnergyAutoAdjustPrice // 蛋蛋能量-自动调整价格 - jobs[taskMd.CornEggEnergyAutoCommunityDividends] = taskEggEnergyCommunityDividends // 蛋蛋能量-社区分红 - jobs[taskMd.CornEggEnergyAutomaticScoring] = taskEggEnergyAutomaticScoring // 蛋蛋能量-自动打分 - jobs[taskMd.CornEggEnergyAutoCachingEggPointStatistics] = taskAutoCachingEggPointStatistics // 蛋蛋分统计落地页-缓存 - jobs[taskMd.CornEggEnergyAutoUpdateUserAccess] = taskEggEnergyAutoUpdateUserAccess // es蛋蛋分记录-自动更新访问次数 + jobs[taskMd.CornEggEnergyAutoReleaseTeamEggEnergy] = taskEggEnergyAutoReleaseTeamEggEnergy // 蛋蛋能量-自动释放团队蛋蛋能量到个人能量 + jobs[taskMd.CornSettlementStarLevelDividends] = taskEggEnergySettlementStarLevelDividends // 蛋蛋能量-结算星级分红 + jobs[taskMd.CornEggEnergyDealUserPublicPlatoonPunish] = taskEggEnergyDealUserPublicPlatoonPunish // 蛋蛋能量-公排处罚 + jobs[taskMd.CornEggEnergyAutoAdjustPrice] = taskEggEnergyAutoAdjustPrice // 蛋蛋能量-自动调整价格 + jobs[taskMd.CornEggEnergyAutoCommunityDividends] = taskEggEnergyCommunityDividends // 蛋蛋能量-社区分红 + jobs[taskMd.CornEggEnergyAutomaticScoring] = taskEggEnergyAutomaticScoring // 蛋蛋能量-自动打分 + jobs[taskMd.CornEggEnergyAutoCachingEggPointStatistics] = taskAutoCachingEggPointStatistics // 蛋蛋分统计落地页-缓存 + jobs[taskMd.CornEggEnergyAutoUpdateUserAccess] = taskEggEnergyAutoUpdateUserAccess // es蛋蛋分记录-自动更新访问次数 + jobs[taskMd.CornEggEnergyAutoDeleteTableAdvertisingCallback] = taskAutoDeleteTableAdvertisingCallback // 定时清除七天以前的广告回调数据 } diff --git a/app/task/md/cron_key.go b/app/task/md/cron_key.go index 6be0674..8f670b1 100644 --- a/app/task/md/cron_key.go +++ b/app/task/md/cron_key.go @@ -1,16 +1,17 @@ package md const ( - CronEggEnergyAutoRecordPrices = "cron_egg_energy_auto_record_price" // 自动记录价格 - CronEggEnergyDealPlatformRevenueData = "cron_egg_energy_deal_platform_revenue_data" // 处理平台收益 - CronEggEnergyDealFundData = "cron_egg_energy_deal_fund_data" // 处理价值投入 - CronEggEnergyUserEggScore = "cron_egg_energy_user_egg_score" // 处理蛋蛋分 - CornEggEnergyAutoReleaseTeamEggEnergy = "cron_egg_energy_auto_release_team_egg_energy" // 处理团队蛋蛋能量释放到个人蛋蛋能量 - CornSettlementStarLevelDividends = "cron_egg_energy_settlement_star_level_dividends" // 结算星级分红 - CornEggEnergyDealUserPublicPlatoonPunish = "cron_egg_energy_deal_user_public_platoon_punish" // 公排处罚 - CornEggEnergyAutoAdjustPrice = "cron_egg_energy_auto_adjust_price" // 自动调整价格 - CornEggEnergyAutoCommunityDividends = "cron_egg_energy_community_dividends" // 社区分红 - CornEggEnergyAutomaticScoring = "cron_egg_energy_automatic_score" // 自动打分 - CornEggEnergyAutoCachingEggPointStatistics = "cron_egg_energy_auto_caching_egg_point_statistics" // 缓存蛋蛋分统计落地页 - CornEggEnergyAutoUpdateUserAccess = "cron_egg_energy_auto_update_user_access" // 同步用户访问次数到es + CronEggEnergyAutoRecordPrices = "cron_egg_energy_auto_record_price" // 自动记录价格 + CronEggEnergyDealPlatformRevenueData = "cron_egg_energy_deal_platform_revenue_data" // 处理平台收益 + CronEggEnergyDealFundData = "cron_egg_energy_deal_fund_data" // 处理价值投入 + CronEggEnergyUserEggScore = "cron_egg_energy_user_egg_score" // 处理蛋蛋分 + CornEggEnergyAutoReleaseTeamEggEnergy = "cron_egg_energy_auto_release_team_egg_energy" // 处理团队蛋蛋能量释放到个人蛋蛋能量 + CornSettlementStarLevelDividends = "cron_egg_energy_settlement_star_level_dividends" // 结算星级分红 + CornEggEnergyDealUserPublicPlatoonPunish = "cron_egg_energy_deal_user_public_platoon_punish" // 公排处罚 + CornEggEnergyAutoAdjustPrice = "cron_egg_energy_auto_adjust_price" // 自动调整价格 + CornEggEnergyAutoCommunityDividends = "cron_egg_energy_community_dividends" // 社区分红 + CornEggEnergyAutomaticScoring = "cron_egg_energy_automatic_score" // 自动打分 + CornEggEnergyAutoCachingEggPointStatistics = "cron_egg_energy_auto_caching_egg_point_statistics" // 缓存蛋蛋分统计落地页 + CornEggEnergyAutoUpdateUserAccess = "cron_egg_energy_auto_update_user_access" // 同步用户访问次数到es + CornEggEnergyAutoDeleteTableAdvertisingCallback = "cron_egg_energy_auto_delete_table_advertising_callback" // 同步用户访问次数到es ) diff --git a/app/task/task_auto_delete_table_advertising_callback.go b/app/task/task_auto_delete_table_advertising_callback.go new file mode 100644 index 0000000..2fcf3c3 --- /dev/null +++ b/app/task/task_auto_delete_table_advertising_callback.go @@ -0,0 +1,22 @@ +package task + +import ( + "applet/app/task/svc" + "math/rand" + "time" + "xorm.io/xorm" +) + +func taskAutoDeleteTableAdvertisingCallback(eg *xorm.Engine) { + for { + if len(ch) > workerNum { + time.Sleep(time.Millisecond * time.Duration(rand.Intn(1000))) + } else { + goto START + } + } +START: + ch <- 1 + svc.AutoDeleteTableAdvertisingCallback(eg) + <-ch +} diff --git a/etc/cfg.yml b/etc/cfg.yml index 8613cbe..f9bff39 100644 --- a/etc/cfg.yml +++ b/etc/cfg.yml @@ -89,7 +89,7 @@ mq: pwd: 'guest' es: - url: 'http://120.55.48.175:9200' + url: 'http://123.57.140.192:9200' user: 'elastic' pwd: 'fnuo123'