邮件奖励优化 商队重置数据补充

This commit is contained in:
meixiongfeng 2023-07-18 11:15:47 +08:00
parent c934e20f96
commit 4e39cb4afe
8 changed files with 135 additions and 73 deletions

View File

@ -45,10 +45,14 @@ type (
//邮件业务模块对外接口定义 提供给其他模块使用的
Imail interface {
// 注意 此接口逐步废弃
SendMailByCid(session IUserSession, cid string, res []*pb.UserAssets) bool
SendNewMail(mail *pb.DBMailData, uid ...string) bool // 批量发送邮件 支持跨服
SendMailByUID(uid string, cid string, res []*cfg.Gameatn, Param []string) bool
IGetReddot
// 所有邮件奖励统一调这个接口
SendRewardMailByCid(session IUserSession, cid string, res []*cfg.Gameatn) bool
}
//道具背包接口
IItems interface {

View File

@ -73,9 +73,8 @@ func (this *PandaAtlas) CheckActivatePandaAtlasCollect(uid string, id string) (e
Time: configure.Now().Unix(),
Activate: false,
}
update := make(map[string]interface{}, 0)
update["collect"] = atlas.Collect
if err = model.Add(uid, update); err != nil {
if err = model.Add(uid, atlas); err != nil {
this.Errorf("err:%v", err)
}
return

View File

@ -147,28 +147,24 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
}
// 商队盈利收益奖励
var old int64 // 计算之前的结果
if u := this.module.ModuleUser.GetUser(session.GetUserId()); u != nil {
old = u.Profit
}
reward := this.configure.GetCaravanReward()
for index, v := range reward {
if v.Key == 0 || v.Key <= int32(old) {
continue
}
if len(reward) > index+1 && reward[index+1].Key > int32(old)+addScore {
var (
res []*pb.UserAssets
)
for _, v := range reward[index+1].Reward {
for _, v := range reward {
if v.Key > 0 {
if caravan.Profit > int64(v.Key) {
if _, ok := caravan.Reward[v.Key]; !ok {
var res []*pb.UserAssets
for _, v1 := range v.Reward {
res = append(res, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
A: v1.A,
T: v1.T,
N: v1.N,
})
}
this.module.ModuleMail.SendMailByCid(session, "CaravanProfitRewards", res)
caravan.Reward[v.Key] = true
update["reward"] = caravan.Reward
}
}
}
}
} else { // 买入

View File

@ -40,9 +40,12 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.CaravanGetListRe
return
}
// list.Merchantmoney = conf.Moneynumtop.N
// update := make(map[string]interface{})
// update["merchantmoney"] = list.Merchantmoney // 更新虚拟币
// this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update)
update := make(map[string]interface{})
list.Reward = make(map[int32]bool, 0)
list.Profit = 0
update["reward"] = list.Reward // 初始化利润奖励
update["profit"] = list.Profit // 初始化商品利润
this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update)
}
}
// 刷新城市货物信息

View File

