From d8bc36d47a9c93178d4e83827845e8d443e59703 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 14 Aug 2023 17:46:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E9=98=9F=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/api_buyorsell.go | 31 ++++++++++++++++++++++--------- modules/user/model_user.go | 15 ++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/modules/caravan/api_buyorsell.go b/modules/caravan/api_buyorsell.go index c0f15d45e..62736b189 100644 --- a/modules/caravan/api_buyorsell.go +++ b/modules/caravan/api_buyorsell.go @@ -247,17 +247,30 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe // 任务统计 var szTask []*pb.BuriedParam - if req.IsBuy { - var buyCount int32 - for _, v := range req.Items { - buyCount += v - } - - szTask = append(szTask, comm.GetBuriedParam(comm.Rtype209, 1, buyCount)) - } else { // 卖 - //szTask = append(szTask, comm.GetBuriedParam(comm.Rtype300, 1, buyCount)) + var opCount int32 + for _, v := range req.Items { + opCount += v } + if req.IsBuy { + szTask = append(szTask, comm.GetBuriedParam(comm.Rtype209, req.City, opCount)) + } else { // 卖 + //向指定X城市贩卖货物,贩卖货物价值需要X虚拟币以上 + var price int32 + for k, v := range req.Items { + + price += caravan.Items[k].Price * v + } + szTask = append(szTask, comm.GetBuriedParam(comm.Rtype210, req.City, price)) + + // 急需货物 + if v, ok := caravan.City[req.City]; ok { + for range v.Exspecial { + + } + } + } + szTask = append(szTask, comm.GetBuriedParam(comm.Rtype212, req.City)) // 接取任务后,商队抵达指定城市 go this.module.ModuleBuried.TriggerBuried(session.Clone(), szTask...) return } diff --git a/modules/user/model_user.go b/modules/user/model_user.go index b82d3226a..d6754663a 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -379,21 +379,22 @@ func (this *ModelUser) ChangeLevel(event interface{}, next func(event interface{ func (this *ModelUser) AddUserProfit(uid string, score int64) (err error) { var ( - model *db.DBModel - value map[string]interface{} + model *db.DBModel + update map[string]interface{} ) if score < 0 { return } user := &pb.DBUser{} - value["profit"] = score + update = make(map[string]interface{}, 0) + update["profit"] = score if db.IsCross() { if model, err = this.module.GetDBModelByUid(uid, this.TableName); err == nil { if err := this.Get(uid, user); err != nil { this.module.Errorf("err:%v", err) } - value["profit"] = user.Profit + score - return model.Change(uid, value) + update["profit"] = user.Profit + score + return model.Change(uid, update) } else { this.module.Errorln(err) return err @@ -403,10 +404,10 @@ func (this *ModelUser) AddUserProfit(uid string, score int64) (err error) { if err := this.Get(uid, user); err != nil { this.module.Errorf("err:%v", err) } - value["profit"] = user.Profit + score + update["profit"] = user.Profit + score } - return this.Change(uid, value) + return this.Change(uid, update) }