上传gm接口
This commit is contained in:
parent
91a6ed427c
commit
2d34083ae4
@ -35,6 +35,8 @@ type (
|
||||
AddItem(session IUserSession, itemid string, addnum int32, bPush bool) (code pb.ErrorCode)
|
||||
///添加多个物品到背包 (可以加物品和减物品)
|
||||
AddItems(session IUserSession, items map[string]int32, bPush bool) (change []*pb.DB_UserItemData, code pb.ErrorCode)
|
||||
///清理道具
|
||||
CleanItems(session IUserSession) (code pb.ErrorCode)
|
||||
}
|
||||
|
||||
//英雄
|
||||
@ -346,6 +348,11 @@ type (
|
||||
IGrowtask interface {
|
||||
BingoAllGrowTask(session IUserSession) error
|
||||
}
|
||||
//支付模块
|
||||
IPay interface {
|
||||
//模拟发货
|
||||
ModulePayDelivery(session IUserSession, Productid string, Price int32) (code pb.ErrorCode)
|
||||
}
|
||||
//支付发货
|
||||
IPayDelivery interface {
|
||||
Delivery(session IUserSession, pid string) (code pb.ErrorCode, items []*pb.UserAssets)
|
||||
|
@ -148,6 +148,24 @@ func (this *Items) AddItems(session comm.IUserSession, items map[string]int32, b
|
||||
return
|
||||
}
|
||||
|
||||
//清理背包
|
||||
func (this *Items) CleanItems(session comm.IUserSession) (code pb.ErrorCode) {
|
||||
var (
|
||||
err error
|
||||
itmes []*pb.DB_UserItemData
|
||||
)
|
||||
if itmes, err = this.modelItems.QueryUserPack(session.GetUserId()); err != nil {
|
||||
this.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
for _, v := range itmes {
|
||||
v.Amount = 0
|
||||
}
|
||||
this.modelItems.DeleteUserPack(session.GetUserId(), itmes...)
|
||||
this.itemsChangePush(session, itmes) //推送道具背包变化
|
||||
return
|
||||
}
|
||||
|
||||
//Evens--------------------------------------------------------------------------------------------------------------------------------
|
||||
//推送道具变化消息
|
||||
func (this *Items) itemsChangePush(session comm.IUserSession, items []*pb.DB_UserItemData) (err error) {
|
||||
|
@ -10,6 +10,8 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -143,3 +145,73 @@ func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDelivery
|
||||
go this.ModuleHero.RechargeMoney(session.GetUserId(), conf.Amount)
|
||||
return
|
||||
}
|
||||
|
||||
//发货
|
||||
func (this *Pay) ModulePayDelivery(session comm.IUserSession, Productid string, Price int32) (code pb.ErrorCode) {
|
||||
var (
|
||||
conf *cfg.GameRechargeData
|
||||
info *pb.DBUserPay
|
||||
res []*cfg.Gameatn
|
||||
items []*pb.UserAssets
|
||||
err error
|
||||
online bool
|
||||
)
|
||||
|
||||
if conf, err = this.configure.getGameRecharge(Productid); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
if info, err = this.modelPayUser.queryUserPay(session.GetUserId()); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
if info.Record[Productid] > 0 {
|
||||
res = conf.Vipexp
|
||||
} else {
|
||||
res = conf.DiamondNumDouble
|
||||
}
|
||||
info.Record[Productid]++
|
||||
|
||||
if code = this.DispenseRes(session, res, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
orderid := primitive.NewObjectID().Hex()
|
||||
if err = this.modelPay.addUserPayOrder(&pb.DBPayOrder{
|
||||
Orderid: orderid,
|
||||
Uid: session.GetUserId(),
|
||||
Productid: Productid,
|
||||
Ctime: configure.Now().Unix(),
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
this.modelPayUser.updateUserPay(info)
|
||||
|
||||
switch conf.RechargeType {
|
||||
case 1:
|
||||
break
|
||||
case 2:
|
||||
code, items = this.modelDaily.delivery(session, Productid)
|
||||
break
|
||||
case 3:
|
||||
code, items = this.privilege.Delivery(session, Productid)
|
||||
break
|
||||
}
|
||||
for _, v := range res {
|
||||
items = append(items, &pb.UserAssets{A: v.A, T: v.T, N: v.N})
|
||||
}
|
||||
session.SendMsg(string(this.GetType()), "shipped", &pb.PayShippedPush{
|
||||
Pid: Productid,
|
||||
Orderid: orderid,
|
||||
Items: items,
|
||||
Info: info,
|
||||
})
|
||||
if online {
|
||||
if err = session.Push(); err != nil {
|
||||
this.Errorln(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
go this.ModuleHero.RechargeMoney(session.GetUserId(), conf.Amount)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user