syntax = "proto3";

package types;

message PurchaseRecord {
    int64 amount = 1;
    int64 number = 2;
    int64 index  = 3;
    int64 way    = 4;
}

message PurchaseRecords {
    repeated PurchaseRecord record         = 1;
    int64                   fundWin        = 2;
    int64                   amountOneRound = 3;
    string                  addr           = 4;
}

message Lottery {
    string                       lotteryId                  = 1;
    int32                        status                     = 2;
    int64                        createHeight               = 3;
    int64                        fund                       = 4;
    int64                        purBlockNum                = 5;
    int64                        drawBlockNum               = 6;
    int64                        lastTransToPurState        = 7;
    int64                        lastTransToDrawState       = 8;
    //map<string, PurchaseRecords> records                    = 9;
    int64                        totalPurchasedTxNum        = 10;
    string                       createAddr                 = 11;
    int64                        round                      = 12;
    int64                        luckyNumber                = 13;
    int64                        createOnMain               = 14;
    int64                        lastTransToPurStateOnMain  = 15;
    int64                        lastTransToDrawStateOnMain = 16;
    repeated MissingRecord missingRecords                   = 17;
    int64                        opRewardRatio              = 18;
    int64                        devRewardRatio             = 19;
    repeated PurchaseRecords     purRecords                 = 20;
    int64                        totalAddrNum               = 21;
    int64                        buyAmount                  = 22;
}

message MissingRecord {
    repeated int32 times = 1;
}

message LotteryAction {
    oneof value {
        LotteryCreate create = 1;
        LotteryBuy    buy    = 2;
        LotteryDraw   draw   = 3;
        LotteryClose  close  = 4;
    }
    int32 ty = 10;
}

message LotteryCreate {
    int64 purBlockNum    = 1;
    int64 drawBlockNum   = 2;
    int64 opRewardRatio  = 3;
    int64 devRewardRatio = 4;
}

message LotteryBuy {
    string lotteryId = 1;
    int64  amount    = 2;
    int64  number    = 3;
    int64  way       = 4;
}

message LotteryDraw {
    string lotteryId = 1;
}

message LotteryClose {
    string lotteryId = 1;
}

message ReceiptLottery {
    string               lotteryId    = 1;
    int32                status       = 2;
    int32                prevStatus   = 3;
    string               addr         = 4;
    int64                round        = 5;
    int64                number       = 6;
    int64                amount       = 7;
    int64                luckyNumber  = 8;
    int64                time         = 9;
    string               txHash       = 10;
    LotteryUpdateBuyInfo updateInfo   = 11;
    int64                way          = 12;
    int64                index        = 13;
    int64                totalAddrNum = 14;
    int64                buyAmount    = 15;
    LotteryGainInfos     gainInfos    = 16;
    int64                luckyAddrNum = 17;
    int64                totalFund    = 18;
    int64                factor       = 19;
}

message ReqLotteryInfo {
    string lotteryId = 1;
}

message ReqLotteryBuyInfo {
    string lotteryId = 1;
    string addr      = 2;
    int64  round     = 3;
}

message ReqLotteryBuyHistory {
    string lotteryId = 1;
    string addr      = 2;
    int64  round     = 3;
    int32  count     = 4;
    int32  direction = 5;
    int64  index     = 6;
}

message ReqLotteryLuckyInfo {
    string   lotteryId   = 1;
    repeated int64 round = 2;
}

message ReqLotteryLuckyHistory {
    string lotteryId = 1;
    int64  round     = 2;
    int32  count     = 3;
    int32  direction = 4;
}

message ReplyLotteryNormalInfo {
    int64  createHeight   = 1;
    int64  purBlockNum    = 2;
    int64  drawBlockNum   = 3;
    string createAddr     = 4;
    int64  opRewardRatio  = 5;
    int64  devRewardRatio = 6;
}

message ReplyLotteryCurrentInfo {
    int32    status                       = 1;
    int64    fund                         = 2;
    int64    lastTransToPurState          = 3;
    int64    lastTransToDrawState         = 4;
    int64    totalPurchasedTxNum          = 5;
    int64    round                        = 6;
    int64    luckyNumber                  = 7;
    int64    lastTransToPurStateOnMain    = 8;
    int64    lastTransToDrawStateOnMain   = 9;
    int64    purBlockNum                  = 10;
    int64    drawBlockNum                 = 11;
    repeated MissingRecord missingRecords = 12;
    int64    totalAddrNum                 = 13;
    int64    buyAmount                    = 14;
}

message ReplyLotteryHistoryLuckyNumber {
    repeated int64 luckyNumber = 1;
}

message ReplyLotteryShowInfo {
    repeated LotteryBuyRecord records = 1;
}

message LotteryNumberRecord {
    int64 number = 1;
    int64 amount = 2;
}

// used for execlocal
message LotteryBuyRecord {
    int64  number = 1;
    int64  amount = 2;
    int64  round  = 3;
    int64  type   = 4;
    int64  way    = 5;
    int64  index  = 6;
    int64  time   = 7;
    string txHash = 8;
}

message LotteryBuyRecords {
    repeated LotteryBuyRecord records = 1;
}

message LotteryDrawRecord {
    int64  number       = 1;
    int64  round        = 2;
    int64  time         = 3;
    string txHash       = 4;
    int64  totalAddrNum = 5;
    int64  buyAmount    = 6;
    int64  luckyAddrNum = 7;
    int64  totalFund    = 8;
    int64  factor       = 9;
}

message LotteryDrawRecords {
    repeated LotteryDrawRecord records = 1;
}

message LotteryUpdateRec {
    int64 index = 1;
    int64 type  = 2;
}

message LotteryUpdateRecs {
    repeated LotteryUpdateRec records = 1;
}

message LotteryUpdateBuyInfo {
    map<string, LotteryUpdateRecs> buyInfo = 1;
}

message ReplyLotteryPurchaseAddr {
    repeated string address = 1;
}

message LotteryGainInfos{
    repeated LotteryGainInfo gains = 1;
}

message LotteryGainInfo{
    string  addr       = 1;
    int64   buyAmount  = 2;
    int64   fundAmount = 3;
}

message LotteryGainRecord{
    string  addr       = 1;
    int64   buyAmount  = 2;
    int64   fundAmount = 3;
    int64   round      = 4;
}

message LotteryGainRecords {
    repeated LotteryGainRecord records = 1;
}

message ReqLotteryGainHistory {
    string lotteryId = 1;
    string addr      = 2;
    int64  round     = 3;
    int32  count     = 4;
    int32  direction = 5;
}

message ReqLotteryGainInfo {
    string lotteryId = 1;
    string addr      = 2;
    int64  round     = 3;
}

