Commit df1468ff authored by hujiebin's avatar hujiebin

tx操作配套小助手

parent 7a98c379
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
......@@ -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
}
......
......@@ -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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment