|
@@ -1,6 +1,7 @@
|
|
|
package services
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"fmt"
|
|
|
"hongze/hongze_cygx/models/rai_serve"
|
|
|
"hongze/hongze_cygx/utils"
|
|
@@ -29,7 +30,7 @@ func CygxRaiServeBillRedisAdd(content, source string, userId, comapnyId, sourceI
|
|
|
go utils.SendAlarmMsg("权益服务统计添加到Redis队列中,写入Redis队列消息失败 CygxRaiServeBillRedisAdd:"+err.Error()+msg, 2)
|
|
|
}
|
|
|
}()
|
|
|
- log := &rai_serve.RaiServeBillRedis{Content: content, UserId: userId, ComapnyId: comapnyId, SourceId: sourceId, RegisterPlatform: registerPlatform, ViewTime: viewTime}
|
|
|
+ log := &rai_serve.RaiServeBillRedis{Content: content, Source: source, UserId: userId, ComapnyId: comapnyId, SourceId: sourceId, RegisterPlatform: registerPlatform, ViewTime: viewTime}
|
|
|
if utils.Re == nil {
|
|
|
err := utils.Rc.LPush(utils.CYGX_RAI_SERVE_BILL_KEY, log)
|
|
|
if err != nil {
|
|
@@ -38,3 +39,139 @@ func CygxRaiServeBillRedisAdd(content, source string, userId, comapnyId, sourceI
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func CygxRaiServeBillRedisAddReduce() (err error) {
|
|
|
+ for {
|
|
|
+
|
|
|
+ utils.Rc.Brpop(utils.CYGX_RAI_SERVE_BILL_KEY, func(b []byte) {
|
|
|
+ var log rai_serve.RaiServeBillRedis
|
|
|
+ if err := json.Unmarshal(b, &log); err != nil {
|
|
|
+ fmt.Println("json unmarshal wrong!")
|
|
|
+ go utils.SendAlarmMsg("处理研选活动扣点处理Redis队列消息失败:"+err.Error()+string(b), 2)
|
|
|
+ }
|
|
|
+ switch log.Source {
|
|
|
+ case utils.CYGX_OBJ_YANXUANSPECIAL:
|
|
|
+ go RaiServeBillRedisAddReduceByYanxuanspecial(log)
|
|
|
+ fmt.Println("研选专栏阅读记录处理")
|
|
|
+ break
|
|
|
+
|
|
|
+ default:
|
|
|
+ fmt.Println(string(b))
|
|
|
+ go utils.SendAlarmMsg("处理研选活动扣点处理Redis队列消息失败:"+string(b), 2)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func RaiServeBillRedisAddReduceByYanxuanspecial(log rai_serve.RaiServeBillRedis) (err error) {
|
|
|
+ source := log.Source
|
|
|
+ userId := log.UserId
|
|
|
+ sourceId := log.SourceId
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("用户报名活动扣点,处理Redis队列消息失败:"+err.Error()+fmt.Sprint("source:", source, "userId:", userId, "sourceId", sourceId), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return
|
|
|
+}
|