diff --git a/internal/model/res_m/property.go b/internal/model/res_m/property.go new file mode 100644 index 0000000000000000000000000000000000000000..832ce72f035dd28755e46ea103ad51244952e60b --- /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 951a41858f418b40a4e084fcf20f47af9daa1b1c..43173529594fde2bcd2acf2ea71c9b3c1beb7244 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 df1ebd4e65c107b9557fa329f2846e558d1e271d..42e7cf563cfa1927d8e741e6659bb329d5754cfd 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 }