diff --git a/modules/troll/api_buyorsell.go b/modules/troll/api_buyorsell.go index e8f047726..357e832ef 100644 --- a/modules/troll/api_buyorsell.go +++ b/modules/troll/api_buyorsell.go @@ -167,5 +167,8 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell this.module.ModifyTrollData(session.GetUserId(), update) this.module.SeTrollRankList(trolltrain.TotalEarn, session.GetUserId()) session.SendMsg(string(this.module.GetType()), TrollBuyOrSellResp, &pb.TrollBuyOrSellResp{Data: trolltrain}) + if gold != 0 { + this.module.record.AddTrollRecord(session.GetUserId(), gold, trolltrain.TarinPos) + } return } diff --git a/modules/troll/model_record.go b/modules/troll/model_record.go index 2a8b8ad2c..13cfa0e72 100644 --- a/modules/troll/model_record.go +++ b/modules/troll/model_record.go @@ -33,11 +33,12 @@ func (this *ModelRecord) GetTrollRecord(uid string) (result []*pb.DBTrollRecord, } // 添加收益列表 -func (this *ModelRecord) AddTrollRecord(uid string, gold int32) (err error) { +func (this *ModelRecord) AddTrollRecord(uid string, gold, pos int32) (err error) { troll := &pb.DBTrollRecord{ Id: primitive.NewObjectID().Hex(), Uid: uid, Gold: gold, + Pos: pos, Time: time.Now().Unix(), } if err = this.AddList(uid, troll.Id, troll); err != nil { diff --git a/modules/troll/module.go b/modules/troll/module.go index 91f6093f1..23067f41e 100644 --- a/modules/troll/module.go +++ b/modules/troll/module.go @@ -178,7 +178,7 @@ func (this *Troll) SellAllItem(uid string, troll *pb.DBTrollTrain, price map[int troll.GridNum = 0 // 清空格子 // 写统计 if gold > 0 { - this.record.AddTrollRecord(uid, gold) + this.record.AddTrollRecord(uid, gold, troll.TarinPos) } return @@ -255,7 +255,7 @@ func (this *Troll) BuyAllItem(uid string, troll *pb.DBTrollTrain, price map[int3 } // 写统计 if gold != 0 { - this.record.AddTrollRecord(uid, gold) + this.record.AddTrollRecord(uid, gold, troll.TarinPos) } return } diff --git a/pb/troll_db.pb.go b/pb/troll_db.pb.go index 4057b98a7..6670f630d 100644 --- a/pb/troll_db.pb.go +++ b/pb/troll_db.pb.go @@ -229,7 +229,8 @@ type DBTrollRecord struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID Gold int32 `protobuf:"varint,3,opt,name=gold,proto3" json:"gold"` // 收益 - Time int64 `protobuf:"varint,4,opt,name=time,proto3" json:"time"` // 交易时间 + Pos int32 `protobuf:"varint,4,opt,name=pos,proto3" json:"pos"` // 商人位置 + Time int64 `protobuf:"varint,5,opt,name=time,proto3" json:"time"` // 交易时间 } func (x *DBTrollRecord) Reset() { @@ -285,6 +286,13 @@ func (x *DBTrollRecord) GetGold() int32 { return 0 } +func (x *DBTrollRecord) GetPos() int32 { + if x != nil { + return x.Pos + } + return 0 +} + func (x *DBTrollRecord) GetTime() int64 { if x != nil { return x.Time @@ -355,14 +363,15 @@ var file_troll_troll_db_proto_rawDesc = []byte{ 0x53, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x49, 0x44, 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, 0x05, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x59, 0x0a, 0x0d, 0x44, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x6b, 0x0a, 0x0d, 0x44, 0x42, 0x54, 0x72, 0x6f, 0x6c, 0x6c, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 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, 0x12, 0x0a, 0x04, 0x67, 0x6f, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x67, 0x6f, - 0x6c, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x6f, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x03, 0x70, 0x6f, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (