From e0cc5b77d57275ed79f7d1215fbae4b88510967e Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 14:36:16 +0800 Subject: [PATCH 01/12] update --- .../egg_canal_invite_user_nums_consume_test.go | 17 +++++++++++++++++ consume/md/consume_key.go | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 consume/egg_canal_invite_user_nums_consume_test.go diff --git a/consume/egg_canal_invite_user_nums_consume_test.go b/consume/egg_canal_invite_user_nums_consume_test.go new file mode 100644 index 0000000..3376567 --- /dev/null +++ b/consume/egg_canal_invite_user_nums_consume_test.go @@ -0,0 +1,17 @@ +package consume + +import ( + rule "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy" + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "fmt" + "testing" +) + +func TestExistOrDefaultUserEggScore(t *testing.T) { + es.Init("http://123.57.140.192:9200/", "elastic", "fnuo123") + err := rule.ExistOrDefaultUserEggScore(2) + if err != nil { + fmt.Println(err) + return + } +} diff --git a/consume/md/consume_key.go b/consume/md/consume_key.go index 5e66b99..5a8e402 100644 --- a/consume/md/consume_key.go +++ b/consume/md/consume_key.go @@ -169,7 +169,7 @@ var RabbitMqQueueKeyList = []*MqQueue{ Name: "egg_canal_invite_user_nums_queue", Type: DirectQueueType, IsPersistent: false, - RoutKey: "egg_canal_invite_user_nums", + RoutKey: "user_relate", BindKey: "", ConsumeFunName: "EggCanalInviteUserNumsConsume", }, @@ -178,7 +178,7 @@ var RabbitMqQueueKeyList = []*MqQueue{ Name: "egg_canal_violate_nums_queue", Type: DirectQueueType, IsPersistent: false, - RoutKey: "egg_canal_violate_nums", + RoutKey: "user_tag_records", BindKey: "", ConsumeFunName: "EggCanalViolateNumsConsume", }, @@ -205,7 +205,7 @@ var RabbitMqQueueKeyList = []*MqQueue{ Name: "egg_canal_person_add_activity_value_queue", Type: DirectQueueType, IsPersistent: false, - RoutKey: "egg_canal_person_add_activity_value", + RoutKey: "egg_canal_user_virtual_coin_flow", BindKey: "", ConsumeFunName: "EggCanalPersonAddActivityValueConsume", }, From c2035d6bbba7fc8692d82a09602230b9d59c72dc Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 15:30:28 +0800 Subject: [PATCH 02/12] update --- consume/egg_canal_invite_user_nums_consume.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/consume/egg_canal_invite_user_nums_consume.go b/consume/egg_canal_invite_user_nums_consume.go index 9c19110..e9bb3ba 100644 --- a/consume/egg_canal_invite_user_nums_consume.go +++ b/consume/egg_canal_invite_user_nums_consume.go @@ -59,6 +59,7 @@ func handleEggCanalInviteUserNumsConsume(msg []byte) error { var canalMsg *md.CanalUserRelateMessage[md.CanalUserRelate] err := json.Unmarshal(msg, &canalMsg) if err != nil { + fmt.Println("EggCanalInviteUserNumsConsumeFaliedUnMarshal_ERR:::::", err.Error()) return nil } @@ -71,18 +72,22 @@ func handleEggCanalInviteUserNumsConsume(msg []byte) error { for _, item := range canalMsg.Data { parentUid := item.ParentUid id := fmt.Sprintf("%d%d-%d", year, week, parentUid) + fmt.Println("ESid:" + id + "=====================>") // 新增拉新人数 script := elastic.NewScript("ctx._source.invite_user_nums += params.inc").Param("inc", 1) - _, err = es.EsClient.Update(). + service, err := es.EsClient.Update(). Index(index). Id(id). Script(script). Do(context.Background()) if err != nil { + fmt.Println("EggCanalInviteUserNumsConsumeFailedUpdateInviteUserNums_ERR:::::", err.Error()) return err } + fmt.Println(service) } } + fmt.Println("EggCanalInviteUserNumsConsume_Succeed::::") return nil } From 65bfe540fde1b8e7df006f5531d63e46f7ebba62 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 15:41:26 +0800 Subject: [PATCH 03/12] update --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 059db5e..025080a 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ go 1.19 require ( code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241212120727-3681308aeb14 - code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212140020-c99f60b4f868 + code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241213073654-f37e71ad92ef code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 github.com/boombuler/barcode v1.0.1 From 80726ae26c4926b6368afee06a5537b661b5b6a4 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 15:58:01 +0800 Subject: [PATCH 04/12] update egg canal type --- consume/egg_canal_invite_user_nums_consume.go | 2 +- consume/egg_canal_person_add_activity_value_consume.go | 4 ++-- consume/egg_canal_violate_nums_consume.go | 4 ++-- .../md_egg_canal_person_add_activity_value_consume.go | 10 +++++----- consume/md/md_egg_canal_user_relate_consume.go | 8 ++++---- consume/md/md_egg_canal_violate_nums_consume.go | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/consume/egg_canal_invite_user_nums_consume.go b/consume/egg_canal_invite_user_nums_consume.go index e9bb3ba..daa008f 100644 --- a/consume/egg_canal_invite_user_nums_consume.go +++ b/consume/egg_canal_invite_user_nums_consume.go @@ -71,7 +71,7 @@ func handleEggCanalInviteUserNumsConsume(msg []byte) error { if canalMsg.Type == md2.CanalMsgInsertSqlType { for _, item := range canalMsg.Data { parentUid := item.ParentUid - id := fmt.Sprintf("%d%d-%d", year, week, parentUid) + id := fmt.Sprintf("%d%d-%s", year, week, parentUid) fmt.Println("ESid:" + id + "=====================>") // 新增拉新人数 diff --git a/consume/egg_canal_person_add_activity_value_consume.go b/consume/egg_canal_person_add_activity_value_consume.go index 90c5c63..99d5f59 100644 --- a/consume/egg_canal_person_add_activity_value_consume.go +++ b/consume/egg_canal_person_add_activity_value_consume.go @@ -80,9 +80,9 @@ func handleEggCanalPersonAddActivityValueConsume(msg []byte) error { if canalMsg.Type == md2.CanalMsgInsertSqlType { for _, item := range canalMsg.Data { uid := item.Uid - id := fmt.Sprintf("%d%d-%d", year, week, uid) + id := fmt.Sprintf("%d%d-%s", year, week, uid) - if item.CoinId != personEggPointsCoinId && item.Direction != 1 { + if item.CoinId != utils2.IntToStr(personEggPointsCoinId) && item.Direction != "1" { continue } diff --git a/consume/egg_canal_violate_nums_consume.go b/consume/egg_canal_violate_nums_consume.go index cb42785..a2d0e0b 100644 --- a/consume/egg_canal_violate_nums_consume.go +++ b/consume/egg_canal_violate_nums_consume.go @@ -85,7 +85,7 @@ func handleEggCanalViolateNumsConsume(msg []byte) error { continue } uid := item.Uid - id := fmt.Sprintf("%d%d-%d", year, week, uid) + id := fmt.Sprintf("%d%d-%s", year, week, uid) // 2.2. 增加违规次数记录 script := elastic.NewScript("ctx._source.violate_nums += params.inc").Param("inc", 1) @@ -115,7 +115,7 @@ func handleEggCanalViolateNumsConsume(msg []byte) error { continue } uid := item.Uid - id := fmt.Sprintf("%d%d-%d", year, week, uid) + id := fmt.Sprintf("%d%d-%s", year, week, uid) // 3.2 减少违规次数记录 script := elastic.NewScript("ctx._source.violate_nums -= params.dec").Param("dec", 1) diff --git a/consume/md/md_egg_canal_person_add_activity_value_consume.go b/consume/md/md_egg_canal_person_add_activity_value_consume.go index 09e09e9..de27fae 100644 --- a/consume/md/md_egg_canal_person_add_activity_value_consume.go +++ b/consume/md/md_egg_canal_person_add_activity_value_consume.go @@ -1,16 +1,16 @@ package md type CanalUserVirtualCoinFlow struct { - Id int64 `json:"id"` - Uid int64 `json:"uid"` - CoinId int `json:"coin_id"` - Direction int `json:"direction"` + Id string `json:"id"` + Uid string `json:"uid"` + CoinId string `json:"coin_id"` + Direction string `json:"direction"` Title string `json:"title"` Amount string `json:"amount"` BeforeAmount string `json:"before_amount"` AfterAmount string `json:"after_amount"` SysFee string `json:"sys_fee"` - TransferType int `json:"transfer_type"` + TransferType string `json:"transfer_type"` } type CanalUserVirtualCoinFlowMessage[T any] struct { diff --git a/consume/md/md_egg_canal_user_relate_consume.go b/consume/md/md_egg_canal_user_relate_consume.go index 7bb22d7..862b58d 100644 --- a/consume/md/md_egg_canal_user_relate_consume.go +++ b/consume/md/md_egg_canal_user_relate_consume.go @@ -1,10 +1,10 @@ package md type CanalUserRelate struct { - Id int64 `json:"id"` - ParentUid int64 `json:"parent_uid"` - Uid int64 `json:"uid"` - Level int `json:"level"` + Id string `json:"id"` + ParentUid string `json:"parent_uid"` + Uid string `json:"uid"` + Level string `json:"level"` InviteTime string `json:"invite_time"` } diff --git a/consume/md/md_egg_canal_violate_nums_consume.go b/consume/md/md_egg_canal_violate_nums_consume.go index 297e8cd..7ca5ff7 100644 --- a/consume/md/md_egg_canal_violate_nums_consume.go +++ b/consume/md/md_egg_canal_violate_nums_consume.go @@ -1,9 +1,9 @@ package md type CanalTagRecords struct { - Id int `json:"id" ` - TagId int `json:"tag_id" ` - Uid int64 `json:"uid" ` + Id string `json:"id" ` + TagId string `json:"tag_id" ` + Uid string `json:"uid" ` Memo string `json:"memo" ` CreateAt string `json:"create_at" ` UpdateAt string `json:"update_at" ` From 6e0c47e5eabdd4831b514aff2fad774e950d517c Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 16:05:18 +0800 Subject: [PATCH 05/12] update es id --- consume/egg_canal_invite_user_nums_consume.go | 2 +- consume/egg_canal_person_add_activity_value_consume.go | 2 +- consume/egg_canal_violate_nums_consume.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/consume/egg_canal_invite_user_nums_consume.go b/consume/egg_canal_invite_user_nums_consume.go index daa008f..06f2774 100644 --- a/consume/egg_canal_invite_user_nums_consume.go +++ b/consume/egg_canal_invite_user_nums_consume.go @@ -71,7 +71,7 @@ func handleEggCanalInviteUserNumsConsume(msg []byte) error { if canalMsg.Type == md2.CanalMsgInsertSqlType { for _, item := range canalMsg.Data { parentUid := item.ParentUid - id := fmt.Sprintf("%d%d-%s", year, week, parentUid) + id := fmt.Sprintf("%d%d_%s", year, week, parentUid) fmt.Println("ESid:" + id + "=====================>") // 新增拉新人数 diff --git a/consume/egg_canal_person_add_activity_value_consume.go b/consume/egg_canal_person_add_activity_value_consume.go index 99d5f59..14ee4b8 100644 --- a/consume/egg_canal_person_add_activity_value_consume.go +++ b/consume/egg_canal_person_add_activity_value_consume.go @@ -80,7 +80,7 @@ func handleEggCanalPersonAddActivityValueConsume(msg []byte) error { if canalMsg.Type == md2.CanalMsgInsertSqlType { for _, item := range canalMsg.Data { uid := item.Uid - id := fmt.Sprintf("%d%d-%s", year, week, uid) + id := fmt.Sprintf("%d%d_%s", year, week, uid) if item.CoinId != utils2.IntToStr(personEggPointsCoinId) && item.Direction != "1" { continue diff --git a/consume/egg_canal_violate_nums_consume.go b/consume/egg_canal_violate_nums_consume.go index a2d0e0b..9a3d727 100644 --- a/consume/egg_canal_violate_nums_consume.go +++ b/consume/egg_canal_violate_nums_consume.go @@ -115,7 +115,7 @@ func handleEggCanalViolateNumsConsume(msg []byte) error { continue } uid := item.Uid - id := fmt.Sprintf("%d%d-%s", year, week, uid) + id := fmt.Sprintf("%d%d_%s", year, week, uid) // 3.2 减少违规次数记录 script := elastic.NewScript("ctx._source.violate_nums -= params.dec").Param("dec", 1) From bfcc54c4894900aaca21d2808040ec139397e275 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 16:28:18 +0800 Subject: [PATCH 06/12] fix update person add activity value --- consume/egg_canal_person_add_activity_value_consume.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consume/egg_canal_person_add_activity_value_consume.go b/consume/egg_canal_person_add_activity_value_consume.go index 14ee4b8..bc97bf6 100644 --- a/consume/egg_canal_person_add_activity_value_consume.go +++ b/consume/egg_canal_person_add_activity_value_consume.go @@ -87,7 +87,7 @@ func handleEggCanalPersonAddActivityValueConsume(msg []byte) error { } // 3. 增加个人活跃积分 - script := elastic.NewScript("ctx._source.person_add_activity_value += params.inc").Param("inc", item.Amount) + script := elastic.NewScript("ctx._source.person_add_activity_value += params.inc").Param("inc", utils2.StrToInt(item.Amount)) _, err = es.EsClient.Update(). Index(index). Id(id). From 4a795309c585cbc26c581979e17810b5175e4967 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 17:04:43 +0800 Subject: [PATCH 07/12] update --- consume/egg_canal_invite_user_nums_consume.go | 1 - consume/egg_canal_person_add_activity_value_consume.go | 5 ++++- consume/egg_canal_violate_nums_consume.go | 2 +- consume/egg_energy_deal_user_ecpm.go | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/consume/egg_canal_invite_user_nums_consume.go b/consume/egg_canal_invite_user_nums_consume.go index 06f2774..7b83735 100644 --- a/consume/egg_canal_invite_user_nums_consume.go +++ b/consume/egg_canal_invite_user_nums_consume.go @@ -72,7 +72,6 @@ func handleEggCanalInviteUserNumsConsume(msg []byte) error { for _, item := range canalMsg.Data { parentUid := item.ParentUid id := fmt.Sprintf("%d%d_%s", year, week, parentUid) - fmt.Println("ESid:" + id + "=====================>") // 新增拉新人数 script := elastic.NewScript("ctx._source.invite_user_nums += params.inc").Param("inc", 1) diff --git a/consume/egg_canal_person_add_activity_value_consume.go b/consume/egg_canal_person_add_activity_value_consume.go index bc97bf6..8da879a 100644 --- a/consume/egg_canal_person_add_activity_value_consume.go +++ b/consume/egg_canal_person_add_activity_value_consume.go @@ -88,15 +88,18 @@ func handleEggCanalPersonAddActivityValueConsume(msg []byte) error { // 3. 增加个人活跃积分 script := elastic.NewScript("ctx._source.person_add_activity_value += params.inc").Param("inc", utils2.StrToInt(item.Amount)) - _, err = es.EsClient.Update(). + updateDoc, err := es.EsClient.Update(). Index(index). Id(id). Script(script). Do(context.Background()) if err != nil { + fmt.Println("EggCanalPersonAddActivityValueConsumeUpdateDoc_ERR::::", err.Error()) return err } + fmt.Println("updateDoc==========>", updateDoc) } } + fmt.Println("EggCanalPersonAddActivityValueConsume_End::::::") return nil } diff --git a/consume/egg_canal_violate_nums_consume.go b/consume/egg_canal_violate_nums_consume.go index 9a3d727..626e191 100644 --- a/consume/egg_canal_violate_nums_consume.go +++ b/consume/egg_canal_violate_nums_consume.go @@ -85,7 +85,7 @@ func handleEggCanalViolateNumsConsume(msg []byte) error { continue } uid := item.Uid - id := fmt.Sprintf("%d%d-%s", year, week, uid) + id := fmt.Sprintf("%d%d_%s", year, week, uid) // 2.2. 增加违规次数记录 script := elastic.NewScript("ctx._source.violate_nums += params.inc").Param("inc", 1) diff --git a/consume/egg_energy_deal_user_ecpm.go b/consume/egg_energy_deal_user_ecpm.go index 500d331..9418008 100644 --- a/consume/egg_energy_deal_user_ecpm.go +++ b/consume/egg_energy_deal_user_ecpm.go @@ -67,7 +67,7 @@ func handleEggEnergyDealUserECPMConsume(msgData []byte) error { yearStr := utils2.IntToStr(year) weekStr := utils2.IntToStr(week) index := es2.GetAppointIndexFromAlias(yearStr, weekStr) - id := fmt.Sprintf("%d%d-%d", year, week, msg.Uid) + id := fmt.Sprintf("%d%d_%d", year, week, msg.Uid) m := md2.EggEnergyUserEggScoreEs{ Ecpm: utils2.StrToFloat64(msg.Ecpm), From 6c829df38a0fc5d39f0ab561ef176f98cd575346 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 17:25:08 +0800 Subject: [PATCH 08/12] update --- consume/egg_energy_deal_user_ecpm.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/consume/egg_energy_deal_user_ecpm.go b/consume/egg_energy_deal_user_ecpm.go index 9418008..c3f6a11 100644 --- a/consume/egg_energy_deal_user_ecpm.go +++ b/consume/egg_energy_deal_user_ecpm.go @@ -69,9 +69,8 @@ func handleEggEnergyDealUserECPMConsume(msgData []byte) error { index := es2.GetAppointIndexFromAlias(yearStr, weekStr) id := fmt.Sprintf("%d%d_%d", year, week, msg.Uid) - m := md2.EggEnergyUserEggScoreEs{ - Ecpm: utils2.StrToFloat64(msg.Ecpm), - } + updateMap := make(map[string]interface{}) + updateMap["ecpm"] = utils2.StrToFloat64(msg.Ecpm) updateDocRet, err := es.UpdateDoc(index, id, m) if err != nil { return err From 2c3184ed52d0e2ba647ce146d029a351f18e4734 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 17:27:14 +0800 Subject: [PATCH 09/12] fix es update ecpm --- consume/egg_energy_deal_user_ecpm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consume/egg_energy_deal_user_ecpm.go b/consume/egg_energy_deal_user_ecpm.go index c3f6a11..e6ea3d4 100644 --- a/consume/egg_energy_deal_user_ecpm.go +++ b/consume/egg_energy_deal_user_ecpm.go @@ -71,7 +71,7 @@ func handleEggEnergyDealUserECPMConsume(msgData []byte) error { updateMap := make(map[string]interface{}) updateMap["ecpm"] = utils2.StrToFloat64(msg.Ecpm) - updateDocRet, err := es.UpdateDoc(index, id, m) + updateDocRet, err := es.UpdateDoc(index, id, updateMap) if err != nil { return err } From 88be150fc16761116ed91c0857c62fd0ce766f62 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 20:02:16 +0800 Subject: [PATCH 10/12] update --- ...canal_person_add_activity_value_consume.go | 2 + ..._person_add_activity_value_consume_test.go | 51 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 consume/egg_canal_person_add_activity_value_consume_test.go diff --git a/consume/egg_canal_person_add_activity_value_consume.go b/consume/egg_canal_person_add_activity_value_consume.go index 8da879a..3314e74 100644 --- a/consume/egg_canal_person_add_activity_value_consume.go +++ b/consume/egg_canal_person_add_activity_value_consume.go @@ -79,6 +79,7 @@ func handleEggCanalPersonAddActivityValueConsume(msg []byte) error { // 2. 监听插入信息 if canalMsg.Type == md2.CanalMsgInsertSqlType { for _, item := range canalMsg.Data { + fmt.Println("item======>", item) uid := item.Uid id := fmt.Sprintf("%d%d_%s", year, week, uid) @@ -87,6 +88,7 @@ func handleEggCanalPersonAddActivityValueConsume(msg []byte) error { } // 3. 增加个人活跃积分 + fmt.Println("amount==========>", item.Amount) script := elastic.NewScript("ctx._source.person_add_activity_value += params.inc").Param("inc", utils2.StrToInt(item.Amount)) updateDoc, err := es.EsClient.Update(). Index(index). diff --git a/consume/egg_canal_person_add_activity_value_consume_test.go b/consume/egg_canal_person_add_activity_value_consume_test.go new file mode 100644 index 0000000..4059738 --- /dev/null +++ b/consume/egg_canal_person_add_activity_value_consume_test.go @@ -0,0 +1,51 @@ +package consume + +import ( + "applet/app/cfg" + "applet/app/db" + "applet/consume/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "testing" +) + +func TestHandleEggCanalPersonAddActivityValueConsume(t *testing.T) { + dbcfg := cfg.DBCfg{ + Host: "119.23.182.117:3306", + Name: "egg", + User: "root", + Psw: "Fnuo123com@", + ShowLog: true, + MaxLifetime: 30, + MaxOpenConns: 100, + MaxIdleConns: 100, + Path: "tmp/%s.log", + } + db.InitDB(&dbcfg) + es.Init("http://123.57.140.192:9200/", "elastic", "fnuo123") + data := md.CanalUserVirtualCoinFlow{ + Id: "", + Uid: "36", + CoinId: "3", + Direction: "1", + Title: "", + Amount: "10", + BeforeAmount: "", + AfterAmount: "", + SysFee: "", + TransferType: "", + } + + m := md.CanalUserVirtualCoinFlowMessage[md.CanalUserVirtualCoinFlow]{ + Data: []md.CanalUserVirtualCoinFlow{data}, + Database: "", + ES: 0, + ID: 0, + IsDdl: false, + Old: []md.CanalUserVirtualCoinFlow{}, + PkNames: []string{}, + Table: "", + TS: 0, + Type: "INSERT", + } + HandleEggCanalPersonAddActivityValueConsume(&m) +} From de9f82dfcf0ce520ab06f0ed979c4a73fc79f760 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 20:03:29 +0800 Subject: [PATCH 11/12] update --- ...egg_canal_invite_user_nums_consume_test.go | 17 ------- ..._person_add_activity_value_consume_test.go | 51 ------------------- 2 files changed, 68 deletions(-) delete mode 100644 consume/egg_canal_invite_user_nums_consume_test.go delete mode 100644 consume/egg_canal_person_add_activity_value_consume_test.go diff --git a/consume/egg_canal_invite_user_nums_consume_test.go b/consume/egg_canal_invite_user_nums_consume_test.go deleted file mode 100644 index 3376567..0000000 --- a/consume/egg_canal_invite_user_nums_consume_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package consume - -import ( - rule "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy" - "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" - "fmt" - "testing" -) - -func TestExistOrDefaultUserEggScore(t *testing.T) { - es.Init("http://123.57.140.192:9200/", "elastic", "fnuo123") - err := rule.ExistOrDefaultUserEggScore(2) - if err != nil { - fmt.Println(err) - return - } -} diff --git a/consume/egg_canal_person_add_activity_value_consume_test.go b/consume/egg_canal_person_add_activity_value_consume_test.go deleted file mode 100644 index 4059738..0000000 --- a/consume/egg_canal_person_add_activity_value_consume_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package consume - -import ( - "applet/app/cfg" - "applet/app/db" - "applet/consume/md" - "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" - "testing" -) - -func TestHandleEggCanalPersonAddActivityValueConsume(t *testing.T) { - dbcfg := cfg.DBCfg{ - Host: "119.23.182.117:3306", - Name: "egg", - User: "root", - Psw: "Fnuo123com@", - ShowLog: true, - MaxLifetime: 30, - MaxOpenConns: 100, - MaxIdleConns: 100, - Path: "tmp/%s.log", - } - db.InitDB(&dbcfg) - es.Init("http://123.57.140.192:9200/", "elastic", "fnuo123") - data := md.CanalUserVirtualCoinFlow{ - Id: "", - Uid: "36", - CoinId: "3", - Direction: "1", - Title: "", - Amount: "10", - BeforeAmount: "", - AfterAmount: "", - SysFee: "", - TransferType: "", - } - - m := md.CanalUserVirtualCoinFlowMessage[md.CanalUserVirtualCoinFlow]{ - Data: []md.CanalUserVirtualCoinFlow{data}, - Database: "", - ES: 0, - ID: 0, - IsDdl: false, - Old: []md.CanalUserVirtualCoinFlow{}, - PkNames: []string{}, - Table: "", - TS: 0, - Type: "INSERT", - } - HandleEggCanalPersonAddActivityValueConsume(&m) -} From ea9f778993bc95bdc81a07015c453e67f7afad13 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Fri, 13 Dec 2024 20:16:24 +0800 Subject: [PATCH 12/12] update --- consume/egg_canal_person_add_activity_value_consume.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/consume/egg_canal_person_add_activity_value_consume.go b/consume/egg_canal_person_add_activity_value_consume.go index 3314e74..0ce0505 100644 --- a/consume/egg_canal_person_add_activity_value_consume.go +++ b/consume/egg_canal_person_add_activity_value_consume.go @@ -79,7 +79,6 @@ func handleEggCanalPersonAddActivityValueConsume(msg []byte) error { // 2. 监听插入信息 if canalMsg.Type == md2.CanalMsgInsertSqlType { for _, item := range canalMsg.Data { - fmt.Println("item======>", item) uid := item.Uid id := fmt.Sprintf("%d%d_%s", year, week, uid) @@ -88,8 +87,8 @@ func handleEggCanalPersonAddActivityValueConsume(msg []byte) error { } // 3. 增加个人活跃积分 - fmt.Println("amount==========>", item.Amount) - script := elastic.NewScript("ctx._source.person_add_activity_value += params.inc").Param("inc", utils2.StrToInt(item.Amount)) + amount := utils2.StrToFloat64(item.Amount) + script := elastic.NewScript("ctx._source.person_add_activity_value += params.inc").Param("inc", int(amount)) updateDoc, err := es.EsClient.Update(). Index(index). Id(id).