@ -53,7 +53,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
this.lock.Unlock()
})
this.FindCaravanReward(4500)
return
}
@ -210,25 +209,6 @@ func (this *configureComp) GetCaravanReward() (reward []*cfg.GameCaravanRewardDa
return
}
// 找到指定奖励区间的数据
func (this *configureComp) FindCaravanReward(score int32) (index int32) {
score = 2500
if v, err := this.GetConfigure(game_caravan_reward); err == nil {
if configure, ok := v.(*cfg.GameCaravanReward); ok {
reward := configure.GetDataList()
for ipos, v := range reward {
if score >= v.Key && len(reward) > ipos+1 && score <= reward[ipos+1].Key {
index = int32(ipos) + 1
return
}
}
}
} else {
log.Errorf("get GetCaravanInitCity conf err:%v", err)
}
return
}
func (this *configureComp) GetCaravanMoreReward() (reward []*cfg.Gameatn) {
if v, err := this.GetConfigure(game_caravan_reward); err == nil {
if configure, ok := v.(*cfg.GameCaravanReward); ok {

View File

@ -40,7 +40,8 @@ func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err
Goods: map[string]*pb.Goods{},
City: map[int32]*pb.CityInfo{},
Oldprice: map[string]int32{},
Group: make(map[int32]bool),
Group: make(map[int32]bool, 0),
Reward: make(map[int32]bool, 0),
}
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {
// 创建一条数据

View File

@ -301,3 +301,65 @@ func (this *Mail) SendMailByUID(uid string, cid string, res []*cfg.Gameatn, Para
}
return true
}
func (this *Mail) SendRewardMailByCid(session comm.IUserSession, cid string, res []*cfg.Gameatn) bool {
var (
resReward []*pb.UserAssets
)
// 获取额外配置
conf := this.configure.GetMailConf(cid)
if conf == nil {
this.Errorf("can't found mail by cid: %s", cid)
return false
}
if len(conf.Reword) > 0 {
res = append(res, conf.Reword...)
}
for _, v := range res {
resReward = append(resReward, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
// 构建一个每日奖励邮件对象
mail := &pb.DBMailData{
ObjId: primitive.NewObjectID().Hex(),
Uid: session.GetUserId(),
CreateTime: uint64(configure.Now().Unix()),
DueTime: uint64(configure.Now().Unix() + 30*24*3600),
Items: resReward,
Cid: cid,
Param: []string{},
}
mail.Check = false
mail.Reward = true
if len(mail.GetItems()) > 0 {
mail.Reward = false
}
if db.IsCross() { // 如果是跨服 则取本服的db
tag, _, b := utils.UIdSplit(session.GetUserId())
if b {
if conn, err := db.ServerDBConn(tag); err == nil {
dbModel := db.NewDBModel(comm.TableMail, time.Hour, conn)
if _, err = dbModel.DB.InsertOne(comm.TableMail, mail); err != nil {
this.Errorf("InsertOne mail failed:%v", err)
}
}
}
} else {
err := this.modelMail.MailInsertUserMail(mail)
if err != nil {
this.Errorf("create mail failed :%v", err)
return false
}
}
// 通知玩家
this.AddNewMailPush(session, mail)
return true
}

View File

@ -248,6 +248,7 @@ type DBCaravan struct {
Oldprice map[string]int32 `protobuf:"bytes,16,rep,name=oldprice,proto3" json:"oldprice" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 上一次价格 key 货物ID
Rtime int64 `protobuf:"varint,17,opt,name=rtime,proto3" json:"rtime"` // 客户端不用这个时间
Group map[int32]bool `protobuf:"bytes,18,rep,name=group,proto3" json:"group" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //服务器用
Reward map[int32]bool `protobuf:"bytes,19,rep,name=reward,proto3" json:"reward" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 记录盈利奖励
}
func (x *DBCaravan) Reset() {
@ -401,6 +402,13 @@ func (x *DBCaravan) GetGroup() map[int32]bool {
return nil
}
func (x *DBCaravan) GetReward() map[int32]bool {
if x != nil {
return x.Reward
}
return nil
}
type CaravanRankInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -527,7 +535,7 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{
0x22, 0x35, 0x0a, 0x07, 0x42, 0x61, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e,
0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22, 0xd3, 0x06, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x61,
0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22, 0xbe, 0x07, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x61,
0x72, 0x61, 0x76, 0x61, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2b, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73,
@ -560,7 +568,10 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{
0x6d, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x12,
0x2b, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15,
0x2e, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x1a, 0x42, 0x0a, 0x0a,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x2e, 0x0a, 0x06,
0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x13, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x44,
0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x2e, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x1a, 0x42, 0x0a, 0x0a,
0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1e, 0x0a, 0x05,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61,
@ -580,20 +591,24 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{
0x02, 0x38, 0x01, 0x1a, 0x38, 0x0a, 0x0a, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x45, 0x6e, 0x74, 0x72,
0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03,
0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01,
0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xbf, 0x01,
0x0a, 0x0f, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x66,
0x6f, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x6c,
0x76, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x76, 0x12,
0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x18,
0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x12, 0x24, 0x0a, 0x0d, 0x6d,
0x65, 0x72, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01,
0x28, 0x05, 0x52, 0x0d, 0x6d, 0x65, 0x72, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x6d, 0x6f, 0x6e, 0x65,
0x79, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x4c, 0x76, 0x18, 0x07,
0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x4c, 0x76, 0x42,
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x39, 0x0a,
0x0b, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xbf, 0x01, 0x0a, 0x0f, 0x43, 0x61, 0x72,
0x61, 0x76, 0x61, 0x6e, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03,
0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01,
0x28, 0x05, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x76, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76,
0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74,
0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05,
0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x65, 0x72, 0x63, 0x68, 0x61,
0x6e, 0x74, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d,
0x65, 0x72, 0x63, 0x68, 0x61, 0x6e, 0x74, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09,
0x63, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x4c, 0x76, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52,
0x09, 0x63, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x4c, 0x76, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -608,7 +623,7 @@ func file_caravan_caravan_db_proto_rawDescGZIP() []byte {
return file_caravan_caravan_db_proto_rawDescData
}
var file_caravan_caravan_db_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_caravan_caravan_db_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_caravan_caravan_db_proto_goTypes = []interface{}{
(*Goods)(nil), // 0: Goods
(*CityInfo)(nil), // 1: CityInfo
@ -621,6 +636,7 @@ var file_caravan_caravan_db_proto_goTypes = []interface{}{
nil, // 8: DBCaravan.CityEntry
nil, // 9: DBCaravan.OldpriceEntry
nil, // 10: DBCaravan.GroupEntry
nil, // 11: DBCaravan.RewardEntry
}
var file_caravan_caravan_db_proto_depIdxs = []int32{
5, // 0: CityInfo.count:type_name -> CityInfo.CountEntry
@ -629,14 +645,15 @@ var file_caravan_caravan_db_proto_depIdxs = []int32{
8, // 3: DBCaravan.city:type_name -> DBCaravan.CityEntry
9, // 4: DBCaravan.oldprice:type_name -> DBCaravan.OldpriceEntry
10, // 5: DBCaravan.group:type_name -> DBCaravan.GroupEntry
2, // 6: DBCaravan.ItemsEntry.value:type_name -> BagInfo
0, // 7: DBCaravan.GoodsEntry.value:type_name -> Goods
1, // 8: DBCaravan.CityEntry.value:type_name -> CityInfo
9, // [9:9] is the sub-list for method output_type
9, // [9:9] is the sub-list for method input_type
9, // [9:9] is the sub-list for extension type_name
9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
11, // 6: DBCaravan.reward:type_name -> DBCaravan.RewardEntry
2, // 7: DBCaravan.ItemsEntry.value:type_name -> BagInfo
0, // 8: DBCaravan.GoodsEntry.value:type_name -> Goods
1, // 9: DBCaravan.CityEntry.value:type_name -> CityInfo
10, // [10:10] is the sub-list for method output_type
10, // [10:10] is the sub-list for method input_type
10, // [10:10] is the sub-list for extension type_name
10, // [10:10] is the sub-list for extension extendee
0, // [0:10] is the sub-list for field type_name
}
func init() { file_caravan_caravan_db_proto_init() }
@ -712,7 +729,7 @@ func file_caravan_caravan_db_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_caravan_caravan_db_proto_rawDesc,
NumEnums: 0,
NumMessages: 11,
NumMessages: 12,
NumExtensions: 0,
NumServices: 0,
},