From df1468ffd24eb16b9a0988f9a7dba7cf2bdc497b Mon Sep 17 00:00:00 2001 From: hujiebin Date: Wed, 22 Mar 2023 15:54:23 +0800 Subject: [PATCH] =?UTF-8?q?tx=E6=93=8D=E4=BD=9C=E9=85=8D=E5=A5=97=E5=B0=8F?= =?UTF-8?q?=E5=8A=A9=E6=89=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/model/res_m/property.go | 14 ++++++++++++++ txop/headwear_tx/headwear.go | 24 ++++++++++++++++++++++++ txop/ride_tx/ride.go | 24 ++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 internal/model/res_m/property.go diff --git a/internal/model/res_m/property.go b/internal/model/res_m/property.go new file mode 100644 index 0000000..832ce72 --- /dev/null +++ b/internal/model/res_m/property.go @@ -0,0 +1,14 @@ +package res_m + +import ( + "git.hilo.cn/hilo-common/domain" + "git.hilo.cn/hilo-common/resource/mysql" +) + +type ResProperty struct { + mysql.Entity + *domain.Model `gorm:"-"` + Name mysql.Str + PicUrl mysql.Str + EffectUrl mysql.Str +} \ No newline at end of file diff --git a/txop/headwear_tx/headwear.go b/txop/headwear_tx/headwear.go index 951a418..4317352 100644 --- a/txop/headwear_tx/headwear.go +++ b/txop/headwear_tx/headwear.go @@ -4,8 +4,12 @@ import ( "errors" "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/internal/enum/headwear_e" + "git.hilo.cn/hilo-common/internal/enum/msg_e" + "git.hilo.cn/hilo-common/internal/model/msg_m" + "git.hilo.cn/hilo-common/internal/model/res_m" "git.hilo.cn/hilo-common/internal/model/user_m" "git.hilo.cn/hilo-common/resource/mysql" + "strconv" "time" ) @@ -32,6 +36,26 @@ func SendHeadwear(model *domain.Model, receiverUserId mysql.ID, headdressId mysq if _, err = AddUserHeadwearLog(model, receiverUserId, headdressId, headwear_e.ActivityTrigger, headwear_e.AddSecond, &receiveHeadwearDuration, nil, 0); err != nil { model.Log.Error(err) } + // 配套小助手 + go func() { + model := domain.CreateModelContext(model.MyContext) + resHeadwear := res_m.ResHeadwear{} + if err := model.Db.Model(&res_m.ResHeadwear{}).First(&resHeadwear, headdressId).Error; err != nil { + model.Log.Errorf("SendHeadwear get ResHeadwear fail:%v", err) + return + } + user, err := user_m.GetUser(model, receiverUserId) + if err != nil { + model.Log.Errorf("SendHeadwear GetUser fail:%v", err) + return + } + if err := msg_m.NewUserRecord(model, receiverUserId, msg_e.AddProps, user.Nick, user.ID, "", strconv.Itoa(int(days)), resHeadwear.PicUrl, "", "").Persistent(); err != nil { + model.Log.Errorf("SendHeadwear NewUserRecord fail:%v", err) + return + } + //推送msg + _ = msg_m.SendEmasMsgAssistant(model, user.ExternalId, user.DeviceType) + }() return err } diff --git a/txop/ride_tx/ride.go b/txop/ride_tx/ride.go index df1ebd4..42e7cf5 100644 --- a/txop/ride_tx/ride.go +++ b/txop/ride_tx/ride.go @@ -2,9 +2,13 @@ package ride_tx import ( "git.hilo.cn/hilo-common/domain" + "git.hilo.cn/hilo-common/internal/enum/msg_e" "git.hilo.cn/hilo-common/internal/enum/property_e" + "git.hilo.cn/hilo-common/internal/model/msg_m" + "git.hilo.cn/hilo-common/internal/model/res_m" "git.hilo.cn/hilo-common/internal/model/user_m" "git.hilo.cn/hilo-common/resource/mysql" + "strconv" "time" ) @@ -36,5 +40,25 @@ func SendRide(model *domain.Model, receiverUserId mysql.ID, rideId mysql.ID, day }).Persistent(); err != nil { model.Log.Error(err) } + // 配套小助手 + go func() { + model := domain.CreateModelContext(model.MyContext) + resProperty := res_m.ResProperty{} + if err := model.Db.Model(&res_m.ResProperty{}).First(&resProperty, rideId).Error; err != nil { + model.Log.Errorf("SendRide get ResProperty fail:%v", err) + return + } + user, err := user_m.GetUser(model, receiverUserId) + if err != nil { + model.Log.Errorf("SendRide GetUser fail:%v", err) + return + } + if err := msg_m.NewUserRecord(model, user.ID, msg_e.AddProps, user.Nick, user.ID, "", strconv.Itoa(int(days)), resProperty.PicUrl, "", "").Persistent(); err != nil { + model.Log.Errorf("SendRide NewUserRecord fail:%v", err) + return + } + //推送msg + _ = msg_m.SendEmasMsgAssistant(model, user.ExternalId, user.DeviceType) + }() return nil } -- 2.22.0