package msg import ( "git.hilo.cn/hilo-common/domain" "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/user_m" "git.hilo.cn/hilo-common/resource/mysql" "git.hilo.cn/hilo-common/utils" ) // 发送小助手消息 func SendLittleAssistantMsg(model *domain.Model, userId mysql.ID, t msg_e.MsgUserRecordType, diamondIncome mysql.Str, dayNum mysql.Str, propertyUrl mysql.Str, beanNum mysql.Str, groupCode mysql.Str, users ...*user_m.User) (err error) { defer utils.CheckGoPanic() var user *user_m.User if len(users) > 0 { user = users[0] } else { user, err = user_m.GetUser(model, userId) if err != nil { model.Log.Errorf("SendLittleAssistantMsg GetUser userId:%v, err:%v", userId, err) return err } } if err = msg_m.NewUserRecord(model, user.ID, t, user.Nick, user.ID, diamondIncome, dayNum, propertyUrl, beanNum, groupCode).Persistent(); err != nil { model.Log.Errorf("SendLittleAssistantMsg NewUserRecord err:%v", err) return err } err = msg_m.SendEmasMsgAssistant(model, user.ExternalId, user.DeviceType) if err != nil { model.Log.Errorf("SendLittleAssistantMsg SendEmasMsgAssistant userId:%v, err:%v", userId, err) return err } return nil }