订单回调优化
This commit is contained in:
parent
532ff64d3b
commit
d269955408
|
@ -330,7 +330,7 @@ func (this *Player) OnLogined() {
|
|||
|
||||
this.SendJackPotInit()
|
||||
|
||||
this.GetPayGoodsInfo()
|
||||
this.GetShopInfo()
|
||||
|
||||
PlayerOnlineSington.Check = true
|
||||
|
||||
|
@ -419,7 +419,7 @@ func (this *Player) OnRehold() {
|
|||
this.SendJackPotInit()
|
||||
PlayerOnlineSington.Check = true
|
||||
|
||||
this.GetPayGoodsInfo()
|
||||
this.GetShopInfo()
|
||||
|
||||
this.CheckShowRed()
|
||||
|
||||
|
@ -3720,126 +3720,145 @@ func (this *Player) GetMatchFreeTimes() int32 {
|
|||
return 0
|
||||
}
|
||||
|
||||
// 玩家登录 检查充值状态
|
||||
func (this *Player) GetPayGoodsInfo() {
|
||||
if this.IsRob {
|
||||
// DoShopInfo 订单完成处理逻辑
|
||||
// isLogin 是否登录
|
||||
func (this *Player) DoShopInfo(info *model.DbShop, isLogin bool) {
|
||||
if info == nil {
|
||||
return
|
||||
}
|
||||
|
||||
op := "Callback"
|
||||
if isLogin {
|
||||
op = "CallbackLogin"
|
||||
}
|
||||
|
||||
switch info.PageId {
|
||||
case ShopPageBackend:
|
||||
logger.Logger.Tracef("GetPayGoodsInfo ShopPageBackend %+v", *info)
|
||||
default:
|
||||
if len(info.Amount) > 0 {
|
||||
this.AddCoin(int64(info.Amount[0]), 0, info.GainWay, op, info.Remark)
|
||||
this.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, op, info.Remark)
|
||||
}
|
||||
this.AddMoneyPayTotal(int64(info.ConsumeNum))
|
||||
this.MoneyTotal += int64(info.ConsumeTypeNum)
|
||||
info.Amount[2] = int32(this.GetVIPExpByPay(int64(info.ConsumeNum)))
|
||||
this.dirty = true
|
||||
this.SendDiffData()
|
||||
|
||||
var itemInfo []*playerproto.PayItem
|
||||
var items []*model.Item
|
||||
if info.ItemInfo != nil {
|
||||
for _, v := range info.ItemInfo {
|
||||
items = append(items, &model.Item{ItemId: v.ItemId, ItemNum: v.ItemNum})
|
||||
itemInfo = append(itemInfo, &playerproto.PayItem{
|
||||
ItemId: v.ItemId,
|
||||
ItemNum: v.ItemNum,
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(items) > 0 {
|
||||
BagMgrSingleton.AddItems(&model.AddItemParam{
|
||||
Platform: this.Platform,
|
||||
SnId: this.SnId,
|
||||
Change: items,
|
||||
GainWay: info.GainWay,
|
||||
Operator: info.Operator,
|
||||
Remark: info.Remark,
|
||||
})
|
||||
}
|
||||
|
||||
//钻石存储罐
|
||||
if info.PageId == ShopPageDiamondBank {
|
||||
WelfareMgrSington.DiamondBankTakeCoin(this)
|
||||
}
|
||||
|
||||
// 通行证
|
||||
if info.PageId == ShopPagePermit {
|
||||
this.Permit = info.CreateTs.Local()
|
||||
LogChannelSingleton.WriteLog(&model.BackendPermitJoin{
|
||||
Platform: this.Platform,
|
||||
StartTs: PlatformMgrSingleton.GetConfig(this.Platform).PermitStartTs,
|
||||
SnId: this.SnId,
|
||||
Ts: time.Now().Unix(),
|
||||
})
|
||||
TaskSubjectSingleton.Touch(common.TaskTypeBuyPermit, &TaskData{
|
||||
SnId: this.SnId,
|
||||
Num: 1,
|
||||
})
|
||||
}
|
||||
|
||||
switch info.Remark {
|
||||
case "BlindBox":
|
||||
if len(info.OtherParams) > 0 {
|
||||
this.WelfData.BlindBoxId = info.OtherParams[0]
|
||||
} else {
|
||||
logger.Logger.Errorf("GetPayGoodsInfo BlindBox OtherParams is nil")
|
||||
}
|
||||
case "FirstRecharge":
|
||||
if len(info.OtherParams) > 0 {
|
||||
|
||||
this.WelfData.FirstPayDay = info.OtherParams[0]
|
||||
this.WelfData.FirstPayTickets = info.Ts
|
||||
} else {
|
||||
logger.Logger.Errorf("GetPayGoodsInfo FirstRecharge OtherParams is nil")
|
||||
}
|
||||
case "ContinuousPay":
|
||||
if len(info.OtherParams) > 0 {
|
||||
this.WelfData.ContinuousPayDay = info.OtherParams[0]
|
||||
this.WelfData.ContinuousPayTickets = info.Ts
|
||||
} else {
|
||||
logger.Logger.Errorf("GetPayGoodsInfo ContinuousPay OtherParams is nil")
|
||||
}
|
||||
}
|
||||
|
||||
this.UpdatePlayerVipBag(info.ShopId)
|
||||
this.UpdateShopID(info.ShopId)
|
||||
|
||||
PayGoodsInfo := &playerproto.SCPayGoodsInfo{
|
||||
Gold: info.Amount,
|
||||
Item: itemInfo,
|
||||
ShopId: info.ShopId,
|
||||
Money: int64(info.ConsumeTypeNum),
|
||||
Name: info.Remark,
|
||||
}
|
||||
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_PAYGOODSINFO), PayGoodsInfo)
|
||||
}
|
||||
|
||||
// 充值任务
|
||||
if info.ConsumeNum > 0 {
|
||||
TaskSubjectSingleton.Touch(common.TaskTypePay, &TaskData{
|
||||
SnId: this.SnId,
|
||||
Num: int64(info.ConsumeNum),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Player) GetShopInfo() {
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
info := model.GetDbShopLogsByState(this.Platform, this.SnId)
|
||||
if info != nil {
|
||||
for _, shop := range info {
|
||||
err := model.UpdateDbShopState(shop.Platform, shop.LogId.Hex(), 1)
|
||||
if err != nil {
|
||||
logger.Logger.Error("GetPayGoodsInfo.UpdateDbShopState err:", err)
|
||||
logger.Logger.Error("Player CallbackPayment UpdateDbShopState err:", err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return info
|
||||
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
|
||||
if data != nil {
|
||||
infos := data.([]*model.DbShop)
|
||||
for _, info := range infos {
|
||||
switch info.PageId {
|
||||
case ShopPageBackend:
|
||||
logger.Logger.Tracef("GetPayGoodsInfo ShopPageBackend %+v", *info)
|
||||
default:
|
||||
var itemInfo []*playerproto.PayItem
|
||||
var items []*model.Item
|
||||
if len(info.Amount) > 0 {
|
||||
this.AddCoin(int64(info.Amount[0]), 0, info.GainWay, "Callback_login", info.Remark)
|
||||
this.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback_login", info.Remark)
|
||||
}
|
||||
this.AddMoneyPayTotal(int64(info.ConsumeNum))
|
||||
this.MoneyTotal += int64(info.ConsumeTypeNum)
|
||||
if info.ItemInfo != nil {
|
||||
for _, v := range info.ItemInfo {
|
||||
items = append(items, &model.Item{ItemId: v.ItemId, ItemNum: v.ItemNum})
|
||||
itemInfo = append(itemInfo, &playerproto.PayItem{
|
||||
ItemId: v.ItemId,
|
||||
ItemNum: v.ItemNum,
|
||||
})
|
||||
}
|
||||
}
|
||||
//钻石存储罐
|
||||
if info.PageId == ShopPageDiamondBank {
|
||||
WelfareMgrSington.DiamondBankTakeCoin(this)
|
||||
}
|
||||
if info.PageId == ShopPagePermit {
|
||||
this.Permit = info.CreateTs.Local()
|
||||
LogChannelSingleton.WriteLog(&model.BackendPermitJoin{
|
||||
Platform: this.Platform,
|
||||
StartTs: PlatformMgrSingleton.GetConfig(this.Platform).PermitStartTs,
|
||||
SnId: this.SnId,
|
||||
Ts: time.Now().Unix(),
|
||||
})
|
||||
TaskSubjectSingleton.Touch(common.TaskTypeBuyPermit, &TaskData{
|
||||
SnId: this.SnId,
|
||||
Num: 1,
|
||||
})
|
||||
}
|
||||
switch info.Remark {
|
||||
case "BlindBox":
|
||||
if len(info.OtherParams) > 0 {
|
||||
this.WelfData.BlindBoxId = info.OtherParams[0]
|
||||
} else {
|
||||
logger.Logger.Errorf("GetPayGoodsInfo BlindBox OtherParams is nil")
|
||||
}
|
||||
case "FirstRecharge":
|
||||
if len(info.OtherParams) > 0 {
|
||||
|
||||
this.WelfData.FirstPayDay = info.OtherParams[0]
|
||||
this.WelfData.FirstPayTickets = info.Ts
|
||||
} else {
|
||||
logger.Logger.Errorf("GetPayGoodsInfo FirstRecharge OtherParams is nil")
|
||||
}
|
||||
case "ContinuousPay":
|
||||
if len(info.OtherParams) > 0 {
|
||||
|
||||
this.WelfData.ContinuousPayDay = info.OtherParams[0]
|
||||
this.WelfData.ContinuousPayTickets = info.Ts
|
||||
} else {
|
||||
logger.Logger.Errorf("GetPayGoodsInfo ContinuousPay OtherParams is nil")
|
||||
}
|
||||
}
|
||||
this.UpdatePlayerVipBag(info.ShopId)
|
||||
this.UpdateShopID(info.ShopId)
|
||||
|
||||
this.dirty = true
|
||||
this.SendDiffData()
|
||||
|
||||
info.Amount[2] = int32(this.GetVIPExpByPay(int64(info.ConsumeNum)))
|
||||
|
||||
BagMgrSingleton.AddItems(&model.AddItemParam{
|
||||
Platform: this.Platform,
|
||||
SnId: this.SnId,
|
||||
Change: items,
|
||||
GainWay: info.GainWay,
|
||||
Operator: info.Operator,
|
||||
Remark: info.Remark,
|
||||
})
|
||||
|
||||
PayGoodsInfo := &playerproto.SCPayGoodsInfo{
|
||||
Gold: info.Amount,
|
||||
Item: itemInfo,
|
||||
ShopId: info.ShopId,
|
||||
Money: int64(info.ConsumeTypeNum),
|
||||
Name: info.Remark,
|
||||
}
|
||||
proto.SetDefaults(PayGoodsInfo)
|
||||
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_PAYGOODSINFO), PayGoodsInfo)
|
||||
}
|
||||
if info.ConsumeNum > 0 {
|
||||
TaskSubjectSingleton.Touch(common.TaskTypePay, &TaskData{
|
||||
SnId: this.SnId,
|
||||
Num: int64(info.ConsumeNum),
|
||||
})
|
||||
}
|
||||
}
|
||||
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
|
||||
})).StartByFixExecutor("GetPayGoodsLogs")
|
||||
shops, ok := i.([]*model.DbShop)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for _, info := range shops {
|
||||
this.DoShopInfo(info, true)
|
||||
}
|
||||
})).StartByExecutor(fmt.Sprintf("Player%v", this.SnId))
|
||||
}
|
||||
|
||||
func (this *Player) SendJackPotInit() {
|
||||
|
|
|
@ -3445,8 +3445,18 @@ func init() {
|
|||
pack.Msg = "OrderId == nil || msg.Platform == nil"
|
||||
return common.ResponseTag_ParamError, pack
|
||||
}
|
||||
|
||||
retFail := func(errorMsg string) {
|
||||
pack.Tag = webapiproto.TagCode_FAILED
|
||||
pack.Msg = errorMsg
|
||||
tNode.TransRep.RetFiels = pack
|
||||
tNode.Resume()
|
||||
}
|
||||
|
||||
var info *model.DbShop
|
||||
var state int32
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
info := model.GetDbShopLog(msg.Platform, msg.OrderId)
|
||||
info = model.GetDbShopLog(msg.Platform, msg.OrderId)
|
||||
if info == nil {
|
||||
return errors.New("info is nil")
|
||||
}
|
||||
|
@ -3454,123 +3464,55 @@ func init() {
|
|||
if info.State != 0 {
|
||||
return errors.New("the order state not 0 " + info.LogId.Hex())
|
||||
}
|
||||
var state = msg.State
|
||||
return nil
|
||||
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
||||
if i != nil || info == nil {
|
||||
logger.Logger.Errorf("CallbackPayment error %v shoplog:%#v", i, info)
|
||||
retFail("购买记录查询失败")
|
||||
return
|
||||
}
|
||||
|
||||
state = msg.GetState()
|
||||
player := PlayerMgrSington.GetPlayerBySnId(info.SnId)
|
||||
if player != nil && player.IsOnLine() {
|
||||
if len(info.Amount) > 0 {
|
||||
player.AddCoin(int64(info.Amount[0]), 0, info.GainWay, "Callback", info.Remark)
|
||||
player.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback", info.Remark)
|
||||
}
|
||||
player.AddMoneyPayTotal(int64(info.ConsumeNum))
|
||||
player.MoneyTotal += int64(info.ConsumeTypeNum)
|
||||
player.dirty = true
|
||||
player.SendDiffData()
|
||||
info.Amount[2] = int32(player.GetVIPExpByPay(int64(info.ConsumeNum)))
|
||||
|
||||
var itemInfo []*playerproto.PayItem
|
||||
var items []*model.Item
|
||||
if info.ItemInfo != nil {
|
||||
for _, v := range info.ItemInfo {
|
||||
items = append(items, &model.Item{ItemId: v.ItemId, ItemNum: v.ItemNum})
|
||||
itemInfo = append(itemInfo, &playerproto.PayItem{
|
||||
ItemId: v.ItemId,
|
||||
ItemNum: v.ItemNum,
|
||||
})
|
||||
}
|
||||
}
|
||||
BagMgrSingleton.AddItems(&model.AddItemParam{
|
||||
Platform: player.Platform,
|
||||
SnId: player.SnId,
|
||||
Change: items,
|
||||
GainWay: info.GainWay,
|
||||
Operator: "Callback",
|
||||
Remark: info.Remark,
|
||||
})
|
||||
//钻石存储罐
|
||||
if info.PageId == ShopPageDiamondBank {
|
||||
WelfareMgrSington.DiamondBankTakeCoin(player)
|
||||
}
|
||||
if info.PageId == ShopPagePermit {
|
||||
player.Permit = info.CreateTs.Local()
|
||||
LogChannelSingleton.WriteLog(&model.BackendPermitJoin{
|
||||
Platform: player.Platform,
|
||||
StartTs: PlatformMgrSingleton.GetConfig(player.Platform).PermitStartTs,
|
||||
SnId: player.SnId,
|
||||
Ts: time.Now().Unix(),
|
||||
})
|
||||
TaskSubjectSingleton.Touch(common.TaskTypeBuyPermit, &TaskData{
|
||||
SnId: player.SnId,
|
||||
Num: 1,
|
||||
})
|
||||
}
|
||||
switch info.Remark {
|
||||
case "BlindBox":
|
||||
if len(info.OtherParams) > 0 {
|
||||
player.WelfData.BlindBoxId = info.OtherParams[0]
|
||||
} else {
|
||||
logger.Logger.Errorf("CallbackPayment BlindBox OtherParams is nil")
|
||||
}
|
||||
case "FirstRecharge":
|
||||
if len(info.OtherParams) > 0 {
|
||||
|
||||
player.WelfData.FirstPayDay = info.OtherParams[0]
|
||||
player.WelfData.FirstPayTickets = info.Ts
|
||||
} else {
|
||||
logger.Logger.Errorf("CallbackPayment FirstRecharge OtherParams is nil")
|
||||
}
|
||||
case "ContinuousPay":
|
||||
if len(info.OtherParams) > 0 {
|
||||
|
||||
player.WelfData.ContinuousPayDay = info.OtherParams[0]
|
||||
player.WelfData.ContinuousPayTickets = info.Ts
|
||||
} else {
|
||||
logger.Logger.Errorf("CallbackPayment ContinuousPay OtherParams is nil")
|
||||
}
|
||||
}
|
||||
player.UpdatePlayerVipBag(info.ShopId)
|
||||
player.UpdateShopID(info.ShopId)
|
||||
|
||||
PayGoodsInfo := &playerproto.SCPayGoodsInfo{
|
||||
Gold: info.Amount,
|
||||
Item: itemInfo,
|
||||
}
|
||||
proto.SetDefaults(PayGoodsInfo)
|
||||
player.SendToClient(int(playerproto.PlayerPacketID_PACKET_SC_PAYGOODSINFO), PayGoodsInfo)
|
||||
|
||||
TaskSubjectSingleton.Touch(common.TaskTypePay, &TaskData{
|
||||
SnId: player.SnId,
|
||||
Num: int64(info.ConsumeNum),
|
||||
})
|
||||
InviteTask(msg.Platform, player.PSnId, player.SnId, common.InviteScoreTypePay, int64(info.ConsumeNum))
|
||||
} else {
|
||||
if state == 1 {
|
||||
if player == nil {
|
||||
if info.State == 1 {
|
||||
state = 3
|
||||
}
|
||||
psnid, err := model.GetPlayerInviteSnid(msg.Platform, info.SnId)
|
||||
}
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
err := model.UpdateDbShopState(msg.Platform, msg.OrderId, state)
|
||||
if err != nil {
|
||||
logger.Logger.Error("UpdateDbShopState.err:", err)
|
||||
logger.Logger.Error("CallbackPayment UpdateDbShopState error:", err)
|
||||
return err
|
||||
}
|
||||
InviteTask(msg.Platform, psnid, info.SnId, common.InviteScoreTypePay, int64(info.ConsumeNum))
|
||||
}
|
||||
err := model.UpdateDbShopState(msg.Platform, msg.OrderId, state)
|
||||
if err != nil {
|
||||
logger.Logger.Error("UpdateDbShopState.err:", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||||
if data != nil && data.(error) != nil {
|
||||
info := data.(error)
|
||||
pack.Tag = webapiproto.TagCode_FAILED
|
||||
pack.Msg = fmt.Sprintf("%v", info)
|
||||
} else {
|
||||
return nil
|
||||
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
||||
if i != nil {
|
||||
retFail("购买记录状态修改失败")
|
||||
return
|
||||
}
|
||||
if player != nil {
|
||||
player.DoShopInfo(info, false)
|
||||
// 邀请积分
|
||||
InviteTask(msg.Platform, player.PSnId, info.SnId, common.InviteScoreTypePay, int64(info.ConsumeNum))
|
||||
} else {
|
||||
// 邀请积分
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
psnid, err := model.GetPlayerInviteSnid(msg.Platform, info.SnId)
|
||||
if err != nil {
|
||||
logger.Logger.Error("CallbackPayment GetPlayerInviteSnid error:", err)
|
||||
return err
|
||||
}
|
||||
InviteTask(msg.Platform, psnid, info.SnId, common.InviteScoreTypePay, int64(info.ConsumeNum))
|
||||
return nil
|
||||
}), nil, "InvitePayTask").Start()
|
||||
}
|
||||
pack.Tag = webapiproto.TagCode_SUCCESS
|
||||
pack.Msg = "success"
|
||||
}
|
||||
tNode.TransRep.RetFiels = pack
|
||||
tNode.Resume()
|
||||
}), "CallbackPayment").Start()
|
||||
tNode.TransRep.RetFiels = pack
|
||||
tNode.Resume()
|
||||
})).StartByExecutor(fmt.Sprintf("Player%v", info.SnId))
|
||||
})).StartByFixExecutor("CallbackPayment")
|
||||
return common.ResponseTag_TransactYield, pack
|
||||
}))
|
||||
|
||||
|
|
Loading…
Reference in New Issue