package model

import (
	"mongo.games.com/goserver/core/logger"
	"time"
)

var (
	DbVipDBName   = "log"
	DbVipCollName = "log_vip"
)

type DbVip struct {
	Platform    string     //平台
	SnId        int32      //玩家id
	VipLevel    int32      //领取礼包的VIP等级
	Type        int32      //领取类型 0-每日礼包 1-每日金币礼包 2-固定礼包
	ConsumeType int32      //消耗类型
	ConsumeNum  int64      //消耗数量
	ItemInfo    []ItemInfo //道具 获得
	Ts          int64      //领取时间
	ShopId      int32      //商品id
	ShopName    string     //商品名称
}

func NewDbVip(platform string, snId int32, vipLevel int32, Type int32, consumeType int32, consumeNum int64, itemInfo []ItemInfo, shopId int32, shopName string) *DbVip {
	ts := time.Now()
	return &DbVip{Platform: platform, SnId: snId, VipLevel: vipLevel, Type: Type, Ts: ts.Unix(), ConsumeType: consumeType, ConsumeNum: consumeNum, ItemInfo: itemInfo, ShopId: shopId, ShopName: shopName}
}

type DbVipLogArgs struct {
	Log *DbVip
}

func InsertDbVipLog(log *DbVip) (err error) {
	if rpcCli == nil {
		logger.Logger.Error("model.InsertDbVipLog rpcCli == nil")
		return
	}
	var ret bool
	args := &DbVipLogArgs{
		Log: log,
	}
	err = rpcCli.CallWithTimeout("DbVipLogSvc.InsertDbVipLog", args, &ret, time.Second*30)
	if err != nil {
		logger.Logger.Warn("InsertDbVipLog error:", err)
		return
	}
	return
}
