商队盈利调整
This commit is contained in:
parent
1cb46ae804
commit
f7469a9560
@ -26,6 +26,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
sellValue int32 // 任务统计 贩卖货物价值
|
sellValue int32 // 任务统计 贩卖货物价值
|
||||||
buyValue int32 // 任务统计 贩卖货物价值
|
buyValue int32 // 任务统计 贩卖货物价值
|
||||||
sellSpValue int32 // 任务统计 向指定X城市贩卖货物贩卖货物价值
|
sellSpValue int32 // 任务统计 向指定X城市贩卖货物贩卖货物价值
|
||||||
|
profitValue int32 // 盈利
|
||||||
)
|
)
|
||||||
update = make(map[string]interface{})
|
update = make(map[string]interface{})
|
||||||
if errdata = this.BuyOrSellCheck(session, req); errdata != nil {
|
if errdata = this.BuyOrSellCheck(session, req); errdata != nil {
|
||||||
@ -65,31 +66,37 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
}
|
}
|
||||||
items := caravan.Items[k]
|
items := caravan.Items[k]
|
||||||
var price int32
|
var price int32
|
||||||
|
var prePrice int32 // 之前的价格
|
||||||
price = items.Price
|
price = items.Price
|
||||||
|
prePrice = items.Price
|
||||||
bFound := false
|
bFound := false
|
||||||
for _, key := range cityInfo.Special {
|
for _, key := range cityInfo.Special {
|
||||||
if key == k {
|
if key == k {
|
||||||
if cityConf, err := this.module.configure.GetCaravanCity(req.City); err == nil {
|
if cityConf, err := this.module.configure.GetCaravanCity(req.City); err == nil {
|
||||||
price = cityConf.Specialnum * price / 1000
|
price = cityConf.Specialnum * price / 1000
|
||||||
sellSpValue += cityConf.Specialnum * price * v / 1000
|
|
||||||
bFound = true
|
bFound = true
|
||||||
} else {
|
|
||||||
errdata = &pb.ErrorData{
|
|
||||||
Code: pb.ErrorCode_TrollItemNoEnough, // 道具数量不足
|
|
||||||
Title: pb.ErrorCode_TrollItemNoEnough.ToString(),
|
|
||||||
Message: err.Error(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !bFound {
|
if !bFound {
|
||||||
price = cityInfo.ExspecialPCT * price / 1000
|
for _, key := range cityInfo.Exspecial {
|
||||||
|
if key == k {
|
||||||
|
bFound = true
|
||||||
|
price = cityInfo.ExspecialPCT * price / 1000
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !bFound {
|
||||||
|
if cityConf, err := this.module.configure.GetCaravanCity(req.City); err == nil {
|
||||||
|
price = cityConf.Orspecial * price / 1000
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sellValue += price * v
|
sellValue += price * v
|
||||||
|
if price > prePrice {
|
||||||
|
profitValue = (price - prePrice) * v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var addRes []*cfg.Gameatn
|
var addRes []*cfg.Gameatn
|
||||||
|
|
||||||
@ -102,13 +109,12 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
addRes = append(addRes, &cfg.Gameatn{
|
addRes = append(addRes, &cfg.Gameatn{
|
||||||
A: "attr",
|
A: "attr",
|
||||||
T: "profit",
|
T: "profit",
|
||||||
N: sellValue,
|
N: profitValue,
|
||||||
})
|
})
|
||||||
if errdata = this.module.DispenseRes(session, addRes, true); errdata != nil {
|
if errdata = this.module.DispenseRes(session, addRes, true); errdata != nil {
|
||||||
this.module.Errorf("获得虚拟币失败:%v", errdata)
|
this.module.Errorf("获得虚拟币失败:%v", errdata)
|
||||||
}
|
}
|
||||||
this.module.ArrayBag(caravan)
|
this.module.ArrayBag(caravan)
|
||||||
//curProfit := this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), "profit")
|
|
||||||
|
|
||||||
// 统计 收益
|
// 统计 收益
|
||||||
var lvReward []*cfg.Gameatn
|
var lvReward []*cfg.Gameatn
|
||||||
@ -139,20 +145,6 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe
|
|||||||
if len(lvReward) > 0 { // 商队等级奖励 改发邮件
|
if len(lvReward) > 0 { // 商队等级奖励 改发邮件
|
||||||
this.module.mail.SendRewardMailByCid(session, comm.CaravanLvReward, lvReward)
|
this.module.mail.SendRewardMailByCid(session, comm.CaravanLvReward, lvReward)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商队盈利收益奖励
|
|
||||||
// reward := this.configure.GetCaravanReward()
|
|
||||||
// for _, v := range reward {
|
|
||||||
// if v.Key > 0 {
|
|
||||||
// if curProfit > int64(v.Key) {
|
|
||||||
// if _, ok := caravan.Reward[v.Key]; !ok {
|
|
||||||
// this.module.mail.SendRewardMailByCid(session, comm.CaravanLvReward, v.Reward)
|
|
||||||
// caravan.Reward[v.Key] = true
|
|
||||||
// update["reward"] = caravan.Reward
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
} else { // 买入
|
} else { // 买入
|
||||||
for k, v := range req.Items {
|
for k, v := range req.Items {
|
||||||
if _, ok := caravan.Items[k]; !ok {
|
if _, ok := caravan.Items[k]; !ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user