商店购买

This commit is contained in:
sk 2024-09-06 16:23:57 +08:00
parent b4bab0de1e
commit 5bdf3d78df
1 changed files with 26 additions and 6 deletions

View File

@ -63,6 +63,7 @@ const (
const ( const (
ShopTypeCoin = iota + 1 // 金币 ShopTypeCoin = iota + 1 // 金币
ShopTypeDiamond // 钻石 ShopTypeDiamond // 钻石
SHopTypeItem // 道具
) )
// 商品参数类型 // 商品参数类型
@ -1267,26 +1268,45 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any,
//钻石 //钻石
amount[ShopParamDiamond] = bbd.Grade amount[ShopParamDiamond] = bbd.Grade
} }
dbShop = this.NewDbShop(p, 0, amount[:], ShopConsumeMoney, int32(bbd.Price2), common.GainWay_ActBlindBox, nil, 0, "", 0, remark, []int32{bbd.Id})
var itemInfo []model.ItemInfo
var webItemInfo []*webapi_proto.ItemInfo
for _, info := range shopInfo.GetItems() {
itemInfo = append(itemInfo, model.ItemInfo{
ItemId: info.ItemId,
ItemNum: info.ItemNum,
})
webItemInfo = append(webItemInfo, &webapi_proto.ItemInfo{
ItemId: info.ItemId,
ItemNum: info.ItemNum,
})
}
dbShop = this.NewDbShop(p, 0, amount[:], ShopConsumeMoney, int32(bbd.Price2), common.GainWay_ActBlindBox, itemInfo, 0, "", 0, remark, []int32{bbd.Id})
err := model.InsertDbShopLog(dbShop) err := model.InsertDbShopLog(dbShop)
if err != nil { if err != nil {
logger.Logger.Errorf("model.InsertDbShopLog err:", err) logger.Logger.Errorf("model.InsertDbShopLog err:", err)
return nil return nil
} }
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS, return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS,
p.DeviceId, bbd.Name, amount, int32(bbd.Price2), nil, "", p.Channel, p.ChannelId) p.DeviceId, bbd.Name, amount, int32(bbd.Price2), webItemInfo, "", p.Channel, p.ChannelId)
} else if wfs, ok := data.(*webapi_proto.WelfareSpree); ok { } else if wfs, ok := data.(*webapi_proto.WelfareSpree); ok {
var items []model.ItemInfo var items []model.ItemInfo
var webItemInfo []*webapi_proto.ItemInfo
for _, it := range wfs.Item { for _, it := range wfs.Item {
if it.Type == 1 { if it.Type == ShopTypeCoin {
amount[ShopParamCoin] = it.Grade amount[ShopParamCoin] = it.Grade
} else if it.Type == 2 { } else if it.Type == ShopTypeDiamond {
amount[ShopParamDiamond] = it.Grade amount[ShopParamDiamond] = it.Grade
} else if it.Type == 3 { } else if it.Type == SHopTypeItem {
items = append(items, model.ItemInfo{ items = append(items, model.ItemInfo{
ItemId: it.Item_Id, ItemId: it.Item_Id,
ItemNum: int64(it.Grade), ItemNum: int64(it.Grade),
}) })
webItemInfo = append(webItemInfo, &webapi_proto.ItemInfo{
ItemId: it.GetItem_Id(),
ItemNum: int64(it.GetGrade()),
})
} }
} }
var gainWay int32 = common.GainWay_ActFirstPay var gainWay int32 = common.GainWay_ActFirstPay
@ -1300,7 +1320,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any,
return nil return nil
} }
return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS, return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS,
p.DeviceId, "FirstRecharge", amount, int32(wfs.Price2), nil, "", p.Channel, p.ChannelId) p.DeviceId, "FirstRecharge", amount, int32(wfs.Price2), webItemInfo, "", p.Channel, p.ChannelId)
} }
return nil return nil
}), task.CompleteNotifyWrapper(func(retdata interface{}, t task.Task) { }), task.CompleteNotifyWrapper(func(retdata interface{}, t task.Task) {