sync_data.go 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361
  1. package task
  2. import (
  3. "context"
  4. "encoding/json"
  5. "errors"
  6. "fmt"
  7. "github.com/go-redis/redis/v8"
  8. "go.uber.org/zap"
  9. "gorm.io/gorm"
  10. "log-server/global"
  11. "log-server/model/log/request"
  12. "log-server/model/task"
  13. "log-server/model/task/control"
  14. request2 "log-server/model/task/request"
  15. "log-server/model/typeManage"
  16. "log-server/service/cache"
  17. "log-server/utils"
  18. "strconv"
  19. "time"
  20. )
  21. type SyncData struct {
  22. GameTask GameTask
  23. cache cache.Cache
  24. common Common
  25. Person typeManage.ResponsiblePerson
  26. }
  27. func (s *SyncData) SyncXmyGameData(date string) (mps map[int]control.XmyPayRequestReplyData, err error) {
  28. xmyUrl := "http://api.sheepsdk.17xmy.com/foreign/api/get_youhua_data.php"
  29. xmyParams := map[string]string{
  30. "start_day": date,
  31. "end_day": date,
  32. }
  33. requestData := new(control.XmyReply)
  34. xmyByteData, err := utils.HttpGet(xmyUrl, xmyParams)
  35. if err != nil {
  36. return
  37. }
  38. _ = json.Unmarshal(xmyByteData, &requestData)
  39. mps = map[int]control.XmyPayRequestReplyData{}
  40. for _, data := range requestData.Data.List {
  41. gameId, _ := strconv.Atoi(data.GameId)
  42. mps[gameId] = data
  43. }
  44. return
  45. }
  46. func (s *SyncData) SyncXmyFreeData(date string, gameId int) (num int, err error) {
  47. xmyFreeUrl := "http://rtd.kfzs.com/fake.php"
  48. xmyFreeParams := map[string]string{
  49. "day": date,
  50. "game_id": strconv.Itoa(gameId),
  51. }
  52. requestData := new(control.XmyFreeReply)
  53. xmyByteData, err := utils.HttpGet(xmyFreeUrl, xmyFreeParams)
  54. if err != nil {
  55. return
  56. }
  57. _ = json.Unmarshal(xmyByteData, &requestData)
  58. if len(requestData.Data) != 0 {
  59. num, _ = strconv.Atoi(requestData.Data[0].Num)
  60. }
  61. return
  62. }
  63. func (s *SyncData) SyncWslGameData(date string) (mps map[string]int, err error) {
  64. wslUrl := "http://148.70.251.170/wsl-A/get_sheep_pay.php"
  65. wslParams := map[string]string{
  66. "times": date,
  67. }
  68. var requestData []control.WslReply
  69. wslByteData, err := utils.HttpGet(wslUrl, wslParams)
  70. if err != nil {
  71. return
  72. }
  73. _ = json.Unmarshal(wslByteData, &requestData)
  74. mps = map[string]int{}
  75. for _, data := range requestData {
  76. num, _ := strconv.Atoi(data.Money)
  77. mps[data.GameId] = num
  78. }
  79. return
  80. }
  81. var taskStatistics = "%s:taskStatistics"
  82. func (s *SyncData) SyncRoomData(date string, gameIdInt int) (ts request.TaskStatistics, err error) {
  83. ctx := context.Background()
  84. key := fmt.Sprintf(taskStatistics, date)
  85. gameIdStr := strconv.Itoa(gameIdInt)
  86. data, err := global.GVA_REDIS.HGet(ctx, key, gameIdStr).Result()
  87. if err != nil {
  88. if err == redis.Nil {
  89. global.GVA_LOG.Info("SyncRoomData not data", zap.Error(err))
  90. } else {
  91. global.GVA_LOG.Error("SyncRoomData fail", zap.Error(err))
  92. return
  93. }
  94. }
  95. _ = json.Unmarshal([]byte(data), &ts)
  96. return
  97. }
  98. // 获取任务完成数据
  99. func (s *SyncData) CompleteTaskData(date string) (mps map[int]task.GameTargetComplete, err error) {
  100. db := global.GVA_DB.Table("game_target_complete")
  101. db = db.Where("create_date = ?", date)
  102. var apiList []task.GameTargetComplete
  103. mps = map[int]task.GameTargetComplete{}
  104. err = db.Order("id desc").Find(&apiList).Error
  105. for _, api := range apiList {
  106. mps[api.TaskId] = api
  107. }
  108. return
  109. }
  110. // 同步每天的任务基础数据
  111. func (s *SyncData) EveryDaySyncTaskData() {
  112. db := global.GVA_DB.Model(&task.GameTask{})
  113. var apiList []task.GameTask
  114. db = db.Where("is_del = ?", -1)
  115. db = db.Where("status = ?", 1)
  116. err := db.Order("id desc").Find(&apiList).Error
  117. if err != nil {
  118. global.GVA_LOG.Error("EveryDaySyncTaskData fail", zap.Error(err))
  119. return
  120. }
  121. date := time.Now().Add(+time.Hour * 24)
  122. var gameTargetCompletes []*task.GameTargetComplete
  123. for _, gameTask := range apiList {
  124. if !errors.Is(global.GVA_DB.Where("task_id = ?", gameTask.TaskId).Where("create_date = ?", date).First(&task.GameTargetComplete{}).Error, gorm.ErrRecordNotFound) {
  125. continue
  126. }
  127. gameTargetComplete := s.GameTask.CreateGameTargetCompleteModel(gameTask, date)
  128. gameTargetCompletes = append(gameTargetCompletes, gameTargetComplete)
  129. }
  130. err = global.GVA_DB.Model(&task.GameTargetComplete{}).Omit("update_time", "game_rate", "is_complete").Create(gameTargetCompletes).Error
  131. if err != nil {
  132. global.GVA_LOG.Error("create GameTargetComplete fail", zap.Error(err))
  133. return
  134. }
  135. return
  136. }
  137. // 定时同步机房群控、小绵羊数据
  138. func (s *SyncData) SyncTaskData() {
  139. db := global.GVA_DB.Model(&task.GameTask{})
  140. var apiList []task.GameTask
  141. db = db.Where("is_del = ?", -1)
  142. db = db.Where("status = ?", 1)
  143. err := db.Order("id desc").Find(&apiList).Error
  144. if err != nil {
  145. global.GVA_LOG.Error("EveryDaySyncTaskData fail", zap.Error(err))
  146. return
  147. }
  148. if len(apiList) == 0 {
  149. global.GVA_LOG.Info("没有任务数据")
  150. return
  151. }
  152. date := time.Now().Format("2006-01-02")
  153. xmyGameData, err := s.SyncXmyGameData(date)
  154. if err != nil {
  155. global.GVA_LOG.Error("SyncTaskData get xmy data fail", zap.Error(err))
  156. return
  157. }
  158. completeTaskData, err := s.CompleteTaskData(date)
  159. if err != nil {
  160. global.GVA_LOG.Error("CompleteTaskData get data fail", zap.Error(err))
  161. return
  162. }
  163. wslData, err := s.SyncWslGameData(date)
  164. if err != nil {
  165. global.GVA_LOG.Error("SyncWslGameData get wsl data fail", zap.Error(err))
  166. return
  167. }
  168. for _, gameTask := range apiList {
  169. var gameTarget task.GameTargetComplete
  170. roomData, _ := s.SyncRoomData(date, gameTask.TaskId)
  171. if gameTask.GameIdXmy != "" {
  172. gameIdXmy, _ := strconv.Atoi(gameTask.GameIdXmy)
  173. xmyGameInfo := xmyGameData[gameIdXmy]
  174. gameTarget.NewComplete, _ = strconv.Atoi(xmyGameInfo.UserNum)
  175. gameTarget.PayComplete, _ = strconv.Atoi(xmyGameInfo.Cnt)
  176. gameTarget.RetainedComplete, _ = strconv.Atoi(xmyGameInfo.ActiveUserNum)
  177. f, _ := strconv.ParseFloat(xmyGameInfo.Amount, 64)
  178. gameTarget.Amount = int(f)
  179. num, _ := s.SyncXmyFreeData(date, gameIdXmy)
  180. if num != 0 {
  181. gameTarget.PayTarget = num
  182. if gameTarget.PayTarget > completeTaskData[gameTask.TaskId].PayTarget {
  183. lastPayAddUpdateTimeKey := fmt.Sprintf(LastPayAddUpdateTimeKey, date, gameTask.TaskId)
  184. _ = s.cache.SetCacheStr(context.Background(), lastPayAddUpdateTimeKey, time.Now().Unix())
  185. // 本次加付费目标数据
  186. lastPayAddNumKey := fmt.Sprintf(LastPayAddNumKey, date, gameTask.TaskId)
  187. _ = s.cache.SetCacheStr(context.Background(), lastPayAddNumKey, gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget)
  188. payErrAddNumKey := fmt.Sprintf(PayErrAddNumKey, date, gameTask.TaskId)
  189. s.common.SaveGameAddFee(gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget, gameTarget.PayTarget, gameTask.TaskName)
  190. go s.FreeSendMsg(gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget, gameTarget.PayTarget, gameTask.TaskName, gameTask.User)
  191. // 如果当前付费目标完成,加入一下逻辑
  192. if completeTaskData[gameTask.TaskId].PayTarget <= completeTaskData[gameTask.TaskId].PayComplete {
  193. lastPayCompletedUpdateTimeKey := fmt.Sprintf(LastPayCompletedUpdateTimeKey, date, gameTask.TaskId)
  194. _ = s.cache.SetCacheStr(context.Background(), lastPayCompletedUpdateTimeKey, time.Now().Unix())
  195. _ = s.cache.SetCacheStr(context.Background(), payErrAddNumKey, gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget)
  196. } else {
  197. n, _ := s.cache.GetCacheNum(context.Background(), payErrAddNumKey)
  198. _ = s.cache.SetCacheStr(context.Background(), payErrAddNumKey, gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget+n)
  199. }
  200. }
  201. }
  202. } else {
  203. gameTarget.NewComplete = roomData.NewCompleteLocal
  204. gameTarget.PayComplete = roomData.PayCompleteLocal
  205. gameTarget.RetainedComplete = roomData.NewCompleteLocal + roomData.RetainedCompleteLocal
  206. gameTarget.Amount = gameTask.PayPrice * roomData.PayCompleteLocal
  207. if gameTarget.RetainedComplete < roomData.RetainedComplete {
  208. gameTarget.RetainedComplete = roomData.RetainedComplete
  209. }
  210. }
  211. gameTarget.GameRate = roomData.GameRate
  212. if gameTask.GamePortId == 5 && gameTask.LoginMethod == 2 {
  213. mzGameId := gameTask.MzGameId + "-" + gameTask.MzChannel
  214. if _, ok := wslData[mzGameId]; ok {
  215. gameTarget.PayTarget = wslData[mzGameId]
  216. if gameTarget.PayTarget > completeTaskData[gameTask.TaskId].PayTarget {
  217. lastPayAddUpdateTimeKey := fmt.Sprintf(LastPayAddUpdateTimeKey, date, gameTask.TaskId)
  218. _ = s.cache.SetCacheStr(context.Background(), lastPayAddUpdateTimeKey, time.Now().Unix())
  219. // 本次加付费目标数据
  220. lastPayAddNumKey := fmt.Sprintf(LastPayAddNumKey, date, gameTask.TaskId)
  221. _ = s.cache.SetCacheStr(context.Background(), lastPayAddNumKey, gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget)
  222. payErrAddNumKey := fmt.Sprintf(PayErrAddNumKey, date, gameTask.TaskId)
  223. s.common.SaveGameAddFee(gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget, gameTarget.PayTarget, gameTask.TaskName)
  224. go s.FreeSendMsg(gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget, gameTarget.PayTarget, gameTask.TaskName, gameTask.User)
  225. // 如果当前付费目标完成,加入一下逻辑
  226. if completeTaskData[gameTask.TaskId].PayTarget <= completeTaskData[gameTask.TaskId].PayComplete {
  227. lastPayCompletedUpdateTimeKey := fmt.Sprintf(LastPayCompletedUpdateTimeKey, date, gameTask.TaskId)
  228. _ = s.cache.SetCacheStr(context.Background(), lastPayCompletedUpdateTimeKey, time.Now().Unix())
  229. _ = s.cache.SetCacheStr(context.Background(), payErrAddNumKey, gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget)
  230. } else {
  231. n, _ := s.cache.GetCacheNum(context.Background(), payErrAddNumKey)
  232. _ = s.cache.SetCacheStr(context.Background(), payErrAddNumKey, gameTarget.PayTarget-completeTaskData[gameTask.TaskId].PayTarget+n)
  233. }
  234. }
  235. }
  236. }
  237. gameTarget.IsComplete = -1
  238. if gameTarget.RetainedComplete+completeTaskData[gameTask.TaskId].HandRetainedComplete >= completeTaskData[gameTask.TaskId].RetainedTarget && gameTarget.PayComplete >= completeTaskData[gameTask.TaskId].PayTarget && gameTarget.NewComplete+completeTaskData[gameTask.TaskId].HandNewComplete >= completeTaskData[gameTask.TaskId].NewTarget {
  239. gameTarget.IsComplete = 1
  240. }
  241. global.GVA_DB.Model(&task.GameTargetComplete{}).Where("task_id = ?", gameTask.TaskId).Where("create_date = ?", date).Omit("create_date", "update_time", "task_id").Updates(gameTarget)
  242. }
  243. return
  244. }
  245. func (s *SyncData) DayTargetDataStatistics() {
  246. date := time.Now().Add(-time.Hour * 24).Format("2006-01-02")
  247. request1 := request2.GameTaskStatisticsRequest{
  248. GroupKey: "user,gt.game_port_id",
  249. Date: date,
  250. }
  251. gameTargets, err := s.GameTask.EveryDayTargetData(date, request1)
  252. if err != nil {
  253. global.GVA_LOG.Error("DayTargetDataStatistics 统计数据失败", zap.Error(err))
  254. return
  255. }
  256. if len(gameTargets) == 0 {
  257. global.GVA_LOG.Info("没有数据统计", zap.Error(err))
  258. return
  259. }
  260. var gameTargetDates []task.GameTargetStatistics
  261. for _, gameTarget := range gameTargets {
  262. var gameTargetDate task.GameTargetStatistics
  263. gameTargetDate.PayTarget = gameTarget.PayTarget
  264. gameTargetDate.NewTarget = gameTarget.NewTarget
  265. gameTargetDate.RetainedTarget = gameTarget.RetainedTarget
  266. gameTargetDate.PayComplete = gameTarget.PayComplete
  267. gameTargetDate.NewComplete = gameTarget.NewComplete + gameTarget.HandNewComplete
  268. gameTargetDate.RetainedComplete = gameTarget.RetainedComplete + gameTarget.HandRetainedComplete
  269. gameTargetDate.Amount = gameTarget.Amount
  270. gameTargetDate.GamePortId = gameTarget.GamePortId
  271. gameTargetDate.User = gameTarget.User
  272. gameTargetDate.TaskDate = gameTarget.CreateDate
  273. if !errors.Is(global.GVA_DB.Where("user = ?", gameTarget.User).Where("task_date = ?", gameTarget.CreateDate).Where("game_port_id = ?", gameTarget.GamePortId).First(&task.GameTargetStatistics{}).Error, gorm.ErrRecordNotFound) {
  274. err := global.GVA_DB.Where("user = ?", gameTarget.User).Where("task_date = ?", gameTarget.CreateDate).Where("game_port_id = ?", gameTarget.GamePortId).Omit("update_time", "task_date", "user", "game_port_id", "task_month", "task_year").Updates(&gameTargetDate).Error
  275. if err != nil {
  276. global.GVA_LOG.Error("DayTargetDataStatistics 更新统计数据失败", zap.Error(err))
  277. }
  278. continue
  279. }
  280. year, month, _ := time.Now().Date()
  281. gameTargetDate.TaskMonth = int(month)
  282. gameTargetDate.TaskYear = year
  283. gameTargetDates = append(gameTargetDates, gameTargetDate)
  284. }
  285. if len(gameTargetDates) < 1 {
  286. return
  287. }
  288. global.GVA_DB.Omit("update_time").Create(gameTargetDates)
  289. }
  290. var LastMsgSendTimeKey = "%s:lastMsgSendTime" // 上次活跃发送消息时间
  291. var LastNewCompletedKey = "%s:msgSendInfo:%d:lastNewCompleted" // 最后新增完成数量
  292. var LastPayCompletedKey = "%s:msgSendInfo:%d:lastPayCompleted" // 最后支付完成数量
  293. var LastRetainedCompletedKey = "%s:msgSendInfo:%d:lastRetainedCompleted" // 最后留存完成数量
  294. var LastNewCompletedUpdateTimeKey = "%s:msgSendInfo:%d:lastNewCompletedUpdateTime" // 最后新增完成更新时间
  295. var LastPayCompletedUpdateTimeKey = "%s:msgSendInfo:%d:lastPayCompletedUpdateTime" // 最后支付完成更新时间
  296. var LastRetainedCompletedUpdateTimeKey = "%s:msgSendInfo:%d:lastRetainedCompletedUpdateTime" // 最后留存完成更新时间
  297. var LastPayAddUpdateTimeKey = "%s:msgSendInfo:%d:lastPayAddUpdateTime" // 最后加付费时间
  298. var LastPayAddNumKey = "%s:msgSendInfo:%d:lastPayAddNum" // 最后加付费数量
  299. var PayErrAddNumKey = "%s:msgSendInfo:%d:PayErrAddNum" // 支付异常累加数量
  300. var TaskCompletedStatusKey = "%s:taskCompletedStatus" // 任务完成状态-1,1
  301. var LastFreeMsgSendTimeKey = "%s:lastFreeMsgSendTime" // 上次付费发送消息时间
  302. type CompletedInfo struct {
  303. AlsoTarget int //剩余数量
  304. Rate int //时间段做的任务数
  305. TimeRate int // 完成任务数据更新时间
  306. TaskId int
  307. AddPayUpdateTime int
  308. }
  309. // 获取未完成的任务数据
  310. func (s *SyncData) TaskNoCompleteDate(date string) (completesInfo []task.GameTargetComplete, err error) {
  311. db := global.GVA_DB.Table("game_target_complete")
  312. db = db.Where("is_complete = ?", -1)
  313. db = db.Where("create_date = ?", date)
  314. err = db.Find(&completesInfo).Error
  315. if err != nil {
  316. return
  317. }
  318. return
  319. }
  320. func (s *SyncData) TaskMsgSendInitData(ctx context.Context, completesInfo []task.GameTargetComplete, ctime int64, date, taskCompletedStatusKey, lastMsgSendTimeKey string) {
  321. for _, complete := range completesInfo {
  322. lastNewCompletedKey := fmt.Sprintf(LastNewCompletedKey, date, complete.TaskId)
  323. lastPayCompletedKey := fmt.Sprintf(LastPayCompletedKey, date, complete.TaskId)
  324. lastRetainedCompletedKey := fmt.Sprintf(LastRetainedCompletedKey, date, complete.TaskId)
  325. lastPayCompletedUpdateTimeKey := fmt.Sprintf(LastPayCompletedUpdateTimeKey, date, complete.TaskId)
  326. lastNewCompletedUpdateTimeKey := fmt.Sprintf(LastNewCompletedUpdateTimeKey, date, complete.TaskId)
  327. lastRetainedCompletedUpdateTimeKey := fmt.Sprintf(LastRetainedCompletedUpdateTimeKey, date, complete.TaskId)
  328. lastNewCompleted := complete.NewComplete + complete.HandNewComplete //上次新增完成数
  329. _ = s.cache.SetCacheStr(ctx, lastNewCompletedKey, lastNewCompleted)
  330. lastPayCompleted := complete.PayComplete + complete.HandPayComplete //上次支付完成数
  331. _ = s.cache.SetCacheStr(ctx, lastPayCompletedKey, lastPayCompleted)
  332. lastRetainedCompleted := complete.RetainedComplete + complete.HandRetainedComplete //上次活跃完成数
  333. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedKey, lastRetainedCompleted)
  334. //lastNewCompletedUpdateTime := complete.NewComplete //上次新增完成更新时间
  335. _ = s.cache.SetCacheStr(ctx, lastNewCompletedUpdateTimeKey, ctime)
  336. //lastPayCompletedUpdateTime := complete.NewComplete //上次支付完成更新时间
  337. _ = s.cache.SetCacheStr(ctx, lastPayCompletedUpdateTimeKey, ctime)
  338. //lastRetainedCompletedUpdateTime := complete.NewComplete //上次留存完成更新时间
  339. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedUpdateTimeKey, ctime)
  340. //lastPayAddUpdateTime := complete.NewComplete //上次付费增加更新时间
  341. }
  342. _ = s.cache.SetCacheStr(ctx, taskCompletedStatusKey, -1)
  343. _ = s.cache.SetCacheStr(ctx, lastMsgSendTimeKey, time.Now().Unix())
  344. }
  345. func (s *SyncData) TaskMsgSendRetainedData(ctx context.Context, completesInfo []task.GameTargetComplete, ctime int64, date, lastMsgSendTimeKey string) {
  346. var mps = make(map[int]map[string]CompletedInfo)
  347. lastMsgSendTime, _ := s.cache.GetCacheNum(ctx, lastMsgSendTimeKey)
  348. for _, complete := range completesInfo {
  349. lastNewCompletedKey := fmt.Sprintf(LastNewCompletedKey, date, complete.TaskId)
  350. lastRetainedCompletedKey := fmt.Sprintf(LastRetainedCompletedKey, date, complete.TaskId)
  351. lastNewCompletedUpdateTimeKey := fmt.Sprintf(LastNewCompletedUpdateTimeKey, date, complete.TaskId)
  352. lastRetainedCompletedUpdateTimeKey := fmt.Sprintf(LastRetainedCompletedUpdateTimeKey, date, complete.TaskId)
  353. currentNewCompleted := complete.NewComplete + complete.HandNewComplete
  354. currentRetainedCompleted := complete.RetainedComplete + complete.HandRetainedComplete
  355. var RateMp = make(map[string]CompletedInfo)
  356. var newBool = false
  357. var retainedBoll = false
  358. // 处理新增
  359. if complete.NewTarget > currentNewCompleted {
  360. lastNewCompleted, _ := s.cache.GetCacheNum(ctx, lastNewCompletedKey)
  361. alsoNewTarget := complete.NewTarget - currentNewCompleted
  362. newRate := 0
  363. lastNewCompletedUpdateTime, _ := s.cache.GetCacheNum(ctx, lastNewCompletedUpdateTimeKey)
  364. timeRate := int(ctime) - lastNewCompletedUpdateTime
  365. if lastNewCompleted < currentNewCompleted {
  366. newRate = currentNewCompleted - lastNewCompleted
  367. _ = s.cache.SetCacheStr(ctx, lastNewCompletedKey, currentNewCompleted)
  368. _ = s.cache.SetCacheStr(ctx, lastNewCompletedUpdateTimeKey, ctime) //上次新增完成更新时间
  369. }
  370. RateMp["newRate"] = CompletedInfo{
  371. AlsoTarget: alsoNewTarget,
  372. Rate: newRate,
  373. TimeRate: timeRate,
  374. TaskId: complete.TaskId,
  375. }
  376. } else {
  377. newBool = true
  378. // 如果当前新增为0,或者完成也更新时间
  379. _ = s.cache.SetCacheStr(ctx, lastNewCompletedUpdateTimeKey, ctime) //上次新增完成更新时间
  380. }
  381. // 处理留存
  382. if complete.RetainedTarget > currentRetainedCompleted {
  383. lastRetainedCompleted, _ := s.cache.GetCacheNum(ctx, lastRetainedCompletedKey)
  384. alsoRetainedTarget := complete.RetainedTarget - currentRetainedCompleted
  385. retainedRate := 0
  386. lastRetainedCompletedUpdateTime, _ := s.cache.GetCacheNum(ctx, lastRetainedCompletedUpdateTimeKey)
  387. timeRate := int(ctime) - lastRetainedCompletedUpdateTime
  388. if lastRetainedCompleted < currentRetainedCompleted {
  389. retainedRate = currentRetainedCompleted - lastRetainedCompleted
  390. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedKey, currentRetainedCompleted)
  391. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedUpdateTimeKey, ctime) //上次留存完成更新时间
  392. }
  393. RateMp["retainedRate"] = CompletedInfo{
  394. AlsoTarget: alsoRetainedTarget,
  395. Rate: retainedRate,
  396. TimeRate: timeRate,
  397. TaskId: complete.TaskId,
  398. }
  399. } else {
  400. retainedBoll = true
  401. // 如果当前留存为0,或者完成也更新时间
  402. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedUpdateTimeKey, ctime) //上次留存完成更新时间
  403. }
  404. if !newBool || !retainedBoll {
  405. mps[complete.TaskId] = RateMp
  406. }
  407. }
  408. var taskStatistics = "%s:taskStatistics"
  409. var retained = "# 活跃播报 "
  410. if len(mps) == 0 {
  411. global.GVA_LOG.Warn(retained)
  412. }
  413. retained += fmt.Sprintf("<font color=\"warning\">%s</font>", time.Now().Format("2006-01-02 15:04:05"))
  414. var errMsg = "**以下游戏目标效率为零:**"
  415. var errMsgZ = ""
  416. var sendMsg = map[string]string{}
  417. var errSendMsg = map[string]string{}
  418. var m int // 时间内
  419. m = (int(ctime) - lastMsgSendTime) / 60
  420. for taskId, data := range mps {
  421. key := fmt.Sprintf(taskStatistics, date)
  422. gameIdStr := strconv.Itoa(taskId)
  423. gameTask, err := global.GVA_REDIS.HGet(ctx, key, gameIdStr).Result()
  424. if err != nil {
  425. if err == redis.Nil {
  426. continue
  427. } else {
  428. global.GVA_LOG.Error("TaskMsgSendRetainedData获取缓存任务数据失败", zap.Error(err))
  429. continue
  430. }
  431. }
  432. var taskStatistics request.TaskStatistics
  433. _ = json.Unmarshal([]byte(gameTask), &taskStatistics)
  434. var eMsg = "" //单条异常数据
  435. var isNew = false
  436. var nm int //新增时间内
  437. var rm int //存时间内
  438. var rate string //效率
  439. var newErr = false
  440. var retainedErr = false
  441. var name = taskStatistics.Remark
  442. if info, ok := data["newRate"]; ok {
  443. sendMsg[name] += "\n"
  444. sendMsg[name] += taskStatistics.GameName
  445. sendMsg[name] += ",新增差"
  446. //sendMsg[name] += strconv.Itoa(info.AlsoTarget)
  447. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%d</font>", info.AlsoTarget)
  448. isNew = true
  449. if info.TimeRate > 60*60*24 {
  450. lastNewCompletedUpdateTimeKey := fmt.Sprintf(LastNewCompletedUpdateTimeKey, date, info.TaskId)
  451. _ = s.cache.SetCacheStr(ctx, lastNewCompletedUpdateTimeKey, ctime) //上次新增完成更新时间
  452. nm = 1
  453. } else {
  454. nm = info.TimeRate / 60
  455. }
  456. rate = strconv.Itoa(info.Rate)
  457. if info.Rate == 0 {
  458. newErr = true
  459. }
  460. }
  461. if info, ok := data["retainedRate"]; ok {
  462. if !isNew {
  463. sendMsg[name] += "\n"
  464. sendMsg[name] += taskStatistics.GameName
  465. rate = strconv.Itoa(info.Rate)
  466. sendMsg[name] += "活跃差"
  467. } else {
  468. rate += "/" + strconv.Itoa(info.Rate)
  469. sendMsg[name] += ",活跃差"
  470. }
  471. if info.TimeRate > 60*60*24 {
  472. lastRetainedCompletedUpdateTimeKey := fmt.Sprintf(LastRetainedCompletedUpdateTimeKey, date, info.TaskId)
  473. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedUpdateTimeKey, ctime) //上次留存完成更新时间
  474. rm = 1
  475. } else {
  476. rm = info.TimeRate / 60
  477. }
  478. //sendMsg[name] += strconv.Itoa(info.AlsoTarget)
  479. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%d</font>", info.AlsoTarget)
  480. if info.Rate == 0 {
  481. retainedErr = true
  482. }
  483. }
  484. // 5分钟数据没动报异常数据
  485. if newErr && nm > 4 {
  486. eMsg += "\n"
  487. eMsg += taskStatistics.GameName
  488. eMsg += ",新增"
  489. if nm >= 60 {
  490. eMsg += "("
  491. eMsg += strconv.Itoa(nm / 60)
  492. eMsg += "小时内)"
  493. } else {
  494. eMsg += "("
  495. eMsg += strconv.Itoa(nm)
  496. eMsg += "分钟内)"
  497. }
  498. }
  499. if retainedErr && rm > 4 {
  500. if !newErr {
  501. eMsg += "\n"
  502. eMsg += taskStatistics.GameName
  503. }
  504. eMsg += ",活跃"
  505. if rm >= 60 {
  506. eMsg += "("
  507. eMsg += strconv.Itoa(rm / 60)
  508. eMsg += "小时内)"
  509. } else {
  510. eMsg += "("
  511. eMsg += strconv.Itoa(rm)
  512. eMsg += "分钟内)"
  513. }
  514. }
  515. if eMsg != "" {
  516. errMsgZ += eMsg
  517. errSendMsg[name] += eMsg
  518. }
  519. sendMsg[name] += ","
  520. if m >= 60 {
  521. sendMsg[name] += strconv.Itoa(m / 60)
  522. sendMsg[name] += "小时内完成"
  523. } else {
  524. sendMsg[name] += strconv.Itoa(m)
  525. sendMsg[name] += "分钟内完成"
  526. }
  527. //sendMsg[name] += rate
  528. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%s</font>", rate)
  529. }
  530. hour := time.Now().Hour()
  531. msg := ""
  532. mpsPerson, _ := s.Person.GetUserInfo()
  533. //b1 ,_ := json.Marshal(mpsPerson)
  534. //global.GVA_LOG.Warn(string(b1))
  535. var mobile []string
  536. if hour >= 16 {
  537. if len(sendMsg) == 0 {
  538. return
  539. }
  540. if len(mps) != 0 && len(errSendMsg) != 0 {
  541. for name, _ := range errSendMsg {
  542. mobile = append(mobile, mpsPerson[name])
  543. }
  544. }
  545. for name, msg := range sendMsg {
  546. retained += "\n"
  547. retained += "**" + name + "**"
  548. retained += msg
  549. }
  550. msg = retained
  551. if errMsgZ != "" {
  552. msg += "\n"
  553. //msg += errMsg + errMsgZ
  554. msg += fmt.Sprintf("<font color=\"warning\">%s</font>", errMsg+errMsgZ)
  555. }
  556. } else {
  557. if errMsgZ != "" {
  558. //msg += errMsg + errMsgZ
  559. }
  560. if len(mps) != 0 && len(errSendMsg) != 0 {
  561. msg += "# 活跃播报 "
  562. msg += errMsg
  563. for name, m := range errSendMsg {
  564. mobile = append(mobile, mpsPerson[name])
  565. msg += "\n"
  566. msg += "**" + name + "**"
  567. msg += fmt.Sprintf("<font color=\"warning\">%s</font>", m)
  568. }
  569. }
  570. }
  571. //global.GVA_LOG.Warn(msg)
  572. _ = s.cache.SetCacheStr(ctx, lastMsgSendTimeKey, time.Now().Unix())
  573. if msg == "" {
  574. return
  575. }
  576. url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
  577. var sendData SendMsg
  578. sendData.MsgType = "markdown"
  579. sendData.Markdown.Content = msg
  580. s.SendMsgData(url, sendData)
  581. if len(mobile) != 0 {
  582. var sendTextData SendTextMsg
  583. sendTextData.MsgType = "text"
  584. sendTextData.Text.MentionedMobileList = mobile
  585. //b ,_ := json.Marshal(sendTextData)
  586. //global.GVA_LOG.Warn(string(b))
  587. s.SendMsgData(url, sendTextData)
  588. }
  589. }
  590. func (s *SyncData) TaskMsgSendFreeData(ctx context.Context, completesInfo []task.GameTargetComplete, ctime int64, date, lastFreeMsgSendTimeKey string, isOne bool) {
  591. var RateMp = make(map[int]CompletedInfo)
  592. lastFreeMsgSendTime, _ := s.cache.GetCacheNum(ctx, lastFreeMsgSendTimeKey)
  593. for _, complete := range completesInfo {
  594. lastPayCompletedKey := fmt.Sprintf(LastPayCompletedKey, date, complete.TaskId)
  595. lastPayCompletedUpdateTimeKey := fmt.Sprintf(LastPayCompletedUpdateTimeKey, date, complete.TaskId)
  596. lastPayAddUpdateTimeKey := fmt.Sprintf(LastPayAddUpdateTimeKey, date, complete.TaskId)
  597. currentPayCompleted := complete.PayComplete + complete.HandPayComplete
  598. // 付费处理
  599. if complete.PayTarget != 0 && complete.PayTarget > currentPayCompleted {
  600. lastPayCompleted, _ := s.cache.GetCacheNum(ctx, lastPayCompletedKey)
  601. alsoPayTarget := complete.PayTarget - currentPayCompleted
  602. payRate := 0
  603. lastPayCompletedUpdateTime, _ := s.cache.GetCacheNum(ctx, lastPayCompletedUpdateTimeKey)
  604. lastPayAddUpdateTime, _ := s.cache.GetCacheNum(ctx, lastPayAddUpdateTimeKey)
  605. timeRate := int(ctime) - lastPayCompletedUpdateTime
  606. if lastPayCompleted < currentPayCompleted {
  607. payRate = currentPayCompleted - lastPayCompleted
  608. _ = s.cache.SetCacheStr(ctx, lastPayCompletedKey, currentPayCompleted)
  609. _ = s.cache.SetCacheStr(ctx, lastPayCompletedUpdateTimeKey, ctime) //上次付费更新时间
  610. }
  611. RateMp[complete.TaskId] = CompletedInfo{
  612. AlsoTarget: alsoPayTarget,
  613. Rate: payRate,
  614. TimeRate: timeRate,
  615. TaskId: complete.TaskId,
  616. AddPayUpdateTime: lastPayAddUpdateTime,
  617. }
  618. } else {
  619. // 如果当前付费为0,或者完成也更新时间
  620. _ = s.cache.SetCacheStr(ctx, lastPayCompletedUpdateTimeKey, ctime) //上次付费更新时间
  621. }
  622. }
  623. if isOne {
  624. _ = s.cache.SetCacheStr(ctx, lastFreeMsgSendTimeKey, time.Now().Unix())
  625. return
  626. }
  627. if len(RateMp) == 0 {
  628. global.GVA_LOG.Info("TaskMsgSendFreeData没有查询到未完成付费数据")
  629. return
  630. }
  631. var taskStatistics = "%s:taskStatistics"
  632. var retained = "付费播报 "
  633. retained += fmt.Sprintf("<font color=\"warning\">%s</font>", time.Now().Format("2006-01-02 15:04:05"))
  634. var errMsg = "**以下游戏付费效率为零:**"
  635. var errMsgZ = ""
  636. var sendMsg = map[string]string{}
  637. var m int //时间内
  638. m = (int(ctime) - lastFreeMsgSendTime) / 60
  639. mpsPerson, _ := s.Person.GetUserInfo()
  640. var mobile []string
  641. for taskId, data := range RateMp {
  642. if data.AlsoTarget <= 0 {
  643. continue
  644. }
  645. key := fmt.Sprintf(taskStatistics, date)
  646. gameIdStr := strconv.Itoa(taskId)
  647. gameTask, err := global.GVA_REDIS.HGet(ctx, key, gameIdStr).Result()
  648. if err != nil {
  649. if err == redis.Nil {
  650. continue
  651. } else {
  652. global.GVA_LOG.Error("TaskMsgSendRetainedData获取缓存任务数据失败", zap.Error(err))
  653. continue
  654. }
  655. }
  656. var taskStatistics request.TaskStatistics
  657. _ = json.Unmarshal([]byte(gameTask), &taskStatistics)
  658. var name = taskStatistics.Remark
  659. sendMsg[name] += "\n"
  660. sendMsg[name] += taskStatistics.GameName
  661. sendMsg[name] += ",付费差"
  662. //sendMsg[name] += strconv.Itoa(data.AlsoTarget)
  663. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%d</font>", data.AlsoTarget)
  664. if data.TimeRate > 60*60*24 {
  665. lastPayCompletedUpdateTimeKey := fmt.Sprintf(LastPayCompletedUpdateTimeKey, date, data.TaskId)
  666. _ = s.cache.SetCacheStr(ctx, lastPayCompletedUpdateTimeKey, ctime) //上次付费更新时间
  667. data.TimeRate = 60 * 60 * 2
  668. }
  669. // 5分钟数据没动报异常数据
  670. if data.TimeRate/60 >= 2 {
  671. if data.Rate == 0 {
  672. lastPayAddNumKey := fmt.Sprintf(LastPayAddNumKey, date, data.TaskId)
  673. payErrAddNumKey := fmt.Sprintf(PayErrAddNumKey, date, data.TaskId)
  674. numErr, _ := s.cache.GetCacheNum(context.Background(), payErrAddNumKey)
  675. lastAddFeeNumErr, _ := s.cache.GetCacheNum(context.Background(), lastPayAddNumKey)
  676. errMsgZ += "\n"
  677. errMsgZ += taskStatistics.GameName
  678. errMsgZ += "("
  679. if data.TimeRate/60 >= 60 {
  680. errMsgZ += strconv.Itoa(data.TimeRate / 60 / 60)
  681. errMsgZ += "小时内(+" + strconv.Itoa(numErr) + "))"
  682. } else {
  683. errMsgZ += strconv.Itoa(data.TimeRate / 60)
  684. errMsgZ += "分钟内(+" + strconv.Itoa(numErr) + "))"
  685. }
  686. errMsgZ += ","
  687. errMsgZ += "最后加付费时间 "
  688. t := time.Unix(int64(data.AddPayUpdateTime), 0)
  689. errMsgZ += t.Format("15:04:05")
  690. errMsgZ += "(+" + strconv.Itoa(lastAddFeeNumErr) + ")"
  691. if _, ok := mpsPerson[name]; ok {
  692. mobile = append(mobile, mpsPerson[name])
  693. }
  694. }
  695. }
  696. sendMsg[name] += ","
  697. if m >= 60 {
  698. sendMsg[name] += strconv.Itoa(m / 60)
  699. sendMsg[name] += "分钟内完成"
  700. } else {
  701. sendMsg[name] += strconv.Itoa(m)
  702. sendMsg[name] += "分钟内完成"
  703. }
  704. //sendMsg[name] += strconv.Itoa(data.Rate)
  705. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%d</font>", data.Rate)
  706. }
  707. if len(sendMsg) == 0 {
  708. return
  709. }
  710. for name, msg := range sendMsg {
  711. retained += "\n"
  712. retained += name
  713. retained += msg
  714. }
  715. msg := retained
  716. if errMsgZ != "" {
  717. msg += "\n"
  718. //msg += errMsg + errMsgZ
  719. msg += fmt.Sprintf("<font color=\"warning\">%s</font>", errMsg+errMsgZ)
  720. }
  721. _ = s.cache.SetCacheStr(ctx, lastFreeMsgSendTimeKey, time.Now().Unix())
  722. url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
  723. var sendData SendMsg
  724. sendData.MsgType = "markdown"
  725. sendData.Markdown.Content = msg
  726. s.SendMsgData(url, sendData)
  727. if len(mobile) != 0 {
  728. var sendTextData SendTextMsg
  729. sendTextData.MsgType = "text"
  730. sendTextData.Text.MentionedMobileList = mobile
  731. s.SendMsgData(url, sendTextData)
  732. }
  733. return
  734. }
  735. func (s *SyncData) SendMsgData(url string, params interface{}) {
  736. _, _ = utils.HttpPost(url, params)
  737. return
  738. }
  739. //活跃新增数据推送
  740. func (s *SyncData) TaskMsgSend() {
  741. date := time.Now().Format("2006-01-02")
  742. ctx := context.Background()
  743. taskCompletedStatusKey := fmt.Sprintf(TaskCompletedStatusKey, date)
  744. taskCompletedStatus, _ := s.cache.GetCacheNum(ctx, taskCompletedStatusKey)
  745. if taskCompletedStatus == 1 {
  746. return
  747. }
  748. completesInfo, err := s.TaskNoCompleteDate(date)
  749. if err != nil {
  750. global.GVA_LOG.Error("TaskMsgSend查询任务数据报错", zap.Error(err))
  751. }
  752. if len(completesInfo) == 0 {
  753. global.GVA_LOG.Info("TaskMsgSend没有查询到未完成数据")
  754. }
  755. lastMsgSendTimeKey := fmt.Sprintf(LastMsgSendTimeKey, date)
  756. b, err := s.cache.ExistsKey(context.Background(), lastMsgSendTimeKey)
  757. if err != nil {
  758. global.GVA_LOG.Error("TaskMsgSend查询任务数据报错", zap.Error(err))
  759. return
  760. }
  761. ctime := time.Now().Unix()
  762. if !b {
  763. s.TaskMsgSendInitData(ctx, completesInfo, ctime, date, taskCompletedStatusKey, lastMsgSendTimeKey)
  764. } else {
  765. lastMsgSendTime, _ := s.cache.GetCacheNum(ctx, lastMsgSendTimeKey)
  766. if int(ctime)-lastMsgSendTime < 60 {
  767. global.GVA_LOG.Error("TaskMsgSend上次数据发送时间还没到5分钟", zap.Error(err))
  768. return
  769. }
  770. s.TaskMsgSendRetainedData(ctx, completesInfo, ctime, date, lastMsgSendTimeKey)
  771. }
  772. }
  773. //活跃新增数据推送
  774. func (s *SyncData) TaskFreeMsgSend() {
  775. date := time.Now().Format("2006-01-02")
  776. ctx := context.Background()
  777. taskCompletedStatusKey := fmt.Sprintf(TaskCompletedStatusKey, date)
  778. taskCompletedStatus, _ := s.cache.GetCacheNum(ctx, taskCompletedStatusKey)
  779. if taskCompletedStatus == 1 {
  780. return
  781. }
  782. completesInfo, err := s.TaskNoCompleteDate(date)
  783. if err != nil {
  784. global.GVA_LOG.Error("TaskMsgSend查询任务数据报错", zap.Error(err))
  785. }
  786. if len(completesInfo) == 0 {
  787. global.GVA_LOG.Info("TaskMsgSend没有查询到未完成数据")
  788. }
  789. lastFreeMsgSendTimeKey := fmt.Sprintf(LastFreeMsgSendTimeKey, date)
  790. ctime := time.Now().Unix()
  791. lastFreeMsgSendTime, _ := s.cache.GetCacheNum(ctx, lastFreeMsgSendTimeKey)
  792. if int(ctime)-lastFreeMsgSendTime < 60 {
  793. global.GVA_LOG.Error("TaskMsgSend上次数据发送时间还没到5分钟", zap.Error(err))
  794. return
  795. }
  796. var isOne = false
  797. if lastFreeMsgSendTime == 0 {
  798. isOne = true
  799. }
  800. s.TaskMsgSendFreeData(ctx, completesInfo, ctime, date, lastFreeMsgSendTimeKey, isOne)
  801. }
  802. func (s *SyncData) CheckTaskCompletedInfo() {
  803. date := time.Now().Format("2006-01-02")
  804. ctx := context.Background()
  805. taskCompletedStatusKey := fmt.Sprintf(TaskCompletedStatusKey, date)
  806. completesInfo, err := s.TaskNoCompleteDate(date)
  807. if err != nil {
  808. global.GVA_LOG.Error("CheckTaskCompletedInfo查询任务数据报错", zap.Error(err))
  809. return
  810. }
  811. status, _ := s.cache.GetCacheNum(ctx, taskCompletedStatusKey)
  812. if status == 1 {
  813. global.GVA_LOG.Info("任务已完成")
  814. return
  815. }
  816. if len(completesInfo) == 0 {
  817. global.GVA_LOG.Info("TaskMsgSend没有查询到未完成数据")
  818. time.Sleep(time.Second * 10)
  819. _ = s.cache.SetCacheStr(ctx, taskCompletedStatusKey, 1)
  820. msg := "# 监控报警 "
  821. msg += fmt.Sprintf("<font color=\"warning\">%s</font>", time.Now().Format("2006-01-02 15:04:05"))
  822. msg += "\n"
  823. msg += "今日任务目标已完成"
  824. url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
  825. var sendData SendMsg
  826. sendData.MsgType = "markdown"
  827. sendData.Markdown.Content = msg
  828. s.SendMsgData(url, sendData)
  829. }
  830. }
  831. func (s *SyncData) TaskMsgSendRetainedDataUpdate(ctx context.Context, completesInfo []task.GameTargetComplete, ctime int64, date, lastMsgSendTimeKey string) {
  832. var mps = make(map[int]map[string]CompletedInfo)
  833. lastMsgSendTime, _ := s.cache.GetCacheNum(ctx, lastMsgSendTimeKey)
  834. for _, complete := range completesInfo {
  835. lastNewCompletedKey := fmt.Sprintf(LastNewCompletedKey, date, complete.TaskId)
  836. lastRetainedCompletedKey := fmt.Sprintf(LastRetainedCompletedKey, date, complete.TaskId)
  837. lastNewCompletedUpdateTimeKey := fmt.Sprintf(LastNewCompletedUpdateTimeKey, date, complete.TaskId)
  838. lastRetainedCompletedUpdateTimeKey := fmt.Sprintf(LastRetainedCompletedUpdateTimeKey, date, complete.TaskId)
  839. currentNewCompleted := complete.NewComplete + complete.HandNewComplete
  840. currentRetainedCompleted := complete.RetainedComplete + complete.HandRetainedComplete
  841. var RateMp = make(map[string]CompletedInfo)
  842. var newBool = false
  843. var retainedBoll = false
  844. // 处理新增
  845. if complete.NewTarget > currentNewCompleted {
  846. lastNewCompleted, _ := s.cache.GetCacheNum(ctx, lastNewCompletedKey)
  847. alsoNewTarget := complete.NewTarget - currentNewCompleted
  848. newRate := 0
  849. lastNewCompletedUpdateTime, _ := s.cache.GetCacheNum(ctx, lastNewCompletedUpdateTimeKey)
  850. timeRate := int(ctime) - lastNewCompletedUpdateTime
  851. if lastNewCompleted < currentNewCompleted {
  852. newRate = currentNewCompleted - lastNewCompleted
  853. _ = s.cache.SetCacheStr(ctx, lastNewCompletedKey, currentNewCompleted)
  854. _ = s.cache.SetCacheStr(ctx, lastNewCompletedUpdateTimeKey, ctime) //上次新增完成更新时间
  855. }
  856. RateMp["newRate"] = CompletedInfo{
  857. AlsoTarget: alsoNewTarget,
  858. Rate: newRate,
  859. TimeRate: timeRate,
  860. TaskId: complete.TaskId,
  861. }
  862. } else {
  863. newBool = true
  864. // 如果当前新增为0,或者完成也更新时间
  865. _ = s.cache.SetCacheStr(ctx, lastNewCompletedUpdateTimeKey, ctime) //上次新增完成更新时间
  866. }
  867. // 处理留存
  868. if complete.RetainedTarget > currentRetainedCompleted {
  869. lastRetainedCompleted, _ := s.cache.GetCacheNum(ctx, lastRetainedCompletedKey)
  870. alsoRetainedTarget := complete.RetainedTarget - currentRetainedCompleted
  871. retainedRate := 0
  872. lastRetainedCompletedUpdateTime, _ := s.cache.GetCacheNum(ctx, lastRetainedCompletedUpdateTimeKey)
  873. timeRate := int(ctime) - lastRetainedCompletedUpdateTime
  874. if lastRetainedCompleted < currentRetainedCompleted {
  875. retainedRate = currentRetainedCompleted - lastRetainedCompleted
  876. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedKey, currentRetainedCompleted)
  877. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedUpdateTimeKey, ctime) //上次留存完成更新时间
  878. }
  879. RateMp["retainedRate"] = CompletedInfo{
  880. AlsoTarget: alsoRetainedTarget,
  881. Rate: retainedRate,
  882. TimeRate: timeRate,
  883. TaskId: complete.TaskId,
  884. }
  885. } else {
  886. retainedBoll = true
  887. // 如果当前留存为0,或者完成也更新时间
  888. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedUpdateTimeKey, ctime) //上次留存完成更新时间
  889. }
  890. if !newBool || !retainedBoll {
  891. mps[complete.TaskId] = RateMp
  892. }
  893. }
  894. var taskStatistics = "%s:taskStatistics"
  895. var retained = "# 活跃播报 "
  896. if len(mps) == 0 {
  897. global.GVA_LOG.Warn(retained)
  898. }
  899. retained += fmt.Sprintf("<font color=\"warning\">%s</font>", time.Now().Format("2006-01-02 15:04:05"))
  900. var errMsg = "**以下游戏目标效率为零:**"
  901. var errMsgZ = ""
  902. var sendMsg = map[string]string{}
  903. var errSendMsg = map[string]string{}
  904. var m int // 时间内
  905. m = (int(ctime) - lastMsgSendTime) / 60
  906. for taskId, data := range mps {
  907. key := fmt.Sprintf(taskStatistics, date)
  908. gameIdStr := strconv.Itoa(taskId)
  909. gameTask, err := global.GVA_REDIS.HGet(ctx, key, gameIdStr).Result()
  910. if err != nil {
  911. if err == redis.Nil {
  912. continue
  913. } else {
  914. global.GVA_LOG.Error("TaskMsgSendRetainedData获取缓存任务数据失败", zap.Error(err))
  915. continue
  916. }
  917. }
  918. var taskStatistics request.TaskStatistics
  919. _ = json.Unmarshal([]byte(gameTask), &taskStatistics)
  920. var eMsg = "" //单条异常数据
  921. var isNew = false
  922. var nm int //新增时间内
  923. var rm int //存时间内
  924. var rate string //效率
  925. var newErr = false
  926. var retainedErr = false
  927. var name = taskStatistics.Remark
  928. if info, ok := data["newRate"]; ok {
  929. sendMsg[name] += "\n"
  930. sendMsg[name] += taskStatistics.GameName
  931. sendMsg[name] += ",新增差"
  932. //sendMsg[name] += strconv.Itoa(info.AlsoTarget)
  933. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%d</font>", info.AlsoTarget)
  934. isNew = true
  935. if info.TimeRate > 60*60*24 {
  936. lastNewCompletedUpdateTimeKey := fmt.Sprintf(LastNewCompletedUpdateTimeKey, date, info.TaskId)
  937. _ = s.cache.SetCacheStr(ctx, lastNewCompletedUpdateTimeKey, ctime) //上次新增完成更新时间
  938. nm = 1
  939. } else {
  940. nm = info.TimeRate / 60
  941. }
  942. rate = strconv.Itoa(info.Rate)
  943. if info.Rate == 0 {
  944. newErr = true
  945. }
  946. }
  947. if info, ok := data["retainedRate"]; ok {
  948. if !isNew {
  949. sendMsg[name] += "\n"
  950. sendMsg[name] += taskStatistics.GameName
  951. rate = strconv.Itoa(info.Rate)
  952. sendMsg[name] += "活跃差"
  953. } else {
  954. rate += "/" + strconv.Itoa(info.Rate)
  955. sendMsg[name] += ",活跃差"
  956. }
  957. if info.TimeRate > 60*60*24 {
  958. lastRetainedCompletedUpdateTimeKey := fmt.Sprintf(LastRetainedCompletedUpdateTimeKey, date, info.TaskId)
  959. _ = s.cache.SetCacheStr(ctx, lastRetainedCompletedUpdateTimeKey, ctime) //上次留存完成更新时间
  960. rm = 1
  961. } else {
  962. rm = info.TimeRate / 60
  963. }
  964. //sendMsg[name] += strconv.Itoa(info.AlsoTarget)
  965. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%d</font>", info.AlsoTarget)
  966. if info.Rate == 0 {
  967. retainedErr = true
  968. }
  969. }
  970. // 5分钟数据没动报异常数据
  971. if newErr && nm > 4 {
  972. eMsg += "\n"
  973. eMsg += taskStatistics.GameName
  974. eMsg += ",新增"
  975. if nm >= 60 {
  976. eMsg += "("
  977. eMsg += strconv.Itoa(nm / 60)
  978. eMsg += "小时内)"
  979. } else {
  980. eMsg += "("
  981. eMsg += strconv.Itoa(nm)
  982. eMsg += "分钟内)"
  983. }
  984. }
  985. if retainedErr && rm > 4 {
  986. if !newErr {
  987. eMsg += "\n"
  988. eMsg += taskStatistics.GameName
  989. }
  990. eMsg += ",活跃"
  991. if rm >= 60 {
  992. eMsg += "("
  993. eMsg += strconv.Itoa(rm / 60)
  994. eMsg += "小时内)"
  995. } else {
  996. eMsg += "("
  997. eMsg += strconv.Itoa(rm)
  998. eMsg += "分钟内)"
  999. }
  1000. }
  1001. if eMsg != "" {
  1002. errMsgZ += eMsg
  1003. errSendMsg[name] += eMsg
  1004. }
  1005. sendMsg[name] += ","
  1006. if m >= 60 {
  1007. sendMsg[name] += strconv.Itoa(m / 60)
  1008. sendMsg[name] += "小时内完成"
  1009. } else {
  1010. sendMsg[name] += strconv.Itoa(m)
  1011. sendMsg[name] += "分钟内完成"
  1012. }
  1013. //sendMsg[name] += rate
  1014. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%s</font>", rate)
  1015. }
  1016. hour := time.Now().Hour()
  1017. msg := ""
  1018. mpsPerson, _ := s.Person.GetUserInfoData()
  1019. //b1 ,_ := json.Marshal(mpsPerson)
  1020. //global.GVA_LOG.Warn(string(b1))
  1021. var mobile []string
  1022. if hour >= 16 {
  1023. if len(sendMsg) == 0 {
  1024. return
  1025. }
  1026. if len(mps) != 0 && len(errSendMsg) != 0 {
  1027. for name, _ := range errSendMsg {
  1028. mobile = append(mobile, mpsPerson[name].MobilePhoneNumber)
  1029. }
  1030. }
  1031. for name, msg := range sendMsg {
  1032. retained += "\n"
  1033. retained += "**" + name + "**"
  1034. retained += msg
  1035. }
  1036. msg = retained
  1037. if errMsgZ != "" {
  1038. msg += "\n"
  1039. //msg += errMsg + errMsgZ
  1040. msg += fmt.Sprintf("<font color=\"warning\">%s</font>", errMsg+errMsgZ)
  1041. }
  1042. for pName, pMsg := range sendMsg {
  1043. if hour >= mpsPerson[pName].StartTime {
  1044. personMsg := pMsg
  1045. if _, ok := errSendMsg[pName]; ok {
  1046. personMsg += fmt.Sprintf("<font color=\"warning\">%s</font>", errSendMsg[pName])
  1047. }
  1048. url := mpsPerson[pName].Url
  1049. var sendPersonData SendMsg
  1050. sendPersonData.MsgType = "markdown"
  1051. sendPersonData.Markdown.Content = personMsg
  1052. s.SendMsgData(url, sendPersonData)
  1053. if mpsPerson[pName].Custodians != "" {
  1054. if _, ok := mpsPerson[mpsPerson[pName].Custodians]; ok {
  1055. custodiansMsg := fmt.Sprintf("<font color=\"warning\">%s的任务</font>", pName)
  1056. custodiansMsg += "\n"
  1057. custodiansMsg += personMsg
  1058. var custodiansData SendMsg
  1059. custodiansData.MsgType = "markdown"
  1060. custodiansData.Markdown.Content = custodiansMsg
  1061. urlCustodians := mpsPerson[mpsPerson[pName].Custodians].Url
  1062. s.SendMsgData(urlCustodians, custodiansData)
  1063. }
  1064. }
  1065. }
  1066. }
  1067. } else {
  1068. if errMsgZ != "" {
  1069. //msg += errMsg + errMsgZ
  1070. }
  1071. if len(mps) != 0 && len(errSendMsg) != 0 {
  1072. msg += "# 活跃播报 "
  1073. msg += errMsg
  1074. for name, m := range errSendMsg {
  1075. mobile = append(mobile, mpsPerson[name].MobilePhoneNumber)
  1076. msg += "\n"
  1077. msg += "**" + name + "**"
  1078. msg += fmt.Sprintf("<font color=\"warning\">%s</font>", m)
  1079. }
  1080. }
  1081. for pName, pMsg := range sendMsg {
  1082. if hour >= mpsPerson[pName].StartTime {
  1083. var personMsg = "# 付费播报 "
  1084. personMsg += fmt.Sprintf("<font color=\"warning\">%s</font>", time.Now().Format("2006-01-02 15:04:05"))
  1085. personMsg = pMsg
  1086. if _, ok := errSendMsg[pName]; ok {
  1087. personMsg += fmt.Sprintf("<font color=\"warning\">%s</font>", errSendMsg[pName])
  1088. }
  1089. url := mpsPerson[pName].Url
  1090. var sendPersonData SendMsg
  1091. sendPersonData.MsgType = "markdown"
  1092. sendPersonData.Markdown.Content = personMsg
  1093. s.SendMsgData(url, sendPersonData)
  1094. if mpsPerson[pName].Custodians != "" {
  1095. custodiansMsg := fmt.Sprintf("<font color=\"warning\">%s的任务</font>", pName)
  1096. custodiansMsg += "\n"
  1097. custodiansMsg += personMsg
  1098. var custodiansData SendMsg
  1099. custodiansData.MsgType = "markdown"
  1100. custodiansData.Markdown.Content = custodiansMsg
  1101. urlCustodians := mpsPerson[mpsPerson[pName].Custodians].Url
  1102. s.SendMsgData(urlCustodians, custodiansData)
  1103. }
  1104. }
  1105. }
  1106. }
  1107. //global.GVA_LOG.Warn(msg)
  1108. _ = s.cache.SetCacheStr(ctx, lastMsgSendTimeKey, time.Now().Unix())
  1109. if msg == "" {
  1110. return
  1111. }
  1112. url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
  1113. var sendData SendMsg
  1114. sendData.MsgType = "markdown"
  1115. sendData.Markdown.Content = msg
  1116. s.SendMsgData(url, sendData)
  1117. if len(mobile) != 0 {
  1118. var sendTextData SendTextMsg
  1119. sendTextData.MsgType = "text"
  1120. sendTextData.Text.MentionedMobileList = mobile
  1121. //b ,_ := json.Marshal(sendTextData)
  1122. //global.GVA_LOG.Warn(string(b))
  1123. s.SendMsgData(url, sendTextData)
  1124. }
  1125. }
  1126. func (s *SyncData) TaskMsgSendFreeDataUpdate(ctx context.Context, completesInfo []task.GameTargetComplete, ctime int64, date, lastFreeMsgSendTimeKey string, isOne bool) {
  1127. var RateMp = make(map[int]CompletedInfo)
  1128. lastFreeMsgSendTime, _ := s.cache.GetCacheNum(ctx, lastFreeMsgSendTimeKey)
  1129. for _, complete := range completesInfo {
  1130. lastPayCompletedKey := fmt.Sprintf(LastPayCompletedKey, date, complete.TaskId)
  1131. lastPayCompletedUpdateTimeKey := fmt.Sprintf(LastPayCompletedUpdateTimeKey, date, complete.TaskId)
  1132. lastPayAddUpdateTimeKey := fmt.Sprintf(LastPayAddUpdateTimeKey, date, complete.TaskId)
  1133. currentPayCompleted := complete.PayComplete + complete.HandPayComplete
  1134. // 付费处理
  1135. if complete.PayTarget != 0 && complete.PayTarget > currentPayCompleted {
  1136. lastPayCompleted, _ := s.cache.GetCacheNum(ctx, lastPayCompletedKey)
  1137. alsoPayTarget := complete.PayTarget - currentPayCompleted
  1138. payRate := 0
  1139. lastPayCompletedUpdateTime, _ := s.cache.GetCacheNum(ctx, lastPayCompletedUpdateTimeKey)
  1140. lastPayAddUpdateTime, _ := s.cache.GetCacheNum(ctx, lastPayAddUpdateTimeKey)
  1141. timeRate := int(ctime) - lastPayCompletedUpdateTime
  1142. if lastPayCompleted < currentPayCompleted {
  1143. payRate = currentPayCompleted - lastPayCompleted
  1144. _ = s.cache.SetCacheStr(ctx, lastPayCompletedKey, currentPayCompleted)
  1145. _ = s.cache.SetCacheStr(ctx, lastPayCompletedUpdateTimeKey, ctime) //上次付费更新时间
  1146. }
  1147. RateMp[complete.TaskId] = CompletedInfo{
  1148. AlsoTarget: alsoPayTarget,
  1149. Rate: payRate,
  1150. TimeRate: timeRate,
  1151. TaskId: complete.TaskId,
  1152. AddPayUpdateTime: lastPayAddUpdateTime,
  1153. }
  1154. } else {
  1155. // 如果当前付费为0,或者完成也更新时间
  1156. _ = s.cache.SetCacheStr(ctx, lastPayCompletedUpdateTimeKey, ctime) //上次付费更新时间
  1157. }
  1158. }
  1159. if isOne {
  1160. _ = s.cache.SetCacheStr(ctx, lastFreeMsgSendTimeKey, time.Now().Unix())
  1161. return
  1162. }
  1163. if len(RateMp) == 0 {
  1164. global.GVA_LOG.Info("TaskMsgSendFreeData没有查询到未完成付费数据")
  1165. return
  1166. }
  1167. var taskStatistics = "%s:taskStatistics"
  1168. var retained = "# 付费播报 "
  1169. retained += fmt.Sprintf("<font color=\"warning\">%s</font>", time.Now().Format("2006-01-02 15:04:05"))
  1170. var errMsg = "**以下游戏付费效率为零:**"
  1171. var errMsgZ = ""
  1172. var sendMsg = map[string]string{}
  1173. var m int //时间内
  1174. m = (int(ctime) - lastFreeMsgSendTime) / 60
  1175. mpsPerson, _ := s.Person.GetUserInfoData()
  1176. var mobile []string
  1177. for taskId, data := range RateMp {
  1178. if data.AlsoTarget <= 0 {
  1179. continue
  1180. }
  1181. key := fmt.Sprintf(taskStatistics, date)
  1182. gameIdStr := strconv.Itoa(taskId)
  1183. gameTask, err := global.GVA_REDIS.HGet(ctx, key, gameIdStr).Result()
  1184. if err != nil {
  1185. if err == redis.Nil {
  1186. continue
  1187. } else {
  1188. global.GVA_LOG.Error("TaskMsgSendRetainedData获取缓存任务数据失败", zap.Error(err))
  1189. continue
  1190. }
  1191. }
  1192. var taskStatistics request.TaskStatistics
  1193. _ = json.Unmarshal([]byte(gameTask), &taskStatistics)
  1194. var name = taskStatistics.Remark
  1195. sendMsg[name] += "\n"
  1196. sendMsg[name] += taskStatistics.GameName
  1197. sendMsg[name] += ",付费差"
  1198. //sendMsg[name] += strconv.Itoa(data.AlsoTarget)
  1199. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%d</font>", data.AlsoTarget)
  1200. if data.TimeRate > 60*60*24 {
  1201. lastPayCompletedUpdateTimeKey := fmt.Sprintf(LastPayCompletedUpdateTimeKey, date, data.TaskId)
  1202. _ = s.cache.SetCacheStr(ctx, lastPayCompletedUpdateTimeKey, ctime) //上次付费更新时间
  1203. data.TimeRate = 60 * 60 * 2
  1204. }
  1205. // 5分钟数据没动报异常数据
  1206. if data.TimeRate/60 >= 2 {
  1207. if data.Rate == 0 {
  1208. lastPayAddNumKey := fmt.Sprintf(LastPayAddNumKey, date, data.TaskId)
  1209. payErrAddNumKey := fmt.Sprintf(PayErrAddNumKey, date, data.TaskId)
  1210. numErr, _ := s.cache.GetCacheNum(context.Background(), payErrAddNumKey)
  1211. lastAddFeeNumErr, _ := s.cache.GetCacheNum(context.Background(), lastPayAddNumKey)
  1212. errMsgZ += "\n"
  1213. errMsgZ += taskStatistics.GameName
  1214. errMsgZ += "("
  1215. if data.TimeRate/60 >= 60 {
  1216. errMsgZ += strconv.Itoa(data.TimeRate / 60 / 60)
  1217. errMsgZ += "小时内(+" + strconv.Itoa(numErr) + "))"
  1218. } else {
  1219. errMsgZ += strconv.Itoa(data.TimeRate / 60)
  1220. errMsgZ += "分钟内(+" + strconv.Itoa(numErr) + "))"
  1221. }
  1222. errMsgZ += ","
  1223. errMsgZ += "最后加付费时间 "
  1224. t := time.Unix(int64(data.AddPayUpdateTime), 0)
  1225. errMsgZ += t.Format("15:04:05")
  1226. errMsgZ += "(+" + strconv.Itoa(lastAddFeeNumErr) + ")"
  1227. if _, ok := mpsPerson[name]; ok {
  1228. mobile = append(mobile, mpsPerson[name].MobilePhoneNumber)
  1229. }
  1230. }
  1231. }
  1232. sendMsg[name] += ","
  1233. if m >= 60 {
  1234. sendMsg[name] += strconv.Itoa(m / 60)
  1235. sendMsg[name] += "分钟内完成"
  1236. } else {
  1237. sendMsg[name] += strconv.Itoa(m)
  1238. sendMsg[name] += "分钟内完成"
  1239. }
  1240. //sendMsg[name] += strconv.Itoa(data.Rate)
  1241. sendMsg[name] += fmt.Sprintf("<font color=\"warning\">%d</font>", data.Rate)
  1242. }
  1243. if len(sendMsg) == 0 {
  1244. return
  1245. }
  1246. hour := time.Now().Hour()
  1247. for name, msg := range sendMsg {
  1248. retained += "\n"
  1249. retained += name
  1250. retained += msg
  1251. if hour >= mpsPerson[name].StartTime {
  1252. var personMsg = "# 付费播报 "
  1253. personMsg += fmt.Sprintf("<font color=\"warning\">%s</font>", time.Now().Format("2006-01-02 15:04:05"))
  1254. personMsg = msg
  1255. url := mpsPerson[name].Url
  1256. var sendPersonData SendMsg
  1257. sendPersonData.MsgType = "markdown"
  1258. sendPersonData.Markdown.Content = personMsg
  1259. s.SendMsgData(url, sendPersonData)
  1260. if mpsPerson[name].Custodians != "" {
  1261. if _, ok := mpsPerson[mpsPerson[name].Custodians]; ok {
  1262. custodiansMsg := fmt.Sprintf("<font color=\"warning\">%s的任务</font>", name)
  1263. custodiansMsg += "\n"
  1264. custodiansMsg += personMsg
  1265. var custodiansData SendMsg
  1266. custodiansData.MsgType = "markdown"
  1267. custodiansData.Markdown.Content = custodiansMsg
  1268. urlCustodians := mpsPerson[mpsPerson[name].Custodians].Url
  1269. s.SendMsgData(urlCustodians, custodiansData)
  1270. }
  1271. }
  1272. }
  1273. }
  1274. msg := retained
  1275. if errMsgZ != "" {
  1276. msg += "\n"
  1277. //msg += errMsg + errMsgZ
  1278. msg += fmt.Sprintf("<font color=\"warning\">%s</font>", errMsg+errMsgZ)
  1279. }
  1280. global.GVA_LOG.Warn(msg)
  1281. _ = s.cache.SetCacheStr(ctx, lastFreeMsgSendTimeKey, time.Now().Unix())
  1282. url := global.GVA_CONFIG.SendUrl.ComputerSendUrl
  1283. var sendData SendMsg
  1284. sendData.MsgType = "markdown"
  1285. sendData.Markdown.Content = msg
  1286. s.SendMsgData(url, sendData)
  1287. if len(mobile) != 0 {
  1288. var sendTextData SendTextMsg
  1289. sendTextData.MsgType = "text"
  1290. sendTextData.Text.MentionedMobileList = mobile
  1291. s.SendMsgData(url, sendTextData)
  1292. }
  1293. return
  1294. }
  1295. // 加付费通知
  1296. func (s *SyncData) FreeSendMsg(num, target int, taskName, director string) {
  1297. hour := time.Now().Hour()
  1298. if hour < 8 {
  1299. return
  1300. }
  1301. person, err := s.Person.GetUserInfoByName(director)
  1302. if err != nil {
  1303. global.GVA_LOG.Error("FreeSendMsg获取用户数据失败"+director, zap.Error(err))
  1304. }
  1305. if person.PushStatus != 1 {
  1306. return
  1307. }
  1308. personMsg := "# 加付费"
  1309. personMsg += fmt.Sprintf("<font color=\"warning\">%s</font>", time.Now().Format("2006-01-02 15:04:05"))
  1310. personMsg += "\n"
  1311. personMsg += taskName
  1312. personMsg += fmt.Sprintf("<font color=\"warning\"> 加付费 %d, 当前付费目标 %d</font>", num, target)
  1313. url := person.Url
  1314. var sendData SendMsg
  1315. sendData.MsgType = "markdown"
  1316. sendData.Markdown.Content = personMsg
  1317. s.SendMsgData(url, sendData)
  1318. }